git repos / blockattack-game

blame: source/misc/embedded_libs/fmt-8.1.1/test/cuda-test/cuda-cpp14.cu

normal view · raw

f8deb5b9 Poul Sander 2022-01-15 13:55 1
//  Direct NVCC command line example:
f8deb5b9 Poul Sander 2022-01-15 13:55 2
//
f8deb5b9 Poul Sander 2022-01-15 13:55 3
//  nvcc ./cuda-cpp14.cu -x cu -I"../include" -l"fmtd" -L"../build/Debug" \
f8deb5b9 Poul Sander 2022-01-15 13:55 4
//       -std=c++14 -Xcompiler /std:c++14 -Xcompiler /Zc:__cplusplus
f8deb5b9 Poul Sander 2022-01-15 13:55 5
f8deb5b9 Poul Sander 2022-01-15 13:55 6
// Ensure that we are using the latest C++ standard for NVCC
f8deb5b9 Poul Sander 2022-01-15 13:55 7
// The version is C++14
f8deb5b9 Poul Sander 2022-01-15 13:55 8
//
f8deb5b9 Poul Sander 2022-01-15 13:55 9
// https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#c-cplusplus-language-support
f8deb5b9 Poul Sander 2022-01-15 13:55 10
// https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros
f8deb5b9 Poul Sander 2022-01-15 13:55 11
static_assert(__cplusplus >= 201402L, "expect C++ 2014 for nvcc");
f8deb5b9 Poul Sander 2022-01-15 13:55 12
f8deb5b9 Poul Sander 2022-01-15 13:55 13
#include <fmt/core.h>
f8deb5b9 Poul Sander 2022-01-15 13:55 14
f8deb5b9 Poul Sander 2022-01-15 13:55 15
#include <cuda.h>
f8deb5b9 Poul Sander 2022-01-15 13:55 16
#include <iostream>
f8deb5b9 Poul Sander 2022-01-15 13:55 17
f8deb5b9 Poul Sander 2022-01-15 13:55 18
extern auto make_message_cpp() -> std::string;
f8deb5b9 Poul Sander 2022-01-15 13:55 19
extern auto make_message_cuda() -> std::string;
f8deb5b9 Poul Sander 2022-01-15 13:55 20
f8deb5b9 Poul Sander 2022-01-15 13:55 21
int main() {
f8deb5b9 Poul Sander 2022-01-15 13:55 22
  std::cout << make_message_cuda() << std::endl;
f8deb5b9 Poul Sander 2022-01-15 13:55 23
  std::cout << make_message_cpp() << std::endl;
f8deb5b9 Poul Sander 2022-01-15 13:55 24
}
f8deb5b9 Poul Sander 2022-01-15 13:55 25
f8deb5b9 Poul Sander 2022-01-15 13:55 26
auto make_message_cuda() -> std::string {
f8deb5b9 Poul Sander 2022-01-15 13:55 27
  return fmt::format("nvcc compiler \t: __cplusplus == {}", __cplusplus);
f8deb5b9 Poul Sander 2022-01-15 13:55 28
}
1970-01-01 00:00 29