From cae5ddd4a2c9343ec7367c9049c5cc0c8628a9c4 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 8 Jan 2020 11:09:20 -0500 Subject: Setup of runtime cuda device (#1162) * CUDA generated first test compiles. * WIP on enabling CUDA in render-test. * Detect CUDA_PATH environmental variable to build build cuda support into render-test. Added WIP cuda-compute-util.cpp/h Added CUDA as a renderer type. * Fix libraries needed for cuda in premake. * Added -enable-cuda premake option. Defaults to false. * Creates CUDA device, loads PTX and finds entry point. * Fix some erroneous cruft from slang-cuda-prelude.h --- premake5.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'premake5.lua') diff --git a/premake5.lua b/premake5.lua index 1905bd2f4..4de256321 100644 --- a/premake5.lua +++ b/premake5.lua @@ -84,10 +84,26 @@ newoption { allowed = { { "true", "True"}, { "false", "False" } } } +newoption { + trigger = "enable-cuda", + description = "(Optional) If true will enable cuda tests, if CUDA is found via CUDA_PATH", + value = "bool", + default = "false", + allowed = { { "true", "True"}, { "false", "False" } } +} + buildLocation = _OPTIONS["build-location"] executeBinary = (_OPTIONS["execute-binary"] == "true") targetDetail = _OPTIONS["target-detail"] buildGlslang = (_OPTIONS["build-glslang"] == "true") +enableCuda = (_OPTIONS["enable-cuda"] == "true") + +-- cudaPath is only set if cuda is enabled, and CUDA_PATH enviromental variable is set +cudaPath = nil +if enableCuda then + -- Get the CUDA path from the environment variable. If set, CUDA will be assumed installed + cudaPath = os.getenv("CUDA_PATH") +end -- Is true when the target is really windows (ie not something on top of windows like cygwin) local isTargetWindows = (os.target() == "windows") and not (targetDetail == "mingw" or targetDetail == "cygwin") @@ -529,6 +545,21 @@ toolSharedLibrary "render-test" -- d3dcompiler_47.dll is copied from the external/slang-binaries submodule. postbuildcommands { '"$(SolutionDir)tools\\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/%{cfg.platform:lower()}/" "%{cfg.targetdir}/" "windows-%{cfg.platform:lower()}"'} end + + if type(cudaPath) == "string" and isTargetWindows then + addSourceDir "tools/render-test/cuda" + defines { "RENDER_TEST_CUDA" } + includedirs { cudaPath .. "/include" } + includedirs { cudaPath .. "/include", cudaPath .. "/common/inc" } + + filter { "platforms:x86" } + libdirs { cudaPath .. "/lib/Win32/" } + + filter { "platforms:x64" } + libdirs { cudaPath .. "/lib/x64/" } + + links { "cuda", "cudart" } + end -- -- `gfx` is a utility library for doing GPU rendering -- cgit v1.2.3