Problem 1841 - Intel C++ Compiler can't compile G4GIDI_mass.cc and tpia_mass.cc in lend/src
Summary: Intel C++ Compiler can't compile G4GIDI_mass.cc and tpia_mass.cc in lend/src
Status: RESOLVED INVALID
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes/hadronic/models/lend (show other problems)
Version: 10.2
Hardware: All Linux
: P5 trivial
Assignee: tkoi
URL:
Depends on:
Blocks:
 
Reported: 2016-03-11 10:40 CET by Bastian Beischer
Modified: 2016-04-17 22:57 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
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