diff --git a/cpp/src/core/srercode.h b/cpp/src/core/srercode.h index 996f3e59..cf23102f 100644 --- a/cpp/src/core/srercode.h +++ b/cpp/src/core/srercode.h @@ -234,7 +234,6 @@ #define SRWL_INCORRECT_PARAM_FOR_CONV_WITH_GAUS 181 + FIRST_XOP_ERR #define SRWL_INCORRECT_PARAM_FOR_CONV_MAG_2_PER 182 + FIRST_XOP_ERR #define IMPROPER_OPTICAL_COMPONENT_MIRROR_SPHERE 183 + FIRST_XOP_ERR -//#define IMPROPER_OPTICAL_COMPONENT_MIRROR_USE_CASE 184 + FIRST_XOP_ERR #define IMPROPER_OPTICAL_COMPONENT_CRYSTAL_USE_CASE 184 + FIRST_XOP_ERR #define SRWL_INCORRECT_PARAM_FOR_UND_FLD_INTERP_IND_SEARCH 185 + FIRST_XOP_ERR #define SRWL_INCORRECT_PARAM_FOR_SPHER_WAVE_COMP 186 + FIRST_XOP_ERR diff --git a/cpp/src/lib/srerror.cpp b/cpp/src/lib/srerror.cpp index 70b3df8f..157c1a83 100644 --- a/cpp/src/lib/srerror.cpp +++ b/cpp/src/lib/srerror.cpp @@ -285,6 +285,11 @@ CErrWarn::CErrWarn() warning.push_back("Electron beam is not ultra-relativistic. The resulting accuracy may be poor."); warning.push_back("To calculate emission at harmonics (HGHG), this version of GENESIS requires Electron Distribution data."); //#define GENESIS_RAD_HARM_CALC_NEEDS_ELEC_DISTRIB 24 + SRW_WARNINGS_OFFSET warning.push_back("Zero wavefront radius of curvature was submitted; the corresponding quadratic phase term was not treated."); //#define ZERO_WFR_RAD_CURV_PH_TERM_NOT_TREATED 25 + SRW_WARNINGS_OFFSET +#ifdef _OFFLOAD_GPU //HG21032024 + warning.push_back("GPU usage is requested, but GPU offloading failed. Computation will be performed on CPU."); //#define GPU_COMPUTATION_FAILED 26 + SRW_WARNINGS_OFFSET +#else + warning.push_back("GPU usage is requested, but GPU offloading is not compiled in. Computation will be performed on CPU."); //#define GPU_COMPUTATION_FAILED 26 + SRW_WARNINGS_OFFSET +#endif //}; } diff --git a/cpp/src/lib/srwlib.cpp b/cpp/src/lib/srwlib.cpp index 1d24738b..1070cef4 100644 --- a/cpp/src/lib/srwlib.cpp +++ b/cpp/src/lib/srwlib.cpp @@ -768,8 +768,8 @@ EXP int CALL srwlCalcIntFromElecField(char* pInt, SRWLWfr* pWfr, char polar, cha //HG26022024 (commented-out) //#ifdef _OFFLOAD_GPU //HG07022024 -// srwlUtiGPUProc(1, arParGPU); //OC20022024 -// //srwlUtiGPUProc(1, pvGPU); //initialize GPU + srwlUtiGPUProc(1, arParGPU); //HG21042024 Uncommented (required, must've been missed in previous exchanges) //OC20022024 + //srwlUtiGPUProc(1, pvGPU); //initialize GPU //#endif SRWLPrtTrj *pTrj=0; //OC23022020 @@ -1032,10 +1032,10 @@ EXP int CALL srwlPropagElecField(SRWLWfr* pWfr, SRWLOptC* pOpt, int nInt, char** //double start; //get_walltime (&start); -#ifdef _OFFLOAD_GPU //HG07022024 +//#ifdef _OFFLOAD_GPU //HG21032024 (commented-out) //HG07022024 srwlUtiGPUProc(1, arParGPU); //OC20022024 //srwlUtiGPUProc(1, pvGPU); -#endif +//#endif //HG21032024 (commented-out) try { srTCompositeOptElem optCont(*pOpt); @@ -1109,10 +1109,10 @@ EXP int CALL srwlUtiFFT(char* pcData, char typeData, double* arMesh, int nMesh, if(ny > 1) dimFFT = 2; //float *pfData = (float*)pcData; //OC31012019 (commented-out) -#ifdef _OFFLOAD_GPU //HG07022024 +//#ifdef _OFFLOAD_GPU //HG21032024 (commented-out) //HG07022024 srwlUtiGPUProc(1, arParGPU); //OC20022024 //srwlUtiGPUProc(1, pvGPU); -#endif +//#endif //HG21032024 (commented-out) if(dimFFT == 1) { @@ -1609,7 +1609,33 @@ EXP int CALL srwlUtiGPUProc(int op, double* arParGPU) //OC20022024 { #ifdef _OFFLOAD_GPU //HG07022024 if(op == 0) CAuxGPU::Fini(); - if(op == 1) CAuxGPU::Init(); + //if(op == 1) CAuxGPU::Init(); + if(op == 1) //HG22032024 + { + CAuxGPU::Init(); + if(arParGPU != 0 && arParGPU[0] > 0 && arParGPU[1] > 0) //HG07022024 + { + //Check if any GPU is available + if(!CAuxGPU::GPUAvailable()) + { + CErrWarn::AddWarningMessage(&gVectWarnNos, GPU_COMPUTATION_FAILED); + return 0; + } + + //Make sure that the specific GPU index requested is available + TGPUUsageArg parGPU(arParGPU); + if(!CAuxGPU::GPUEnabled(&parGPU)) + { + CErrWarn::AddWarningMessage(&gVectWarnNos, GPU_COMPUTATION_FAILED); + return 0; + } + } + } +#else + //Emits warning message that GPU offloading is not compiled in if GPU is requested during initialization + if(arParGPU != 0 && arParGPU[0] > 0 && arParGPU[1] > 0 && op == 1) + CErrWarn::AddWarningMessage(&gVectWarnNos, GPU_COMPUTATION_FAILED); + #endif //HG07022024 return 0; } diff --git a/env/python/srwpy/SRWLIB_ExampleViewDataFile.py b/env/python/srwpy/SRWLIB_ExampleViewDataFile.py index f92fa8aa..5dfd165c 100644 --- a/env/python/srwpy/SRWLIB_ExampleViewDataFile.py +++ b/env/python/srwpy/SRWLIB_ExampleViewDataFile.py @@ -57,7 +57,6 @@ def main(): #HG22032024 uti_plot_data_file(opt.infile, opt.readlab, opt.e, opt.x, opt.y, opt.joined, opt.multicol_data, opt.multicol_data_col_x, opt.multicol_data_col_y, #OC14112017 #MR31102017 opt.scale, opt.width_pixels) - uti_plot_show() if __name__=='__main__': #HG22032024 diff --git a/env/python/srwpy/examples/SRWLIB_Example17.py b/env/python/srwpy/examples/SRWLIB_Example17.py index bf72c4de..7bfadfde 100644 --- a/env/python/srwpy/examples/SRWLIB_Example17.py +++ b/env/python/srwpy/examples/SRWLIB_Example17.py @@ -170,6 +170,7 @@ #[10]: New Horizontal wavefront Center position after Shift #[11]: New Vertical wavefront Center position after Shift # [0][1][2] [3][4] [5] [6] [7] [8] [9][10][11] + ppSmp = [0, 0, 1., 0, 0, 1., 55., 1., 55., 0, 0, 0] ppSmp_Det = [0, 0, 1., 3, 0, 1., 1., 1., 1., 0, 0, 0] ppFin = [0, 0, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]