mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-02 11:28:20 +00:00
345ba07f1d
test cuda: import fmt in CUDA source code Current test is only for Windows(cl.exe). Need to test more with the other host compilers... * Activate the test when `find_package(CUDA)` worked * The test runs with C++14 Detailed comments in 'test/cuda-test' test cuda: add more comment / macro check * checks both `__NVCC__` and `__CUDACC__` More comments for CMake and CUDA source file. test cuda: <fmt/core.h> checks NVCC and CUDA The header file checks 2 things. * __NVCC__: if the compiler is from NVIDIA * __CUDACC__: if the source code is CUDA(.cu) file Since we can't sure all users prefer latest, Version for `find_pacakge(CUDA)` is downgraded to 9.0. This is the minimum version for C++14 in CUDA
29 lines
905 B
Plaintext
29 lines
905 B
Plaintext
// Direct NVCC command line example:
|
|
//
|
|
// nvcc ./cuda-cpp14.cu -x cu -I"../include" -l"fmtd" -L"../build/Debug" \
|
|
// -std=c++14 -Xcompiler /std:c++14 -Xcompiler /Zc:__cplusplus
|
|
|
|
// Ensure that we are using the latest C++ standard for NVCC
|
|
// The version is C++14
|
|
//
|
|
// https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#c-cplusplus-language-support
|
|
// https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros
|
|
static_assert(__cplusplus >= 201402L, "expect C++ 2014 for nvcc");
|
|
|
|
#include <fmt/core.h>
|
|
|
|
#include <cuda.h>
|
|
#include <iostream>
|
|
|
|
extern auto make_message_cpp() -> std::string;
|
|
extern auto make_message_cuda() -> std::string;
|
|
|
|
int main() {
|
|
std::cout << make_message_cuda() << std::endl;
|
|
std::cout << make_message_cpp() << std::endl;
|
|
}
|
|
|
|
auto make_message_cuda() -> std::string {
|
|
return fmt::format("nvcc compiler \t: __cplusplus == {}", __cplusplus);
|
|
}
|