| 491 | } |
| 492 | |
| 493 | void |
| 494 | Device::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"); |
nothing calls this directly
no test coverage detected