Skip to content

Commit

Permalink
Fix a bug with server and client number calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
houjun committed Nov 15, 2024
1 parent 2e2d036 commit c3b5ecd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/api/pdc_client_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/server/pdc_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
6 changes: 3 additions & 3 deletions src/server/pdc_server_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/tests/kvtag_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c3b5ecd

Please sign in to comment.