From faf0eaf8e47a41a945798902e4b8edce5ed002bb Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 13 Feb 2025 20:54:09 -0500 Subject: [PATCH 1/2] add check_for_nan to print from GPUs if USE_GPU_PRINTF=TRUE --- Source/driver/Castro.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/driver/Castro.cpp b/Source/driver/Castro.cpp index 7b9db57de3..d2cfd5c6bf 100644 --- a/Source/driver/Castro.cpp +++ b/Source/driver/Castro.cpp @@ -4490,13 +4490,18 @@ Castro::check_for_nan(const MultiFab& state_in, int check_ghost) } if (state_in.contains_nan(URHO,state_in.nComp(),ng,true)) { -#ifdef AMREX_USE_GPU +#if defined(AMREX_USE_GPU) && !defined(ALLOW_GPU_PRINTF) std::string abort_string = std::string("State has NaNs in check_for_nan()"); amrex::Abort(abort_string.c_str()); #else for (int i = 0; i < state_in.nComp(); i++) { if (state_in.contains_nan(URHO + i, 1, ng, true)) { +#ifndef AMREX_USE_GPU std::string abort_string = std::string("State has NaNs in the ") + desc_lst[State_Type].name(i) + std::string(" component::check_for_nan()"); +#else + AMREX_DEVICE_PRINTF("State has NaNs in the %s component::check_for_nan()", + desc_lst[State_Type].name(i)); +#endif amrex::Abort(abort_string.c_str()); } } From 469d3f47111551414c27e4d489a0b4acccbb1d32 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 13 Feb 2025 21:12:34 -0500 Subject: [PATCH 2/2] fix --- Source/driver/Castro.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/driver/Castro.cpp b/Source/driver/Castro.cpp index d2cfd5c6bf..fbfe8b1e11 100644 --- a/Source/driver/Castro.cpp +++ b/Source/driver/Castro.cpp @@ -4496,12 +4496,7 @@ Castro::check_for_nan(const MultiFab& state_in, int check_ghost) #else for (int i = 0; i < state_in.nComp(); i++) { if (state_in.contains_nan(URHO + i, 1, ng, true)) { -#ifndef AMREX_USE_GPU std::string abort_string = std::string("State has NaNs in the ") + desc_lst[State_Type].name(i) + std::string(" component::check_for_nan()"); -#else - AMREX_DEVICE_PRINTF("State has NaNs in the %s component::check_for_nan()", - desc_lst[State_Type].name(i)); -#endif amrex::Abort(abort_string.c_str()); } }