Skip to content

Commit 9f2b68d

Browse files
authored
Add CS, PRL, LDC and RDC access patterns with supporting config (#118)
* Add CS, PRL, RDC, and LDC patterns and supporting config * Remove extra whitespace * Add Readme for the new patterns * Bugfix: Checks on parameter values separated for different access patterns * Add and modify code documentation * Remove unused parameters to functions * Committing clang-format changes
1 parent 2da97cd commit 9f2b68d

12 files changed

+603
-22
lines changed

commons/h5bench_util.c

Lines changed: 139 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -587,23 +587,77 @@ _set_io_pattern(bench_params *params_in_out)
587587
(params_in_out->io_op == IO_APPEND)) { // file --> mem
588588
if (params_in_out->mem_pattern == PATTERN_CONTIG) {
589589
if (params_in_out->file_pattern == PATTERN_CONTIG) {
590-
switch (params_in_out->num_dims) {
591-
case 1:
592-
(*params_in_out).access_pattern.pattern_read = CONTIG_1D;
593-
ret = 0;
594-
break;
595-
case 2:
596-
(*params_in_out).access_pattern.pattern_read = CONTIG_2D;
597-
ret = 0;
598-
break;
599-
case 3:
600-
(*params_in_out).access_pattern.pattern_read = CONTIG_3D;
601-
ret = 0;
602-
break;
603-
default:
604-
ret = -1;
605-
printf("%s() failed on line %d\n", __func__, __LINE__);
606-
break;
590+
if (params_in_out->read_option == LDC) {
591+
switch (params_in_out->num_dims) {
592+
case 2:
593+
(*params_in_out).access_pattern.pattern_read = LDC_2D;
594+
ret = 0;
595+
break;
596+
default:
597+
ret = -1;
598+
printf("%s(). Unexpected Dimensions for LDC. failed on line %d\n", __func__,
599+
__LINE__);
600+
break;
601+
}
602+
}
603+
else if (params_in_out->read_option == RDC) {
604+
switch (params_in_out->num_dims) {
605+
case 2:
606+
(*params_in_out).access_pattern.pattern_read = RDC_2D;
607+
ret = 0;
608+
break;
609+
default:
610+
ret = -1;
611+
printf("%s(). Unexpected Dimensions for RDC. failed on line %d\n", __func__,
612+
__LINE__);
613+
break;
614+
}
615+
}
616+
else if (params_in_out->read_option == PRL) {
617+
switch (params_in_out->num_dims) {
618+
case 2:
619+
(*params_in_out).access_pattern.pattern_read = PRL_2D;
620+
ret = 0;
621+
break;
622+
default:
623+
ret = -1;
624+
printf("%s(). Unexpected Dimensions for PRL. failed on line %d\n", __func__,
625+
__LINE__);
626+
break;
627+
}
628+
}
629+
else if (params_in_out->read_option == CS) {
630+
switch (params_in_out->num_dims) {
631+
case 2:
632+
(*params_in_out).access_pattern.pattern_read = CS_2D;
633+
ret = 0;
634+
break;
635+
default:
636+
ret = -1;
637+
printf("%s(). Unexpected Dimensions for CS. failed on line %d\n", __func__,
638+
__LINE__);
639+
break;
640+
}
641+
}
642+
else {
643+
switch (params_in_out->num_dims) {
644+
case 1:
645+
(*params_in_out).access_pattern.pattern_read = CONTIG_1D;
646+
ret = 0;
647+
break;
648+
case 2:
649+
(*params_in_out).access_pattern.pattern_read = CONTIG_2D;
650+
ret = 0;
651+
break;
652+
case 3:
653+
(*params_in_out).access_pattern.pattern_read = CONTIG_3D;
654+
ret = 0;
655+
break;
656+
default:
657+
ret = -1;
658+
printf("%s() failed on line %d\n", __func__, __LINE__);
659+
break;
660+
}
607661
}
608662
}
609663
else if (params_in_out->file_pattern == PATTERN_STRIDED) {
@@ -772,15 +826,28 @@ _set_params(char *key, char *val_in, bench_params *params_in_out, int do_write)
772826
}
773827
}
774828
else if (strcmp(key, "READ_OPTION") == 0) {
775-
if (val_in[0] == 'F') { // FULL
829+
if (strcmp(val_in, "FULL") == 0) { // FULL
776830
(*params_in_out).read_option = READ_FULL;
777831
}
778-
else if (val_in[0] == 'P') { // PARTIAL
832+
else if (strcmp(val_in, "PARTIAL") == 0) { // PARTIAL
779833
(*params_in_out).read_option = READ_PARTIAL;
780834
}
781-
else if (val_in[0] == 'S') { // STRIDED
835+
else if (strcmp(val_in, "STRIDED") == 0) { // STRIDED
782836
(*params_in_out).read_option = READ_STRIDED;
783837
}
838+
else if (strcmp(val_in, "LDC") == 0) {
839+
(*params_in_out).read_option = LDC;
840+
}
841+
else if (strcmp(val_in, "RDC") == 0) {
842+
(*params_in_out).read_option = RDC;
843+
}
844+
else if (strcmp(val_in, "PRL") == 0) {
845+
(*params_in_out).read_option = PRL;
846+
}
847+
else if (strcmp(val_in, "CS") == 0) {
848+
(*params_in_out).read_option = CS;
849+
}
850+
784851
else
785852
(*params_in_out).read_option = READ_OPTION_INVALID;
786853
}
@@ -873,12 +940,36 @@ _set_params(char *key, char *val_in, bench_params *params_in_out, int do_write)
873940
return -1;
874941
(*params_in_out).stride = num;
875942
}
943+
else if (strcmp(key, "STRIDE_SIZE_2") == 0) {
944+
unsigned long long num = 0;
945+
if (str_to_ull(val, &num) < 0)
946+
return -1;
947+
(*params_in_out).stride_2 = num;
948+
}
949+
else if (strcmp(key, "STRIDE_SIZE_3") == 0) {
950+
unsigned long long num = 0;
951+
if (str_to_ull(val, &num) < 0)
952+
return -1;
953+
(*params_in_out).stride_3 = num;
954+
}
876955
else if (strcmp(key, "BLOCK_SIZE") == 0) {
877956
unsigned long long num = 0;
878957
if (str_to_ull(val, &num) < 0)
879958
return -1;
880959
(*params_in_out).block_size = num;
881960
}
961+
else if (strcmp(key, "BLOCK_SIZE_2") == 0) {
962+
unsigned long long num = 0;
963+
if (str_to_ull(val, &num) < 0)
964+
return -1;
965+
(*params_in_out).block_size_2 = num;
966+
}
967+
else if (strcmp(key, "BLOCK_SIZE_3") == 0) {
968+
unsigned long long num = 0;
969+
if (str_to_ull(val, &num) < 0)
970+
return -1;
971+
(*params_in_out).block_size_3 = num;
972+
}
882973
else if (strcmp(key, "BLOCK_CNT") == 0) {
883974
unsigned long long num = 0;
884975
if (str_to_ull(val, &num) < 0)
@@ -985,7 +1076,11 @@ bench_params_init(bench_params *params_out)
9851076
(*params_out).num_dims = 1;
9861077

9871078
(*params_out).stride = 0;
1079+
(*params_out).stride_2 = 0;
1080+
(*params_out).stride_3 = 0;
9881081
(*params_out).block_size = 0;
1082+
(*params_out).block_size_2 = 0;
1083+
(*params_out).block_size_3 = 0;
9891084
(*params_out).block_cnt = 0;
9901085
(*params_out).dim_1 = 1;
9911086
(*params_out).dim_2 = 1;
@@ -1109,6 +1204,30 @@ read_config(const char *file_path, bench_params *params_out, int do_write)
11091204
return -1;
11101205
}
11111206
}
1207+
if (params_out->access_pattern.pattern_read == LDC_2D) {
1208+
if (params_out->block_size < 1 || params_out->block_size_2 < 1) {
1209+
printf("LDC read requires BLOCK_SIZE/BLOCK_SIZE_2 no less than 1.\n");
1210+
return -1;
1211+
}
1212+
}
1213+
if (params_out->access_pattern.pattern_read == RDC_2D) {
1214+
if (params_out->block_size < 1 || params_out->block_size_2 < 1) {
1215+
printf("RDC read requires BLOCK_SIZE/BLOCK_SIZE_2 no less than 1.\n");
1216+
return -1;
1217+
}
1218+
}
1219+
if (params_out->access_pattern.pattern_read == PRL_2D) {
1220+
if (params_out->block_size < 1 || params_out->block_size_2 < 1) {
1221+
printf("PRL read requires BLOCK_SIZE/BLOCK_SIZE_2 no less than 1.\n");
1222+
return -1;
1223+
}
1224+
}
1225+
if (params_out->access_pattern.pattern_read == CS_2D) {
1226+
if (params_out->stride < 1 || params_out->stride_2 < 1) {
1227+
printf("CS read requires STRIDE_SIZE/STRIDE_SIZE_2 no less than 1.\n");
1228+
return -1;
1229+
}
1230+
}
11121231
}
11131232
if (params_out->subfiling > 0 && params_out->data_coll == 1) {
11141233
printf("Subfiling does not support collective data buffering for data.\n");

commons/h5bench_util.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ typedef enum read_pattern {
6868
STRIDED_1D,
6969
CONTIG_2D,
7070
CONTIG_3D,
71+
LDC_2D,
72+
RDC_2D,
73+
CS_2D,
74+
PRL_2D,
7175
} read_pattern;
7276

7377
typedef enum pattern {
@@ -85,7 +89,16 @@ typedef enum io_operation {
8589
IO_APPEND,
8690
} io_operation;
8791

88-
typedef enum read_option { READ_OPTION_INVALID, READ_FULL, READ_PARTIAL, READ_STRIDED } read_option;
92+
typedef enum read_option {
93+
READ_OPTION_INVALID,
94+
READ_FULL,
95+
READ_PARTIAL,
96+
READ_STRIDED,
97+
LDC,
98+
RDC,
99+
PRL,
100+
CS
101+
} read_option;
89102

90103
typedef struct bench_params {
91104
io_operation io_op;
@@ -115,7 +128,11 @@ typedef struct bench_params {
115128
duration compute_time;
116129
int num_dims;
117130
unsigned long stride;
131+
unsigned long stride_2;
132+
unsigned long stride_3;
118133
unsigned long block_size;
134+
unsigned long block_size_2;
135+
unsigned long block_size_3;
119136
unsigned long block_cnt;
120137
unsigned long dim_1;
121138
unsigned long dim_2;

h5bench_patterns/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Additions to H5Bench_read
2+
4 new patterns are added to the h5bench read benchmark:
3+
1. CS: Refers to the Cross Stencil data access pattern. A block of fixed sides is used to read data from HDF5. This block is given a fixed stride in each dimension and data till end of file is read.
4+
2. LDC: Refers to the Left Diagonal Corner data access pattern. Data is read from two identical blocks of fixed sides, one in the top left corner and the other in the bottom right corner in the 2D HDF5 file
5+
3. RDC: Refers to the Right Diagonal Corner data access pattern. Data is read from two identical blocks of fixed sides, one in the top right corner and the other in the bottom left corner in the 2D HDF5 file
6+
4. PRL: Refers to the Peripheral data access pattern. Data is read from the periphery of the file, which is a frame of fixed width and height around the file.
7+
8+
These patterns work with a single MPI process. In case multiple processes are used, only the root performs the read operations and all other processes skip the reads. Illustrations of the patterns are given in the table below:
9+
10+
| Pattern -> | CS | LDC | RDC | PRL |
11+
| ---------- | ---------- | ---------- | ---------- | ---------- |
12+
|Illustration | ![CS Pattern](./images/CS.png) | ![LDC Pattern](./images/LDC.png) | ![RDC Pattern](./images/RDC.png) | ![PRL Pattern](./images/PRL.png) |
13+
14+
15+
16+
Steps for running these benchmarks are the same as the other benchmarks. All parameter and requirements and running instructions remain same, except for the following parameters which are additionally required to be provided in the configuration:
17+
1. CS
18+
| Parameter | Description |
19+
| --------- | ----------- |
20+
| `BLOCK_SIZE` | Size of the block of data along `dim_1` |
21+
| `BLOCK_SIZE_2` | Size of the block of data along `dim_2` |
22+
| `STRIDE_SIZE` | Size of the block of data along `dim_1` |
23+
| `STRIDE_SIZE_2` | Size of the block of data along `dim_2` |
24+
25+
2. LDC/RDC
26+
| Parameter | Description |
27+
| --------- | ----------- |
28+
| `BLOCK_SIZE` | Size of the block of data along `dim_1` |
29+
| `BLOCK_SIZE_2` | Size of the block of data along `dim_2` |
30+
31+
3. PRL
32+
| Parameter | Description |
33+
| --------- | ----------- |
34+
| `BLOCK_SIZE` | Size of the frame along `dim_1` |
35+
| `BLOCK_SIZE_2` | Size of the frame along `dim_2` |
36+
37+
Exmaples of some configurations are provided in `h5bench/samples/sync-write-1d-contig-contig-read-<pattern>.json`

0 commit comments

Comments
 (0)