-
Notifications
You must be signed in to change notification settings - Fork 63
Feature: shmem init error checking #1997
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
base: main
Are you sure you want to change the base?
Changes from all commits
9a82481
1233b2d
f2f69cd
a7cf3ff
bd6410f
19fac25
cfb5711
999fa7b
eb704d6
d6a3a9b
904ccf9
3d91658
231f112
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -834,7 +834,7 @@ t8_cmesh_load_and_distribute (const char *fileprefix, const int num_files, sc_MP | |||||
| T8_ASSERT (mpisize >= num_files); | ||||||
|
|
||||||
| /* Try to set the comm type */ | ||||||
| t8_shmem_init (comm); | ||||||
| SC_CHECK_ABORT (t8_shmem_init (comm) > 0, "Error in shared memory setup. Could not load cmesh."); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| t8_shmem_set_type (comm, T8_SHMEM_BEST_TYPE); | ||||||
|
|
||||||
| /* Use cmesh_bcast, if only one process loads the cmesh: */ | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,9 +60,18 @@ t8_shmem_array_is_initialized (const t8_shmem_array_t array) | |
| } | ||
| #endif | ||
|
|
||
| void | ||
| int | ||
| t8_shmem_init (sc_MPI_Comm comm) | ||
| { | ||
| #ifndef T8_ENABLE_MPI | ||
| // If we do not use MPI, there is nothing to do. | ||
| // We only have a single process. | ||
| return 1; | ||
| #endif | ||
| #ifndef SC_ENABLE_MPICOMMSHARED | ||
| SC_ABORT ("Trying to use shared memory but SC_ENABLE_MPICOMMSHARED is not set. This should not happen if you use MPI " | ||
| "v.3.0 or higher. Maybe related to https://github.com/DLR-AMR/t8code/pull/1996."); | ||
| #endif | ||
|
Comment on lines
+66
to
+74
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this only the case when MPI is not linked or also when the number of ranks is 1? |
||
| /* Check whether intranode and internode comms are set | ||
| * for the current communicator. */ | ||
| sc_MPI_Comm intranode; | ||
|
|
@@ -73,8 +82,12 @@ t8_shmem_init (sc_MPI_Comm comm) | |
| if (intranode == sc_MPI_COMM_NULL || internode == sc_MPI_COMM_NULL) { | ||
| /* The inter/intra comms are not set. We need to set them to | ||
| * initialize shared memory usage. */ | ||
| sc_mpi_comm_get_and_attach (comm); | ||
| return sc_mpi_comm_get_and_attach (comm); | ||
| } | ||
| int intranode_size; | ||
| const int mpiret = sc_MPI_Comm_size (intranode, &intranode_size); | ||
| SC_CHECK_MPI (mpiret); | ||
| return intranode_size; | ||
| } | ||
|
|
||
| void | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -104,7 +104,7 @@ t8_forest_partition_create_offsets (t8_forest_t forest) | |||||
| t8_debugf ("Building offsets for forest %p\n", (void *) forest); | ||||||
| comm = forest->mpicomm; | ||||||
| /* Set the shmem array type of comm */ | ||||||
| t8_shmem_init (comm); | ||||||
| SC_CHECK_ABORT (t8_shmem_init (comm) > 0, "Error in shared memory setup. Could not partition forest."); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| t8_shmem_set_type (comm, T8_SHMEM_BEST_TYPE); | ||||||
| /* Initialize the offset array as a shmem array | ||||||
| * holding mpisize+1 many t8_gloidx_t */ | ||||||
|
|
@@ -280,7 +280,7 @@ t8_forest_partition_create_first_desc (t8_forest_t forest) | |||||
|
|
||||||
| if (forest->global_first_desc == NULL) { | ||||||
| /* Set the shmem array type of comm */ | ||||||
| t8_shmem_init (comm); | ||||||
| SC_CHECK_ABORT (t8_shmem_init (comm) > 0, "Error in shared memory setup. Could not partition forest."); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| t8_shmem_set_type (comm, T8_SHMEM_BEST_TYPE); | ||||||
| /* Initialize the offset array as a shmem array | ||||||
| * holding mpisize+1 many t8_linearidx_t to store the elements linear ids */ | ||||||
|
|
@@ -383,7 +383,7 @@ t8_forest_partition_create_tree_offsets (t8_forest_t forest) | |||||
|
|
||||||
| if (forest->tree_offsets == NULL) { | ||||||
| /* Set the shmem array type of comm */ | ||||||
| t8_shmem_init (comm); | ||||||
| SC_CHECK_ABORT (t8_shmem_init (comm) > 0, "Error in shared memory setup. Could not partition forest."); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| t8_shmem_set_type (comm, T8_SHMEM_BEST_TYPE); | ||||||
| /* Only allocate the shmem array, if it is not already allocated */ | ||||||
| t8_shmem_array_init (&forest->tree_offsets, sizeof (t8_gloidx_t), forest->mpisize + 1, comm); | ||||||
|
|
@@ -448,7 +448,7 @@ t8_forest_partition_compute_new_offset (t8_forest_t forest) | |||||
|
|
||||||
| T8_ASSERT (forest->element_offsets == NULL); | ||||||
| /* Set the shmem array type to comm */ | ||||||
| t8_shmem_init (comm); | ||||||
| SC_CHECK_ABORT (t8_shmem_init (comm) > 0, "Error in shared memory setup. Could not partition forest."); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| t8_shmem_set_type (comm, T8_SHMEM_BEST_TYPE); | ||||||
| /* Initialize the shmem array */ | ||||||
| t8_shmem_array_init (&forest->element_offsets, sizeof (t8_gloidx_t), forest->mpisize + 1, comm); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -116,7 +116,8 @@ TEST_P (cmesh_set_partition_offsets_nocommit, test_set_offsets) | |||||
| * the array corresponds to any valid partition. | ||||||
| * We use the offset_concentrate function to build an offset array for a partition | ||||||
| * that concentrates all trees at one process. */ | ||||||
| t8_shmem_init (sc_MPI_COMM_WORLD); | ||||||
| const int intranode_size = t8_shmem_init (sc_MPI_COMM_WORLD); | ||||||
| ASSERT_GT (intranode_size, 0) << "Could not initialize shared memory."; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, sc_MPI_COMM_WORLD, inum_trees); | ||||||
|
|
||||||
| /* Set the partition offsets */ | ||||||
|
|
@@ -135,7 +136,9 @@ TEST_P (cmesh_set_partition_offsets_commit, test_set_offsets) | |||||
| * the array corresponds to any valid partition. | ||||||
| * We use the offset_concentrate function to build an offset array for a partition | ||||||
| * that concentrates all trees at one process. */ | ||||||
| t8_shmem_init (comm); | ||||||
| const int intranode_size = t8_shmem_init (comm); | ||||||
| ASSERT_GT (intranode_size, 0) << "Could not initialize shared memory."; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, comm, inum_trees); | ||||||
|
|
||||||
| /* Set the partition offsets */ | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,7 +58,8 @@ TEST_P (shmem, test_shmem_init_finalize) | |||||
| int mpiret; | ||||||
|
|
||||||
| /* setup shared memory usage */ | ||||||
| t8_shmem_init (comm); | ||||||
| const int intrasize_from_init = t8_shmem_init (comm); | ||||||
| ASSERT_GT (intrasize_from_init, 0) << "Error in t8_shmem_init. No intranode communicator set."; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| /* Get intranode and internode comm */ | ||||||
| sc_mpi_comm_get_node_comms (comm, &intranode, &internode); | ||||||
|
|
@@ -113,7 +114,9 @@ TEST_P (shmem, test_sc_shmem_alloc) | |||||
| t8_debugf ("Checking shared memory type %s.\n", sc_shmem_type_to_string[shmem_type]); | ||||||
|
|
||||||
| /* setup shared memory usage */ | ||||||
| t8_shmem_init (comm); | ||||||
| const int intranode_size = t8_shmem_init (comm); | ||||||
| ASSERT_GT (intranode_size, 0) << "Could not initialize shared memory."; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| t8_shmem_set_type (comm, shmem_type); | ||||||
|
|
||||||
| #if T8_ENABLE_MPI | ||||||
|
|
@@ -196,7 +199,8 @@ TEST_P (shmem, test_shmem_array_allgatherv) | |||||
| const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; | ||||||
|
|
||||||
| /* setup shared memory usage */ | ||||||
| t8_shmem_init (comm); | ||||||
| const int intranode_size = t8_shmem_init (comm); | ||||||
| ASSERT_GT (intranode_size, 0) << "Could not initialize shared memory."; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| t8_shmem_set_type (comm, shmem_type); | ||||||
|
|
||||||
| #if T8_ENABLE_MPI | ||||||
|
|
@@ -246,7 +250,8 @@ TEST_P (shmem, test_shmem_array_prefix) | |||||
| const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; | ||||||
|
|
||||||
| /* setup shared memory usage */ | ||||||
| t8_shmem_init (comm); | ||||||
| const int intranode_size = t8_shmem_init (comm); | ||||||
| ASSERT_GT (intranode_size, 0) << "Could not initialize shared memory."; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| t8_shmem_set_type (comm, shmem_type); | ||||||
|
|
||||||
| #if T8_ENABLE_MPI | ||||||
|
|
@@ -291,7 +296,8 @@ TEST_P (shmem, test_shmem_array) | |||||
| const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; | ||||||
|
|
||||||
| /* setup shared memory usage */ | ||||||
| t8_shmem_init (comm); | ||||||
| const int intranode_size = t8_shmem_init (comm); | ||||||
| ASSERT_GT (intranode_size, 0) << "Could not initialize shared memory."; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| t8_shmem_set_type (comm, shmem_type); | ||||||
|
|
||||||
| #if T8_ENABLE_MPI | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the != 0 fits better the true/false version of C, e.g. true being not zero.