From cd5f09e81b7d0726970e1a7573789b64ea1382ff Mon Sep 17 00:00:00 2001 From: Alex Mouton Date: Mon, 2 Nov 2020 20:00:32 -0800 Subject: [PATCH 1/5] Added a shell.nix for people playing nix at home --- shell.nix | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..2d8f93b --- /dev/null +++ b/shell.nix @@ -0,0 +1,4 @@ +{ pkgs ? import {} }: + pkgs.mkShell { + buildInputs = [ pkgs.git pkgs.ghc pkgs.cabal-install ]; + } From d3f6f6f8ecedd9372f565b6d3ac3e94e9c7e82a7 Mon Sep 17 00:00:00 2001 From: Alex Mouton Date: Mon, 2 Nov 2020 20:01:33 -0800 Subject: [PATCH 2/5] changed cudaLibraryPath to return an array of possible paths. We pick the first viable one. --- Setup.hs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Setup.hs b/Setup.hs index 42bb1a6..59eced9 100644 --- a/Setup.hs +++ b/Setup.hs @@ -137,7 +137,7 @@ libraryBuildInfo -> IO HookedBuildInfo libraryBuildInfo verbosity profile installPath platform@(Platform arch os) ghcVersion extraLibs extraIncludes = do let - libraryPaths = cudaLibraryPath platform installPath : extraLibs + libraryPaths = cudaLibraryPaths platform installPath <> extraLibs includePaths = cudaIncludePath platform installPath : extraIncludes takeFirstExisting paths = do @@ -214,16 +214,16 @@ cudaIncludePath _ installPath = installPath "include" -- Return the location of the libraries relative to the base CUDA installation. -- -cudaLibraryPath :: Platform -> FilePath -> FilePath -cudaLibraryPath (Platform arch os) installPath = installPath libpath +cudaLibraryPaths :: Platform -> FilePath -> [FilePath] +cudaLibraryPaths (Platform arch os) installPath = () <$> [installPath] <*> libpath where libpath = case (os, arch) of - (Windows, I386) -> "lib/Win32" - (Windows, X86_64) -> "lib/x64" - (OSX, _) -> "lib" -- MacOS does not distinguish 32- vs. 64-bit paths - (_, X86_64) -> "lib64" -- treat all others similarly - _ -> "lib" + (Windows, I386) -> ["lib/Win32"] + (Windows, X86_64) -> ["lib/x64"] + (OSX, _) -> ["lib"] -- MacOS does not distinguish 32- vs. 64-bit paths + (_, X86_64) -> ["lib64"] -- treat all others similarly + _ -> ["lib"] -- On Windows and OSX we use different libraries depending on whether we are @@ -261,7 +261,9 @@ cudaGhciLibrariesWindows -> [FilePath] -> IO [FilePath] cudaGhciLibrariesWindows platform installPath libraries = do - candidates <- mapM (importLibraryToDLLFileName platform) [ cudaLibraryPath platform installPath lib <.> "lib" | lib <- libraries ] + let pathRoots = cudaLibraryPaths platform installPath + let toLibPath path lib = path lib <.> "lib" + candidates <- mapM (importLibraryToDLLFileName platform) (toLibPath <$> pathRoots <*> libraries) return [ dropExtension dll | Just dll <- candidates ] From a9a3430ce6f2b4410511945ed3c809f80f959555 Mon Sep 17 00:00:00 2001 From: Alex Mouton Date: Mon, 2 Nov 2020 20:03:35 -0800 Subject: [PATCH 3/5] Add lib to the x86_64 path in cudaLibraryPath --- Setup.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup.hs b/Setup.hs index 59eced9..ed57ade 100644 --- a/Setup.hs +++ b/Setup.hs @@ -222,7 +222,7 @@ cudaLibraryPaths (Platform arch os) installPath = () <$> [installPath] <*> li (Windows, I386) -> ["lib/Win32"] (Windows, X86_64) -> ["lib/x64"] (OSX, _) -> ["lib"] -- MacOS does not distinguish 32- vs. 64-bit paths - (_, X86_64) -> ["lib64"] -- treat all others similarly + (_, X86_64) -> ["lib64", "lib"] -- Prefer lib64, but the nixpkgs distriubtion of cudatools moves files to lib. - AM _ -> ["lib"] From 07a04e79cb41a7339de5583b1dc88691715a6c53 Mon Sep 17 00:00:00 2001 From: Alex Mouton Date: Tue, 3 Nov 2020 21:18:19 -0800 Subject: [PATCH 4/5] Add cudadevrt lib to non-os side of cudaLibraries. hoping to avoid unfound library error --- Setup.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup.hs b/Setup.hs index ed57ade..f84485b 100644 --- a/Setup.hs +++ b/Setup.hs @@ -233,7 +233,7 @@ cudaLibraries :: Platform -> [String] cudaLibraries (Platform _ os) = case os of OSX -> ["cudadevrt", "cudart_static"] - _ -> ["cudart", "cuda"] + _ -> ["cudadevrt", "cudart", "cuda"] cudaGHCiLibraries :: Platform From d9f5b819c73cfc150779cdf52094edbc04b087d0 Mon Sep 17 00:00:00 2001 From: Alex Mouton Date: Tue, 3 Nov 2020 21:36:49 -0800 Subject: [PATCH 5/5] Separate Linux from catchall --- Setup.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Setup.hs b/Setup.hs index f84485b..46b921c 100644 --- a/Setup.hs +++ b/Setup.hs @@ -233,7 +233,8 @@ cudaLibraries :: Platform -> [String] cudaLibraries (Platform _ os) = case os of OSX -> ["cudadevrt", "cudart_static"] - _ -> ["cudadevrt", "cudart", "cuda"] + Linux -> ["cudadevrt"] + _ -> ["cudart", "cuda"] cudaGHCiLibraries :: Platform