Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/kcaching module vars #561

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
11 changes: 7 additions & 4 deletions cx2t/src/claw/wani/transformation/ll/caching/Kcaching.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,13 @@ private List<Integer> 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();
Expand Down
15 changes: 15 additions & 0 deletions test/claw/directive/kcache6/helper_module.f90
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions test/claw/directive/kcache6/main.f90
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions test/claw/directive/kcache6/original_code.f90
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions test/claw/directive/kcache6/reference.f90
Original file line number Diff line number Diff line change
@@ -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