Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

[email protected]+ workaround for Random123. #754

Merged
merged 3 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions CMake/MakefileBuildOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (C) 2016-2021 Blue Brain Project
# Copyright (C) 2016-2022 Blue Brain Project
#
# See top-level LICENSE file for details.
# =============================================================================
Expand Down Expand Up @@ -72,9 +72,17 @@ endforeach()
# PGI compiler adds --c++14;-A option for C++14, remove ";"
string(REPLACE ";" " " CXX14_STD_FLAGS "${CMAKE_CXX14_STANDARD_COMPILE_OPTION}")
string(TOUPPER "${CMAKE_BUILD_TYPE}" _BUILD_TYPE)
set(CORENRN_CXX_FLAGS
"${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_BUILD_TYPE}} ${CXX14_STD_FLAGS} ${NVHPC_ACC_COMP_FLAGS} ${NVHPC_CXX_INLINE_FLAGS}"
)
list(TRANSFORM CORENRN_COMPILE_DEFS PREPEND -D OUTPUT_VARIABLE CORENRN_COMPILE_DEF_FLAGS)
string(
JOIN
" "
CORENRN_CXX_FLAGS
${CMAKE_CXX_FLAGS}
${CMAKE_CXX_FLAGS_${_BUILD_TYPE}}
${CXX14_STD_FLAGS}
${NVHPC_ACC_COMP_FLAGS}
${NVHPC_CXX_INLINE_FLAGS}
${CORENRN_COMPILE_DEF_FLAGS})

# =============================================================================
# nmodl/mod2c related options : TODO
Expand Down
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2016 - 2021 Blue Brain Project/EPFL
# Copyright (c) 2016 - 2022 Blue Brain Project/EPFL
#
# See top-level LICENSE file for details.
# =============================================================================
Expand Down Expand Up @@ -238,7 +238,15 @@ endif()
# =============================================================================
if(CORENRN_HAVE_NVHPC_COMPILER)
# PGI with llvm code generation doesn't have necessary assembly intrinsic headers
add_definitions(-DEIGEN_DONT_VECTORIZE=1)
list(APPEND CORENRN_COMPILE_DEFS EIGEN_DONT_VECTORIZE=1)
if(NOT CORENRN_ENABLE_GPU AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 21.11)
# Random123 does not play nicely with NVHPC 21.11+'s detection of ABM features if it detects the
# compiler to be PGI or NVHPC, see: https://github.com/BlueBrain/CoreNeuron/issues/724 and
# https://github.com/DEShawResearch/random123/issues/6. In fact in GPU builds Random123
# (mis)detects nvc++ as nvcc because we pass the -cuda option and we therefore avoid the
# problem. If GPU support is disabled, we define R123_USE_INTRIN_H=0 to avoid the problem.
list(APPEND CORENRN_COMPILE_DEFS R123_USE_INTRIN_H=0)
endif()
endif()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olupton : FYI - (accidentally) I was trying to use cpu wheel with nvhpc compiler and end-up with this error.

Wonder if this logic needs to be pushed at later stage (in nrnivmodl_core_makefile or similar)


# ~~~
Expand Down
6 changes: 5 additions & 1 deletion coreneuron/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# =============================================================================
# Copyright (c) 2016 - 2021 Blue Brain Project/EPFL
# Copyright (c) 2016 - 2022 Blue Brain Project/EPFL
#
# See top-level LICENSE file for details.
# =============================================================================

# Add compiler flags that should apply to all CoreNEURON targets, but which should not leak into
# other included projects.
add_compile_definitions(${CORENRN_COMPILE_DEFS})

# put libraries (e.g. dll) in bin directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

Expand Down
6 changes: 6 additions & 0 deletions coreneuron/gpu/nrn_acc_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ void cnrn_target_set_default_device(int device_num) {
#endif
}

#ifdef CORENEURON_ENABLE_GPU

static Memb_list* copy_ml_to_device(const Memb_list* ml, int type) {
// As we never run code for artificial cell inside GPU we don't copy it.
int is_art = corenrn.get_is_artificial()[type];
Expand Down Expand Up @@ -259,6 +261,8 @@ static void delete_ml_from_device(Memb_list* ml, int type) {
cnrn_target_delete(ml);
}

#endif

/* note: threads here are corresponding to global nrn_threads array */
void setup_nrnthreads_on_device(NrnThread* threads, int nthreads) {
#ifdef CORENEURON_ENABLE_GPU
Expand Down Expand Up @@ -891,6 +895,7 @@ void update_nrnthreads_on_host(NrnThread* threads, int nthreads) {
* from GPU to CPU.
*/
void update_weights_from_gpu(NrnThread* threads, int nthreads) {
#ifdef CORENEURON_ENABLE_GPU
for (int i = 0; i < nthreads; i++) {
NrnThread* nt = threads + i;
size_t n_weight = nt->n_weight;
Expand All @@ -900,6 +905,7 @@ void update_weights_from_gpu(NrnThread* threads, int nthreads) {
nrn_pragma_omp(target update from(weights [0:n_weight]))
}
}
#endif
}

/** Cleanup device memory that is being tracked by the OpenACC runtime.
Expand Down
2 changes: 2 additions & 0 deletions coreneuron/utils/vrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ void VecPlayContinuous::deliver(double tt, NetCvode* ns) {
}

void VecPlayContinuous::continuous(double tt) {
#ifdef CORENEURON_ENABLE_GPU
NrnThread* nt = nrn_threads + ith_;
#endif
// clang-format off

nrn_pragma_acc(kernels present(this) if(nt->compute_gpu))
Expand Down