From c3b5ecdb00fe64ba3382d416ebaeddfe9c12ecd0 Mon Sep 17 00:00:00 2001 From: Houjun Tang Date: Thu, 14 Nov 2024 16:27:29 -0800 Subject: [PATCH] Fix a bug with server and client number calculation --- src/api/pdc_client_connect.c | 4 ++-- src/server/pdc_server.c | 3 ++- src/server/pdc_server_metadata.c | 6 +++--- src/tests/kvtag_query.c | 14 +++++++------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/api/pdc_client_connect.c b/src/api/pdc_client_connect.c index 5dedf568..acb20881 100644 --- a/src/api/pdc_client_connect.c +++ b/src/api/pdc_client_connect.c @@ -1638,7 +1638,7 @@ PDC_Client_init() // Split the PDC_CLIENT_COMM_WORLD_g communicator, MPI_Comm_split_type requires MPI-3 /* MPI_Comm_split_type(PDC_CLIENT_COMM_WORLD_g, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, */ /* &PDC_SAME_NODE_COMM_g); */ - int sub_comm_color = pdc_client_mpi_rank_g / pdc_server_num_g; + int sub_comm_color = pdc_client_mpi_rank_g / (pdc_client_mpi_size_g / pdc_server_num_g); MPI_Comm_split(PDC_CLIENT_COMM_WORLD_g, sub_comm_color, pdc_client_mpi_rank_g, &PDC_SAME_NODE_COMM_g); MPI_Comm_rank(PDC_SAME_NODE_COMM_g, &pdc_client_same_node_rank_g); @@ -9419,7 +9419,7 @@ PDC_Client_query_kvtag_mpi(const pdc_kvtag_t *kvtag, int *n_res, uint64_t **pdc_ // Only retrieve the metadata snapshot once // TODO: if metadata is changed, need to invalidate the cached snapshot and retrieve a new one if (deserializedBulki_g == NULL) { - server_rank = pdc_client_mpi_rank_g / pdc_server_num_g; + server_rank = pdc_client_mpi_rank_g / (pdc_client_mpi_size_g / pdc_server_num_g); // Send one request to each server at the same time if (pdc_client_same_node_rank_g == 0) ret_value = PDC_Client_query_kvtag_server(server_rank, kvtag, &nshm, &shm_sizes); diff --git a/src/server/pdc_server.c b/src/server/pdc_server.c index 43c9e56e..b9caeecb 100644 --- a/src/server/pdc_server.c +++ b/src/server/pdc_server.c @@ -721,7 +721,8 @@ PDC_Server_set_close(void) start = MPI_Wtime(); #endif char *tmp_env_char = getenv("PDC_DISABLE_CHECKPOINT"); - if (tmp_env_char != NULL && strcmp(tmp_env_char, "TRUE") == 0) { + if (tmp_env_char != NULL && + (strcmp(tmp_env_char, "TRUE") == 0 || atoi(tmp_env_char) == 1)) { if (pdc_server_rank_g == 0) { printf("==PDC_SERVER[0]: checkpoint disabled!\n"); } diff --git a/src/server/pdc_server_metadata.c b/src/server/pdc_server_metadata.c index accc9266..76b98d9a 100644 --- a/src/server/pdc_server_metadata.c +++ b/src/server/pdc_server_metadata.c @@ -1894,13 +1894,13 @@ PDC_Server_seralize_kvtag_someta_to_shm(uint32_t *n_meta, uint64_t **obj_ids, ui goto done; } - if (pdc_server_size_g % pdc_client_num_g != 0) { + if (pdc_client_num_g % pdc_server_size_g != 0) { printf("==PDC_SERVER[%d]: #servers not divisible by clients!\n", pdc_server_rank_g); ret_value = FAIL; goto done; } - nclient_per_server = pdc_server_size_g / pdc_client_num_g; + nclient_per_server = pdc_client_num_g / pdc_server_size_g; nkvtag_per_buf = ceil(metadata_total_count_g / nclient_per_server); if (alloc_size < nclient_per_server) { @@ -1949,7 +1949,7 @@ PDC_Server_seralize_kvtag_someta_to_shm(uint32_t *n_meta, uint64_t **obj_ids, ui kvtag_list_elt->kvtag->type, PDC_CLS_ITEM); } - BULKI_append(kvtag_bulki, key, val); + BULKI_put(kvtag_bulki, key, val); nkvtag_in_buf++; } // End for each kvtag in list diff --git a/src/tests/kvtag_query.c b/src/tests/kvtag_query.c index 8be59d3c..5c449c5f 100644 --- a/src/tests/kvtag_query.c +++ b/src/tests/kvtag_query.c @@ -79,7 +79,7 @@ main(int argc, char *argv[]) { pdcid_t pdc, cont_prop, cont, obj_prop; pdcid_t * obj_ids; - int n_obj, n_add_tag, my_obj, my_obj_s, my_add_tag, my_add_tag_s; + int n_obj, n_add_tag, my_obj, my_obj_s, my_add_tag, my_add_tag_s, my_tags, total_tags; int proc_num = 1, my_rank = 0, i, v, iter, round, selectivity, is_using_dart; char obj_name[128]; double stime, total_time; @@ -156,6 +156,7 @@ main(int argc, char *argv[]) assign_work_to_rank(my_rank, proc_num, n_add_tag, &my_add_tag, &my_add_tag_s); // This is for adding #rounds tags to the objects. + my_tags = 0; for (i = 0; i < my_add_tag; i++) { for (iter = 0; iter < round; iter++) { v = iter; @@ -172,11 +173,16 @@ main(int argc, char *argv[]) printf("fail to add a kvtag to o%d\n", i + my_obj_s); } } + my_tags++; } /* if (my_rank == 0) */ /* println("Rank %d: Added %d kvtag to the %d th object", my_rank, round, i); */ } + MPI_Reduce(&my_tags, &total_tags, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD); + if (my_rank == 0) + println("Added %d kvtags", total_tags); + #ifdef ENABLE_MPI MPI_Barrier(MPI_COMM_WORLD); #endif @@ -225,20 +231,14 @@ main(int argc, char *argv[]) // close a container if (PDCcont_close(cont) < 0) printf("fail to close container c1\n"); - else - printf("successfully close container c1\n"); // close an object property if (PDCprop_close(obj_prop) < 0) printf("Fail to close property @ line %d\n", __LINE__); - else - printf("successfully close object property\n"); // close a container property if (PDCprop_close(cont_prop) < 0) printf("Fail to close property @ line %d\n", __LINE__); - else - printf("successfully close container property\n"); // close pdc if (PDCclose(pdc) < 0)