Skip to content

Commit 2567838

Browse files
author
Damian Rouson
committed
Modified the CMake files and src/extensions/opencoarrays.F90 to build with the Cray compilers. The build now completes. No tests pass. Next steps: adjust the caf and cafrun scripts to switch from mpif90 to ftn an dfrom mpirun to aprun.
1 parent e162c59 commit 2567838

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ endif()
2626
#Report untested Fortran compiler unless explicitly directed to build all examples.
2727
if ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU" )
2828
set(gfortran_compiler true)
29-
# add_definitions(-DPREFIX_NAME=_gfortran_caf_)
29+
elseif ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Cray" )
30+
set(cray_compiler true)
31+
message(WARNING
32+
"Support for the detected compiler (${CMAKE_Fortran_COMPILER_ID}) is experimental. "
33+
"Please report any failures to opencoarrays@googlegroups.com"
34+
)
35+
option(COMPILER_LACKS_C_PTRDIFF_T "iso_c_binding bug filed against CCE 8.4 beta" TRUE)
3036
else()
3137
message(WARNING
32-
"*** Attempting to build with untested Fortran compiler: ${CMAKE_Fortran_COMPILER_ID}."
33-
"*** Please report any failures to opencoarrays@googlegroups.com"
38+
"Attempting to build with untested Fortran compiler: ${CMAKE_Fortran_COMPILER_ID}. "
39+
"Please report any failures to opencoarrays@googlegroups.com\n\n"
3440
)
3541
endif()
3642

src/extensions/opencoarrays.F90

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ module opencoarrays
2929
#ifdef COMPILER_SUPPORTS_ATOMICS
3030
use iso_fortran_env, only : atomic_int_kind
3131
#endif
32-
use iso_c_binding, only : c_int,c_char,c_ptr,c_loc,c_double,c_int32_t,c_ptrdiff_t,c_sizeof,c_bool,c_funloc
32+
#if defined(COMPILER_LACKS_C_PTRDIFF_T) || defined(COMPILER_LACKS_C_SIZEOF_ASSUMED_RANK)
33+
use iso_c_binding, only : c_int,c_char,c_ptr,c_loc,c_double,c_int32_t,c_bool,c_funloc,c_long
34+
#elif defined(COMPILER_LACKS_C_PTRDIFF_T)
35+
use iso_c_binding, only : c_int,c_char,c_ptr,c_loc,c_double,c_int32_t,c_bool,c_funloc,c_long ,c_sizeof
36+
#elif defined(COMPILER_LACKS_C_SIZEOF_ASSUMED_RANK)
37+
use iso_c_binding, only : c_int,c_char,c_ptr,c_loc,c_double,c_int32_t,c_bool,c_funloc,c_ptrdiff_t
38+
#else
39+
use iso_c_binding, only : c_int,c_char,c_ptr,c_loc,c_double,c_int32_t,c_bool,c_funloc,c_ptrdiff_t,c_sizeof
40+
#endif
3341
implicit none
3442

3543
private
@@ -52,6 +60,10 @@ module opencoarrays
5260
end type
5361
#endif
5462

63+
#ifdef COMPILER_LACKS_C_PTRDIFF_T
64+
integer(c_int), parameter :: c_ptrdiff_t=c_long
65+
#endif
66+
5567
! Generic interface to co_broadcast with implementations for various types, kinds, and ranks
5668
interface co_reduce
5769
module procedure co_reduce_c_int,co_reduce_c_double,co_reduce_logical
@@ -376,7 +388,6 @@ function gfc_descriptor_c_int(a) result(a_descriptor)
376388
type(gfc_descriptor_t) :: a_descriptor
377389
integer(c_int), parameter :: unit_stride=1,scalar_offset=-1
378390
integer(c_int) :: i
379-
380391
a_descriptor%dtype = my_dtype(type_=BT_INTEGER,kind_=int(c_sizeof(a)/bytes_per_word,c_int32_t),rank_=rank(a))
381392
a_descriptor%offset = scalar_offset
382393
a_descriptor%base_addr = c_loc(a) ! data
@@ -385,7 +396,14 @@ function gfc_descriptor_c_int(a) result(a_descriptor)
385396
a_descriptor%dim_(i)%lower_bound = lbound(a,i)
386397
a_descriptor%dim_(i)%ubound_ = ubound(a,i)
387398
end do
388-
399+
#if defined(COMPILER_LACKS_C_SIZEOF_ASSUMED_RANK)
400+
contains
401+
function c_sizeof(mold) result(c_size_of_mold)
402+
integer(c_int), intent(in), target :: mold(..)
403+
integer(c_int) :: c_size_of_mold
404+
c_size_of_mold=4
405+
end function
406+
#endif
389407
end function
390408

391409
function gfc_descriptor_logical(a) result(a_descriptor)
@@ -420,6 +438,15 @@ function gfc_descriptor_c_double(a) result(a_descriptor)
420438
a_descriptor%dim_(i)%ubound_ = ubound(a,i)
421439
end do
422440

441+
#if defined(COMPILER_LACKS_C_SIZEOF_ASSUMED_RANK)
442+
contains
443+
function c_sizeof(mold) result(c_size_of_mold)
444+
real(c_double), intent(in), target :: mold(..)
445+
integer(c_int) :: c_size_of_mold
446+
c_size_of_mold=4
447+
end function
448+
#endif
449+
423450
end function
424451

425452
! This version should work for any rank but causes an ICE with gfortran 4.9.2

src/mpi/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ find_package(MPI REQUIRED)
44

55
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
66
set(gfortran_compiler true)
7+
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Cray")
8+
set(cray_compiler true)
79
endif()
810

911
if (CMAKE_VERSION VERSION_GREATER 3.2.3)
@@ -27,6 +29,10 @@ else()
2729
if(gfortran_compiler)
2830
# This applied to gfortran 4.9 and some earlier versions (FIX ME: find out which)
2931
add_definitions(-DCOMPILER_SUPPORTS_CAF_INTRINSICS)
32+
elseif (cray_compiler)
33+
# This applies to CCE 8.4 beta or earlier
34+
add_definitions(-DCOMPILER_LACKS_C_PTRDIFF_T)
35+
add_definitions(-DCOMPILER_LACKS_C_SIZEOF_ASSUMED_RANK)
3036
endif()
3137
endif()
3238
add_library(caf_mpi mpi_caf.c ../common/caf_auxiliary.c ../extensions/opencoarrays.F90)

0 commit comments

Comments
 (0)