95 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			95 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
{ stdenv
 | 
						|
, lib
 | 
						|
, withCFlags
 | 
						|
, intelPackages
 | 
						|
, fetchFromGitHub
 | 
						|
, automake
 | 
						|
, autoconf
 | 
						|
, libtool
 | 
						|
, gnumake
 | 
						|
, autoreconfHook
 | 
						|
, boost
 | 
						|
, adaptivecpp ? null
 | 
						|
, useIntel ? true
 | 
						|
 | 
						|
, useGit ? false
 | 
						|
, gitUrl ? "git@gitlab-internal.bsc.es:task-awareness/tasycl/tasycl.git"
 | 
						|
, gitBranch ? "main"
 | 
						|
, gitCommit ? "78f98dcf60a66e0eaa3b4ebcf55be076bec64825"
 | 
						|
}:
 | 
						|
 | 
						|
assert (useIntel || adaptivecpp != null);
 | 
						|
 | 
						|
let
 | 
						|
  variant = if useIntel then "intel" else "acpp";
 | 
						|
 | 
						|
  syclStdenv =
 | 
						|
    if useIntel then
 | 
						|
      # If we don't set optimization level, separateDebugInfo sets ggdb and
 | 
						|
      # intel disables all optimizations
 | 
						|
      withCFlags ["-O3"] intelPackages.stdenv
 | 
						|
    else
 | 
						|
      withCFlags [ "-L${adaptivecpp}/lib" "-lacpp-rt" "-I${adaptivecpp}/include" ] stdenv
 | 
						|
  ;
 | 
						|
 | 
						|
  release = rec {
 | 
						|
    version = "2.1.0";
 | 
						|
    src = fetchFromGitHub {
 | 
						|
      owner = "bsc-pm";
 | 
						|
      repo = "tasycl";
 | 
						|
      rev = version;
 | 
						|
      hash = "sha256-0kXnb0lHeQNHR27GTLbJ8xbiICLU8k2+FqEnnFSrzzo=";
 | 
						|
    };
 | 
						|
  };
 | 
						|
 | 
						|
  git = rec {
 | 
						|
    version = src.shortRev;
 | 
						|
    src = builtins.fetchGit {
 | 
						|
      url = gitUrl;
 | 
						|
      ref = gitBranch;
 | 
						|
      rev = gitCommit;
 | 
						|
    };
 | 
						|
  };
 | 
						|
 | 
						|
  source = if (useGit) then git else release;
 | 
						|
 | 
						|
  isOldRelease = (!useGit && (builtins.compareVersions source.version "2.0.0" <= 0));
 | 
						|
 | 
						|
in
 | 
						|
 | 
						|
assert !isOldRelease || useIntel; # old releases only work with intel
 | 
						|
 | 
						|
syclStdenv.mkDerivation {
 | 
						|
  pname = "tasycl";
 | 
						|
  inherit (source) src version;
 | 
						|
 | 
						|
  enableParallelBuilding = true;
 | 
						|
  separateDebugInfo = true;
 | 
						|
 | 
						|
  nativeBuildInputs = [
 | 
						|
    autoreconfHook
 | 
						|
    automake
 | 
						|
    autoconf
 | 
						|
    libtool
 | 
						|
    gnumake
 | 
						|
  ];
 | 
						|
 | 
						|
  buildInputs = [
 | 
						|
    boost
 | 
						|
  ];
 | 
						|
 | 
						|
  # only needed for release versions prior or equal to 2.0.0
 | 
						|
  configureFlags = lib.optionals isOldRelease [ "--with-sycl-include=${intelPackages.icx.cc}/include/sycl" ];
 | 
						|
 | 
						|
  # add symlinks so we can explicitly link with tasycl-intel / tasycl-acpp
 | 
						|
  postInstall = ''
 | 
						|
    pushd $out/lib
 | 
						|
    for i in libtasycl* ; do
 | 
						|
      ln -s "$i" "''\${i/tasycl/tasycl-${variant}}"
 | 
						|
    done
 | 
						|
    popd
 | 
						|
  '';
 | 
						|
 | 
						|
  hardeningDisable = [ "all" ];
 | 
						|
}
 |