OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CudaMgr.h File Reference
#include <cstdlib>
#include <map>
#include <mutex>
#include <string>
#include <vector>
#include "CudaMgr/DeviceMemoryAllocationMap.h"
#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 583 of file CudaMgr.cpp.

References LOG, and logger::WARNING.

583  {
584  static const char* CUDA_DEFAULT_PATH = "/usr/local/cuda";
585  const char* env = nullptr;
586 
587  if (!(env = getenv("CUDA_HOME")) && !(env = getenv("CUDA_DIR"))) {
588  // check if the default CUDA directory exists: /usr/local/cuda
589  if (boost::filesystem::exists(boost::filesystem::path(CUDA_DEFAULT_PATH))) {
590  env = CUDA_DEFAULT_PATH;
591  }
592  }
593 
594  if (env == nullptr) {
595  LOG(WARNING) << "Could not find CUDA installation path: environment variables "
596  "CUDA_HOME or CUDA_DIR are not defined";
597  return "";
598  }
599 
600  // check if the CUDA directory is sensible:
601  auto cuda_include_dir = env + std::string("/include");
602  auto cuda_h_file = cuda_include_dir + "/cuda.h";
603  if (!boost::filesystem::exists(boost::filesystem::path(cuda_h_file))) {
604  LOG(WARNING) << "cuda.h does not exist in `" << cuda_include_dir << "`. Discarding `"
605  << env << "` as CUDA installation path.";
606  return "";
607  }
608 
609  return std::string(env);
610 }
#define LOG(tag)
Definition: Logger.h:285
std::string get_cuda_libdevice_dir ( void  )

Definition at line 612 of file CudaMgr.cpp.

References LOG, and logger::WARNING.

Referenced by Executor::initialize_extension_module_sources().

612  {
613  static const char* CUDA_DEFAULT_PATH = "/usr/local/cuda";
614  const char* env = nullptr;
615 
616  if (!(env = getenv("CUDA_HOME")) && !(env = getenv("CUDA_DIR"))) {
617  // check if the default CUDA directory exists: /usr/local/cuda
618  if (boost::filesystem::exists(boost::filesystem::path(CUDA_DEFAULT_PATH))) {
619  env = CUDA_DEFAULT_PATH;
620  }
621  }
622 
623  if (env == nullptr) {
624  LOG(WARNING) << "Could not find CUDA installation path: environment variables "
625  "CUDA_HOME or CUDA_DIR are not defined";
626  return "";
627  }
628 
629  // check if the CUDA directory is sensible:
630  auto libdevice_dir = env + std::string("/nvvm/libdevice");
631  auto libdevice_bc_file = libdevice_dir + "/libdevice.10.bc";
632  if (!boost::filesystem::exists(boost::filesystem::path(libdevice_bc_file))) {
633  LOG(WARNING) << "`" << libdevice_bc_file << "` does not exist. Discarding `" << env
634  << "` as CUDA installation path with libdevice.";
635  return "";
636  }
637 
638  return libdevice_dir;
639 }
#define LOG(tag)
Definition: Logger.h:285

+ Here is the caller graph for this function: