Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: add ARB_CUDA flag to example catalogue #2039

Merged
merged 4 commits into from
Nov 17, 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
29 changes: 16 additions & 13 deletions example/ornstein_uhlenbeck/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
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)
else()
find_package(fmt REQUIRED)
target_link_libraries(ou PRIVATE fmt::fmt-header-only)
endif()

add_dependencies(examples ou)
33 changes: 3 additions & 30 deletions example/ornstein_uhlenbeck/ou.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <fmt/format.h>

#include "ornstein_uhlenbeck_catalogue.hpp"

#include <arborio/label_parse.hpp>

#include <arbor/assert.hpp>
Expand All @@ -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:
Expand All @@ -20,7 +19,7 @@ class recipe: public arb::recipe {

// 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
Expand Down Expand Up @@ -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;
}