summaryrefslogtreecommitdiffstats
path: root/Tests/CudaOnly
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-12-07 16:45:44 (GMT)
committerBrad King <brad.king@kitware.com>2017-01-12 15:39:04 (GMT)
commit5599d858c7881b4331c449ba5c59d255ed50bd11 (patch)
tree9461bf2509ff5b14e6442b2cfde2c8808bd49dc1 /Tests/CudaOnly
parent1155170230ebd096df06ebf108908d6c99242d6d (diff)
downloadCMake-5599d858c7881b4331c449ba5c59d255ed50bd11.zip
CMake-5599d858c7881b4331c449ba5c59d255ed50bd11.tar.gz
CMake-5599d858c7881b4331c449ba5c59d255ed50bd11.tar.bz2
CUDA: Port test cases to Windows with MSVC host compiler
Diffstat (limited to 'Tests/CudaOnly')
-rw-r--r--Tests/CudaOnly/EnableStandard/main.cu8
-rw-r--r--Tests/CudaOnly/EnableStandard/shared.cu8
-rw-r--r--Tests/CudaOnly/WithDefs/CMakeLists.txt7
-rw-r--r--Tests/CudaOnly/WithDefs/main.notcu12
4 files changed, 32 insertions, 3 deletions
diff --git a/Tests/CudaOnly/EnableStandard/main.cu b/Tests/CudaOnly/EnableStandard/main.cu
index 83e9dfd..f7144e6 100644
--- a/Tests/CudaOnly/EnableStandard/main.cu
+++ b/Tests/CudaOnly/EnableStandard/main.cu
@@ -1,8 +1,14 @@
#include <iostream>
+#ifdef _WIN32
+#define IMPORT __declspec(dllimport)
+#else
+#define IMPORT
+#endif
+
int static_cuda11_func(int);
-int shared_cuda11_func(int);
+IMPORT int shared_cuda11_func(int);
void test_functions()
{
diff --git a/Tests/CudaOnly/EnableStandard/shared.cu b/Tests/CudaOnly/EnableStandard/shared.cu
index 28555b3..ccdd0b2 100644
--- a/Tests/CudaOnly/EnableStandard/shared.cu
+++ b/Tests/CudaOnly/EnableStandard/shared.cu
@@ -1,9 +1,15 @@
#include <type_traits>
+#ifdef _WIN32
+#define EXPORT __declspec(dllexport)
+#else
+#define EXPORT
+#endif
+
using tt = std::true_type;
using ft = std::false_type;
-int __host__ shared_cuda11_func(int x)
+EXPORT int __host__ shared_cuda11_func(int x)
{
return x * x + std::integral_constant<int, 17>::value;
}
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index c4ca8b9..6c4011c 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -4,7 +4,12 @@ project (CudaOnlyWithDefs CUDA)
#verify that we can pass explicit cuda arch flags
set(CMAKE_CUDA_FLAGS "-gencode arch=compute_30,code=compute_30")
-set(debug_compile_flags --generate-code arch=compute_20,code=sm_20 -Xcompiler=-Werror)
+set(debug_compile_flags --generate-code arch=compute_20,code=sm_20)
+if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC")
+ list(APPEND debug_compile_flags -Xcompiler=-WX)
+else()
+ list(APPEND debug_compile_flags -Xcompiler=-Werror)
+endif()
set(release_compile_defs DEFREL)
#Goal for this example:
diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu
index 33a49d2..67bf10c 100644
--- a/Tests/CudaOnly/WithDefs/main.notcu
+++ b/Tests/CudaOnly/WithDefs/main.notcu
@@ -2,12 +2,21 @@
#include <cuda_runtime.h>
#include <iostream>
+#ifndef PACKED_DEFINE
+#error "PACKED_DEFINE not defined!"
+#endif
+
static
__global__
void DetermineIfValidCudaDevice()
{
}
+#ifdef _MSC_VER
+#pragma pack(push,1)
+#undef PACKED_DEFINE
+#define PACKED_DEFINE
+#endif
struct PACKED_DEFINE result_type
{
bool valid;
@@ -16,6 +25,9 @@ struct PACKED_DEFINE result_type
#error missing DEFREL flag
#endif
};
+#ifdef _MSC_VER
+#pragma pack(pop)
+#endif
result_type can_launch_kernel()
{