OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CudaMgr.h File Reference
#include <cstdlib>
#include <mutex>
#include <string>
#include <vector>
#include "Logger/Logger.h"
#include "Shared/DeviceGroup.h"
#include "Shared/nocuda.h"
+ Include dependency graph for CudaMgr.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CudaMgr_Namespace::DeviceProperties
 
class  CudaMgr_Namespace::CudaMgr
 

Namespaces

 CudaMgr_Namespace
 

Enumerations

enum  CudaMgr_Namespace::NvidiaDeviceArch {
  CudaMgr_Namespace::NvidiaDeviceArch::Kepler, CudaMgr_Namespace::NvidiaDeviceArch::Maxwell, CudaMgr_Namespace::NvidiaDeviceArch::Pascal, CudaMgr_Namespace::NvidiaDeviceArch::Volta,
  CudaMgr_Namespace::NvidiaDeviceArch::Turing, CudaMgr_Namespace::NvidiaDeviceArch::Ampere
}
 

Functions

std::string get_cuda_home (void)
 
std::string get_cuda_libdevice_dir (void)
 

Function Documentation

std::string get_cuda_home ( void  )

Definition at line 465 of file CudaMgr.cpp.

References LOG, and logger::WARNING.

465  {
466  static const char* CUDA_DEFAULT_PATH = "/usr/local/cuda";
467  const char* env = nullptr;
468 
469  if (!(env = getenv("CUDA_HOME")) && !(env = getenv("CUDA_DIR"))) {
470  // check if the default CUDA directory exists: /usr/local/cuda
471  if (boost::filesystem::exists(boost::filesystem::path(CUDA_DEFAULT_PATH))) {
472  env = CUDA_DEFAULT_PATH;
473  }
474  }
475 
476  if (env == nullptr) {
477  LOG(WARNING) << "Could not find CUDA installation path: environment variables "
478  "CUDA_HOME or CUDA_DIR are not defined";
479  return "";
480  }
481 
482  // check if the CUDA directory is sensible:
483  auto cuda_include_dir = env + std::string("/include");
484  auto cuda_h_file = cuda_include_dir + "/cuda.h";
485  if (!boost::filesystem::exists(boost::filesystem::path(cuda_h_file))) {
486  LOG(WARNING) << "cuda.h does not exist in `" << cuda_include_dir << "`. Discarding `"
487  << env << "` as CUDA installation path.";
488  return "";
489  }
490 
491  return std::string(env);
492 }
#define LOG(tag)
Definition: Logger.h:285
std::string get_cuda_libdevice_dir ( void  )

Definition at line 494 of file CudaMgr.cpp.

References LOG, and logger::WARNING.

Referenced by Executor::initialize_extension_module_sources().

494  {
495  static const char* CUDA_DEFAULT_PATH = "/usr/local/cuda";
496  const char* env = nullptr;
497 
498  if (!(env = getenv("CUDA_HOME")) && !(env = getenv("CUDA_DIR"))) {
499  // check if the default CUDA directory exists: /usr/local/cuda
500  if (boost::filesystem::exists(boost::filesystem::path(CUDA_DEFAULT_PATH))) {
501  env = CUDA_DEFAULT_PATH;
502  }
503  }
504 
505  if (env == nullptr) {
506  LOG(WARNING) << "Could not find CUDA installation path: environment variables "
507  "CUDA_HOME or CUDA_DIR are not defined";
508  return "";
509  }
510 
511  // check if the CUDA directory is sensible:
512  auto libdevice_dir = env + std::string("/nvvm/libdevice");
513  auto libdevice_bc_file = libdevice_dir + "/libdevice.10.bc";
514  if (!boost::filesystem::exists(boost::filesystem::path(libdevice_bc_file))) {
515  LOG(WARNING) << "`" << libdevice_bc_file << "` does not exist. Discarding `" << env
516  << "` as CUDA installation path with libdevice.";
517  return "";
518  }
519 
520  return libdevice_dir;
521 }
#define LOG(tag)
Definition: Logger.h:285

+ Here is the caller graph for this function: