Skip to content

Commit

Permalink
Merge branch 'hotfix/0.13.1'
Browse files Browse the repository at this point in the history
* hotfix/0.13.1:
  Version 0.13.1
  ATLAS-151 Split fctest_mesh in separate files to workaround intel 18.0 internal compiler error
  ATLAS-151 Disable 2 Fortran tests that don't compile with  ifort 18.0.0.033
  ATLAS-150 Fix preprocessor commands
  ATLAS-150 some updates for latest GT release
  • Loading branch information
wdeconinck committed Mar 1, 2018
2 parents be3e70e + e14866b commit 57243b7
Show file tree
Hide file tree
Showing 16 changed files with 504 additions and 360 deletions.
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,6 @@ ecbuild_debug_var( ATLAS_EXTRA_LIBRARIES )
################################################################################
# sources

if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI" AND
CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 16.8 )
set( atlas_fctest_parametrisation_DISABLED TRUE )
ecbuild_warn( "PGI Fortran compiler version tested up to 16.7 has a compiler bug "
"that leads to a segfaults for atlas_fctest_parametrisation. "
"Disabling this test..." )
endif()

include_directories( ${ATLAS_INCLUDE_DIRS} ${ATLAS_EXTRA_INCLUDE_DIRS} )
include(CompileFlags)
add_subdirectory( src )
Expand Down
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.

set ( ${PROJECT_NAME}_VERSION_STR "0.13.0" )
set ( ${PROJECT_NAME}_VERSION_STR "0.13.1" )

4 changes: 2 additions & 2 deletions src/atlas/array/gridtools/GridToolsArray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ArrayT_impl {
public:
ArrayT_impl( ArrayT<Value>& array ) : array_( array ) {}

template <typename... UInts, typename = ::gridtools::all_integers<UInts...>>
template <typename... UInts, typename = ::gridtools::is_all_integral<UInts...>>
void construct( UInts... dims ) {
auto gt_storage = create_gt_storage<Value, typename default_layout_t<sizeof...( dims )>::type>( dims... );
using data_store_t = typename std::remove_pointer<decltype( gt_storage )>::type;
Expand Down Expand Up @@ -147,7 +147,7 @@ class ArrayT_impl {
}
}

template <typename Layout, typename... UInts, typename = ::gridtools::all_integers<UInts...>>
template <typename Layout, typename... UInts, typename = ::gridtools::is_all_integral<UInts...>>
void construct_with_layout( UInts... dims ) {
auto gt_data_store_ptr = create_gt_storage<Value, Layout>( dims... );
using data_store_t = typename std::remove_pointer<decltype( gt_data_store_ptr )>::type;
Expand Down
5 changes: 4 additions & 1 deletion src/atlas/array/gridtools/GridToolsArrayHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ struct my_apply_gt_integer_sequence<::gridtools::gt_integer_sequence<UInt, Indic
}
};

#ifndef __CUDACC__

template <typename DataStore, typename... Dims>
ArraySpec make_spec( DataStore* gt_data_store_ptr, Dims... dims ) {
ArraySpec ATLAS_HOST make_spec( DataStore* gt_data_store_ptr, Dims... dims ) {
static_assert( (::gridtools::is_data_store<DataStore>::value ), "Internal Error: passing a non GT data store" );

if ( gt_data_store_ptr->valid() ) {
Expand Down Expand Up @@ -241,6 +243,7 @@ ArraySpec make_spec( DataStore* gt_data_store_ptr, Dims... dims ) {
make_null_strides( typename ::gridtools::make_gt_integer_sequence<size_t, sizeof...( dims )>::type() ) );
}
}
#endif

//------------------------------------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion src/atlas/array/gridtools/GridToolsTraits.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "gridtools/common/generic_metafunctions/all_integrals.hpp"
#include "gridtools/common/generic_metafunctions/is_all_integrals.hpp"
#include "gridtools/common/generic_metafunctions/accumulate.hpp"
#include "gridtools/storage/storage-facility.hpp"

#include "atlas/array/ArrayViewDefs.h"
Expand Down
25 changes: 25 additions & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,32 @@
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.

######################################################
# Compiler bugs force us to disable some tests

if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI" AND
CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 16.8 )
set( atlas_fctest_parametrisation_DISABLED TRUE )
ecbuild_warn( "PGI Fortran compiler version tested up to 16.7 has a compiler bug "
"that leads to a segfaults for atlas_fctest_parametrisation. "
"Disabling this test..." )
endif()

if( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
if( NOT CMAKE_Fortran_COMPILER_VERSION
AND CMAKE_C_COMPILER_ID MATCHES "Intel" )
set( CMAKE_Fortran_COMPILER_VERSION ${CMAKE_C_COMPILER_VERSION} )
endif()
if( CMAKE_Fortran_COMPILER_VERSION VERSION_EQUAL 18.0 )
set( atlas_fctest_parametrisation_DISABLED TRUE )
ecbuild_warn( "Intel Fortran compiler version tested 18.0 has a internal compiler error "
"when compiling atlas_fctest_parametrisation. "
"Disabling this tests..." )
endif()
endif()


######################################################

# Macro atlas_add_cuda_test
# Envisioned to become part of ecbuild_add_test with a CUDA option
Expand Down
17 changes: 15 additions & 2 deletions src/tests/field/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,31 @@
if( HAVE_FCTEST )

add_fctest( TARGET atlas_fctest_field
CONDITION ATLAS_HAVE_GRIDTOOLS_STORAGE AND ATLAS_GRIDTOOLS_STORAGE_BACKEND_HOST
LINKER_LANGUAGE Fortran
SOURCES fctest_field.F90
LIBS atlas_f
)

add_fctest( TARGET atlas_fctest_field_wrap
LINKER_LANGUAGE Fortran
SOURCES fctest_field_wrap.F90
LIBS atlas_f
)

add_fctest( TARGET atlas_fctest_field_host
CONDITION ATLAS_HAVE_GRIDTOOLS_STORAGE AND ATLAS_GRIDTOOLS_STORAGE_BACKEND_HOST
LINKER_LANGUAGE Fortran
SOURCES fctest_field_host.F90
LIBS atlas_f
)

add_fctest( TARGET atlas_fctest_field_gpu
add_fctest( TARGET atlas_fctest_field_device
CONDITION ATLAS_HAVE_GRIDTOOLS_STORAGE AND ATLAS_GRIDTOOLS_STORAGE_BACKEND_CUDA
LINKER_LANGUAGE Fortran
SOURCES fctest_field_gpu.F90 external_acc_routine.F90
LIBS atlas_f
)

if( TARGET atlas_fctest_field_gpu )
target_compile_options( atlas_fctest_field_gpu PUBLIC ${ACC_Fortran_FLAGS} )
target_link_libraries( atlas_fctest_field_gpu ${ACC_Fortran_FLAGS} )
Expand Down
144 changes: 125 additions & 19 deletions src/tests/field/fctest_field.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,164 @@
! does it submit to any jurisdiction.

! This File contains Unit Tests for testing the
! C++ / Fortran Interfaces to the State Datastructure
! C++ / Fortran Interfaces to the Mesh Datastructure
! @author Willem Deconinck

#include "fckit/fctest.h"

! -----------------------------------------------------------------------------

module fcta_Field_fxt
module fcta_Field_fixture
use atlas_module
use, intrinsic :: iso_c_binding
implicit none

contains

end module

! -----------------------------------------------------------------------------

TESTSUITE_WITH_FIXTURE(fcta_Field,fcta_Field_fxt)
TESTSUITE_WITH_FIXTURE(fctest_atlas_Field,fcta_Field_fixture)

! -----------------------------------------------------------------------------

TESTSUITE_INIT
call atlas_init()
call atlas_library%initialise()
END_TESTSUITE_INIT

! -----------------------------------------------------------------------------

TESTSUITE_FINALIZE
call atlas_finalise()
call atlas_library%finalise()
END_TESTSUITE_FINALIZE

! -----------------------------------------------------------------------------

TEST( test_host_data )
type(atlas_Field) :: field
real(8), pointer :: host(:,:)
real(8), pointer :: device(:,:)
TEST( test_field_name )
implicit none

field = atlas_Field(kind=atlas_real(8),shape=[10,5])
type(atlas_Field) :: field

call field%host_data(host)
field = atlas_Field("field",atlas_real(c_double),(/10/))
FCTEST_CHECK_EQUAL( field%name() , "field" )
call field%final() ! memory leak if not finalized!
END_TEST

FCTEST_CHECK( .not. field%host_needs_update() )
FCTEST_CHECK( .not. field%device_needs_update() )
! -----------------------------------------------------------------------------

call field%clone_to_device()
FCTEST_CHECK( .not. field%device_needs_update() )
TEST( test_field_owners)
implicit none

call field%final()
type(atlas_Field) :: f
type(atlas_Field) :: f2
type(atlas_State) :: state
type(atlas_FieldSet) :: fields
write(0,*) "test_field_owners"
f = atlas_Field("field_test_owners",atlas_real(c_double),(/10/) )
FCTEST_CHECK_EQUAL( f%owners() , 1 )
state = atlas_State()
call state%add(f)
FCTEST_CHECK_EQUAL( f%owners() , 2 )

f2 = state%field("field_test_owners")
FCTEST_CHECK_EQUAL( f%owners() , 3 )
call f2%final()

FCTEST_CHECK_EQUAL( f%owners() , 2 )

call state%remove("field_test_owners")
FCTEST_CHECK_EQUAL( f%owners() , 1 )
fields = atlas_FieldSet("fields")
call fields%add(f)
FCTEST_CHECK_EQUAL( f%owners() , 2 )

call fields%final()
FCTEST_CHECK_EQUAL( f%owners() , 1 )

call f%final() ! memory leak if not finalized!
call state%final()
END_TEST

! -----------------------------------------------------------------------------

TEST( test_field_size )
implicit none

integer, pointer :: fdata_int(:,:)
real(c_float), pointer :: fdata_real32(:,:)
real(c_double), pointer :: fdata_real64(:,:)
type(atlas_Field) :: field

write(*,*) "test_field_size starting"

field = atlas_Field("field_0",atlas_integer(),(/0,10/))
FCTEST_CHECK_EQUAL( field%owners() , 1 )
call field%data(fdata_int)
FCTEST_CHECK_EQUAL( field%datatype() , "int32" )
FCTEST_CHECK_EQUAL( size(fdata_int) , 0 )

call field%final() ! Not necessary, following "=" will handle it
write(0,*) "finalized field0"

field = atlas_Field("field_1",atlas_real(c_float),(/1,10/))
call field%data(fdata_real32)
FCTEST_CHECK_EQUAL( field%datatype() , "real32" )
FCTEST_CHECK_EQUAL( size(fdata_real32) , 10 )

call field%final() !Not necessary, following "=" will handle it

field = atlas_Field("field_2",atlas_real(c_double),(/2,10/))
FCTEST_CHECK_EQUAL( field%owners() , 1 )
call field%data(fdata_real64)
FCTEST_CHECK_EQUAL( field%name(), "field_2" )
FCTEST_CHECK_EQUAL( field%datatype() , "real64" )
FCTEST_CHECK_EQUAL( size(fdata_real64) , 20 )

write(0,*) "Owners = ", field%owners()
call field%attach()
write(0,*) "Owners = ", field%owners()
call field%attach()
write(0,*) "Owners = ", field%owners()
call field%detach()
write(0,*) "Owners = ", field%owners()
call field%detach()
write(0,*) "Owners = ", field%owners()
field = field
write(0,*) "Owners = ", field%owners()
call field%final()
END_TEST

! -----------------------------------------------------------------------------

TEST( test_fieldset )
implicit none

type(atlas_FieldSet) :: fieldset
type(atlas_Field) :: field

write(*,*) "test_fieldset starting"

fieldset = atlas_FieldSet()

field = atlas_Field("field_0",atlas_integer(),(/0,10/))
call fieldset%add( field )

field = atlas_Field("field_1",atlas_integer(),(/1,10/))
call fieldset%add( field )

field = atlas_Field("field_2",atlas_integer(),(/2,10/))
call fieldset%add( field )

FCTEST_CHECK_EQUAL( fieldset%size(), 3_c_size_t )

field = fieldset%field(1)
FCTEST_CHECK_EQUAL( field%name(), "field_0" )
field = fieldset%field(2)
FCTEST_CHECK_EQUAL( field%name(), "field_1" )
field = fieldset%field(3)
FCTEST_CHECK_EQUAL( field%name(), "field_2" )
call fieldset%final()
write(0,*) "test_fieldset end"

END_TEST

! -----------------------------------------------------------------------------

Expand Down
65 changes: 65 additions & 0 deletions src/tests/field/fctest_field_host.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
! (C) Copyright 2013 ECMWF.
! This software is licensed under the terms of the Apache Licence Version 2.0
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
! In applying this licence, ECMWF does not waive the privileges and immunities
! granted to it by virtue of its status as an intergovernmental organisation nor
! does it submit to any jurisdiction.

! This File contains Unit Tests for testing the
! C++ / Fortran Interfaces to the State Datastructure
! @author Willem Deconinck

#include "fckit/fctest.h"

! -----------------------------------------------------------------------------

module fcta_Field_fxt
use atlas_module
use, intrinsic :: iso_c_binding
implicit none

contains

end module

! -----------------------------------------------------------------------------

TESTSUITE_WITH_FIXTURE(fcta_Field,fcta_Field_fxt)

! -----------------------------------------------------------------------------

TESTSUITE_INIT
call atlas_init()
END_TESTSUITE_INIT

! -----------------------------------------------------------------------------

TESTSUITE_FINALIZE
call atlas_finalise()
END_TESTSUITE_FINALIZE

! -----------------------------------------------------------------------------

TEST( test_host_data )
type(atlas_Field) :: field
real(8), pointer :: host(:,:)
real(8), pointer :: device(:,:)

field = atlas_Field(kind=atlas_real(8),shape=[10,5])

call field%host_data(host)

FCTEST_CHECK( .not. field%host_needs_update() )
FCTEST_CHECK( .not. field%device_needs_update() )

call field%clone_to_device()
FCTEST_CHECK( .not. field%device_needs_update() )

call field%final()
END_TEST


! -----------------------------------------------------------------------------

END_TESTSUITE

Loading

0 comments on commit 57243b7

Please sign in to comment.