forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for ast_openmp and ast_cpp_hip
- Loading branch information
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"basename": "ast_cpp_hip-subroutine4-918a576", | ||
"cmd": "cpptranslate --show-ast-cpp-hip {infile}", | ||
"infile": "tests/subroutine4.f90", | ||
"infile_hash": "06ca8a1c322b25fe9280c43f558f6fa92e1a4843b6f6b77e206fdf4e", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "ast_cpp_hip-subroutine4-918a576.stdout", | ||
"stdout_hash": "a6cc3f90c3064b7e0fd74db7867cdb22291414e18ed43fe44c463b6b", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#define blocksize 128 | ||
|
||
//Pass by value variables found in the loop body: scalar | ||
//Pass by reference variables found in the loop body: b a c | ||
__global__ void Tempkernelname(int N, float scalar, float *b, float *a, float *c){ | ||
int i = blockIDx.x*blockDim.x+threadIdx.x; | ||
if (i >= N) return; | ||
c[i] = (a[i]) + ((scalar)*(b[i])); | ||
} | ||
|
||
void triad(float *a, size_t a_size, float *b, size_t b_size, float scalar, | ||
float *c, size_t c_size) | ||
{ | ||
size_t N; | ||
size_t i; | ||
N = a_size; | ||
int gridsize = (N + blocksize - 1)/blocksize; | ||
float *b_d; | ||
hipMalloc(&b_d, N*sizeof(float)); | ||
hipMemcpy(b_d, b, N*sizeof(float), hipMemcpyHostToDevice); | ||
float *a_d; | ||
hipMalloc(&a_d, N*sizeof(float)); | ||
hipMemcpy(a_d, a, N*sizeof(float), hipMemcpyHostToDevice); | ||
float *c_d; | ||
hipMalloc(&c_d, N*sizeof(float)); | ||
hipMemcpy(c_d, c, N*sizeof(float), hipMemcpyHostToDevice); | ||
hipLaunchKernelGGL(Tempkernelname, dim3(gridsize), dim3(blocksize), 0, 0, N, scalar, b_d, a_d, c_d); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"basename": "ast_openmp-subroutine4-0411983", | ||
"cmd": "cpptranslate --show-ast-openmp {infile}", | ||
"infile": "tests/subroutine4.f90", | ||
"infile_hash": "06ca8a1c322b25fe9280c43f558f6fa92e1a4843b6f6b77e206fdf4e", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "ast_openmp-subroutine4-0411983.stdout", | ||
"stdout_hash": "2ba13829eb08486a48eae11b2da02196deecbc68ae4c8c53c6c633bc", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
subroutine triad(a, b, scalar, c) | ||
real, intent(in) :: a(:) | ||
real, intent(in) :: b(:) | ||
real, intent(in) :: scalar | ||
real, intent(out) :: c(:) | ||
integer :: N | ||
integer :: i | ||
N = size(a) | ||
!$OMP PARALLEL DO | ||
do i = 1:N | ||
c(i) = (a(i)) + ((scalar)*(b(i))) | ||
end do | ||
!$OMP END PARALLEL DO | ||
end subroutine triad | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters