Skip to content

Commit

Permalink
Merge pull request #1 from jdinan/wip/travis
Browse files Browse the repository at this point in the history
Add tests and Travis script
  • Loading branch information
jdinan committed Feb 26, 2018
2 parents dbf4309 + 5566141 commit b5b767a
Show file tree
Hide file tree
Showing 152 changed files with 23,319 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
dist: trusty
language: c
dist: trusty
compiler:
- gcc
env:
global:
- TRAVIS_PAR_MAKE="-j 4"
- FI_LOG_LEVEL=warn
- SHMEM_INFO=1
os:
- linux

addons:
apt:
packages:
- gfortran

before_install:
- mkdir $HOME/travis
- mkdir $HOME/travis/build
- mkdir $HOME/travis/install
- export SOS_SRC=$PWD
- cd $HOME/travis
- wget https://raw.githubusercontent.com/Sandia-OpenSHMEM/SOS/master/scripts/simple-build-ofi.sh
- chmod +x simple-build-ofi.sh
- export SOS_VERSION="master"
- ./simple-build-ofi.sh $HOME/travis/build $HOME/travis/install

install:
- cd $SOS_SRC
- ./autogen.sh

script:
- export PATH=$HOME/travis/install/bin:$PATH
- cd $SOS_SRC
- mkdir build
- cd build
- oshcc -showme
- oshc++ -showme
- oshfort -showme
# FIXME: Fortran and threads tests temporarily disabled because of
# compilation issues in Travis environment
- ../configure CC=oshcc CXX=oshc++ FC=oshfort CFLAGS="-std=gnu99" FCFLAGS="-fcray-pointer" --disable-fortran --disable-threads
- make $TRAVIS_PAR_MAKE
- make check
14 changes: 14 additions & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- Makefile -*-
#
# Copyright 2011 Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
# retains certain rights in this software.
#
# Copyright (c) 2017 Intel Corporation. All rights reserved.
# This software is available to you under the BSD license.
#
# This file is part of the Sandia OpenSHMEM software package. For license
# information, see the LICENSE file in the top level directory of the
# distribution.

SUBDIRS = unit performance apps
58 changes: 58 additions & 0 deletions test/apps/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- Makefile -*-
#
# Copyright 2011 Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
# retains certain rights in this software.
#
# Copyright (c) 2016 Los Alamos National Security, LLC. All rights reserved.
#
# Copyright (c) 2017 Intel Corporation. All rights reserved.
# This software is available to you under the BSD license.
#
# This file is part of the Sandia OpenSHMEM software package. For license
# information, see the LICENSE file in the top level directory of the
# distribution.

NPROCS ?= 2
LOG_COMPILER = $(TEST_RUNNER)

AM_LDFLAGS = $(LIBTOOL_WRAPPER_LDFLAGS)

check_PROGRAMS = \
binary-search \
gups

SHORT_TESTS = \
binary-search \
gups

if HAVE_PTHREADS
check_PROGRAMS += \
mandelbrot

SHORT_TESTS += \
mandelbrot
endif

if ENABLE_LENGTHY_TESTS
TESTS = $(check_PROGRAMS)
else
TESTS = $(SHORT_TESTS)
endif

if EXTERNAL_TESTS
bin_PROGRAMS = $(check_PROGRAMS)
AM_CPPFLAGS =
LDADD =
else
AM_CPPFLAGS = -I$(top_builddir)/mpp
LDADD = $(top_builddir)/src/libsma.la
endif

if USE_PMI_SIMPLE
LDADD += $(top_builddir)/pmi-simple/libpmi_simple.la
endif

mandelbrot_LDFLAGS = $(PTHREAD_LIBS)
mandelbrot_CFLAGS = -I$(top_srcdir)/test/unit $(PTHREAD_CFLAGS)
mandelbrot_LDADD = $(LDADD) $(PTHREAD_CFLAGS)
82 changes: 82 additions & 0 deletions test/apps/binary-search.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2017 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>

#define N_PER_PE 10

/* N_PER_PE*N_PES sorted, distributed shared array */
int keys[N_PER_PE];

static int binary_search(int key) {
int low, mid, high;

low = 0;
high = shmem_n_pes()*N_PER_PE;

while(low < high) {
int val;

mid = low + (high-low)/2;
val = shmem_int_g(&keys[mid%N_PER_PE], mid/N_PER_PE);

if(val == key) {
return mid;
} else if(val < key) {
low = mid;
} else {
high = mid;
}
}

return -1;
}

int main(int argc, char **argv) {
int i, errors = 0;

shmem_init();

for (i = 0; i < N_PER_PE; i++)
keys[i] = N_PER_PE * shmem_my_pe() + i;

shmem_barrier_all();

for (i = 0; i < N_PER_PE * shmem_n_pes(); i++) {
int j = binary_search(i);
if (j != i) {
printf("%2d: Error searching for %d. Found at index %d, expected %d\n",
shmem_my_pe(), i, j, i);
errors++;
}
}

shmem_finalize();

return errors;
}
Loading

0 comments on commit b5b767a

Please sign in to comment.