Skip to content

Commit

Permalink
Merge branch 'feature/unittests' of github.com:flux-framework/dyad in…
Browse files Browse the repository at this point in the history
…to feature/unittests
  • Loading branch information
hariharan-devarajan committed Mar 20, 2024
2 parents 9745f7f + 1d5cccb commit 214bd7c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(dspaces_perf)
add_subdirectory(unit)
41 changes: 41 additions & 0 deletions tests/dspaces_perf/data_plane/data_plane.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
#include <fcntl.h>
#include <dspaces.h>
#include <stdio.h>
#include <string.h>

#include <array>

FILE* redirect_stdout(const char* filename)
{
size_t dir_len = strlen(args.dspaces_timing_dir);
bool ends_with_separator = (args.dspaces_timing_dir[dir_len-1] == '/');
size_t filename_len = dir_len + strlen(filename) + 1;
if (!ends_with_separator) {
filename_len += 1;
}
char* full_filename = malloc(filename_len * sizeof(char));
memset(full_filename, 0, filename_len*sizeof(char));
strcpy(full_filename, args.dspaces_timing_dir);
if (!ends_with_separator) {
strcat(full_filename, "/");
}
strcat(full_filename, filename);
return freopen(full_filename, "a", stdout);
}

int restore_stdout(FILE* freopen_fp)
{
return fclose(freopen_fp);
}

void gen_var_name(char* filename, bool is_local, bool add_rank_if_remote, bool next_local_rank, bool next_node) {
size_t node_idx = info.rank / args.process_per_node;
size_t local_rank = info.rank % args.process_per_node;
Expand Down Expand Up @@ -78,6 +103,9 @@ TEST_CASE("RemoteDataBandwidth", "[files= " + std::to_string(args.number_of_file
int ndim = 1;
uint64_t lb = 0;
uint64_t ub = data_len - 1;
FILE* fp = redirect_stdout("remote_data_bandwidth.csv");
REQUIRE(fp != NULL);
printf("rank,var_name,version,mdata_time_ns,data_time_ns\n");
for (size_t file_idx=0; file_idx < args.number_of_files; ++file_idx) {
data_time.resumeTime();
// Using aget instead of get because dyad_get_data also allocates the buffer
Expand All @@ -87,6 +115,7 @@ TEST_CASE("RemoteDataBandwidth", "[files= " + std::to_string(args.number_of_file
REQUIRE (rc == dspaces_SUCCESS);
free(file_data);
}
restore_stdout(fp);
AGGREGATE_TIME(data);
if (info.rank == 0) {
printf("[DSPACES_TEST],%10d,%10lu,%10.6f,%10.6f\n",
Expand Down Expand Up @@ -117,6 +146,9 @@ TEST_CASE("RemoteDataAggBandwidth", "[files= " + std::to_string(args.number_of_f
int ndim = 1;
uint64_t lb = 0;
uint64_t ub = data_len - 1;
FILE* fp = redirect_stdout("remote_data_agg_bandwidth.csv");
REQUIRE(fp != NULL);
printf("rank,var_name,version,mdata_time_ns,data_time_ns\n");
if (info.rank % args.process_per_node != 0)
usleep (10000);
for (size_t file_idx=0; file_idx < args.number_of_files; ++file_idx) {
Expand All @@ -129,6 +161,7 @@ TEST_CASE("RemoteDataAggBandwidth", "[files= " + std::to_string(args.number_of_f
REQUIRE (rc == dspaces_SUCCESS);
free(file_data);
}
restore_stdout(fp);
AGGREGATE_TIME(data);
if (info.rank == 0) {
printf("[DSPACES_TEST],%10d,%10lu,%10.6f,%10.6f\n",
Expand Down Expand Up @@ -160,6 +193,9 @@ TEST_CASE("LocalProcessDataBandwidth", "[files= " + std::to_string(args.number_o
uint64_t lb = 0;
uint64_t ub = data_len - 1;
char* file_data = NULL;
FILE* fp = redirect_stdout("local_process_data_bandwidth.csv");
REQUIRE(fp != NULL);
printf("rank,var_name,version,mdata_time_ns,data_time_ns\n");
for (size_t file_idx=0; file_idx < args.number_of_files; ++file_idx) {
data_time.resumeTime();
// Using aget instead of get because dyad_get_data also allocates the buffer
Expand All @@ -169,6 +205,7 @@ TEST_CASE("LocalProcessDataBandwidth", "[files= " + std::to_string(args.number_o
REQUIRE (rc == dspaces_SUCCESS);
free(file_data);
}
restore_stdout(fp);
AGGREGATE_TIME(data);
if (info.rank == 0) {
printf("[DSPACES_TEST],%10d,%10lu,%10.6f,%10.6f\n",
Expand Down Expand Up @@ -200,6 +237,9 @@ TEST_CASE("LocalNodeDataBandwidth", "[files= " + std::to_string(args.number_of_f
uint64_t lb = 0;
uint64_t ub = data_len - 1;
char* file_data = NULL;
FILE* fp = redirect_stdout("local_node_data_bandwidth.csv");
REQUIRE(fp != NULL);
printf("rank,var_name,version,mdata_time_ns,data_time_ns\n");
for (size_t file_idx=0; file_idx < args.number_of_files; ++file_idx) {
data_time.resumeTime();
// Using aget instead of get because dyad_get_data also allocates the buffer
Expand All @@ -209,6 +249,7 @@ TEST_CASE("LocalNodeDataBandwidth", "[files= " + std::to_string(args.number_of_f
REQUIRE (rc == dspaces_SUCCESS);
free(file_data);
}
restore_stdout(fp);
AGGREGATE_TIME(data);
if (info.rank == 0) {
printf("[DSPACES_TEST],%10d,%10lu,%10.6f,%10.6f\n",
Expand Down
6 changes: 5 additions & 1 deletion tests/dspaces_perf/unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct Info {
size_t num_server_procs;
};
struct Arguments {
const char* dspaces_timing_dir;
// MPI Configurations
size_t process_per_node = 1;
// DataSpaces Configuration
Expand Down Expand Up @@ -63,6 +64,8 @@ cl::Parser define_options() {
"number_of_files")["-n"]["--number_of_files"]("Number of Files") |
cl::Opt(args.server_ppn,
"server_ppn")["-s"]["--server_ppn"]("Number of DataSpaces server processes per node") |
cl::Opt(args.dspaces_timing_dir,
"dspaces_timing_dir")["-t"]["--timing_dir"]("Directory to write DataSpaces internal timings") |
cl::Opt(args.debug,
"debug")["-d"]["--debug"]("debug");
}
Expand All @@ -76,4 +79,5 @@ int posttest() {
return 0;
}
#include "data_plane/data_plane.cpp"
#include "mdm/mdm.cpp"
// Temporarily disable mdm tests
// #include "mdm/mdm.cpp"

0 comments on commit 214bd7c

Please sign in to comment.