-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
886cb5e
commit 0f755db
Showing
3 changed files
with
187 additions
and
1 deletion.
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,97 @@ | ||
#/bin/bash | ||
|
||
# Variables controlling setup process | ||
MODULE_PATH=/etc/lmod/modules/misc/hipifly | ||
HIPIFLY_MODULE=0 | ||
ROCM_VERSION=6.0 | ||
|
||
SUDO="sudo" | ||
|
||
if [ -f /.singularity.d/Singularity ]; then | ||
SUDO="" | ||
fi | ||
|
||
usage() | ||
{ | ||
echo "Usage:" | ||
echo " --module-path [ MODULE_PATH ] default $MODULE_PATH" | ||
echo " --rocm-version [ ROCM_VERSION ] default $ROCM_VERSION" | ||
echo " --hipifly-module [ HIPIFLY_MODULE ], set to 1 to create hipifly, default is $HIPIFLY_MODULE" | ||
echo " --help: this usage information" | ||
exit 1 | ||
} | ||
|
||
send-error() | ||
{ | ||
usage | ||
echo -e "\nError: ${@}" | ||
exit 1 | ||
} | ||
|
||
reset-last() | ||
{ | ||
last() { send-error "Unsupported argument :: ${1}"; } | ||
} | ||
|
||
n=0 | ||
while [[ $# -gt 0 ]] | ||
do | ||
case "${1}" in | ||
"--hipifly-module") | ||
shift | ||
HIPIFLY_MODULE=${1} | ||
reset-last | ||
;; | ||
"--help") | ||
usage | ||
;; | ||
"--rocm-version") | ||
shift | ||
ROCM_VERSION=${1} | ||
reset-last | ||
;; | ||
"--module-path") | ||
shift | ||
MODULE_PATH=${1} | ||
reset-last | ||
;; | ||
"--*") | ||
send-error "Unsupported argument at position $((${n} + 1)) :: ${1}" | ||
;; | ||
*) | ||
last ${1} | ||
;; | ||
esac | ||
n=$((${n} + 1)) | ||
shift | ||
done | ||
|
||
echo "" | ||
echo "===================================" | ||
echo "Setting Up the HIPIFLY Module" | ||
echo "HIPIFLY_MODULE: $HIPIFLY_MODULE" | ||
echo "===================================" | ||
echo "" | ||
|
||
if [ "${HIPIFLY_MODULE}" = "0" ]; then | ||
|
||
echo "Hipifly module will not be created, according to the specified value of HIPIFLY_MODULE" | ||
echo "HIPIFLY_MODULE: $HIPIFLY_MODULE" | ||
exit | ||
|
||
else | ||
HIPIFLY_PATH=/opt/rocmplus-${ROCM_VERSION}/hipifly | ||
${SUDO} mkdir -p ${HIPIFLY_PATH} | ||
${SUDO} cp extras/sources/hipifly/hipifly.h ${HIPIFLY_PATH} | ||
|
||
${SUDO} mkdir -p ${MODULE_PATH} | ||
|
||
# The - option suppresses tabs | ||
cat <<-EOF | ${SUDO} tee ${MODULE_PATH}/dev.lua | ||
whatis(" Hipifly header file ") | ||
load("rocm/${ROCM_VERSION}") | ||
setenv("HIPIFLY_PATH","${HIPIFLY_PATH}") | ||
EOF | ||
|
||
fi | ||
|
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,89 @@ | ||
/* | ||
Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef CUDA_TO_HIP_H | ||
#define CUDA_TO_HIP_H | ||
|
||
#include <hip/hip_runtime.h> | ||
|
||
#define WARPSIZE 64 | ||
static constexpr int maxWarpsPerBlock = 1024/WARPSIZE; | ||
|
||
#define CUFFT_D2Z HIPFFT_D2Z | ||
#define CUFFT_FORWARD HIPFFT_FORWARD | ||
#define CUFFT_INVERSE HIPFFT_BACKWARD | ||
#define CUFFT_Z2D HIPFFT_Z2D | ||
#define CUFFT_Z2Z HIPFFT_Z2Z | ||
|
||
#define cudaDeviceSynchronize hipDeviceSynchronize | ||
#define cudaError hipError_t | ||
#define cudaError_t hipError_t | ||
#define cudaErrorInsufficientDriver hipErrorInsufficientDriver | ||
#define cudaErrorNoDevice hipErrorNoDevice | ||
#define cudaEvent_t hipEvent_t | ||
#define cudaEventCreate hipEventCreate | ||
#define cudaEventElapsedTime hipEventElapsedTime | ||
#define cudaEventRecord hipEventRecord | ||
#define cudaEventSynchronize hipEventSynchronize | ||
#define cudaFree hipFree | ||
#define cudaFreeHost hipHostFree | ||
#define cudaGetDevice hipGetDevice | ||
#define cudaGetDeviceCount hipGetDeviceCount | ||
#define cudaGetErrorString hipGetErrorString | ||
#define cudaGetLastError hipGetLastError | ||
#define cudaHostAlloc hipHostMalloc | ||
#define cudaHostAllocDefault hipHostMallocDefault | ||
#define cudaMalloc hipMalloc | ||
#define cudaMemcpy hipMemcpy | ||
#define cudaMemcpyAsync hipMemcpyAsync | ||
#define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost | ||
#define cudaMemcpyDeviceToDevice hipMemcpyDeviceToDevice | ||
#define cudaMemcpyHostToDevice hipMemcpyHostToDevice | ||
#define cudaMemGetInfo hipMemGetInfo | ||
#define cudaMemset hipMemset | ||
#define cudaReadModeElementType hipReadModeElementType | ||
#define cudaSetDevice hipSetDevice | ||
#define cudaSuccess hipSuccess | ||
#define cudaDeviceProp hipDeviceProp_t | ||
#define cudaGetDeviceProperties hipGetDeviceProperties | ||
#define cudaThreadSynchronize hipDeviceSynchronize | ||
|
||
|
||
#define cufftDestroy hipfftDestroy | ||
#define cufftDoubleComplex hipfftDoubleComplex | ||
#define cufftDoubleReal hipfftDoubleReal | ||
#define cufftExecD2Z hipfftExecD2Z | ||
#define cufftExecZ2D hipfftExecZ2D | ||
#define cufftExecZ2Z hipfftExecZ2Z | ||
#define cufftHandle hipfftHandle | ||
#define cufftPlan3d hipfftPlan3d | ||
#define cufftPlanMany hipfftPlanMany | ||
|
||
static void __attribute__((unused)) check(const hipError_t err, const char *const file, const int line) | ||
{ | ||
if (err == hipSuccess) return; | ||
fprintf(stderr,"HIP ERROR AT LINE %d OF FILE '%s': %s %s\n",line,file,hipGetErrorName(err),hipGetErrorString(err)); | ||
fflush(stderr); | ||
exit(err); | ||
} | ||
|
||
#endif //CUDA_TO_HIP_H |