Add Intel oneAPI 2023 with compilation tests

This commit is contained in:
2023-03-03 18:18:51 +01:00
parent fd84af45f0
commit 115e9beb59
8 changed files with 378 additions and 56 deletions

View File

@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
wxparaver
# Runtimes
nanos6
];
] ++ bsc.testAll;
buildPhase = ''
if [ -e /boot ]; then

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,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
'';
}