Skip to content

Commit

Permalink
Merge pull request #13 from jdinan/pr/v1.4.4
Browse files Browse the repository at this point in the history
Sync with SOS v1.4.4
  • Loading branch information
jdinan authored Sep 19, 2019
2 parents 9ab8263 + ae43717 commit 284c8e6
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 20 deletions.
16 changes: 9 additions & 7 deletions test/apps/mandelbrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ long sumL2_ICM = 0;
pthread_barrier_t fencebar;

// Parameters set on the command-line
int use_contexts = 1;
int use_pipelining = 1;
int use_contexts = 0;
int use_pipelining = 0;
int use_blocking = 0;

static long getTime(void)
Expand Down Expand Up @@ -301,11 +301,11 @@ static void printUsage(void) {
printf("USAGE: mandelbrot [options]\n");
printf(" -t <num_threads> number of worker threads (def: 1)\n");
printf(" -w <width> width of the mandelbrot domain (def: 2048)\n");
printf(" -w <height> height of the mandelbrot domain (def: 2048)\n");
printf(" -h <height> height of the mandelbrot domain (def: 2048)\n");
printf(" -j <job_points> load balancing granularity (def: 128)\n");
printf(" -o output image mandelbrot.pgm (def: off)\n");
printf(" -c use OpenSHMEM contexts (def: on)\n");
printf(" -p enable pipelining (implies -c) (def: on)\n");
printf(" -c use OpenSHMEM contexts (def: off)\n");
printf(" -p enable pipelining (implies -c) (def: off)\n");
printf(" -b use blocking communication (def: off)\n");
printf(" -? prints this message\n");
}
Expand Down Expand Up @@ -505,8 +505,10 @@ int main(int argc, char** argv) {
if (t_arg[i].ctx[0] != SHMEM_CTX_DEFAULT)
shmem_ctx_destroy(t_arg[i].ctx[0]);

if (t_arg[i].ctx[1] != SHMEM_CTX_DEFAULT)
shmem_ctx_destroy(t_arg[i].ctx[1]);
if (use_pipelining) {
if (t_arg[i].ctx[1] != SHMEM_CTX_DEFAULT)
shmem_ctx_destroy(t_arg[i].ctx[1]);
}
}

pthread_barrier_destroy(&fencebar);
Expand Down
2 changes: 1 addition & 1 deletion test/performance/shmem_perf_suite/bi_dir_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ shared(metric_info, start, end) num_threads(metric_info->nthreads)
printf("PE %d, Thr. %d: Error, context creation failed\n",
metric_info->my_node, thread_id);
/* Exit with success to avoid test failures in automated testing */
shmem_global_exit(0);
shmem_global_exit(0);
}

for (i = 0; i < metric_info->warmup; i++) {
Expand Down
4 changes: 2 additions & 2 deletions test/shmemx/atomic_nbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int main(void) {
shmem_barrier_all();

if (target < 0 || target >= npes) {
printf("%d: Invalid target (%ld) in NBI swap test\n", me, result[i]);
printf("%d: Invalid target (%ld) in NBI swap test\n", me, target);
++errors;
}

Expand Down Expand Up @@ -103,7 +103,7 @@ int main(void) {
shmem_barrier_all();

if (target != npes-1) {
printf("%d: Invalid target (%ld) in NBI cswap test\n", me, result[i]);
printf("%d: Invalid target (%ld) in NBI cswap test\n", me, target);
++errors;
}

Expand Down
6 changes: 3 additions & 3 deletions test/shmemx/shmemx_test_some.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ int main(void)
/* Check the flags array */
for (int i = 0; i < npes; i++) {
if (flags[i] != 1)
shmem_global_exit(0);
shmem_global_exit(1);
}

/* check result */
int M = N * npes - 1;
if (total_sum != M * (M + 1) / 2) {
shmem_global_exit(1);
shmem_global_exit(2);
}

/* Sanity check case with NULL status array */
ncompleted = shmemx_int_test_some(flags, npes, indices, NULL, SHMEM_CMP_EQ, 1);

if (ncompleted != npes)
shmem_global_exit(2);
shmem_global_exit(3);

shmem_finalize();
return 0;
Expand Down
6 changes: 3 additions & 3 deletions test/shmemx/shmemx_wait_until_any.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ int main(void)
/* Check the flags array */
for (int i = 0; i < npes; i++) {
if (flags[i] != 1)
shmem_global_exit(0);
shmem_global_exit(1);
}

/* check result */
int M = N * npes - 1;
if (total_sum != M * (M + 1) / 2) {
shmem_global_exit(1);
shmem_global_exit(2);
}

/* Sanity check the case with NULL status array */
completed_idx = shmemx_int_wait_until_any(flags, npes, NULL, SHMEM_CMP_EQ, 1);

if (completed_idx >= npes)
shmem_global_exit(2);
shmem_global_exit(3);

shmem_finalize();
return 0;
Expand Down
6 changes: 3 additions & 3 deletions test/shmemx/shmemx_wait_until_some.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ int main(void)
/* Check the flags array */
for (int i = 0; i < npes; i++) {
if (flags[i] != 1)
shmem_global_exit(0);
shmem_global_exit(1);
}

/* check result */
int M = N * npes - 1;
if (total_sum != M * (M + 1) / 2) {
shmem_global_exit(1);
shmem_global_exit(2);
}

/* Sanity check the case with NULL status array */
ncompleted = shmemx_int_wait_until_some(flags, npes, indices, NULL, SHMEM_CMP_EQ, 1);

if (ncompleted != npes)
shmem_global_exit(2);
shmem_global_exit(3);

shmem_finalize();
return 0;
Expand Down
3 changes: 2 additions & 1 deletion test/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ check_PROGRAMS = \
sync-size \
shmem_ctx_pipelined_reduce \
many-ctx \
shmem_test
shmem_test \
shmem_ptr

# Temporarily disabled: Global exit test tends to fail with MPI-PMI
if !USE_PMI_MPI
Expand Down
99 changes: 99 additions & 0 deletions test/unit/shmem_ptr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (c) 2019 Intel Corporation. All rights reserved.
* This software is available to you under the BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#include <stdio.h>
#include <shmem.h>

int main(void) {
int i, n, errors = 0;
int me, npes;

static int shr_data = -1;
int * shr_heap;

shmem_init();

me = shmem_my_pe();
npes = shmem_n_pes();

shr_heap = shmem_malloc(sizeof(int));

shr_data = me;
*shr_heap = me;

shmem_barrier_all();

/* Check shmem_ptr on data segment */

for (i = n = 0; i < npes; i++) {
int * ptr = (int *) shmem_ptr(&shr_data, i);

if (ptr != NULL) {
int shr_peer = *ptr;
++n;

if (shr_peer != i) {
printf("%2d: Error, shr_data(%d) = %d, expected %d\n", me, i, shr_peer, i);
errors++;
}
}
else if (i == me) {
printf("%2d: Error, shmem_ptr(data) returned NULL for my PE\n", me);
errors++;
}
}

printf("%2d: Found %d data segment peer(s)\n", me, n);
fflush(NULL);
shmem_barrier_all();

/* Check shmem_ptr on heap segment */

for (i = n = 0; i < npes; i++) {
int * ptr = (int *) shmem_ptr(shr_heap, i);

if (ptr != NULL) {
int shr_peer = *ptr;
++n;

if (shr_peer != i) {
printf("%2d: Error, shr_heap(%d) = %d, expected %d\n", me, i, shr_peer, i);
errors++;
}
}
else if (i == me) {
printf("%2d: Error, shmem_ptr(heap) returned NULL for my PE\n", me);
errors++;
}
}

printf("%2d: Found %d heap segment peer(s)\n", me, n);

shmem_finalize();

return errors != 0;
}

0 comments on commit 284c8e6

Please sign in to comment.