Problem 1841

Summary: Intel C++ Compiler can't compile G4GIDI_mass.cc and tpia_mass.cc in lend/src
Product: Geant4 Reporter: Bastian Beischer <beischer>
Component: processes/hadronic/models/lendAssignee: tkoi
Status: RESOLVED INVALID    
Severity: trivial CC: beischer
Priority: P5    
Version: 10.2   
Hardware: All   
OS: Linux   

Description Bastian Beischer 2016-03-11 10:40:35 CET
When trying to compile G4GIDI_mass.cc and tpia_mass.cc in processes/hadronic/models/lend/src the Intel C++ Compiler requires huge amounts of memory (>>10 GB) when compiling with optimizations enabled.

See

https://software.intel.com/en-us/forums/intel-c-compiler/topic/611638

This is a compiler bug but it can be worked around by changing

std::string -> const char*

in the ZAMass struct in these files (actually it appears that these were once const char* and were changed to std::string at some point).

Do you think it's possible to make that change?

Another option is to compile these two files with -O0 which could be done like this (patch for sources.cmake in processes/hadronic/models/lend

--- a/source/processes/hadronic/models/lend/sources.cmake
+++ b/source/processes/hadronic/models/lend/sources.cmake
@@ -172,4 +172,11 @@ set_source_files_properties(
     PROPERTIES COMPILE_DEFINITIONS G4PROCESSES_EXPORT
 )
 
-
+# These two files require infinite memory when compiled with the Intel compiler and optimizations enabled.
+if("${CMAKE_CXX_COMPILER_ID}" MATCHES Intel)
+    foreach(file ${G4had_lend_SOURCES})
+        if ("${file}" MATCHES G4GIDI_mass.cc OR "${file}" MATCHES tpia_mass.cc)
+            set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS -O0)
+        endif()
+    endforeach()
+endif()

This will generate an ICC remark (overriding optimization flag -O2 with -O0 or something like that). If desired that remark could be silenced for these two files.

I think switching from std::string to const char* is the cleaner solution, though.
Comment 1 tkoi 2016-04-17 22:57:36 CEST
Hi

Thank you for reporting this problem.
But we changed the declaration std::string to char const * in 10.02.

Tatsumi