Commit 944c378c authored by Swann Perarnau's avatar Swann Perarnau

Merge branch 'nmc-ecp-ci-test' into 'staging'

ECP-CI mirror from NMC

See merge request !72
parents 32cf7148 8ebdfe3c
Pipeline #8709 passed with stages
in 8 minutes and 28 seconds
variables:
NMC_FE1_SLURM_PARAMETERS: "--nodes=1 --partition=ecp-p9-4v100"
stages:
- build
nmc:batch:env:
stage: build
tags:
- nmc
only:
- master
- staging
script:
- uname -a
- module avail
- lspci
- module load hwloc numactl cuda
- module avail
- lstopo
- env
- which gcc
- gcc --version
- compgen -c gcc
make:nmc-cuda-check:
stage: build
variables:
tags:
- nmc
only:
- master
- staging
script:
- module load numactl hwloc cuda
- env | grep -i cuda
- cat /proc/self/status
- ./autogen.sh
- ./configure
- make -j
- make check VERBOSE=1
artifacts:
when: on_failure
paths:
- tests/test-suite.log
- config.log
make:nmc-cuda-home:
stage: build
variables:
tags:
- nmc
only:
- master
- staging
script:
- module load numactl hwloc cuda
- env | grep -i cuda
- ./autogen.sh
- ./configure --with-cuda=$CUDA_HOME
- make -j
- make check VERBOSE=1
artifacts:
when: on_failure
paths:
- tests/test-suite.log
- config.log
......@@ -104,46 +104,80 @@ if [[ "x$docs" = xtrue ]]; then
fi
AM_CONDITIONAL([BUILD_DOCS],[ test "x$docs" == xtrue ])
# check nvidia compiler and libraries
# check CUDA compiler and libraries
#####################################
BUILD_CUDA=no
AC_DEFINE([HAVE_CUDA], [0], [Whether aml support cuda library calls.])
AC_DEFINE([RUN_CUDA], [0], [Whether the machine on which aml is compiled can run cuda code.])
# Check compilation features
AC_CHECK_PROG([NVCC], [nvcc], [nvcc], [no])
AC_CHECK_LIB(cudart, cudaMalloc, [CUDART=yes], [CUDART=no])
AC_CHECK_HEADERS([cuda.h], [CUDA_H=yes], [CUDA_H=no])
AC_CHECK_HEADERS([cuda_runtime.h], [CUDA_RUNTIME_H=yes], [CUDA_RUNTIME_H=no])
if [[ "x$NVCC" != xno ]] && \
[[ "x$CUDART" = xyes ]] && \
[[ "x$CUDA_H" = xyes ]] && \
[[ "x$CUDA_RUNTIME_H" = xyes ]]
then
BUILD_CUDA=yes
AC_DEFINE([HAVE_CUDA], [1], [Whether aml support cuda library calls.])
AC_ARG_WITH([cuda],
[AS_HELP_STRING([--with-cuda@<:@=yes|no|DIR@:>@],
[support cuda inside the library (default is check)])],
[
if [[ "x$withval" = xno ]]; then
want_cuda="no"
elif [[ "x$withval" = xyes ]]; then
want_cuda="yes"
cuda_home_path="$CUDA_HOME"
else
want_cuda="yes"
cuda_home_path=$withval
fi
],
[
want_cuda="check"
cuda_home_path="$CUDA_HOME"
])
if [[ "x$want_cuda" != xno ]]; then
AC_MSG_NOTICE([starting checks for CUDA])
if [[ -n "$cuda_home_path" ]]; then
nvcc_search_dirs="$PATH$PATH_SEPARATOR$cuda_home_path/bin"
else
nvcc_search_dirs="$PATH"
fi
AC_PATH_PROG([NVCC], [nvcc], [], [$nvcc_search_dirs])
if [[ -n "$NVCC" ]]; then
have_nvcc="yes"
fi
else
AC_MSG_NOTICE([will not check for CUDA])
fi
if [[ "x$have_nvcc" = xyes ]]; then
if [[ -n "$cuda_home_path" ]]; then
CUDA_CFLAGS="-I$cuda_home_path/include"
CUDA_LIBS="-L$cuda_home_path/lib64 -lcudart"
else
CUDA_CFLAGS="-I/usr/local/cuda/include"
CUDA_LIBS="-L/usr/local/cuda/lib64 -lcudart"
fi
saved_LIBS=$LIBS
saved_CFLAGS=$CFLAGS
LIBS="$LIBS $CUDA_LIBS"
CFLAGS="$CFLAGS $CUDA_CFLAGS"
AC_CHECK_HEADER([cuda.h],,
[AC_MSG_ERROR([could not find cuda.h])])
AC_CHECK_HEADER([cuda_runtime.h],,
[AC_MSG_ERROR([could not find cuda_runtime.h])])
AC_CHECK_LIB(cudart, cudaMalloc,,
AC_MSG_ERROR([could not find cudart library]))
LIBS=$saved_LIBS
CFLAGS=$saved_CFLAGS
fi
AM_CONDITIONAL([BUILD_CUDA],[ test "x$BUILD_CUDA" = xyes ])
# Check runtime features
if [[ "x$BUILD_CUDA" = xyes ]]; then
LIBS="$LIBS -lcudart"
RUN_CUDA=no
AC_MSG_CHECKING([that cudart code runs without error])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <cuda.h>
#include <cuda_runtime.h>]],
[int device; return cudaGetDevice(&device) == cudaSuccess ? 0 : 1;])],
[AC_DEFINE([RUN_CUDA], [1], [Whether the machine on which aml is compiled can run cuda code.])
RUN_CUDA=yes],[])
AC_MSG_RESULT($RUN_CUDA)
if [[ "x$have_nvcc" = xyes ]]; then
# we only get there if every test worked
AC_DEFINE([HAVE_CUDA], [1], [Whether aml support cuda library calls.])
have_cuda="yes"
else
have_cuda="no"
fi
AM_CONDITIONAL([RUN_CUDA],[ test "x$RUN_CUDA" = xyes ])
AM_CONDITIONAL([HAVE_CUDA], [ test "x$have_cuda" = xyes ])
AC_SUBST(CUDA_CFLAGS)
AC_SUBST(CUDA_LIBS)
AC_SUBST(NVCC)
# Output
########
......@@ -156,7 +190,7 @@ AC_CONFIG_FILES([Makefile
tests/Makefile
doc/Makefile
benchmarks/Makefile
o2lo
aml.pc
include/aml/utils/version.h], [chmod +x o2lo])
include/aml/utils/version.h])
AC_CONFIG_FILES([o2lo], [chmod +x o2lo])
AC_OUTPUT
......@@ -54,11 +54,13 @@ libaml_la_SOURCES=$(LIB_SOURCES)
#############################################
# Cuda sources
if BUILD_CUDA
if HAVE_CUDA
AM_CPPFLAGS += $(CUDA_CFLAGS)
AM_LDFLAGS += $(CUDA_LIBS)
# Build .c sources using cuda runtime library.
libaml_la_SOURCES+=area/cuda.c
libaml_la_LDFLAGS+=-lcudart
# Build .cu sources containing device code.
#
......
......@@ -217,15 +217,16 @@ int aml_area_linux_create(struct aml_area **area,
/* check if the nodemask is compatible with the nodeset */
if (nodemask != NULL) {
int aml_last = aml_bitmap_last(nodemask);
int allowed_last = numa_bitmask_weight(data->nodeset);
for (int i = 0; i < AML_BITMAP_MAX; i++) {
int ours, theirs;
while (!numa_bitmask_isbitset(data->nodeset, --allowed_last))
;
ours = aml_bitmap_isset(nodemask, i);
theirs = numa_bitmask_isbitset(data->nodeset, i);
if (aml_last > allowed_last) {
err = -AML_EDOM;
goto err_f_node;
if (ours && !theirs) {
err = -AML_EDOM;
goto err_f_node;
}
}
aml_bitmap_copy_to_ulong(nodemask,
data->nodeset->maskp,
......
......@@ -29,7 +29,11 @@ SCRATCH_TESTS = scratch/test_scratch_seq \
scratch/test_scratch_par
if RUN_CUDA
if HAVE_CUDA
AM_CFLAGS += $(CUDA_CFLAGS)
AM_LDFLAGS += $(CUDA_LIBS)
AREA_TESTS += area/test_cuda
endif
......
......@@ -24,7 +24,8 @@ int fd;
const size_t sizes[3] = { 1, 1 << 12, 1 << 20 };
int num_nodes;
struct aml_bitmap mems_allowed;
int last_node;
void test_area(struct aml_area *area, struct aml_area_mmap_options *options)
{
......@@ -53,13 +54,9 @@ void test_case(const struct aml_bitmap *nodemask,
struct aml_area *area;
if (aml_bitmap_last(nodemask) >= num_nodes) {
assert(aml_area_linux_create(&area, nodemask, policy)
== -AML_EDOM);
return;
}
int err = aml_area_linux_create(&area, nodemask, policy);
assert(!aml_area_linux_create(&area, nodemask, policy));
assert(err == AML_SUCCESS);
// Map anonymous test.
test_area(area, (struct aml_area_mmap_options *)(&options));
......@@ -90,24 +87,30 @@ void test_single_node(void)
struct aml_bitmap bitmap;
aml_bitmap_zero(&bitmap);
for (int i = 0; i <= num_nodes; i++) {
aml_bitmap_set(&bitmap, i);
test_flags(&bitmap);
aml_bitmap_clear(&bitmap, i);
for (int i = 0; i <= last_node; i++) {
if (aml_bitmap_isset(&mems_allowed, i)) {
aml_bitmap_set(&bitmap, i);
test_flags(&bitmap);
aml_bitmap_clear(&bitmap, i);
}
}
}
void test_multiple_nodes(void)
{
struct aml_bitmap bitmap;
int first;
aml_bitmap_zero(&bitmap);
aml_bitmap_set(&bitmap, 0);
for (int i = 1; i <= num_nodes; i++) {
aml_bitmap_set(&bitmap, i);
test_flags(&bitmap);
aml_bitmap_clear(&bitmap, i-1);
first = aml_bitmap_first(&mems_allowed);
aml_bitmap_set(&bitmap, first);
for (int i = first+1; i <= last_node; i++) {
if (aml_bitmap_isset(&mems_allowed, i)) {
aml_bitmap_set(&bitmap, i);
test_flags(&bitmap);
aml_bitmap_clear(&bitmap, i);
}
}
}
......@@ -124,6 +127,10 @@ int main(void)
fd = mkstemp(tmp_name);
assert(fd > 1);
/* unlink right away to avoid leaving the file on the system after an
* error. The file will only disappear after close.
*/
unlink(tmp_name);
nw = write(fd, buf, size);
assert(nw == (ssize_t)size);
......@@ -131,12 +138,13 @@ int main(void)
struct bitmask *nodeset = numa_get_mems_allowed();
num_nodes = numa_bitmask_weight(nodeset);
aml_bitmap_copy_from_ulong(&mems_allowed,
nodeset->maskp, nodeset->size);
last_node = aml_bitmap_last(&mems_allowed);
test_single_node();
test_multiple_nodes();
close(fd);
unlink(tmp_name);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment