Move test inside pkgs/

This commit is contained in:
2025-03-04 18:00:04 +01:00
parent e47b8f4afb
commit 3d10f3a568
20 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
{ stdenv, writeText, which, strace }:
let
hello_c = writeText "hello.c" ''
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}
'';
in
stdenv.mkDerivation rec {
version = "0.0.1";
name = "asan-c";
buildInputs = [ stdenv which strace ];
src = hello_c;
dontUnpack = true;
dontConfigure = true;
NIX_DEBUG = 0;
buildPhase = ''
cp ${hello_c} hello.c
$CC -v -fsanitize=address hello.c -o hello
./hello
'';
installPhase = ''
touch $out
'';
}

View File

@@ -0,0 +1,20 @@
{stdenv, clang-ompss2, nanos6}:
stdenv.mkDerivation rec {
version = "0.0.1";
name = "test-clang-ompss2";
src = ./.;
buildInputs = [ clang-ompss2 nanos6 ];
NIX_DEBUG = 1;
buildPhase = ''
clang -fompss-2 hello.c -o hello
./hello
clang++ -fompss-2 hello.cc -o hello
./hello
'';
installPhase = ''
mkdir -p $out
'';
}

View File

@@ -0,0 +1,46 @@
{
stdenv
, writeText
, openmp
}:
let
hello_c = writeText "hello.c" ''
int main(int argc, char *argv[])
{
#pragma omp parallel
{
}
return 0;
}
'';
in stdenv.mkDerivation {
pname = "openmp-test-ld";
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 = [ openmp ];
buildPhase = ''
set -x
cp ${hello_c} hello.c
clang -fopenmp=libompv ./hello.c -o hello
set +x
'';
installPhase = ''
touch $out
'';
}

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=libompv ./hello.c -lnosv -o hello
./hello | grep "INSIDE TASK OK"
set +x
'';
installPhase = ''
touch $out
'';
}

View File

@@ -0,0 +1,46 @@
{
stdenv
, writeText
}:
let
hello_c = writeText "hello.c" ''
int main(int argc, char *argv[])
{
int test = 1;
#pragma omp parallel
#pragma omp single
#pragma omp task
test = 0;
return test;
}
'';
in stdenv.mkDerivation {
pname = "openmp-test";
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;
buildPhase = ''
set -x
cp ${hello_c} hello.c
clang -fopenmp ./hello.c -o hello
./hello
set +x
'';
installPhase = ''
touch $out
'';
}

View File

@@ -0,0 +1,68 @@
{ stdenv, writeText, which, strace }:
let
hello_c = writeText "hello.c" ''
#include <stdio.h>
#include <limits.h>
#include <xmmintrin.h>
int main()
{
printf("Hello world!\n");
return 0;
}
'';
shuffle_c = writeText "shuffle.c" ''
#include <stdio.h>
typedef int v4si __attribute__ ((vector_size (16)));
int main(void) {
v4si a = {1,2,3,4};
v4si b = {5,6,7,8};
v4si mask1 = {0,1,1,3};
v4si mask2 = {0,4,2,5};
v4si res;
#if defined(__GNUC__) && (__GNUC__ >= 7)
res = __builtin_shuffle (a, mask1); /* res is {1,2,2,4} */
res = __builtin_shuffle (a, b, mask2); /* res is {1,5,3,6} */
printf("%d %d %d %d\n", res[0], res[1], res[2], res[3]);
#endif
return 0;
}
'';
in
stdenv.mkDerivation rec {
version = "0.0.1";
name = "hello-c";
buildInputs = [ stdenv which strace ];
src = hello_c;
dontUnpack = true;
dontConfigure = true;
NIX_DEBUG = 0;
buildPhase = ''
set -x
echo CC=$CC
which $CC
$CC -v
cp ${hello_c} hello.c
$CC -v hello.c -o hello
./hello
# Only gcc
#cp ${shuffle_c} shuffle.c
#$CC shuffle.c -o shuffle
#./shuffle
set +x
'';
installPhase = ''
touch $out
'';
}

View File

@@ -0,0 +1,36 @@
{ stdenv, writeText, which, strace }:
let
hello_cpp = writeText "hello.cpp" ''
#include <cstdio>
int main()
{
printf("Hello world!\n");
return 0;
}
'';
in
stdenv.mkDerivation rec {
version = "0.0.1";
name = "hello-cpp";
buildInputs = [ stdenv which strace ];
src = hello_cpp;
dontUnpack = true;
dontConfigure = true;
NIX_DEBUG = 0;
buildPhase = ''
cp $src hello.cpp
set -x
echo CXX=$CXX
which $CXX
$CXX hello.cpp -o hello
./hello
set +x
'';
installPhase = ''
touch $out
'';
}

View File

@@ -0,0 +1,35 @@
{ stdenv, writeText, which, strace }:
let
hello_f90 = writeText "hello.f90" ''
program hello
print *, 'Hello, World!'
end program hello
'';
in
stdenv.mkDerivation rec {
version = "0.0.1";
name = "hello-f90";
buildInputs = [ stdenv which strace ];
src = hello_f90;
dontUnpack = true;
dontConfigure = true;
NIX_DEBUG = 0;
buildPhase = ''
set -x
echo FC=$FC
which $FC
$FC -v
cp ${hello_f90} hello.f90
$FC hello.f90 -o hello
./hello
set +x
'';
installPhase = ''
touch $out
'';
}

View File

@@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}

View File

@@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}

View File

@@ -0,0 +1,25 @@
{
stdenv
, flangOmpss2Git
, runCommand
, writeText
, strace
}:
stdenv.mkDerivation {
name = "flang-ompss2-test";
buildInputs = [ strace flangOmpss2Git ];
file = writeText "hi.f90"
''
program hello
print *, 'Hello, World!'
end program hello
'';
phases = [ "installPhase" ];
installPhase = ''
set -x
flang "$file" -c -o hi.o
flang hi.o -o hi
install -Dm555 hi "$out"
'';
}

View File

@@ -0,0 +1,43 @@
{ stdenv, writeText, which, strace }:
let
hello_c = writeText "hello.c" ''
#include <stdio.h>
#include <limits.h>
#include <xmmintrin.h>
int main()
{
printf("Hello world!\n");
return 0;
}
'';
in
stdenv.mkDerivation rec {
version = "0.0.1";
name = "lto-c";
buildInputs = [ stdenv which strace ];
src = hello_c;
dontUnpack = true;
dontConfigure = true;
NIX_DEBUG = 0;
buildPhase = ''
set -x
echo CC=$CC
echo LD=$LD
echo -------------------------------------------
env
echo -------------------------------------------
cp ${hello_c} hello.c
$CC -v -flto hello.c -o hello
./hello
set +x
'';
installPhase = ''
touch $out
'';
}

View File

@@ -0,0 +1,52 @@
{ stdenv, writeText, which, strace, gdb }:
let
task_c = writeText "task.c" ''
#include <stdio.h>
int main()
{
for (int i = 0; i < 10; i++) {
#pragma oss task
printf("Hello world!\n");
}
return 0;
}
'';
in
stdenv.mkDerivation rec {
version = "0.0.1";
name = "task_c";
src = task_c;
dontUnpack = true;
dontConfigure = true;
hardeningDisable = [ "all" ];
#NIX_DEBUG = 1;
buildInputs = [ ]; #strace gdb;
# NODES 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;
buildPhase = ''
set -x
#$CC -v
cp ${task_c} task.c
echo CC=$CC
echo NANOS6_HOME=$NANOS6_HOME
echo NODES_HOME=$NODES_HOME
cat task.c
$CC -fompss-2 task.c -o task
#strace -ff -e trace=open,openat -s9999999 ./task
LD_DEBUG=libs ./task
#gdb -batch -ex "run" -ex "bt" ./task
set +x
'';
installPhase = ''
touch $out
'';
}

View File

@@ -0,0 +1,50 @@
{ stdenv, writeText, which, strace }:
let
shuffle_c = writeText "shuffle.c" ''
#include <stdio.h>
typedef int v4si __attribute__ ((vector_size (16)));
int main(void) {
v4si a = {1,2,3,4};
v4si b = {5,6,7,8};
v4si mask1 = {0,1,1,3};
v4si mask2 = {0,4,2,5};
v4si res;
#if defined(__GNUC__) && (__GNUC__ >= 7)
res = __builtin_shuffle (a, mask1); /* res is {1,2,2,4} */
res = __builtin_shuffle (a, b, mask2); /* res is {1,5,3,6} */
printf("%d %d %d %d\n", res[0], res[1], res[2], res[3]);
#endif
return 0;
}
'';
in
stdenv.mkDerivation rec {
version = "0.0.1";
name = "hello-c";
buildInputs = [ stdenv which strace ];
src = hello_c;
dontUnpack = true;
dontConfigure = true;
NIX_DEBUG = 0;
buildPhase = ''
cp $src hello.c
set -x
echo CC=$CC
which $CC
#strace -ff -e trace=execve -s99999999 $CC hello.c -o hello
$CC hello.c -o hello
./hello
set +x
'';
installPhase = ''
touch $out
'';
}