From e83a5c26385695949b89b76ac29dcda443bec014 Mon Sep 17 00:00:00 2001 From: Mikhail Brinskii Date: Sat, 21 Oct 2023 13:07:05 +0300 Subject: [PATCH] Sync: Add new fence test Test the scenario when two puts of different length are done with a fence between them --- verifier/sync/osh_sync_tc8.c | 55 +++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/verifier/sync/osh_sync_tc8.c b/verifier/sync/osh_sync_tc8.c index 6879944..ebdb68f 100644 --- a/verifier/sync/osh_sync_tc8.c +++ b/verifier/sync/osh_sync_tc8.c @@ -15,7 +15,8 @@ #include "osh_sync_tests.h" -static int test_item1(const int size, const int number_of_iterations); +static int test_item1(const int size1, const int size2, + const int number_of_iterations); /**************************************************************************** * Test Case processing procedure @@ -24,11 +25,12 @@ int osh_sync_tc8(const TE_NODE *node, int argc, const char *argv[]) { int rc = TC_PASS; int ri = TC_PASS; + int size, ti; UNREFERENCED_PARAMETER(argc); UNREFERENCED_PARAMETER(argv); - ri = test_item1(1, 100000); + ri = test_item1(1, 1, 100000); log_item(node, 1, ri); shmem_barrier_all(); if (rc == TC_PASS) @@ -36,7 +38,7 @@ int osh_sync_tc8(const TE_NODE *node, int argc, const char *argv[]) rc = ri; } - ri = test_item1(1000, 4000); + ri = test_item1(1000, 1000, 4000); log_item(node, 2, ri); shmem_barrier_all(); if (rc == TC_PASS) @@ -44,7 +46,7 @@ int osh_sync_tc8(const TE_NODE *node, int argc, const char *argv[]) rc = ri; } - ri = test_item1(4000, 1000); + ri = test_item1(4000, 4000, 1000); log_item(node, 3, ri); shmem_barrier_all(); if (rc == TC_PASS) @@ -52,7 +54,7 @@ int osh_sync_tc8(const TE_NODE *node, int argc, const char *argv[]) rc = ri; } - ri = test_item1(100000, 100); + ri = test_item1(100000, 100000, 100); log_item(node, 4, ri); shmem_barrier_all(); if (rc == TC_PASS) @@ -60,46 +62,61 @@ int osh_sync_tc8(const TE_NODE *node, int argc, const char *argv[]) rc = ri; } + for (size = 1000000, ti = 5; size >= 1; size /= 10, ++ti) { + ri = test_item1(size, 1, 10); + log_item(node, ti, ri); + shmem_barrier_all(); + if (rc == TC_PASS) + { + rc = ri; + } + } + return rc; } -static int test_item1(const int size, const int number_of_iterations) +static int test_item1(const int size1, const int size2, const int number_of_iterations) { long me = _my_pe(); int num_pe = _num_pes(); int rc = TC_PASS; + int max_size = sys_max(size1, size2); int i, j; - char zero[size]; - - memset(zero, 0, size); - char *test_array = shmalloc(num_pe * sizeof(char) * size); + char *zero, *test_array; if (num_pe <= 1) return TC_SETUP_FAIL; + zero = calloc(size1, sizeof(char)); + test_array = shmalloc(num_pe * sizeof(char) * max_size); + if ((zero == NULL) || (test_array == NULL)) + return TC_SETUP_FAIL; + for (i = 0; i < number_of_iterations; i++) { - char test_value[size]; + char test_value[size2]; - memset(test_value, (char)i, size); - shmem_putmem(test_array + me * size, &zero, size, 1); + memset(test_value, (char)i, size2); + shmem_putmem(test_array + me * max_size, zero, size1, 1); shmem_fence(); - shmem_putmem(test_array + me * size, &test_value, size, 1); + shmem_putmem(test_array + me * max_size, &test_value, size2, 1); shmem_fence(); shmem_barrier_all(); if (me != 1) - shmem_getmem(test_array, test_array, num_pe * size, 1); - for (j = 0; j < size; j++) { - if (test_array[me * size + j] != test_value[j]) + shmem_getmem(test_array, test_array, num_pe * max_size, 1); + for (j = 0; j < size2; j++) { + if (test_array[me * max_size + j] != test_value[j]) { - unsigned char got = test_array[me * size + j]; + unsigned char got = test_array[me * max_size + j]; unsigned char set = test_value[j]; rc = TC_FAIL; - log_debug(OSH_TC, "(2) fence failed at size %d got = %x expected = %x\n", size, got, set); + log_debug(OSH_TC, "(2) fence failed at size %d got = %x expected = %x\n", + max_size, got, set); } } } + free(zero); shfree(test_array); return rc;