Closed ramsampath closed 1 month ago
We have not seen this issue on Linux machines with CUDA 12.2 or any other versions. The error message "For this host platform" also seems to suggest that the issue is specific to Windows. I suspect using CUDA 11 would not work either. Unfortunately, I don't have any Windows machines with Nvidia GPUs for testing. Nevertheless, could you try the following? Please let us know whether it works for you or not!
diff --git a/Src/Base/AMReX_PODVector.H b/Src/Base/AMReX_PODVector.H
index 0f10dfb94e..1098964942 100644
--- a/Src/Base/AMReX_PODVector.H
+++ b/Src/Base/AMReX_PODVector.H
@@ -45,11 +45,10 @@ namespace amrex
[[maybe_unused]] Allocator<T> const& allocator)
{
#ifdef AMREX_USE_GPU
+ auto f = [=] AMREX_GPU_DEVICE (Size i) noexcept { data[i] = value; };
if constexpr (RunOnGpu<Allocator<T>>::value)
{
- amrex::ParallelFor(count, [=] AMREX_GPU_DEVICE (Size i) noexcept {
- data[i] = value;
- });
+ amrex::ParallelFor(count, f);
Gpu::streamSynchronize();
return;
}
@@ -58,10 +57,7 @@ namespace amrex
if (allocator.arena()->isManaged() ||
allocator.arena()->isDevice())
{
- amrex::ParallelFor(count, [=] AMREX_GPU_DEVICE (Size i) noexcept
- {
- data[i] = value;
- });
+ amrex::ParallelFor(count, f);
Gpu::streamSynchronize();
return;
}
It works, thanks! I'm building pyamrex in Windows (CUDA 11.7), succeed if I turn off Particle. However, it's difficult to do the same change for "AMReX_ParticleContainerI.H", since the parameter of "AMREX_HOST_DEVICE_FOR_1D" macro is defined inside the loop.
diff --git a/Src/Base/AMReX_PODVector.H b/Src/Base/AMReX_PODVector.H
index 0e7458fe5..8706bba6d 100644
--- a/Src/Base/AMReX_PODVector.H
+++ b/Src/Base/AMReX_PODVector.H
@@ -45,11 +45,10 @@ namespace amrex
[[maybe_unused]] Allocator<T> const& allocator)
{
#ifdef AMREX_USE_GPU
+ auto f = [=] AMREX_GPU_DEVICE (Size i) noexcept { data[i] = value; };
if constexpr (RunOnGpu<Allocator<T>>::value)
{
- amrex::ParallelFor(count, [=] AMREX_GPU_DEVICE (Size i) noexcept {
- data[i] = value;
- });
+ amrex::ParallelFor(count, f);
Gpu::streamSynchronize();
return;
}
@@ -58,10 +57,7 @@ namespace amrex
if (allocator.arena()->isManaged() ||
allocator.arena()->isDevice())
{
- amrex::ParallelFor(count, [=] AMREX_GPU_DEVICE (Size i) noexcept
- {
- data[i] = value;
- });
+ amrex::ParallelFor(count, f);
Gpu::streamSynchronize();
return;
}
@@ -101,11 +97,10 @@ namespace amrex
[[maybe_unused]] Allocator<T> const& allocator)
{
#ifdef AMREX_USE_GPU
+ auto f = [=] AMREX_GPU_DEVICE (Size i) noexcept { dst[i] = src[i]; };
if constexpr (RunOnGpu<Allocator<T>>::value)
{
- amrex::ParallelFor(count, [=] AMREX_GPU_DEVICE (Size i) noexcept {
- dst[i] = src[i];
- });
+ amrex::ParallelFor(count, f);
Gpu::Device::streamSynchronize();
return;
}
@@ -114,10 +109,7 @@ namespace amrex
if (allocator.arena()->isManaged() ||
allocator.arena()->isDevice())
{
- amrex::ParallelFor(count, [=] AMREX_GPU_DEVICE (Size i) noexcept
- {
- dst[i] = src[i];
- });
+ amrex::ParallelFor(count, f);
Gpu::streamSynchronize();
return;
}
Closing this due to inactivity -- let us know if you still have questions!
Hello ,
I am getting the following error(s) in building AMReX using Visual Studio 2019 ..
Could you kindly throw some light on how to fix this ?
Severity Code Description Project File Line Suppression State Error For this host platform/dialect, an extended lambda cannot be defined inside the 'if' or 'else' block of a constexpr if statement amrex_3d D:\FDYNAMICS\ThirdParty\amrex\Src\Base\AMReX_PODVector.H 50
Does AMREx work with CUDA 12.2 or should i downgrade to CUDA 11.x and try ?
Thank you. Ram.