Add a more strict test for OpenMP+nOS-V

In this test we ensure that the worksharing region is running inside a
nOS-V task, so we know that we are not using the vanilla OpenMP by
accident.

We also keep the previous test test/compilers/clang-openmp.nix as-is, so
we can check that the compiler injects the nosv library dependency in
the final binary on its own.

Reviewed-by: Aleix Roca Nonell <aleix.rocanonell@bsc.es>
This commit is contained in:
Rodrigo Arias 2023-11-23 15:23:15 +01:00
parent 20ded0c0df
commit d9ae85ce4b
2 changed files with 63 additions and 0 deletions

View File

@ -78,6 +78,9 @@ in bscPkgs // {
clangNosvOpenmp-task = callPackage ./test/compilers/clang-openmp.nix {
stdenv = final.stdenvClangOmpss2OpenmpNodes;
};
clangNosvOpenmp-nosv = callPackage ./test/compilers/clang-openmp-nosv.nix {
stdenv = final.stdenvClangOmpss2OpenmpNodes;
};
};
pkgs = final.runCommand "ci-pkgs" { }

View File

@ -0,0 +1,60 @@
{
stdenv
, nosv
, writeText
}:
let
hello_c = writeText "hello.c" ''
#include <nosv.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
int test = 1;
#pragma omp parallel
#pragma omp single
#pragma omp task
{
if (nosv_self() == NULL) {
printf("nosv_self() returned NULL\n");
exit(1);
} else {
printf("nosv_self() INSIDE TASK OK\n");
}
test = 0;
}
return test;
}
'';
in stdenv.mkDerivation {
pname = "openmp-test-nosv";
version = "1.0.0";
dontUnpack = true;
dontConfigure = true;
# nOS-V requires access to /sys/devices to request NUMA information. It will
# fail to run otherwise, so we disable the sandbox for this test.
__noChroot = true;
buildInputs = [ nosv ];
buildPhase = ''
set -x
cp ${hello_c} hello.c
clang -fopenmp ./hello.c -lnosv -o hello
./hello | grep "INSIDE TASK OK"
set +x
'';
installPhase = ''
touch $out
'';
}