Skip to content

Commit

Permalink
fabtests/multinode: add enum to fix magic numbers
Browse files Browse the repository at this point in the history
Add an enum to set the pattern in a more readable way

Signed-off-by: Alex McKinley <[email protected]>
  • Loading branch information
alex-mckinley authored and shefty committed Nov 3, 2022
1 parent 443599c commit d2da72f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 8 additions & 1 deletion fabtests/multinode/include/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ enum multi_xfer{
multi_rma,
};

enum multi_pattern {
PATTERN_MESH,
PATTERN_RING,
PATTERN_GATHER,
PATTERN_BROADCAST,
};

struct multi_xfer_method {
char* name;
int (*send)();
Expand All @@ -69,7 +76,7 @@ struct pm_job_info {
size_t name_len;
fi_addr_t *fi_addrs;
enum multi_xfer transfer_method;
int pattern;
enum multi_pattern pattern;
};

struct multinode_xfer_state {
Expand Down
14 changes: 7 additions & 7 deletions fabtests/multinode/src/harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include <core.h>
struct pm_job_info pm_job;

static int parse_caps(char *caps)
static enum multi_xfer parse_caps(char *caps)
{
if (strcmp(caps, "msg") == 0) {
return multi_msg;
Expand All @@ -57,19 +57,19 @@ static int parse_caps(char *caps)
}
}

static int parse_pattern(char *pattern)
static enum multi_pattern parse_pattern(char *pattern)
{
if (strcmp(pattern, "full_mesh") == 0) {
return 0;
return PATTERN_MESH;
} else if (strcmp(pattern, "ring") == 0) {
return 1;
return PATTERN_RING;
} else if (strcmp(pattern, "gather") == 0) {
return 2;
return PATTERN_GATHER;
} else if (strcmp(pattern, "broadcast") == 0) {
return 3;
return PATTERN_BROADCAST;
} else {
printf("Warn: Invalid pattern, defaulting to full_mesh\n");
return 0;
return PATTERN_MESH;
}
}

Expand Down

0 comments on commit d2da72f

Please sign in to comment.