Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update names based on new naming convention with prif and caffeine #45

Merged
merged 8 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example/hello.f90
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
program hello_world
use caffeine_m, only : caf_caffeinate, this_image => caf_this_image, num_images => caf_num_images, caf_stop
use prif_m, only : prif_caffeinate, this_image => prif_this_image, num_images => prif_num_images, prif_stop
implicit none

if (caf_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit code"
if (prif_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit code"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be prif_init?


print *, "Hello from image", this_image(), "of", num_images()

call caf_stop(stop_code=0) ! normal termination
call prif_stop(stop_code=0) ! normal termination

end program
6 changes: 3 additions & 3 deletions example/support-test/error_stop_character_code.f90
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
program error_stop_character_code
use caffeine_m, only : caf_caffeinate, caf_error_stop
use prif_m, only : prif_caffeinate, prif_error_stop
implicit none

if (caf_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"
if (prif_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"

call caf_error_stop("Oh snap!")
call prif_error_stop("Oh snap!")

stop 0 ! ../../test/caf_error_stop_test.f90 will report a test failure if this line runs
end program
8 changes: 4 additions & 4 deletions example/support-test/error_stop_integer_code.f90
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
program error_stop_integer_code
use caffeine_m, only : caf_caffeinate, caf_error_stop
use prif_m, only : prif_caffeinate, prif_error_stop
implicit none

if (caf_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"
if (prif_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"

call caf_error_stop(1)
call prif_error_stop(1)

stop 0 ! caffeine/test/caf_error_stop_test.f90 reports a failure if this line runs
end program
end program
6 changes: 3 additions & 3 deletions example/support-test/stop_with_integer_code.f90
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
program stop_with_no_code
use caffeine_m, only : caf_caffeinate, caf_stop
use prif_m, only : prif_caffeinate, prif_stop
implicit none

if (caf_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"
if (prif_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"

call caf_stop(1)
call prif_stop(1)

stop 2 ! caffeine/test/zzz_finalization_test.f90 reports a failure if this line runs
end program
6 changes: 3 additions & 3 deletions example/support-test/stop_with_no_code.f90
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
program stop_with_no_code
use caffeine_m, only : caf_caffeinate, caf_stop
use prif_m, only : prif_caffeinate, prif_stop
implicit none

if (caf_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"
if (prif_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"

call caf_stop
call prif_stop

stop 1 ! caffeine/test/zzz_finalization_test.f90 reports a failure if this line runs
end program
8 changes: 4 additions & 4 deletions src/caffeine/assert/assert_s.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

module procedure assert
use caffeine_characterizable_m, only : characterizable_t
use program_termination_m, only: caf_error_stop
use image_enumeration_m, only: this_image => caf_this_image
use program_termination_m, only: prif_error_stop
use image_enumeration_m, only: this_image => prif_this_image

character(len=:), allocatable :: header, trailer

Expand Down Expand Up @@ -52,7 +52,7 @@

end if represent_diagnostics_as_string

call caf_error_stop(header // ' with diagnostic data "' // trailer // '"')
call prif_error_stop(header // ' with diagnostic data "' // trailer // '"')

end if check_assertion

Expand All @@ -77,7 +77,7 @@ pure function string(numeric) result(number_as_string)
type is(real)
write(untrimmed_string, *) numeric
class default
call caf_error_stop("Internal error in subroutine 'assert': unsupported type in function 'string'.")
call prif_error_stop("Internal error in subroutine 'assert': unsupported type in function 'string'.")
end select

number_as_string = trim(adjustl(untrimmed_string))
Expand Down
12 changes: 6 additions & 6 deletions src/caffeine/assert/intrinsic_array_s.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
submodule(caffeine_intrinsic_array_m) caffeine_intrinsic_array_s
use program_termination_m, only: caf_error_stop
use program_termination_m, only: prif_error_stop
implicit none

contains
Expand All @@ -22,7 +22,7 @@
type is(double precision)
intrinsic_array%double_precision_1D = array
class default
call caf_error_stop("intrinsic_array_t construct: unsupported rank-2 type")
call prif_error_stop("intrinsic_array_t construct: unsupported rank-2 type")
end select
#ifndef NAGFOR
rank(2)
Expand All @@ -38,7 +38,7 @@
type is(double precision)
intrinsic_array%double_precision_2D = array
class default
call caf_error_stop("intrinsic_array_t construct: unsupported rank-2 type")
call prif_error_stop("intrinsic_array_t construct: unsupported rank-2 type")
end select

rank(3)
Expand All @@ -54,11 +54,11 @@
type is(double precision)
intrinsic_array%double_precision_3D = array
class default
call caf_error_stop("intrinsic_array_t construct: unsupported rank-3 type")
call prif_error_stop("intrinsic_array_t construct: unsupported rank-3 type")
end select

rank default
call caf_error_stop("intrinsic_array_t construct: unsupported rank")
call prif_error_stop("intrinsic_array_t construct: unsupported rank")
end select
#endif

Expand All @@ -74,7 +74,7 @@
allocated(self%logical_2D), allocated(self%real_2D), &
allocated(self%complex_3D), allocated(self%complex_double_3D), allocated(self%integer_3D), &
allocated(self%logical_3D), allocated(self%real_3D) &
])) call caf_error_stop("intrinsic_array_t as_character: ambiguous component allocation status.")
])) call prif_error_stop("intrinsic_array_t as_character: ambiguous component allocation status.")

if (allocated(self%complex_1D)) then
character_self = repeat(" ", ncopies = single_number_width*size(self%complex_1D))
Expand Down
10 changes: 5 additions & 5 deletions src/caffeine/caffeinate_decaffeinate_m.f90
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt
module caffeinate_decaffeinate_m
use team_type_m, only: team_type
use team_type_m, only: prif_team_type
implicit none

private
public :: caf_caffeinate, caf_decaffeinate, default_team
public :: prif_caffeinate, prif_decaffeinate, default_team

type(team_type), target :: default_team
type(prif_team_type), target :: default_team

interface

module function caf_caffeinate() result(exit_code)
module function prif_caffeinate() result(exit_code)
implicit none
integer exit_code
end function

module subroutine caf_decaffeinate(exit_code)
module subroutine prif_decaffeinate(exit_code)
implicit none
integer, intent(in) :: exit_code
end subroutine
Expand Down
18 changes: 9 additions & 9 deletions src/caffeine/caffeinate_decaffeinate_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
! Terms of use are as specified in LICENSE.txt
submodule(caffeinate_decaffeinate_m) caffeinate_decaffeinate_s
use iso_c_binding, only : c_int, c_loc, c_char, c_null_char
use synchronization_m, only : caf_sync_all
use caffeine_h_m, only : caf_c_caffeinate, caf_c_decaffeinate
use program_termination_m, only: caf_error_stop
use synchronization_m, only : prif_sync_all
use caffeine_h_m, only : caf_caffeinate, caf_decaffeinate
use program_termination_m, only: prif_error_stop
implicit none

contains

module procedure caf_caffeinate
module procedure prif_caffeinate

integer i
integer, parameter :: max_arg_len = 1024

associate(argc => int(command_argument_count(),c_int))
associate(argv => [(c_loc(c_interop_arg(i)), i=0,argc)])
call caf_c_caffeinate(argc, argv)
call caf_caffeinate(argc, argv)
end associate
end associate

! TODO: establish non-allocatable coarrays

call caf_sync_all
call prif_sync_all

exit_code = 0

Expand All @@ -39,14 +39,14 @@ function c_interop_arg(argnum) result(arg)
arg => targ
#endif
call get_command_argument(argnum, arg, arglen)
if (arglen+1>max_arg_len) call caf_error_stop("maximum argument length exceeded")
if (arglen+1>max_arg_len) call prif_error_stop("maximum argument length exceeded")
arg(arglen+1:arglen+1) = c_null_char
end function

end procedure

module procedure caf_decaffeinate
call caf_c_decaffeinate(exit_code)
module procedure prif_decaffeinate
call caf_decaffeinate(exit_code)
end procedure

end submodule caffeinate_decaffeinate_s
30 changes: 15 additions & 15 deletions src/caffeine/caffeine.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static gex_Rank_t rank, size;
const int double_Complex_workaround =4100;
#endif

void caf_c_caffeinate(int argc, char *argv[])
void caf_caffeinate(int argc, char *argv[])
{
GASNET_SAFE(gex_Client_Init(&myclient, &myep, &myteam, "caffeine", &argc, &argv, 0));

Expand All @@ -42,28 +42,28 @@ void caf_c_caffeinate(int argc, char *argv[])
GASNET_SAFE(gex_Segment_Attach(&mysegment, myteam, segsz));
}

void caf_c_decaffeinate(int exit_code)
void caf_decaffeinate(int exit_code)
{
gasnet_exit(exit_code);
}

int caf_c_this_image()
int caf_this_image()
{
return gex_TM_QueryRank(myteam) + 1;
}

int caf_c_num_images()
int caf_num_images()
{
return gex_TM_QuerySize(myteam);
}

void caf_c_sync_all()
void caf_sync_all()
{
gasnet_barrier_notify(0,GASNET_BARRIERFLAG_ANONYMOUS);
gasnet_barrier_wait(0,GASNET_BARRIERFLAG_ANONYMOUS);
}

void caf_c_co_reduce(
void caf_co_reduce(
CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg, int num_elements, gex_Coll_ReduceFn_t* user_op, void* client_data
)
{
Expand All @@ -85,7 +85,7 @@ void caf_c_co_reduce(
if (stat != NULL) *stat = 0;
}

void caf_c_co_broadcast(CFI_cdesc_t * a_desc, int source_image, int* stat, int num_elements)
void caf_co_broadcast(CFI_cdesc_t * a_desc, int source_image, int* stat, int num_elements)
{
char* c_loc_a = (char*) a_desc->base_addr;
size_t c_sizeof_a = a_desc->elem_len;
Expand Down Expand Up @@ -117,7 +117,7 @@ void set_stat_errmsg_or_abort(int* stat, char* errmsg, const int return_stat, co
}
}

void caf_c_co_max(CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg, size_t num_elements)
void caf_co_max(CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg, size_t num_elements)
{
gex_DT_t a_type;

Expand Down Expand Up @@ -147,7 +147,7 @@ void caf_c_co_max(CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg
if (stat != NULL) *stat = 0;
}

void caf_c_co_min(CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg, size_t num_elements)
void caf_co_min(CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg, size_t num_elements)
{
gex_DT_t a_type;

Expand Down Expand Up @@ -177,7 +177,7 @@ void caf_c_co_min(CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg
if (stat != NULL) *stat = 0;
}

void caf_c_co_sum(CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg, size_t num_elements)
void caf_co_sum(CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg, size_t num_elements)
{
gex_DT_t a_type;

Expand Down Expand Up @@ -209,18 +209,18 @@ void caf_c_co_sum(CFI_cdesc_t* a_desc, int result_image, int* stat, char* errmsg
if (stat != NULL) *stat = 0;
}

bool caf_c_same_cfi_type(CFI_cdesc_t* a_desc, CFI_cdesc_t* b_desc)
bool caf_same_cfi_type(CFI_cdesc_t* a_desc, CFI_cdesc_t* b_desc)
{
if (a_desc->type == b_desc->type) return true;
return false;
}

size_t caf_c_elem_len(CFI_cdesc_t* a_desc)
size_t caf_elem_len(CFI_cdesc_t* a_desc)
{
return a_desc->elem_len;
}

bool caf_c_numeric_type(CFI_cdesc_t* a_desc)
bool caf_numeric_type(CFI_cdesc_t* a_desc)
{
switch (a_desc->type)
{
Expand All @@ -235,12 +235,12 @@ bool caf_c_numeric_type(CFI_cdesc_t* a_desc)
}

#ifdef __GNUC__
bool caf_c_is_f_string(CFI_cdesc_t* a_desc){
bool caf_is_f_string(CFI_cdesc_t* a_desc){
if ( (a_desc->type - 5) % 256 == 0) return true;
return false;
}
#else // The code below is untested but believed to conform with the Fortran 2018 standard.
bool caf_c_is_f_string(CFI_cdesc_t* a_desc){
bool caf_is_f_string(CFI_cdesc_t* a_desc){
if (a_desc->type == CFI_type_char) return true;
return false;
}
Expand Down
Loading
Loading