From a9eedba0769723f2d3be53a0253e6436486ec0d7 Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Sun, 14 Aug 2022 11:24:50 +0200 Subject: [PATCH] add `setMaxNumThreads` and `setMinOffsetsPerThread` methods to the `WFAligner` class --- bindings/cpp/WFAligner.cpp | 9 +++++++++ bindings/cpp/WFAligner.hpp | 5 +++++ wavefront/wavefront_aligner.c | 18 ++++++++++++++++++ wavefront/wavefront_aligner.h | 7 ++++++- wavefront/wavefront_bialigner.c | 14 ++++++++++++++ wavefront/wavefront_bialigner.h | 7 ++++++- 6 files changed, 58 insertions(+), 2 deletions(-) diff --git a/bindings/cpp/WFAligner.cpp b/bindings/cpp/WFAligner.cpp index ce571de..d2f4c82 100644 --- a/bindings/cpp/WFAligner.cpp +++ b/bindings/cpp/WFAligner.cpp @@ -210,6 +210,15 @@ void WFAligner::setMaxMemory( const uint64_t maxMemoryAbort) { wavefront_aligner_set_max_memory(wfAligner,maxMemoryResident,maxMemoryAbort); } +// Parallelization +void WFAligner::setMaxNumThreads( + const int maxNumThreads) { + wavefront_aligner_set_max_num_threads(wfAligner, maxNumThreads); +} +void WFAligner::setMinOffsetsPerThread( + const int minOffsetsPerThread) { + wavefront_aligner_set_min_offsets_per_thread(wfAligner, minOffsetsPerThread); +} /* * Accessors */ diff --git a/bindings/cpp/WFAligner.hpp b/bindings/cpp/WFAligner.hpp index 5d6a31d..fbdec2a 100644 --- a/bindings/cpp/WFAligner.hpp +++ b/bindings/cpp/WFAligner.hpp @@ -136,6 +136,11 @@ class WFAligner { void setMaxMemory( const uint64_t maxMemoryResident, const uint64_t maxMemoryAbort); + // Parallelization + void setMaxNumThreads( + const int maxNumThreads); + void setMinOffsetsPerThread( + const int minOffsetsPerThread); // Accessors int getAlignmentScore(); int getAlignmentStatus(); diff --git a/wavefront/wavefront_aligner.c b/wavefront/wavefront_aligner.c index 27b16b6..020ce36 100644 --- a/wavefront/wavefront_aligner.c +++ b/wavefront/wavefront_aligner.c @@ -394,6 +394,24 @@ void wavefront_aligner_set_max_memory( wf_aligner->bialigner,max_memory_resident,max_memory_abort); } } +void wavefront_aligner_set_max_num_threads( + wavefront_aligner_t* const wf_aligner, + const int max_num_threads) { + wf_aligner->system.max_num_threads = max_num_threads; + if (wf_aligner->bialigner != NULL) { + wavefront_bialigner_set_max_num_threads( + wf_aligner->bialigner,max_num_threads); + } +} +void wavefront_aligner_set_min_offsets_per_thread( + wavefront_aligner_t* const wf_aligner, + const int min_offsets_per_thread) { + wf_aligner->system.min_offsets_per_thread = min_offsets_per_thread; + if (wf_aligner->bialigner != NULL) { + wavefront_bialigner_set_min_offsets_per_thread( + wf_aligner->bialigner,min_offsets_per_thread); + } +} /* * Utils */ diff --git a/wavefront/wavefront_aligner.h b/wavefront/wavefront_aligner.h index 977f596..77cca4b 100644 --- a/wavefront/wavefront_aligner.h +++ b/wavefront/wavefront_aligner.h @@ -202,7 +202,12 @@ void wavefront_aligner_set_max_memory( wavefront_aligner_t* const wf_aligner, const uint64_t max_memory_resident, const uint64_t max_memory_abort); - +void wavefront_aligner_set_max_num_threads( + wavefront_aligner_t* const wf_aligner, + const int max_num_threads); +void wavefront_aligner_set_min_offsets_per_thread( + wavefront_aligner_t* const wf_aligner, + const int min_offsets_per_thread); /* * Utils */ diff --git a/wavefront/wavefront_bialigner.c b/wavefront/wavefront_bialigner.c index c250f74..f77dd46 100644 --- a/wavefront/wavefront_bialigner.c +++ b/wavefront/wavefront_bialigner.c @@ -129,3 +129,17 @@ void wavefront_bialigner_set_max_memory( wf_bialigner->alg_subsidiary->system.max_memory_resident = max_memory_resident; wf_bialigner->alg_subsidiary->system.max_memory_abort = max_memory_abort; } +void wavefront_bialigner_set_max_num_threads( + wavefront_bialigner_t* const wf_bialigner, + const int max_num_threads) { + wf_bialigner->alg_forward->system.max_num_threads = max_num_threads; + wf_bialigner->alg_reverse->system.max_num_threads = max_num_threads; + wf_bialigner->alg_subsidiary->system.max_num_threads = max_num_threads; +} +void wavefront_bialigner_set_min_offsets_per_thread( + wavefront_bialigner_t* const wf_bialigner, + const int min_offsets_per_thread) { + wf_bialigner->alg_forward->system.min_offsets_per_thread = min_offsets_per_thread; + wf_bialigner->alg_reverse->system.min_offsets_per_thread = min_offsets_per_thread; + wf_bialigner->alg_subsidiary->system.min_offsets_per_thread = min_offsets_per_thread; +} diff --git a/wavefront/wavefront_bialigner.h b/wavefront/wavefront_bialigner.h index c12ea07..f787a04 100644 --- a/wavefront/wavefront_bialigner.h +++ b/wavefront/wavefront_bialigner.h @@ -89,5 +89,10 @@ void wavefront_bialigner_set_max_memory( wavefront_bialigner_t* const wf_bialigner, const uint64_t max_memory_resident, const uint64_t max_memory_abort); - +void wavefront_bialigner_set_max_num_threads( + wavefront_bialigner_t* const wf_bialigner, + const int max_num_threads); +void wavefront_bialigner_set_min_offsets_per_thread( + wavefront_bialigner_t* const wf_bialigner, + const int min_offsets_per_thread); #endif /* WAVEFRONT_BIALIGNER_H_ */