Skip to content

Commit

Permalink
update output
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangwei217245 committed Mar 20, 2023
1 parent 65688e5 commit fe1f8b4
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/tests/kvtag_add_get_scale.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ assign_work_to_rank(int rank, int size, int nwork, int *my_count, int *my_start)
return 1;
}


uint64_t
atoui64(char *arg) {
char *endptr;
uint64_t num = strtoull(arg, &endptr, 10);

if (*endptr != '\0') {
printf("Invalid input: %s\n", arg);
return 1;
}
return num;
}

void
print_usage(char *name)
{
Expand All @@ -69,8 +82,9 @@ main(int argc, char *argv[])
{
pdcid_t pdc, cont_prop, cont, obj_prop;
pdcid_t * obj_ids;
int n_obj, n_add_tag, n_query, my_obj, my_obj_s, my_add_tag, my_query, my_add_tag_s, my_query_s;
int proc_num, my_rank, i, v;
uint64_t n_obj, n_add_tag, n_query, my_obj, my_obj_s, my_add_tag, my_query, my_add_tag_s, my_query_s;
int proc_num, my_rank
uint64_t i, v;
char obj_name[128];
double stime, total_time;
pdc_kvtag_t kvtag;
Expand All @@ -86,9 +100,9 @@ main(int argc, char *argv[])
print_usage(argv[0]);
goto done;
}
n_obj = atoi(argv[1]);
n_add_tag = atoi(argv[2]);
n_query = atoi(argv[3]);
n_obj = atoui64(argv[1]);
n_add_tag = atoui64(argv[2]);
n_query = atoui64(argv[3]);

if (n_add_tag > n_obj || n_query > n_obj) {
if (my_rank == 0)
Expand All @@ -101,7 +115,7 @@ main(int argc, char *argv[])
assign_work_to_rank(my_rank, proc_num, n_obj, &my_obj, &my_obj_s);

if (my_rank == 0)
printf("Create %d obj, %d tags, query %d\n", my_obj, my_add_tag, my_query);
printf("Create %llu obj, %llu tags, query %llu\n", my_obj, my_add_tag, my_query);

// create a pdc
pdc = PDCinit("pdc");
Expand All @@ -124,14 +138,14 @@ main(int argc, char *argv[])
// Create a number of objects, add at least one tag to that object
obj_ids = (pdcid_t *)calloc(my_obj, sizeof(pdcid_t));
for (i = 0; i < my_obj; i++) {
sprintf(obj_name, "obj%d", my_obj_s + i);
sprintf(obj_name, "obj%llu", my_obj_s + i);
obj_ids[i] = PDCobj_create(cont, obj_name, obj_prop);
if (obj_ids[i] <= 0)
printf("Fail to create object @ line %d!\n", __LINE__);
}

if (my_rank == 0)
printf("Created %d objects\n", n_obj);
printf("Created %llu objects\n", n_obj);

// Add tags
kvtag.name = "Group";
Expand All @@ -145,15 +159,15 @@ main(int argc, char *argv[])
for (i = 0; i < my_add_tag; i++) {
v = i + my_add_tag_s;
if (PDCobj_put_tag(obj_ids[i], kvtag.name, kvtag.value, kvtag.size) < 0)
printf("fail to add a kvtag to o%d\n", i + my_obj_s);
printf("fail to add a kvtag to o%llu\n", i + my_obj_s);
}

#ifdef ENABLE_MPI
MPI_Barrier(MPI_COMM_WORLD);
total_time = MPI_Wtime() - stime;
#endif
if (my_rank == 0)
printf("Total time to add tags to %d objects: %.4f\n", n_add_tag, total_time);
printf("Total time to add tags to %llu objects: %.4f\n", n_add_tag, total_time);

values = (pdc_kvtag_t **)calloc(my_query, sizeof(pdc_kvtag_t *));

Expand All @@ -163,21 +177,21 @@ main(int argc, char *argv[])
#endif
for (i = 0; i < my_query; i++) {
if (PDCobj_get_tag(obj_ids[i], kvtag.name, (void *)&values[i], (void *)&value_size) < 0)
printf("fail to get a kvtag from o%d\n", i + my_query_s);
printf("fail to get a kvtag from o%llu\n", i + my_query_s);
}

#ifdef ENABLE_MPI
MPI_Barrier(MPI_COMM_WORLD);
total_time = MPI_Wtime() - stime;
#endif
if (my_rank == 0)
printf("Total time to retrieve tags from %d objects: %.4f\n", n_query, total_time);
printf("Total time to retrieve tags from %llu objects: %.4f\n", n_query, total_time);

fflush(stdout);

for (i = 0; i < my_query; i++) {
if (*(int *)(values[i]->value) != i + my_add_tag_s)
printf("Error with retrieved tag from o%d\n", i + my_query_s);
printf("Error with retrieved tag from o%llu\n", i + my_query_s);

PDC_free_kvtag(&values[i]);
}
Expand All @@ -186,7 +200,7 @@ main(int argc, char *argv[])
// close first object
for (i = 0; i < my_obj; i++) {
if (PDCobj_close(obj_ids[i]) < 0)
printf("fail to close object o%d\n", i + my_obj_s);
printf("fail to close object o%llu\n", i + my_obj_s);
}

// close a container
Expand Down

0 comments on commit fe1f8b4

Please sign in to comment.