Splitting the pre-processor from the compilation is a typical paint point of using psyclone. "cpp" can be used for custom preprocessor defines but for doing it properly (psyclone workflow equivalent to using only the compiler) is quite tricky because there is compiler-specific defines .e.g the __NVCOMPILER causing the issue here, but also feature-specific _OPENMP or architecture-specific __SSE3__. Not doing the exact same thing on the cpp than in the compiler leads to very subtle differences.
When injecting psyclone to other projects we always have to go through this initial step of modifying the build systems, which is complex because each build-system is different and the previously mentioned subtleties make it is a complex logic to get right. So for some time I thought that psyclone should have an easier way to be injected to build systems that take responsibility of this preprocessor/compiler splitting step with a compiler wrapper tool psyclonefc (similar to mpifort - btw mpi also adds defines that cpp misses) where the wrapper:
- does the preprocessor with the same compiler and feature-flags that the compiler would take
- applies psyclone
- compiles.
This will make sure that no compiler/architecture define is lost and the logic of dealing with each compiler preprocessor are encoded into psyclone instead of repeated in each project.
Using the tool would look like this:
FC=psyclonefc PSYCLONE_COMPILER=mpifort make
Which inside the build system, when it find the $FC <flags> <input.f90> it does steps 1 and 2 for each *.f90 file and finally step 3 with all preprocessed and psycloned sources.
Splitting the pre-processor from the compilation is a typical paint point of using psyclone. "cpp" can be used for custom preprocessor defines but for doing it properly (psyclone workflow equivalent to using only the compiler) is quite tricky because there is compiler-specific defines .e.g the
__NVCOMPILERcausing the issue here, but also feature-specific_OPENMPor architecture-specific__SSE3__. Not doing the exact same thing on the cpp than in the compiler leads to very subtle differences.When injecting psyclone to other projects we always have to go through this initial step of modifying the build systems, which is complex because each build-system is different and the previously mentioned subtleties make it is a complex logic to get right. So for some time I thought that psyclone should have an easier way to be injected to build systems that take responsibility of this preprocessor/compiler splitting step with a compiler wrapper tool
psyclonefc(similar to mpifort - btw mpi also adds defines that cpp misses) where the wrapper:This will make sure that no compiler/architecture define is lost and the logic of dealing with each compiler preprocessor are encoded into psyclone instead of repeated in each project.
Using the tool would look like this:
FC=psyclonefc PSYCLONE_COMPILER=mpifort makeWhich inside the build system, when it find the
$FC <flags> <input.f90>it does steps 1 and 2 for each *.f90 file and finally step 3 with all preprocessed and psycloned sources.