Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU: Add Device::deviceVendor() function and fix #3416 #3418

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Src/Base/AMReX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,10 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
pp.queryAdd("abort_on_unused_inputs", system::abort_on_unused_inputs);

#ifdef AMREX_USE_SYCL
// Disable SIGSEGV handling by default for certain Intel GPUs,
// because it is currently used by their managed memory
// implementation.
if (Gpu::Device::deviceName().find("[0x0bd6]") != std::string::npos || // PVC
Gpu::Device::deviceName().find("[0x020f]") != std::string::npos) { // ATS
// Disable SIGSEGV handling by default for Intel GPUs, because it is
// currently used by their managed memory implementation with discrete
// GPUs
if (Gpu::Device::deviceVendor().find("Intel") != std::string::npos) {
system::handle_sigsegv = 0;
}
#endif
Expand Down
15 changes: 15 additions & 0 deletions Src/Base/AMReX_GpuDevice.H
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ using gpuDeviceProp_t = cudaDeviceProp;
#elif defined(AMREX_USE_SYCL)
struct gpuDeviceProp_t {
std::string name;
std::string vendor; // SYCL only (inferred for CUDA and HIP)
std::size_t totalGlobalMem;
std::size_t sharedMemPerBlock;
int multiProcessorCount;
Expand Down Expand Up @@ -141,6 +142,20 @@ public:
static int devicePropMinor () noexcept { return device_prop.minor; }
#endif

static std::string deviceVendor() noexcept
{
#if defined(AMREX_USE_HIP) && defined(__HIP_PLATFORM_AMD__)
return std::string("AMD");
#elif defined(AMREX_USE_CUDA) || (defined(AMREX_USE_HIP) && defined(__HIP_PLATFORM_NVIDIA__))
// Using HIP on NVIDIA GPUs isn't currently supported by AMReX
return std::string("NVIDIA");
#elif defined(AMREX_USE_SYCL)
return device_prop.vendor;
#else
return std::string("Unknown");
#endif
}

static std::size_t freeMemAvailable ();
static void profilerStart ();
static void profilerStop ();
Expand Down
2 changes: 2 additions & 0 deletions Src/Base/AMReX_GpuDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ Device::initialize_gpu ()
{ // device property
auto const& d = *sycl_device;
device_prop.name = d.get_info<sycl::info::device::name>();
device_prop.vendor = d.get_info<sycl::info::device::vendor>();
device_prop.totalGlobalMem = d.get_info<sycl::info::device::global_mem_size>();
device_prop.sharedMemPerBlock = d.get_info<sycl::info::device::local_mem_size>();
device_prop.multiProcessorCount = d.get_info<sycl::info::device::max_compute_units>();
Expand All @@ -489,6 +490,7 @@ Device::initialize_gpu ()
{
amrex::Print() << "Device Properties:\n"
<< " name: " << device_prop.name << "\n"
<< " vendor: " << device_prop.vendor << "\n"
<< " totalGlobalMem: " << device_prop.totalGlobalMem << "\n"
<< " sharedMemPerBlock: " << device_prop.sharedMemPerBlock << "\n"
<< " multiProcessorCount: " << device_prop.multiProcessorCount << "\n"
Expand Down