test cuda: applied PR reviews

This commit is contained in:
luncliff 2019-08-29 02:23:07 +00:00
parent 14c5dab2e6
commit 30c5209963
4 changed files with 16 additions and 41 deletions

View File

@ -133,15 +133,8 @@
# endif
#endif
// Workaround broken [[deprecated]] in the Intel compiler.
#ifdef __INTEL_COMPILER
# define FMT_DEPRECATED_ALIAS
#else
# define FMT_DEPRECATED_ALIAS FMT_DEPRECATED
#endif
// Workaround broken [[deprecated]] for the NVCC (CUDA with C++14)
#if defined(__NVCC__) || defined(__CUDACC__)
// Workaround broken [[deprecated]] in the Intel compiler and NVCC
#if defined(__INTEL_COMPILER) || defined(__NVCC__) || defined(__CUDACC__)
# define FMT_DEPRECATED_ALIAS
#else
# define FMT_DEPRECATED_ALIAS FMT_DEPRECATED

View File

@ -232,15 +232,6 @@ endif ()
#
find_package(CUDA 9.0)
if(CUDA_FOUND)
add_test(cuda-test ${CMAKE_CTEST_COMMAND}
-C ${CMAKE_BUILD_TYPE}
--build-and-test
"${CMAKE_CURRENT_SOURCE_DIR}/cuda-test"
"${CMAKE_CURRENT_BINARY_DIR}/cuda-test"
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-options
"-DFMT_DIR=${PROJECT_BINARY_DIR}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
)
add_subdirectory(cuda-test)
add_test(NAME cuda-test COMMAND fmt-in-cuda-test)
endif()

View File

@ -24,13 +24,10 @@
# Follow the Root CMakeLists.txt
cmake_minimum_required(VERSION 3.1)
project(fmt-cuda-test LANGUAGES CXX)
# See 'test/CMakeLists.txt'. It's using ${PROJECT_BINARY_DIR}
find_package(FMT REQUIRED)
# The environment variables (CUDA_BIN_PATH & CUDA_PATH) must be specified
find_package(CUDA REQUIRED)
# We already knows the packages. This part shows example.
# find_package(CUDA 9.0 REQUIRED)
# find_package(FMT 6.0 REQUIRED)
#
# Update these when NVCC becomes ready for C++ 17 features
@ -39,6 +36,9 @@ find_package(CUDA REQUIRED)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED 14)
#
# https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html
#
list(APPEND CUDA_NVCC_FLAGS "-std=c++14")
if(MSVC)
# this is the solution of pytorch
@ -62,27 +62,20 @@ cuda_add_executable(fmt-in-cuda-test
cpp14.cc
)
#
# https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html
#
set_target_properties(fmt-in-cuda-test
PROPERTIES
CXX_STANDARD 14 # Notice this is for C++ code
)
target_compile_features(fmt-in-cuda-test
PRIVATE
cxx_std_14 # just make sure of the property
)
get_target_property(cuda_standard
get_target_property(IN_USE_CUDA_STANDARD
fmt-in-cuda-test CUDA_STANDARD
)
message(STATUS "cuda_standard: ${cuda_standard}")
message(STATUS "cuda_standard: ${IN_USE_CUDA_STANDARD}")
get_target_property(cuda_standard_required
get_target_property(IN_USE_CUDA_STANDARD_REQUIRED
fmt-in-cuda-test CUDA_STANDARD_REQUIRED
)
message(STATUS "cuda_standard_required: ${cuda_standard_required}")
message(STATUS "cuda_standard_required: ${IN_USE_CUDA_STANDARD_REQUIRED}")
#
# https://cmake.org/cmake/help/latest/module/FindCUDA.html

View File

@ -34,14 +34,12 @@ static_assert(__cplusplus >= 201402L, "expect C++ 2014 for nvcc");
#include <cuda.h>
#include <iostream>
using namespace std;
extern auto make_message_cpp() -> std::string;
extern auto make_message_cuda() -> std::string;
int main(int, char*[]) {
cout << make_message_cuda() << endl;
cout << make_message_cpp() << endl;
std::cout << make_message_cuda() << std::endl;
std::cout << make_message_cpp() << std::endl;
}
auto make_message_cuda() -> std::string {