diff --git a/cx2t/src/claw/wani/transformation/ll/caching/Kcaching.java b/cx2t/src/claw/wani/transformation/ll/caching/Kcaching.java index f3bb02f8b..b8ab0c8f7 100644 --- a/cx2t/src/claw/wani/transformation/ll/caching/Kcaching.java +++ b/cx2t/src/claw/wani/transformation/ll/caching/Kcaching.java @@ -259,10 +259,13 @@ private List generateInferredOffsets(XcodeProgram xcodeml, { Xid id = fctDef.getSymbolTable().get(var); if(id == null) { - throw new IllegalTransformationException("Variable " + var + - " defined in the data clause has not been found", - _claw.getPragma().lineNo() - ); + id = fctDef.findParentModule().getSymbolTable().get(var); + if(id == null) { + throw new IllegalTransformationException("Variable " + var + + " defined in the data clause has not been found", + _claw.getPragma().lineNo() + ); + } } FbasicType basicType = xcodeml.getTypeTable().getBasicType(id); int dim = basicType.getDimensions(); diff --git a/test/claw/directive/kcache6/helper_module.f90 b/test/claw/directive/kcache6/helper_module.f90 new file mode 100644 index 000000000..fa6d9f16c --- /dev/null +++ b/test/claw/directive/kcache6/helper_module.f90 @@ -0,0 +1,15 @@ +! +! This file is released under terms of BSD license +! See LICENSE file for more information +! +! Helper module to provide some arrays that can be imported +! +module helper_module + implicit none + + public + real(KIND=8) :: array1(10,20) + real(KIND=8) :: array2(10,20) + real(KIND=8) :: array3(10,20) + +end module helper_module diff --git a/test/claw/directive/kcache6/main.f90 b/test/claw/directive/kcache6/main.f90 new file mode 100644 index 000000000..5a69ed978 --- /dev/null +++ b/test/claw/directive/kcache6/main.f90 @@ -0,0 +1,11 @@ +! +! This file is released under terms of BSD license +! See LICENSE file for more information +! +! Entry point for the module test +! +PROGRAM claw_test + USE kcache_module, ONLY: kcache + + CALL kcache() +END PROGRAM claw_test diff --git a/test/claw/directive/kcache6/original_code.f90 b/test/claw/directive/kcache6/original_code.f90 new file mode 100644 index 000000000..ec30bdfdd --- /dev/null +++ b/test/claw/directive/kcache6/original_code.f90 @@ -0,0 +1,40 @@ +! +! This file is released under terms of BSD license +! See LICENSE file for more information +! +! Simple program to test the kcache directive +! + +MODULE kcache_module +USE helper_module, ONLY: array1, array2, array3 + +contains + +SUBROUTINE kcache() + + INTEGER :: i,j + + DO i = 1,10 + DO j = 1,20 + array1(i,j) = 1.0 + array2(i,j) = 2.0 + array3(i,j) = 3.0 + END DO + END DO + + DO i = 1,10 + DO j = 2,20 + !$claw kcache data(array2, array3) + !$claw kcache data(array1) offset(0,-1) + array1(i,j) = array1(i,j-1) * 2.0 + array2(i,j) = array2(i,j) * 2.0 + array1(i,j-1) + array3(i,j) = array3(i,j) * 2.0 + array1(i,j-1) + array2(i,j) + array1(i,j-1) = array2(i,j) + END DO + END DO + PRINT*, SUM(array1) + PRINT*, SUM(array2) + PRINT*, SUM(array3) +END SUBROUTINE kcache + +END MODULE kcache_module diff --git a/test/claw/directive/kcache6/reference.f90 b/test/claw/directive/kcache6/reference.f90 new file mode 100644 index 000000000..3e1f40ba6 --- /dev/null +++ b/test/claw/directive/kcache6/reference.f90 @@ -0,0 +1,37 @@ +MODULE kcache_module + USE helper_module , ONLY: array1 , array2 , array3 + +CONTAINS + SUBROUTINE kcache ( ) + + INTEGER :: i + INTEGER :: j + REAL ( KIND= 8 ) :: array2_k + REAL ( KIND= 8 ) :: array3_k + REAL ( KIND= 8 ) :: array1_k_m1 + + DO i = 1 , 10 , 1 + DO j = 1 , 20 , 1 + array1 ( i , j ) = 1.0 + array2 ( i , j ) = 2.0 + array3 ( i , j ) = 3.0 + END DO + END DO + DO i = 1 , 10 , 1 + DO j = 2 , 20 , 1 + array1_k_m1 = array1 ( i , j - 1 ) * 2.0 + array1 ( i , j ) = array1_k_m1 + array2_k = array2 ( i , j ) * 2.0 + array1_k_m1 + array2 ( i , j ) = array2_k + array3_k = array3 ( i , j ) * 2.0 + array1_k_m1 + array2_k + array3 ( i , j ) = array3_k + array1_k_m1 = array2_k + END DO + END DO + PRINT * , sum ( array1 ) + PRINT * , sum ( array2 ) + PRINT * , sum ( array3 ) + END SUBROUTINE kcache + +END MODULE kcache_module +