-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor CUDA and HIP vector kernel(s).
- Loading branch information
Showing
20 changed files
with
197 additions
and
74 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
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
]] | ||
|
||
set(ReSolve_CPU_SRC | ||
cpuVectorKernels.cpp | ||
#cpuVectorKernels.cpp | ||
cpuKernels.cpp | ||
MemoryUtils.cpp | ||
) | ||
|
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
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
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
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,17 @@ | ||
/** | ||
* @file cudaVectorKernels.h | ||
* @author Slaven Peles ([email protected]) | ||
* @brief Contains declarations of CUDA vector kernel wrappers. | ||
* @date 2023-12-08 | ||
* | ||
* @note Kernel wrappers implemented here are intended for use in hardware | ||
* agnostic code. | ||
*/ | ||
#pragma once | ||
|
||
#include <resolve/Common.hpp> | ||
|
||
namespace ReSolve | ||
{ | ||
void cuda_set_array_const(index_type n, real_type val, real_type* arr); | ||
} |
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
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 was deleted.
Oops, something went wrong.
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,17 @@ | ||
/** | ||
* @file hipVectorKernels.h | ||
* @author Slaven Peles ([email protected]) | ||
* @brief Contains declaration of HIP vector kernels. | ||
* @date 2023-12-08 | ||
* | ||
* @note Kernel wrappers implemented here are intended for use in hardware | ||
* agnostic code. | ||
*/ | ||
#pragma once | ||
|
||
#include <resolve/Common.hpp> | ||
|
||
namespace ReSolve | ||
{ | ||
void hip_set_array_const(index_type n, real_type c, real_type* v); | ||
} |
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,39 @@ | ||
/** | ||
* @file hipVectorKernels.hip | ||
* @author Slaven Peles ([email protected]) | ||
* @brief Contains implementation of HIP vector kernels. | ||
* @date 2023-12-08 | ||
* | ||
* @note Kernel wrappers implemented here are intended for use in hardware | ||
* agnostic code. | ||
*/ | ||
|
||
#include <hip/hip_runtime.h> | ||
|
||
#include <resolve/Common.hpp> | ||
#include <resolve/hip/hipVectorKernels.h> | ||
|
||
namespace ReSolve { | ||
|
||
namespace kernels { | ||
|
||
__global__ void set_array_to_const(index_type n, real_type val, real_type* arr) | ||
{ | ||
index_type i = blockIdx.x * blockDim.x + threadIdx.x; | ||
while (i < n) | ||
{ | ||
arr[i] = val; | ||
i += blockDim.x * gridDim.x; | ||
} | ||
} | ||
} // namespace kernels | ||
|
||
void hip_set_array_const(index_type n, real_type c, real_type* v) | ||
{ | ||
index_type num_blocks; | ||
index_type block_size = 512; | ||
num_blocks = (n + block_size - 1) / block_size; | ||
hipLaunchKernelGGL(kernels::set_array_to_const, dim3(num_blocks), dim3(block_size), 0, 0, n, c, v); | ||
} | ||
|
||
} // namespace ReSolve |
Oops, something went wrong.