https://github.com/Kitware/CMake
Revision 031fa14b7eab1e85882eb5a9e10cb8f7f66c1350 authored by Brad King on 07 June 2022, 14:57:07 UTC, committed by Kitware Robot on 07 June 2022, 14:57:13 UTC
d14349c907 ci: Enable ISPC tests on Linux, Windows, and macOS nightly builds
49996faaac ci: remove ISPC from the Fedora CI image
3e791592ad gitlab-ci: init macOS and Windows jobs with per-CMAKE_CONFIGURATION scripts

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7336
2 parent s 4224df9 + d14349c
Raw File
Tip revision: 031fa14b7eab1e85882eb5a9e10cb8f7f66c1350 authored by Brad King on 07 June 2022, 14:57:07 UTC
Merge topic 'ci-ispc'
Tip revision: 031fa14
CMakeCUDACompilerABI.cu
#ifndef __CUDACC__
#  error "A C or C++ compiler has been selected for CUDA"
#endif

#include <cstdio>

#include <cuda_runtime.h>

#include "CMakeCompilerABI.h"

int main(int argc, char* argv[])
{
  int require = 0;
  require += info_sizeof_dptr[argc];
  require += info_byte_order_big_endian[argc];
  require += info_byte_order_little_endian[argc];
#if defined(ABI_ID)
  require += info_abi[argc];
#endif
  static_cast<void>(argv);

  int count = 0;
  if (cudaGetDeviceCount(&count) != cudaSuccess || count == 0) {
    std::fprintf(stderr, "No CUDA devices found.\n");
    return -1;
  }

  int found = 0;
  const char* sep = "";
  for (int device = 0; device < count; ++device) {
    cudaDeviceProp prop;
    if (cudaGetDeviceProperties(&prop, device) == cudaSuccess) {
      std::printf("%s%d%d", sep, prop.major, prop.minor);
      sep = ";";
      found = 1;
    }
  }

  if (!found) {
    std::fprintf(stderr, "No CUDA architecture detected from any devices.\n");
    // Convince the compiler that the non-zero return value depends
    // on the info strings so they are not optimized out.
    return require ? -1 : 1;
  }

  return 0;
}
back to top