Skip to content

Commit

Permalink
Switch to the new SUBPAR_USES_OPENMP_RANGE macro in subpar v0.3.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Aug 30, 2024
1 parent 2eefc2d commit d93262e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if(TATAMI_HDF5_FETCH_EXTERN)
add_subdirectory(extern)
else()
find_package(tatami_tatami_chunked 2.0.0 CONFIG REQUIRED)
find_package(ltla_subpar 0.2.1 CONFIG REQUIRED)
find_package(ltla_subpar 0.3.1 CONFIG REQUIRED)
endif()

target_link_libraries(tatami_hdf5 INTERFACE tatami::tatami_chunked ltla::subpar)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

include(CMakeFindDependencyMacro)
find_dependency(tatami_tatami_chunked 2.0.0 CONFIG REQUIRED)
find_dependency(ltla_subpar 0.2.1 CONFIG REQUIRED)
find_dependency(ltla_subpar 0.3.1 CONFIG REQUIRED)

if(@TATAMI_HDF5_FIND_HDF5@)
# Not REQUIRED, so don't use find_dependency according to
Expand Down
4 changes: 2 additions & 2 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ include(FetchContent)
FetchContent_Declare(
tatami_chunked
GIT_REPOSITORY https://github.com/tatami-inc/tatami_chunked
GIT_TAG master # ^v2.0.0
GIT_TAG master # ^2.0.0
)

FetchContent_Declare(
subpar
GIT_REPOSITORY https://github.com/LTLA/subpar
GIT_TAG master # ^v0.2.1
GIT_TAG master # ^0.3.1
)

FetchContent_MakeAvailable(tatami_chunked)
Expand Down
8 changes: 4 additions & 4 deletions include/tatami_hdf5/serialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#ifndef TATAMI_HDF5_PARALLEL_LOCK
#include "subpar/subpar.hpp"
#ifndef SUBPAR_USES_OPENMP
#ifndef SUBPAR_USES_OPENMP_RANGE
#include <mutex>
#include <thread>
namespace tatami_hdf5 {
Expand All @@ -30,11 +30,11 @@ namespace tatami_hdf5 {
* This is primarily intended for use inside `tatami::parallelize()` but can also be called anywhere that uses the same parallelization scheme.
* Also check out the [**subpar**](https://ltla.github.io/subpar) library, which implements the default parallelization scheme for `tatami::parallelize()`.
*
* The default serialization mechanism is automatically determined from the definition of the `SUBPAR_USES_OPENMP` macro.
* The default serialization mechanism is automatically determined from the definition of the `SUBPAR_USES_OPENMP_RANGE` macro.
* If defined (i.e., OpenMP is used), `f` is executed in OpenMP critical regions named `"hdf5"`.
* Otherwise, a global mutex from `<mutex>` is used to guard the execution of `f`.
*
* If a custom parallelization scheme is defined via `TATAMI_CUSTOM_PARALLEL` or `SUBPAR_CUSTOM_PARALLEL`, the default serialization mechanism may not be appropriate.
* If a custom parallelization scheme is defined via `TATAMI_CUSTOM_PARALLEL` or `SUBPAR_CUSTOM_PARALLELIZE_RANGE`, the default serialization mechanism may not be appropriate.
* Users should instead define a `TATAMI_HDF5_PARALLEL_LOCK` function-like macro that accepts `f` and executes it in a serial section appropriate to the custom scheme.
* Once defined, this user-defined lock will be used in all calls to `serialize()`.
*
Expand All @@ -46,7 +46,7 @@ void serialize(Function_ f) {
#ifdef TATAMI_HDF5_PARALLEL_LOCK
TATAMI_HDF5_PARALLEL_LOCK(f);
#else
#ifdef SUBPAR_USES_OPENMP
#ifdef SUBPAR_USES_OPENMP_RANGE
#pragma omp critical(hdf5)
{
f();
Expand Down

0 comments on commit d93262e

Please sign in to comment.