MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / initialize_gpu

Method initialize_gpu

Src/Base/AMReX_GpuDevice.cpp:493–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491}
492
493void
494Device::initialize_gpu (bool minimal)
495{
496 amrex::ignore_unused(minimal);
497
498#ifdef AMREX_USE_GPU
499
500 if (gpu_stream_pool.size() != max_gpu_streams) {
501 // no copy/move constructor for std::mutex
502 gpu_stream_pool = Vector<StreamManager>(max_gpu_streams);
503 }
504
505#ifdef AMREX_USE_HIP
506
507 AMREX_HIP_SAFE_CALL(hipGetDeviceProperties(&device_prop, device_id));
508
509 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(warp_size == device_prop.warpSize, "Incorrect warp size");
510
511 // check compute capability
512
513 // AMD devices do not support shared cache banking.
514
515 for (int i = 0; i < max_gpu_streams; ++i) {
516 AMREX_HIP_SAFE_CALL(hipStreamCreate(&gpu_stream_pool[i].getStream()));
517 }
518
519#ifdef AMREX_GPU_STREAM_ALLOC_SUPPORT
520 AMREX_HIP_SAFE_CALL(hipDeviceGetAttribute(&memory_pools_supported, hipDeviceAttributeMemoryPoolsSupported, device_id));
521#endif
522
523#elif defined(AMREX_USE_CUDA)
524 AMREX_CUDA_SAFE_CALL(cudaGetDeviceProperties(&device_prop, device_id));
525
526 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(device_prop.major >= 4 || (device_prop.major == 3 && device_prop.minor >= 5),
527 "Compute capability must be >= 3.5");
528
529#ifdef AMREX_GPU_STREAM_ALLOC_SUPPORT
530 cudaDeviceGetAttribute(&memory_pools_supported, cudaDevAttrMemoryPoolsSupported, device_id);
531#endif
532
533#if defined(CUDART_VERSION) && (CUDART_VERSION < 12040)
534 if ( ! minimal ) {
535 if (sizeof(Real) == 8) {
536 AMREX_CUDA_SAFE_CALL(cudaDeviceSetSharedMemConfig(cudaSharedMemBankSizeEightByte));
537 } else if (sizeof(Real) == 4) {
538 AMREX_CUDA_SAFE_CALL(cudaDeviceSetSharedMemConfig(cudaSharedMemBankSizeFourByte));
539 }
540 }
541#endif
542
543 for (int i = 0; i < max_gpu_streams; ++i) {
544 AMREX_CUDA_SAFE_CALL(cudaStreamCreate(&gpu_stream_pool[i].getStream()));
545#ifdef AMREX_USE_ACC
546 acc_set_cuda_stream(i, gpu_stream_pool[i].getStream());
547#endif
548 }
549
550 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(warp_size == device_prop.warpSize, "Incorrect warp size");

Callers

nothing calls this directly

Calls 8

PrintClass · 0.85
AbortFunction · 0.85
get_max_threadsFunction · 0.85
InitializeGraphFunction · 0.85
sizeMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected