Reviewed-by: Rodrigo Arias Mallo <rodrigo.arias@bsc.es> Tested-by: Rodrigo Arias Mallo <rodrigo.arias@bsc.es>
		
			
				
	
	
		
			60 lines
		
	
	
		
			983 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			983 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
{
 | 
						|
  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
 | 
						|
  requiredSystemFeatures = [ "sys-devices" ];
 | 
						|
 | 
						|
  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
 | 
						|
  '';
 | 
						|
 | 
						|
}
 | 
						|
 |