Skip to content

Sync: Add new fence test #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 36 additions & 19 deletions verifier/sync/osh_sync_tc8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,82 +25,98 @@ 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)
{
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)
{
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)
{
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)
{
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;
Expand Down