Loading elsa/core/CMakeLists.txt +6 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,12 @@ set(MODULE_SOURCES add_library(${ELSA_MODULE_TARGET_NAME} ${MODULE_HEADERS} ${MODULE_SOURCES}) add_library(elsa::${ELSA_MODULE_NAME} ALIAS ${ELSA_MODULE_TARGET_NAME}) # use OpenMP is available find_package(OpenMP REQUIRED) if(OpenMP_CXX_FOUND) target_link_libraries(${ELSA_MODULE_TARGET_NAME} PRIVATE OpenMP::OpenMP_CXX) endif() target_include_directories(${ELSA_MODULE_TARGET_NAME} PUBLIC $<INSTALL_INTERFACE:include/${ELSA_MODULE_NAME}> Loading elsa/core/DataContainer.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -283,11 +283,13 @@ namespace elsa { template <typename data_t> void DataContainer<data_t>::detach() { if (_dataHandler.use_count() == 1) return; if (_dataHandler.use_count() != 1) { #pragma omp barrier #pragma omp single _dataHandler = _dataHandler->clone(); } return; } // ------------------------------------------ // explicit template instantiation Loading elsa/core/DataContainer.h +6 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ namespace elsa * This class provides a container for a signal that is stored in memory. This signal can * be n-dimensional, and will be stored in memory in a linearized fashion. The information * on how this linearization is performed is provided by an associated DataDescriptor. * * The class implements copy-on-write. Therefore any non-const functions should call the * detach() function first to trigger the copy-on-write mechanism. */ template <typename data_t = real_t> class DataContainer { Loading Loading @@ -88,7 +91,6 @@ namespace elsa */ DataContainer<data_t>& operator=(DataContainer<data_t>&& other); /// return the current DataDescriptor const DataDescriptor& getDataDescriptor() const; Loading Loading @@ -191,8 +193,6 @@ namespace elsa /// comparison with another DataContainer bool operator!=(const DataContainer<data_t>& other) const; /// creates the deep copy for the copy-on-write mechanism void detach(); private: /// the current DataDescriptor std::unique_ptr<DataDescriptor> _dataDescriptor; Loading @@ -205,6 +205,9 @@ namespace elsa /// private constructor accepting a DataDescriptor and a DataHandler explicit DataContainer(const DataDescriptor& dataDescriptor, std::unique_ptr<DataHandler<data_t>> dataHandler); /// creates the deep copy for the copy-on-write mechanism void detach(); }; Loading elsa/core/tests/test_DataContainer.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -402,8 +402,7 @@ SCENARIO("Testing the copy-on-write mechanism") { dc.dot(dc2); dc.l1Norm(); // TODO(Jens): this can't really be tested as the member is private - make test scenario friend? THEN("the data handlers are the same") { THEN("the data should still be the same") { REQUIRE(dc3 == dc); } } Loading elsa/projectors/BinaryMethod.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -64,8 +64,6 @@ namespace elsa template <bool adjoint> void BinaryMethod<data_t>::traverseVolume(const DataContainer<data_t>& vector, DataContainer<data_t>& result) const { result.detach(); index_t maxIterations{0}; if (adjoint) { maxIterations = vector.getSize(); Loading Loading
elsa/core/CMakeLists.txt +6 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,12 @@ set(MODULE_SOURCES add_library(${ELSA_MODULE_TARGET_NAME} ${MODULE_HEADERS} ${MODULE_SOURCES}) add_library(elsa::${ELSA_MODULE_NAME} ALIAS ${ELSA_MODULE_TARGET_NAME}) # use OpenMP is available find_package(OpenMP REQUIRED) if(OpenMP_CXX_FOUND) target_link_libraries(${ELSA_MODULE_TARGET_NAME} PRIVATE OpenMP::OpenMP_CXX) endif() target_include_directories(${ELSA_MODULE_TARGET_NAME} PUBLIC $<INSTALL_INTERFACE:include/${ELSA_MODULE_NAME}> Loading
elsa/core/DataContainer.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -283,11 +283,13 @@ namespace elsa { template <typename data_t> void DataContainer<data_t>::detach() { if (_dataHandler.use_count() == 1) return; if (_dataHandler.use_count() != 1) { #pragma omp barrier #pragma omp single _dataHandler = _dataHandler->clone(); } return; } // ------------------------------------------ // explicit template instantiation Loading
elsa/core/DataContainer.h +6 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ namespace elsa * This class provides a container for a signal that is stored in memory. This signal can * be n-dimensional, and will be stored in memory in a linearized fashion. The information * on how this linearization is performed is provided by an associated DataDescriptor. * * The class implements copy-on-write. Therefore any non-const functions should call the * detach() function first to trigger the copy-on-write mechanism. */ template <typename data_t = real_t> class DataContainer { Loading Loading @@ -88,7 +91,6 @@ namespace elsa */ DataContainer<data_t>& operator=(DataContainer<data_t>&& other); /// return the current DataDescriptor const DataDescriptor& getDataDescriptor() const; Loading Loading @@ -191,8 +193,6 @@ namespace elsa /// comparison with another DataContainer bool operator!=(const DataContainer<data_t>& other) const; /// creates the deep copy for the copy-on-write mechanism void detach(); private: /// the current DataDescriptor std::unique_ptr<DataDescriptor> _dataDescriptor; Loading @@ -205,6 +205,9 @@ namespace elsa /// private constructor accepting a DataDescriptor and a DataHandler explicit DataContainer(const DataDescriptor& dataDescriptor, std::unique_ptr<DataHandler<data_t>> dataHandler); /// creates the deep copy for the copy-on-write mechanism void detach(); }; Loading
elsa/core/tests/test_DataContainer.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -402,8 +402,7 @@ SCENARIO("Testing the copy-on-write mechanism") { dc.dot(dc2); dc.l1Norm(); // TODO(Jens): this can't really be tested as the member is private - make test scenario friend? THEN("the data handlers are the same") { THEN("the data should still be the same") { REQUIRE(dc3 == dc); } } Loading
elsa/projectors/BinaryMethod.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -64,8 +64,6 @@ namespace elsa template <bool adjoint> void BinaryMethod<data_t>::traverseVolume(const DataContainer<data_t>& vector, DataContainer<data_t>& result) const { result.detach(); index_t maxIterations{0}; if (adjoint) { maxIterations = vector.getSize(); Loading