From 1cc3f187ee3524e412babf5059fed4757b3769fd Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Fri, 19 Mar 2021 11:25:22 -0500 Subject: Rearranged the test in the following way: 1. Reader waits for a number of ticks (3 by default) before verifying the creation of groups and attributes; 2. Error handling is consistent with traditional setup of the test suite. --- test/testvfdswmr.sh.in | 7 +- test/vfd_swmr_group_writer.c | 538 ++++++++++++++++++++++++++++++++----------- 2 files changed, 411 insertions(+), 134 deletions(-) diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index a2e47b1..fc6b0df 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -610,17 +610,17 @@ if [ ${do_zoo:-no} = yes ]; then fi # -# Make sure that we can create 10000 groups while a reader waits +# Make sure that we can create 1000 groups while a reader waits # for each to appear. # if [ ${do_groups:-no} = yes ]; then echo launch vfd_swmr_group_writer catch_out_err_and_rc vfd_swmr_group_writer \ - ../vfd_swmr_group_writer -q -u 10 -n 10000 & + ../vfd_swmr_group_writer -q -c 100 -n 1000 & pid_writer=$! catch_out_err_and_rc vfd_swmr_group_reader \ - ../vfd_swmr_group_reader -q -u 10 -n 10000 -W & + ../vfd_swmr_group_reader -q -c 100 -n 1000 -u 5 & pid_reader=$! # Wait for the reader to finish before signalling the @@ -628,7 +628,6 @@ if [ ${do_groups:-no} = yes ]; then # reader will find the shadow file when it opens # the .h5 file. wait $pid_reader - kill -USR1 $(cat vfd_swmr_group_writer.pid) wait $pid_writer # Collect exit code of the reader diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 2f355c2..4e323ef 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -18,21 +18,22 @@ #include "hdf5.h" #include "H5Fpkg.h" -// #include "H5Iprivate.h" #include "H5HGprivate.h" #include "H5VLprivate.h" #include "testhdf5.h" #include "vfd_swmr_common.h" +#define READER_WAIT_TICKS 3 + typedef struct { hid_t file, filetype, one_by_one_sid; char filename[PATH_MAX]; char progname[PATH_MAX]; - struct timespec update_interval; unsigned int asteps; + unsigned int csteps; unsigned int nsteps; - bool wait_for_signal; + unsigned int update_interval; bool use_vfd_swmr; } state_t; @@ -42,37 +43,29 @@ typedef struct { , .filename = "" \ , .filetype = H5T_NATIVE_UINT32 \ , .asteps = 10 \ + , .csteps = 10 \ , .nsteps = 100 \ - , .wait_for_signal = true \ - , .use_vfd_swmr = true \ - , .update_interval = (struct timespec){ \ - .tv_sec = 0 \ - , .tv_nsec = 1000000000UL / 30 /* 1/30 second */}} - -static void state_init(state_t *, int, char **); - -static const hid_t badhid = H5I_INVALID_HID; + , .update_interval = READER_WAIT_TICKS \ + , .use_vfd_swmr = true} static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-S] [-W] [-a steps] [-b]\n" - " [-n iterations] [-u milliseconds]\n" + fprintf(stderr, "usage: %s [-S] [-a steps] [-b] [-c]\n" + " [-n iterations] [-u numb_ticks]\n" "\n" "-S: do not use VFD SWMR\n" - "-W: do not wait for a signal before\n" - " exiting\n" "-a steps: `steps` between adding attributes\n" "-b: write data in big-endian byte order\n" - "-n iterations: how many times to expand each dataset\n" - "-u ms: milliseconds interval between updates\n" - " to %s.h5\n" + "-c steps: `steps` between communication between the writer and reader\n" + "-n ngroups: the number of groups\n" + "-u numb_tcks: `numb_ticks` for the reader to wait before verification\n" "\n", - progname, progname); + progname); exit(EXIT_FAILURE); } -static void +static bool state_init(state_t *s, int argc, char **argv) { unsigned long tmp; @@ -80,37 +73,44 @@ state_init(state_t *s, int argc, char **argv) const hsize_t dims = 1; char tfile[PATH_MAX]; char *end; - unsigned long millis; *s = ALL_HID_INITIALIZER; esnprintf(tfile, sizeof(tfile), "%s", argv[0]); esnprintf(s->progname, sizeof(s->progname), "%s", HDbasename(tfile)); - while ((ch = getopt(argc, argv, "SWa:bn:qu:")) != -1) { + while ((ch = getopt(argc, argv, "SWa:bc:n:qu:")) != -1) { switch (ch) { case 'S': s->use_vfd_swmr = false; break; - case 'W': - s->wait_for_signal = false; - break; case 'a': + case 'c': case 'n': + case 'u': errno = 0; tmp = strtoul(optarg, &end, 0); if (end == optarg || *end != '\0') { - errx(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, - optarg); + H5_FAILED(); AT(); + printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); + goto error; } else if (errno != 0) { - err(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, - optarg); - } else if (tmp > UINT_MAX) - errx(EXIT_FAILURE, "`-%c` argument `%lu` too large", ch, tmp); + H5_FAILED(); AT(); + printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); + goto error; + } else if (tmp > UINT_MAX) { + H5_FAILED(); AT(); + printf("`-%c` argument `%lu` too large\n", ch, tmp); + goto error; + } if (ch == 'a') s->asteps = (unsigned)tmp; - else + else if (ch == 'c') + s->csteps = (unsigned)tmp; + else if (ch == 'n') s->nsteps = (unsigned)tmp; + else if (ch == 'u') + s->update_interval = (unsigned)tmp; break; case 'b': s->filetype = H5T_STD_U32BE; @@ -118,21 +118,6 @@ state_init(state_t *s, int argc, char **argv) case 'q': verbosity = 0; break; - case 'u': - errno = 0; - millis = strtoul(optarg, &end, 0); - if (millis == ULONG_MAX && errno == ERANGE) { - err(EXIT_FAILURE, - "option -p argument \"%s\"", optarg); - } else if (*end != '\0') { - errx(EXIT_FAILURE, - "garbage after -p argument \"%s\"", optarg); - } - s->update_interval.tv_sec = (time_t)(millis / 1000UL); - s->update_interval.tv_nsec = - (long)((millis * 1000000UL) % 1000000000UL); - dbgf(1, "%lu milliseconds between updates\n", millis); - break; case '?': default: usage(s->progname); @@ -143,16 +128,39 @@ state_init(state_t *s, int argc, char **argv) argv += optind; /* space for attributes */ - if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) - errx(EXIT_FAILURE, "H5Screate_simple failed"); + if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) { + H5_FAILED(); AT(); + printf("H5Screate_simple failed\n"); + goto error; + } + + if( s->csteps < 1 || s->csteps > s->nsteps) { + H5_FAILED(); AT(); + printf("communication interval is out of bounds\n"); + goto error; + } - if (argc > 0) - errx(EXIT_FAILURE, "unexpected command-line arguments"); + if( s->asteps < 1 || s->asteps > s->nsteps) { + H5_FAILED(); AT(); + printf("attribute interval is out of bounds\n"); + goto error; + } + + if (argc > 0) { + H5_FAILED(); AT(); + printf("unexpected command-line arguments\n"); + goto error; + } esnprintf(s->filename, sizeof(s->filename), "vfd_swmr_group.h5"); + + return true; + +error: + return false; } -static void +static bool add_group_attribute(const state_t *s, hid_t g, hid_t sid, unsigned int which) { hid_t aid; @@ -163,42 +171,78 @@ add_group_attribute(const state_t *s, hid_t g, hid_t sid, unsigned int which) dbgf(1, "setting attribute %s on group %u to %u\n", name, which, which); if ((aid = H5Acreate2(g, name, s->filetype, sid, H5P_DEFAULT, - H5P_DEFAULT)) < 0) - errx(EXIT_FAILURE, "H5Acreate2 failed"); + H5P_DEFAULT)) < 0) { + H5_FAILED(); AT(); + printf("H5Acreate2 failed\n"); + goto error; + } - if (H5Awrite(aid, H5T_NATIVE_UINT, &which) < 0) - errx(EXIT_FAILURE, "H5Awrite failed"); - if (H5Aclose(aid) < 0) - errx(EXIT_FAILURE, "H5Aclose failed"); + if (H5Awrite(aid, H5T_NATIVE_UINT, &which) < 0) { + H5_FAILED(); AT(); + printf("H5Awrite failed\n"); + goto error; + } + + if (H5Aclose(aid) < 0) { + H5_FAILED(); AT(); + printf("H5Aclose failed\n"); + goto error; + } + + return true; + +error: + H5E_BEGIN_TRY { + H5Aclose(aid); + } H5E_END_TRY; + + return false; } -static void +static bool write_group(state_t *s, unsigned int which) { char name[sizeof("/group-9999999999")]; - hid_t g; + hid_t g = H5I_INVALID_HID; + bool result = true; - assert(which < s->nsteps); + if (which >= s->nsteps) { + H5_FAILED(); AT(); + printf("group order is out of bounds\n"); + goto error; + } esnprintf(name, sizeof(name), "/group-%d", which); - g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - if (g < 0) - errx(EXIT_FAILURE, "H5Gcreate(, \"%s\", ) failed", name); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); AT(); + printf("H5Gcreate2 failed\n"); + goto error; + } if (s->asteps != 0 && which % s->asteps == 0) - add_group_attribute(s, g, s->one_by_one_sid, which); + result = add_group_attribute(s, g, s->one_by_one_sid, which); - if (H5Gclose(g) < 0) - errx(EXIT_FAILURE, "H5Gclose failed"); + if (H5Gclose(g) < 0) { + H5_FAILED(); AT(); + printf("H5Gclose failed\n"); + goto error; + } + + return result; + +error: + H5E_BEGIN_TRY { + H5Gclose(g); + } H5E_END_TRY; + + return false; } static bool verify_group_attribute(hid_t g, unsigned int which) { - estack_state_t es; unsigned int read_which; hid_t aid; char name[sizeof("attr-9999999999")]; @@ -208,70 +252,111 @@ verify_group_attribute(hid_t g, unsigned int which) dbgf(1, "verifying attribute %s on group %u equals %u\n", name, which, which); - es = disable_estack(); if ((aid = H5Aopen(g, name, H5P_DEFAULT)) < 0) { - restore_estack(es); - return false; + H5_FAILED(); AT(); + printf("H5Aopen failed\n"); + goto error; } if (H5Aread(aid, H5T_NATIVE_UINT, &read_which) < 0) { - restore_estack(es); - if (H5Aclose(aid) < 0) - errx(EXIT_FAILURE, "H5Aclose failed"); - return false; + H5_FAILED(); AT(); + printf("H5Aread failed\n"); + goto error; } - restore_estack(es); + if (read_which != which) { + H5_FAILED(); AT(); + printf("H5Aread wrong value\n"); + goto error; + } - if (H5Aclose(aid) < 0) - errx(EXIT_FAILURE, "H5Aclose failed"); + if (H5Aclose(aid) < 0) { + H5_FAILED(); AT(); + printf("H5Aread failed\n"); + goto error; + } - return read_which == which; + return true; + +error: + H5E_BEGIN_TRY { + H5Aclose(aid); + } H5E_END_TRY; + + return false; } static bool verify_group(state_t *s, unsigned int which) { char name[sizeof("/group-9999999999")]; - hid_t g; - estack_state_t es; - bool result; + hid_t g = H5I_INVALID_HID; + bool result = true; - assert(which < s->nsteps); + if (which >= s->nsteps) { + H5_FAILED(); AT(); + printf("Group order is out of bounds\n"); + goto error; + } esnprintf(name, sizeof(name), "/group-%d", which); - es = disable_estack(); - g = H5Gopen(s->file, name, H5P_DEFAULT); - restore_estack(es); - - if (g < 0) - return false; + if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { + H5_FAILED(); AT(); + printf("H5Gopen failed\n"); + goto error; + } if (s->asteps != 0 && which % s->asteps == 0) result = verify_group_attribute(g, which); else result = true; - if (H5Gclose(g) < 0) - errx(EXIT_FAILURE, "H5Gclose failed"); + if (H5Gclose(g) < 0) { + H5_FAILED(); AT(); + printf("H5Gclose failed\n"); + goto error; + } return result; + +error: + H5E_BEGIN_TRY { + H5Gclose(g); + } H5E_END_TRY; + + return false; +} + +/* Sleep for `tenths` tenths of a second */ +static void +decisleep(uint32_t tenths) +{ + uint64_t nsec = tenths * 100 * 1000 * 1000; + + H5_nanosleep(nsec); } int main(int argc, char **argv) { - hid_t fapl, fcpl; - sigset_t oldsigs; - herr_t ret; + hid_t fapl = H5I_INVALID_HID, fcpl = H5I_INVALID_HID; unsigned step; - bool writer; + bool writer = false; state_t s; const char *personality; H5F_vfd_swmr_config_t config; - - state_init(&s, argc, argv); + const char *fifo_writer_to_reader = "./fifo_group_writer_to_reader"; + const char *fifo_reader_to_writer = "./fifo_group_reader_to_writer"; + int fd_writer_to_reader = -1, fd_reader_to_writer = -1; + int notify = 0, verify = 0; + unsigned int i; + + if (!state_init(&s, argc, argv)) { + H5_FAILED(); AT(); + printf("state_init failed\n"); + goto error; + } personality = strstr(s.progname, "vfd_swmr_group_"); @@ -282,64 +367,257 @@ main(int argc, char **argv) strcmp(personality, "vfd_swmr_group_reader") == 0) writer = false; else { - errx(EXIT_FAILURE, - "unknown personality, expected vfd_swmr_group_{reader,writer}"); + H5_FAILED(); AT(); + printf("unknown personality, expected vfd_swmr_group_{reader,writer}\n"); + goto error; } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./group-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, &config); - - if (fapl < 0) - errx(EXIT_FAILURE, "vfd_swmr_create_fapl"); + if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, &config)) < 0) { + H5_FAILED(); AT(); + printf("vfd_swmr_create_fapl failed\n"); + goto error; + } - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - errx(EXIT_FAILURE, "H5Pcreate"); + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { + H5_FAILED(); AT(); + printf("H5Pcreate failed\n"); + goto error; + } - ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1); - if (ret < 0) - errx(EXIT_FAILURE, "H5Pset_file_space_strategy"); + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1) < 0) { + H5_FAILED(); AT(); + printf("H5Pset_file_space_strategy failed\n"); + goto error; + } if (writer) s.file = H5Fcreate(s.filename, H5F_ACC_TRUNC, fcpl, fapl); else s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl); - if (s.file == badhid) - errx(EXIT_FAILURE, writer ? "H5Fcreate" : "H5Fopen"); + if (s.file < 0) { + H5_FAILED(); AT(); + printf("H5Fcreate/open failed\n"); + goto error; + } + + /* Use two named pipes(FIFO) to coordinate the writer and reader for + * two-way communication so that the two sides can move forward together. + * One is for the writer to write to the reader. + * The other one is for the reader to signal the writer. */ + if (writer) { + /* Writer creates two named pipes(FIFO) */ + if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) { + H5_FAILED(); AT(); + printf("HDmkfifo failed\n"); + goto error; + } + + if (HDmkfifo(fifo_reader_to_writer, 0600) < 0) { + H5_FAILED(); AT(); + printf("HDmkfifo failed\n"); + goto error; + } + + } + + /* Both the writer and reader open the pipes */ + if ((fd_writer_to_reader = HDopen(fifo_writer_to_reader, O_RDWR)) < 0) { + H5_FAILED(); AT(); + printf("HDopen failed\n"); + goto error; + } - block_signals(&oldsigs); + if ((fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) { + H5_FAILED(); AT(); + printf("HDopen failed\n"); + goto error; + } if (writer) { for (step = 0; step < s.nsteps; step++) { - dbgf(2, "step %d\n", step); - write_group(&s, step); - nanosleep(&s.update_interval, NULL); + dbgf(2, "writer: step %d\n", step); + + if (!write_group(&s, step)) { + H5_FAILED(); AT(); + printf("write_group failed\n"); + + /* At communication interval, notifies the reader about the failture and quit */ + if (step % s.csteps == 0) { + notify = -1; + HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)); + goto error; + } + } else { + /* At communication interval, notifies the reader and waits for its response */ + if (step % s.csteps == 0) { + /* Bump up the value of notify to notice the reader to start to read */ + notify++; + if (HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) { + H5_FAILED(); AT(); + printf("HDwrite failed\n"); + goto error; + } + + /* During the wait, writer makes repeated HDF5 API calls + * to trigger EOT at approximately the correct time */ + for(i = 0; i < config.max_lag + 1; i++) { + decisleep(config.tick_len); + H5E_BEGIN_TRY { + H5Aexists(s.file, "nonexistent"); + } H5E_END_TRY; + } + + /* Receive the same value from the reader and verify it before + * going to the next step */ + verify++; + if (HDread(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) { + H5_FAILED(); AT(); + printf("HDread failed\n"); + goto error; + } + + if (notify == -1) { + H5_FAILED(); AT(); + printf("reader failed to verify group\n"); + goto error; + } + + if (notify != verify) { + H5_FAILED(); AT(); + printf("received message %d, expecting %d\n", notify, verify); + goto error; + } + } + } } } else { - for (step = 0; step < s.nsteps;) { - dbgf(2, "step %d\n", step); - if (verify_group(&s, step)) - step++; - nanosleep(&s.update_interval, NULL); + for (step = 0; step < s.nsteps; step++) { + dbgf(2, "reader: step %d\n", step); + + /* At communication interval, waits for the writer to finish creation before starting verification */ + if (step % s.csteps == 0) { + /* The writer should have bumped up the value of notify. + * Do the same with verify and confirm it */ + verify++; + + /* Receive the notify that the writer bumped up the value */ + if (HDread(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) { + H5_FAILED(); AT(); + printf("HDread failed\n"); + goto error; + } + + if (notify == -1) { + H5_FAILED(); AT(); + printf("writer failed to create group\n"); + goto error; + } + + if (notify != verify) { + H5_FAILED(); AT(); + printf("received message %d, expecting %d\n", notify, verify); + goto error; + } + } + + /* Wait for a few ticks for the update to happen */ + decisleep(config.tick_len * s.update_interval); + + /* Start to verify group */ + if (!verify_group(&s, step)) { + H5_FAILED(); AT(); + printf("verify_group failed\n"); + + /* At communication interval, tell the writer about the failure and exit */ + if (step % s.csteps == 0) { + notify = -1; + HDwrite(fd_reader_to_writer, ¬ify, sizeof(int)); + goto error; + } + } else { + if (step % s.csteps == 0) { + /* Send back the same nofity value for acknowledgement to tell the writer + * move to the next step */ + if (HDwrite(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) { + H5_FAILED(); AT(); + printf("HDwrite failed\n"); + goto error; + } + } + } } } - if (s.use_vfd_swmr && s.wait_for_signal) - await_signal(s.file); + if (H5Pclose(fapl) < 0) { + H5_FAILED(); AT(); + printf("H5Pclose failed\n"); + goto error; + } - restore_signals(&oldsigs); + if (H5Pclose(fcpl) < 0) { + H5_FAILED(); AT(); + printf("H5Pclose failed\n"); + goto error; + } - if (H5Pclose(fapl) < 0) - errx(EXIT_FAILURE, "H5Pclose(fapl)"); + if (H5Fclose(s.file) < 0) { + H5_FAILED(); AT(); + printf("H5Fclose failed\n"); + goto error; + } - if (H5Pclose(fcpl) < 0) - errx(EXIT_FAILURE, "H5Pclose(fcpl)"); + /* Both the writer and reader close the named pipes */ + if (HDclose(fd_writer_to_reader) < 0) { + H5_FAILED(); AT(); + printf("HDclose failed\n"); + goto error; + } - if (H5Fclose(s.file) < 0) - errx(EXIT_FAILURE, "H5Fclose"); + if (HDclose(fd_reader_to_writer) < 0) { + H5_FAILED(); AT(); + printf("HDclose failed\n"); + goto error; + } + + /* Reader finishes last and deletes the named pipes */ + if(!writer) { + if(HDremove(fifo_writer_to_reader) != 0) { + H5_FAILED(); AT(); + printf("HDremove failed\n"); + goto error; + } + + if(HDremove(fifo_reader_to_writer) != 0) { + H5_FAILED(); AT(); + printf("HDremove failed\n"); + goto error; + } + } return EXIT_SUCCESS; + +error: + H5E_BEGIN_TRY { + H5Pclose(fapl); + H5Pclose(fcpl); + H5Fclose(s.file); + } H5E_END_TRY; + + if (fd_writer_to_reader >= 0) + HDclose(fd_writer_to_reader); + + if (fd_writer_to_reader >= 0) + HDclose(fd_reader_to_writer); + + if(!writer) { + HDremove(fifo_writer_to_reader); + HDremove(fifo_reader_to_writer); + } + + return EXIT_FAILURE; } -- cgit v0.12 From cace7d45ca5749be1f534b84c85fec8fdb384f67 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Mon, 22 Mar 2021 16:08:27 -0500 Subject: Adding group number adjustment for vfd_swmr_group_writer.c based on the level of HDF5TestExpress, to speed up the test or do more thorough test. --- test/testvfdswmr.sh.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index 6562ccc..edfdb27 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -40,7 +40,8 @@ nsofterrors=0 # soft errors are expected to occur some of the time # on a couple of nondeterministic tests. ############################################################################### -## test parameters for vfd_swmr_bigset_writer.c based on HDF5TestExpress: +## test parameters for vfd_swmr_bigset_writer.c and vfd_swmr_group_writer.c +## based on HDF5TestExpress: ## 0: Exhaustive run: Tests take a long time to run. ## 1: Default run. ## 2+: Quick run @@ -53,14 +54,17 @@ fi BIGSET_n=25 # -n option: # of iterations BIGSET_few_s=20 # -s option: # of datasets (for few_big test) BIGSET_many_s=500 # -s option: # of datasets (for many_small test) +GROUP_n=100 # -n option: # of groups (for vfd_swmr_group_writer.c) if [[ "$HDF5TestExpress" -eq 0 ]] ; then # Setting for exhaustive run BIGSET_n=50 BIGSET_few_s=40 BIGSET_many_s=1000 + GROUP_n = 400 elif [[ "$HDF5TestExpress" -gt 1 ]]; then # Setting for quick run BIGSET_n=10 BIGSET_few_s=10 BIGSET_many_s=100 + GROUP_n = 40 fi ############################################################################### @@ -610,17 +614,17 @@ if [ ${do_zoo:-no} = yes ]; then fi # -# Make sure that we can create 1000 groups while a reader waits -# for each to appear. +# Make sure that we can create GROUP_n groups (40, 100, or 400 depending on the HDF5TestExpress level) +# while a reader waits for each to appear. # if [ ${do_groups:-no} = yes ]; then echo launch vfd_swmr_group_writer catch_out_err_and_rc vfd_swmr_group_writer \ - ../vfd_swmr_group_writer -q -c 10 -n 100 & + ../vfd_swmr_group_writer -q -c 10 -n $GROUP_n & pid_writer=$! catch_out_err_and_rc vfd_swmr_group_reader \ - ../vfd_swmr_group_reader -q -c 10 -n 100 -u 5 & + ../vfd_swmr_group_reader -q -c 10 -n $GROUP_n -u 5 & pid_reader=$! # Wait for the reader to finish before signalling the -- cgit v0.12 From 89570ab68e16ac1b659854c25d007eb328c8b2b0 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Tue, 23 Mar 2021 11:17:08 -0500 Subject: Fixed a few typos. --- test/testvfdswmr.sh.in | 4 ++-- test/vfd_swmr_group_writer.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index edfdb27..644789c 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -59,12 +59,12 @@ if [[ "$HDF5TestExpress" -eq 0 ]] ; then # Setting for exhaustive run BIGSET_n=50 BIGSET_few_s=40 BIGSET_many_s=1000 - GROUP_n = 400 + GROUP_n=400 elif [[ "$HDF5TestExpress" -gt 1 ]]; then # Setting for quick run BIGSET_n=10 BIGSET_few_s=10 BIGSET_many_s=100 - GROUP_n = 40 + GROUP_n=40 fi ############################################################################### diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 4e323ef..cc705ab 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -611,7 +611,7 @@ error: if (fd_writer_to_reader >= 0) HDclose(fd_writer_to_reader); - if (fd_writer_to_reader >= 0) + if (fd_reader_to_writer >= 0) HDclose(fd_reader_to_writer); if(!writer) { -- cgit v0.12 From 14b1a821b7b12901a91c1b73ff70f6297a0dacd6 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 7 Apr 2021 11:36:46 -0500 Subject: Added an option to disable named pipes, mainly for running the writer and reader seperately or not using VFD SWMR. --- test/vfd_swmr_group_writer.c | 50 ++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index b9dbb42..cc0f593 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -34,6 +34,7 @@ typedef struct { unsigned int nsteps; unsigned int update_interval; bool use_vfd_swmr; + bool use_named_pipes; } state_t; #define ALL_HID_INITIALIZER \ @@ -41,21 +42,24 @@ typedef struct { { \ .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ .filetype = H5T_NATIVE_UINT32, .asteps = 10, .csteps = 10, .nsteps = 100, .update_interval = READER_WAIT_TICKS, \ - .use_vfd_swmr = true \ + .use_vfd_swmr = true, \ + .use_named_pipes = true \ } static void usage(const char *progname) { fprintf(stderr, "usage: %s [-S] [-a steps] [-b] [-c]\n" - " [-n iterations] [-u numb_ticks]\n" + " [-n iterations] [-p] [-q] [-u numb_ticks]\n" "\n" "-S: do not use VFD SWMR\n" "-a steps: `steps` between adding attributes\n" "-b: write data in big-endian byte order\n" "-c steps: `steps` between communication between the writer and reader\n" "-n ngroups: the number of groups\n" + "-p: do not use named pipes, mainly for running the writer and reader seperately\n" "-u numb_tcks: `numb_ticks` for the reader to wait before verification\n" + "-q: silence printouts, few messages\n" "\n", progname); exit(EXIT_FAILURE); @@ -83,7 +87,7 @@ state_init(state_t *s, int argc, char **argv) if (tfile) HDfree(tfile); - while ((ch = getopt(argc, argv, "SWa:bc:n:qu:")) != -1) { + while ((ch = getopt(argc, argv, "Sa:bc:n:pqu:")) != -1) { switch (ch) { case 'S': s->use_vfd_swmr = false; @@ -120,6 +124,9 @@ state_init(state_t *s, int argc, char **argv) case 'b': s->filetype = H5T_STD_U32BE; break; + case 'p': + s->use_named_pipes = false; + break; case 'q': verbosity = 0; break; @@ -413,7 +420,7 @@ main(int argc, char **argv) * two-way communication so that the two sides can move forward together. * One is for the writer to write to the reader. * The other one is for the reader to signal the writer. */ - if (writer) { + if (s.use_named_pipes && writer) { /* Writer creates two named pipes(FIFO) */ if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) { H5_FAILED(); AT(); @@ -430,13 +437,13 @@ main(int argc, char **argv) } /* Both the writer and reader open the pipes */ - if ((fd_writer_to_reader = HDopen(fifo_writer_to_reader, O_RDWR)) < 0) { + if (s.use_named_pipes && (fd_writer_to_reader = HDopen(fifo_writer_to_reader, O_RDWR)) < 0) { H5_FAILED(); AT(); printf("HDopen failed\n"); goto error; } - if ((fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) { + if (s.use_named_pipes && (fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) { H5_FAILED(); AT(); printf("HDopen failed\n"); goto error; @@ -451,14 +458,15 @@ main(int argc, char **argv) printf("write_group failed\n"); /* At communication interval, notifies the reader about the failture and quit */ - if (step % s.csteps == 0) { + if (s.use_named_pipes && (step % s.csteps == 0)) { notify = -1; HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)); - goto error; } + + goto error; } else { /* At communication interval, notifies the reader and waits for its response */ - if (step % s.csteps == 0) { + if (s.use_named_pipes && (step % s.csteps == 0)) { /* Bump up the value of notify to notice the reader to start to read */ notify++; if (HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) { @@ -506,7 +514,7 @@ main(int argc, char **argv) /* At communication interval, waits for the writer to finish creation before starting verification */ - if (step % s.csteps == 0) { + if (s.use_named_pipes && (step % s.csteps == 0)) { /* The writer should have bumped up the value of notify. * Do the same with verify and confirm it */ verify++; @@ -532,7 +540,8 @@ main(int argc, char **argv) } /* Wait for a few ticks for the update to happen */ - decisleep(config.tick_len * s.update_interval); + if (s.use_named_pipes) + decisleep(config.tick_len * s.update_interval); /* Start to verify group */ if (!verify_group(&s, step)) { @@ -540,13 +549,14 @@ main(int argc, char **argv) printf("verify_group failed\n"); /* At communication interval, tell the writer about the failure and exit */ - if (step % s.csteps == 0) { + if (s.use_named_pipes && (step % s.csteps == 0)) { notify = -1; HDwrite(fd_reader_to_writer, ¬ify, sizeof(int)); - goto error; } + + goto error; } else { - if (step % s.csteps == 0) { + if (s.use_named_pipes && (step % s.csteps == 0)) { /* Send back the same nofity value for acknowledgement to tell the writer * move to the next step */ if (HDwrite(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) { @@ -578,20 +588,20 @@ main(int argc, char **argv) } /* Both the writer and reader close the named pipes */ - if (HDclose(fd_writer_to_reader) < 0) { + if (s.use_named_pipes && HDclose(fd_writer_to_reader) < 0) { H5_FAILED(); AT(); printf("HDclose failed\n"); goto error; } - if (HDclose(fd_reader_to_writer) < 0) { + if (s.use_named_pipes && HDclose(fd_reader_to_writer) < 0) { H5_FAILED(); AT(); printf("HDclose failed\n"); goto error; } /* Reader finishes last and deletes the named pipes */ - if(!writer) { + if(s.use_named_pipes && !writer) { if(HDremove(fifo_writer_to_reader) != 0) { H5_FAILED(); AT(); printf("HDremove failed\n"); @@ -614,13 +624,13 @@ error: H5Fclose(s.file); } H5E_END_TRY; - if (fd_writer_to_reader >= 0) + if (s.use_named_pipes && fd_writer_to_reader >= 0) HDclose(fd_writer_to_reader); - if (fd_reader_to_writer >= 0) + if (s.use_named_pipes && fd_reader_to_writer >= 0) HDclose(fd_reader_to_writer); - if(!writer) { + if(s.use_named_pipes && !writer) { HDremove(fifo_writer_to_reader); HDremove(fifo_reader_to_writer); } -- cgit v0.12 From 64458a8ddba8c6c58f2d38b7f0a602c34427f46b Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 7 Apr 2021 21:29:19 -0500 Subject: Changed the command-line option for disabling named pipes from -p to -N, to be consistent with other tests. --- test/vfd_swmr_group_writer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index cc0f593..33f0f7f 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -50,14 +50,14 @@ static void usage(const char *progname) { fprintf(stderr, "usage: %s [-S] [-a steps] [-b] [-c]\n" - " [-n iterations] [-p] [-q] [-u numb_ticks]\n" + " [-n iterations] [-N] [-q] [-u numb_ticks]\n" "\n" "-S: do not use VFD SWMR\n" "-a steps: `steps` between adding attributes\n" "-b: write data in big-endian byte order\n" "-c steps: `steps` between communication between the writer and reader\n" "-n ngroups: the number of groups\n" - "-p: do not use named pipes, mainly for running the writer and reader seperately\n" + "-N: do not use named pipes, mainly for running the writer and reader seperately\n" "-u numb_tcks: `numb_ticks` for the reader to wait before verification\n" "-q: silence printouts, few messages\n" "\n", @@ -87,7 +87,7 @@ state_init(state_t *s, int argc, char **argv) if (tfile) HDfree(tfile); - while ((ch = getopt(argc, argv, "Sa:bc:n:pqu:")) != -1) { + while ((ch = getopt(argc, argv, "Sa:bc:n:Nqu:")) != -1) { switch (ch) { case 'S': s->use_vfd_swmr = false; @@ -124,7 +124,7 @@ state_init(state_t *s, int argc, char **argv) case 'b': s->filetype = H5T_STD_U32BE; break; - case 'p': + case 'N': s->use_named_pipes = false; break; case 'q': -- cgit v0.12