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 all 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, only : prif_init, 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_init() /= 0) error stop "caffeinate returned a non-zero exit code"

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, only : prif_init, prif_error_stop
implicit none

if (caf_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"
if (prif_init() /= 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, only : prif_init, prif_error_stop
implicit none

if (caf_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"
if (prif_init() /= 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, only : prif_init, prif_stop
implicit none

if (caf_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"
if (prif_init() /= 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, only : prif_init, prif_stop
implicit none

if (caf_caffeinate() /= 0) error stop "caffeinate returned a non-zero exit_code"
if (prif_init() /= 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
26 changes: 0 additions & 26 deletions src/caffeine/caffeinate_decaffeinate_m.f90

This file was deleted.

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
28 changes: 14 additions & 14 deletions src/caffeine/caffeine.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,48 @@ enum {

// Program launch and finalization

void caf_c_caffeinate(int argc, char *argv[]);
void caf_c_decaffeinate(int exit_code);
void caf_caffeinate(int argc, char *argv[]);
void caf_decaffeinate(int exit_code);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

prif_stop calls caf_decaffeinate. Should the caffeine side names be updated as well to caf_init and caf_stop to represent more closely the relationship with prif_init and prif_stop?

Choose a reason for hiding this comment

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

I'm not too worried about the names of "implementation" procedures. I would envision an implementation doing, for the sake of reducing procedure call overhead, something like

module prif
  use caffeine, only: &
    prif_init => caffeinate, &
    prif_stop => decaffeinate, &
    ...
end module

At least to the extent that the interfaces match up.


// Image enumeration

int caf_c_this_image();
int caf_c_num_images();
int caf_this_image();
int caf_num_images();

// Synchronization

void caf_c_sync_all();
void caf_sync_all();

// _______ Collective Subroutines _______

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
);

void caf_c_co_broadcast(
void caf_co_broadcast(
CFI_cdesc_t * a_desc, int source_image, int* stat, int num_elements
);

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

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

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

// ____________ Utilities ____________

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);

bool caf_c_numeric_type(CFI_cdesc_t* a_desc);
bool caf_numeric_type(CFI_cdesc_t* a_desc);

bool caf_c_is_f_string(CFI_cdesc_t* a_desc);
bool caf_is_f_string(CFI_cdesc_t* a_desc);

size_t caf_c_elem_len(CFI_cdesc_t* a_desc);
size_t caf_elem_len(CFI_cdesc_t* a_desc);

#endif // CAFFEINE_H
Loading
Loading