Skip to content

Commit

Permalink
Fix HIP on CUDA build
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Apr 28, 2022
1 parent 9eaad38 commit 57db85b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion exts/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DBCSR_ACC := $(OFFLOAD_CC)
DBCSR_ACCFLAGS := $(OFFLOAD_FLAGS) -Xcompiler='-Wno-error'
else ifeq (hip,$(DBCSR_USE_ACCEL))
DBCSR_ACC := $(CXX)
DBCSR_ACCFLAGS := $(CXXFLAGS)
DBCSR_ACCFLAGS := $(CXXFLAGS) -Wno-error=unused-parameter
else ifeq (opencl,$(DBCSR_USE_ACCEL))
DBCSR_ACC := $(CC)
DBCSR_ACCFLAGS := $(CFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion src/grid/hip/grid_hip_context.cu
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ extern "C" void grid_hip_create_task_list(
memset(ctx->number_of_tasks_per_level_.data(), 0, sizeof(int) * nlevels);

std::vector<rocm_backend::task_info> tasks_host(ntasks);
memset(tasks_host.data(), 0, sizeof(rocm_backend::task_info) * ntasks);

size_t coef_size = 0;

Expand All @@ -112,6 +111,7 @@ extern "C" void grid_hip_create_task_list(
const grid_basis_set *ibasis = basis_sets[ikind];
const grid_basis_set *jbasis = basis_sets[jkind];

tasks_host[i] = {};
tasks_host[i].level = level;
tasks_host[i].iatom = iatom;
tasks_host[i].jatom = jatom;
Expand Down
2 changes: 1 addition & 1 deletion src/grid/hip/grid_hip_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ template <typename T> class grid_info {
((fabs(dh_[0] * dh_[3] + dh_[1] * dh_[4] + dh_[2] * dh_[5]) * norm1 *
norm2) < 1e-12);

orthorhombic_ = orthogonal[0] * orthogonal[1] * orthogonal[2];
orthorhombic_ = orthogonal[0] && orthogonal[1] && orthogonal[2];
}

inline void copy_to_host(double *data__, offloadStream_t &stream) {
Expand Down
16 changes: 8 additions & 8 deletions tools/toolchain/scripts/generate_arch_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ if [ "${ENABLE_CUDA}" = __TRUE__ ] && [ "${GPUVER}" != no ]; then
CUDA_DFLAGS="-D__OFFLOAD_CUDA -D__DBCSR_ACC IF_DEBUG(-D__OFFLOAD_PROFILING|)"
LIBS="${LIBS} IF_CUDA(${CUDA_LIBS}|)"
DFLAGS="IF_CUDA(${CUDA_DFLAGS}|) ${DFLAGS}"
NVFLAGS="-g -arch sm_${ARCH_NUM} -O3 -allow-unsupported-compiler -Xcompiler='-fopenmp' --std=c++11 \$(DFLAGS)"
NVFLAGS="-g -arch sm_${ARCH_NUM} -O3 -allow-unsupported-compiler -Xcompiler='-fopenmp -Wall -Wextra -Werror' --std=c++11 \$(DFLAGS)"
check_command nvcc "cuda"
check_lib -lcudart "cuda"
check_lib -lnvrtc "cuda"
Expand Down Expand Up @@ -171,10 +171,10 @@ if [ "${ENABLE_HIP}" = __TRUE__ ] && [ "${GPUVER}" != no ]; then
add_lib_from_paths HIP_LDFLAGS "libroctx64.*" $LIB_PATHS
check_lib -lroctracer64 "hip"
add_lib_from_paths HIP_LDFLAGS "libroctracer64.*" $LIB_PATHS
HIP_FLAGS+="-fPIE -D__HIP_PLATFORM_AMD__ -g --offload-arch=gfx906 -O3 --std=c++11 \$(DFLAGS)"
HIP_FLAGS+="-fPIE -D__HIP_PLATFORM_AMD__ -g --offload-arch=gfx906 -O3 --std=c++11 -Wall -Wextra -Werror \$(DFLAGS)"
LIBS+=" IF_HIP(-lamdhip64 -lhipfft -lhipblas -lrocblas IF_DEBUG(-lroctx64 -lroctracer64|)|)"
DFLAGS+=" IF_HIP(-D__HIP_PLATFORM_AMD__ -D__OFFLOAD_HIP IF_DEBUG(-D__OFFLOAD_PROFILING|)|) -D__DBCSR_ACC"
CXXFLAGS+=" -fopenmp -std=c++11"
CXXFLAGS+=" -fopenmp -std=c++11 -Wall -Wextra -Werror"
;;
Mi100)
check_lib -lamdhip64 "hip"
Expand All @@ -187,10 +187,10 @@ if [ "${ENABLE_HIP}" = __TRUE__ ] && [ "${GPUVER}" != no ]; then
add_lib_from_paths HIP_LDFLAGS "libroctx64.*" $LIB_PATHS
check_lib -lroctracer64 "hip"
add_lib_from_paths HIP_LDFLAGS "libroctracer64.*" $LIB_PATHS
HIP_FLAGS+="-fPIE -D__HIP_PLATFORM_AMD__ -g --offload-arch=gfx908 -O3 --std=c++11 \$(DFLAGS)"
HIP_FLAGS+="-fPIE -D__HIP_PLATFORM_AMD__ -g --offload-arch=gfx908 -O3 --std=c++11 -Wall -Wextra -Werror \$(DFLAGS)"
LIBS+=" IF_HIP(-lamdhip64 -lhipfft -lhipblas -lrocblas IF_DEBUG(-lroctx64 -lroctracer64|)|)"
DFLAGS+=" IF_HIP(-D__HIP_PLATFORM_AMD__ -D__OFFLOAD_HIP IF_DEBUG(-D__OFFLOAD_PROFILING|)|) -D__DBCSR_ACC"
CXXFLAGS+=" -fopenmp -std=c++11"
CXXFLAGS+=" -fopenmp -std=c++11 -Wall -Wextra -Werror"
;;
*)
check_command nvcc "cuda"
Expand All @@ -200,7 +200,7 @@ if [ "${ENABLE_HIP}" = __TRUE__ ] && [ "${GPUVER}" != no ]; then
check_lib -lcufft "cuda"
check_lib -lcublas "cuda"
DFLAGS+=" IF_HIP(-D__HIP_PLATFORM_NVIDIA__ -D__HIP_PLATFORM_NVCC__ -D__OFFLOAD_HIP |) -D__DBCSR_ACC"
HIP_FLAGS=" -g -arch sm_${ARCH_NUM} -O3 -Xcompiler='-fopenmp' --std=c++11 \$(DFLAGS)"
HIP_FLAGS=" -g -arch sm_${ARCH_NUM} -O3 -Xcompiler='-fopenmp -Wall -Wextra -Werror' --std=c++11 \$(DFLAGS)"
add_include_from_paths CUDA_CFLAGS "cuda.h" $INCLUDE_PATHS
HIP_INCLUDES+=" -I${CUDA_PATH:-${CUDA_HOME:-/CUDA_HOME-notset}}/include"
# GCC issues lots of warnings for hip/nvidia_detail/hip_runtime_api.h
Expand Down Expand Up @@ -277,7 +277,7 @@ gen_arch_file() {
#
GPUVER = \${GPUVER}
OFFLOAD_CC = \${NVCC}
OFFLOAD_FLAGS = \${NVFLAGS} -Xcompiler='-Wall -Wextra -Werror'
OFFLOAD_FLAGS = \${NVFLAGS}
OFFLOAD_TARGET = cuda
EOF
fi
Expand All @@ -287,7 +287,7 @@ EOF
#
GPUVER = \${GPUVER}
OFFLOAD_CC = \${ROCM_PATH}/hip/bin/hipcc
OFFLOAD_FLAGS = \${HIP_FLAGS} \${HIP_INCLUDES} -Wall -Wextra -Werror
OFFLOAD_FLAGS = \${HIP_FLAGS} \${HIP_INCLUDES}
OFFLOAD_TARGET = hip
EOF
fi
Expand Down

0 comments on commit 57db85b

Please sign in to comment.