test cuda: applied PR reviews
This commit is contained in:
parent
14c5dab2e6
commit
30c5209963
@ -133,15 +133,8 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Workaround broken [[deprecated]] in the Intel compiler.
|
// Workaround broken [[deprecated]] in the Intel compiler and NVCC
|
||||||
#ifdef __INTEL_COMPILER
|
#if defined(__INTEL_COMPILER) || defined(__NVCC__) || defined(__CUDACC__)
|
||||||
# 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__)
|
|
||||||
# define FMT_DEPRECATED_ALIAS
|
# define FMT_DEPRECATED_ALIAS
|
||||||
#else
|
#else
|
||||||
# define FMT_DEPRECATED_ALIAS FMT_DEPRECATED
|
# define FMT_DEPRECATED_ALIAS FMT_DEPRECATED
|
||||||
|
|||||||
@ -232,15 +232,6 @@ endif ()
|
|||||||
#
|
#
|
||||||
find_package(CUDA 9.0)
|
find_package(CUDA 9.0)
|
||||||
if(CUDA_FOUND)
|
if(CUDA_FOUND)
|
||||||
add_test(cuda-test ${CMAKE_CTEST_COMMAND}
|
add_subdirectory(cuda-test)
|
||||||
-C ${CMAKE_BUILD_TYPE}
|
add_test(NAME cuda-test COMMAND fmt-in-cuda-test)
|
||||||
--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}"
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -24,13 +24,10 @@
|
|||||||
|
|
||||||
# Follow the Root CMakeLists.txt
|
# Follow the Root CMakeLists.txt
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
project(fmt-cuda-test LANGUAGES CXX)
|
|
||||||
|
|
||||||
# See 'test/CMakeLists.txt'. It's using ${PROJECT_BINARY_DIR}
|
# We already knows the packages. This part shows example.
|
||||||
find_package(FMT REQUIRED)
|
# find_package(CUDA 9.0 REQUIRED)
|
||||||
|
# find_package(FMT 6.0 REQUIRED)
|
||||||
# The environment variables (CUDA_BIN_PATH & CUDA_PATH) must be specified
|
|
||||||
find_package(CUDA REQUIRED)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Update these when NVCC becomes ready for C++ 17 features
|
# 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 14)
|
||||||
set(CMAKE_CUDA_STANDARD_REQUIRED 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")
|
list(APPEND CUDA_NVCC_FLAGS "-std=c++14")
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# this is the solution of pytorch
|
# this is the solution of pytorch
|
||||||
@ -62,27 +62,20 @@ cuda_add_executable(fmt-in-cuda-test
|
|||||||
cpp14.cc
|
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
|
target_compile_features(fmt-in-cuda-test
|
||||||
PRIVATE
|
PRIVATE
|
||||||
cxx_std_14 # just make sure of the property
|
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
|
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
|
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
|
# https://cmake.org/cmake/help/latest/module/FindCUDA.html
|
||||||
|
|||||||
@ -34,14 +34,12 @@ static_assert(__cplusplus >= 201402L, "expect C++ 2014 for nvcc");
|
|||||||
#include <cuda.h>
|
#include <cuda.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
extern auto make_message_cpp() -> std::string;
|
extern auto make_message_cpp() -> std::string;
|
||||||
extern auto make_message_cuda() -> std::string;
|
extern auto make_message_cuda() -> std::string;
|
||||||
|
|
||||||
int main(int, char*[]) {
|
int main(int, char*[]) {
|
||||||
cout << make_message_cuda() << endl;
|
std::cout << make_message_cuda() << std::endl;
|
||||||
cout << make_message_cpp() << endl;
|
std::cout << make_message_cpp() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto make_message_cuda() -> std::string {
|
auto make_message_cuda() -> std::string {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user