bscpkgs/test/compilers/clang-openmp-nosv.nix
Raúl Peñacoba 8ceaddfea7 Split OpenMP from Clang in LLVM
As the OpenMP-V implementation requires to be built with nOS-V, we can
split the OpenMP package in a different derivation to prevent rebuilds
of clang. Additionally, as OpenMP-V now can be build alongside the
vanilla OpenMP runtime, we simply build a single openmp derivation with
both runtimes. Only a single build of the clang compiler is now
required.

Reviewed-by: Aleix Roca Nonell <aleix.rocanonell@bsc.es>
Reviewed-by: Rodrigo Arias Mallo <rodrigo.arias@bsc.es>
2023-12-01 16:31:56 +01:00

62 lines
1.0 KiB
Nix

{
stdenv
, nosv
, writeText
, openmp
}:
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 openmp ];
buildPhase = ''
set -x
cp ${hello_c} hello.c
clang -fopenmp=libompv ./hello.c -lnosv -o hello
./hello | grep "INSIDE TASK OK"
set +x
'';
installPhase = ''
touch $out
'';
}