Skip to content
Snippets Groups Projects
Unverified Commit ff3494ec authored by boeschf's avatar boeschf Committed by GitHub
Browse files

BUGFIX: add ARB_CUDA flag to example catalogue (#2039)

fix ornstein_uhlenbeck example on gpu:
- use make_catalogue instead of make_catalogue_standalone
- link to arbor-private-deps
- mark all files as c++ sources when using cuda-clang or hip-clang
parent 38c6cb92
No related branches found
No related tags found
No related merge requests found
make_catalogue_standalone(
NAME ou
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}"
MOD ornstein_uhlenbeck
CXX
CXX_FLAGS_TARGET ${ARB_CXX_FLAGS_TARGET_FULL}
VERBOSE ON)
include(${PROJECT_SOURCE_DIR}/mechanisms/BuildModules.cmake)
add_executable(ou EXCLUDE_FROM_ALL ou.cpp)
add_dependencies(ou ou-catalogue)
target_compile_options(ou PRIVATE ${ARB_CXX_FLAGS_TARGET_FULL})
target_include_directories(ou PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated/ou")
make_catalogue(
NAME ornstein_uhlenbeck
MOD ornstein_uhlenbeck
VERBOSE ${ARB_CAT_VERBOSE}
ADD_DEPS OFF)
target_link_libraries(ou PRIVATE arbor arborio ou-catalogue)
add_executable(ou EXCLUDE_FROM_ALL ou.cpp ${catalogue-ornstein_uhlenbeck-mechanisms})
add_dependencies(ou catalogue-ornstein_uhlenbeck-target)
if(ARB_WITH_CUDA_CLANG OR ARB_WITH_HIP_CLANG)
set_source_files_properties(${catalogue-ornstein_uhlenbeck-meachanisms} PROPERTIES LANGUAGE CXX)
endif()
target_include_directories(ou PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated/ornstein_uhlenbeck")
target_link_libraries(ou PRIVATE arbor-private-deps) # compiler flags, GPU options etc
target_link_libraries(ou PRIVATE arbor arborio)
if (ARB_USE_BUNDLED_FMT)
target_include_directories(ou PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../ext/fmt/include")
target_compile_definitions(ou PRIVATE FMT_HEADER_ONLY)
......@@ -19,5 +23,4 @@ else()
find_package(fmt REQUIRED)
target_link_libraries(ou PRIVATE fmt::fmt-header-only)
endif()
add_dependencies(examples ou)
#include <fmt/format.h>
#include "ornstein_uhlenbeck_catalogue.hpp"
#include <arborio/label_parse.hpp>
#include <arbor/assert.hpp>
......@@ -8,9 +10,6 @@
#include <arbor/cable_cell.hpp>
#include <arbor/simulation.hpp>
// forward declaration
arb::mechanism_catalogue build_catalogue();
// a single-cell recipe with probes
class recipe: public arb::recipe {
public:
......@@ -20,7 +19,7 @@ public:
// build catalogue with stochastic mechanism
cell_gprop_.catalogue = global_default_catalogue();
cell_gprop_.catalogue.import(build_catalogue(), "");
cell_gprop_.catalogue.import(arb::global_ornstein_uhlenbeck_catalogue(), "");
cell_gprop_.default_parameters = neuron_parameter_defaults;
// paint the process on the whole cell
......@@ -153,29 +152,3 @@ int main(int argc, char** argv) {
}
return 0;
}
// load mechanisms from library and add to new catalogue
// =====================================================
extern "C" {
const void* get_catalogue(int*);
}
arb::mechanism_catalogue build_catalogue() {
arb::mechanism_catalogue cat;
int n=0;
const void* ptr = get_catalogue(&n);
const auto* mechs = reinterpret_cast<const arb_mechanism*>(ptr);
for (int i=0; i<n; ++i) {
const auto& mech = mechs[i];
auto ty = mech.type();
auto nm = ty.name;
auto ig = mech.i_gpu();
auto ic = mech.i_cpu();
arb_assert(ic || ig);
cat.add(nm, ty);
if (ic) cat.register_implementation(nm, std::make_unique<arb::mechanism>(ty, *ic));
if (ig) cat.register_implementation(nm, std::make_unique<arb::mechanism>(ty, *ig));
}
return cat;
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment