Shiokaze Framework
A research-oriented fluid solver for computer graphics
loop_splitter.h
Go to the documentation of this file.
1 /*
2 ** loop_splitter.h
3 **
4 ** This is part of Shiokaze, a research-oriented fluid solver for computer graphics.
5 ** Created by Ryoichi Ando <rand@nii.ac.jp> on March 8, 2018.
6 **
7 ** Permission is hereby granted, free of charge, to any person obtaining a copy of
8 ** this software and associated documentation files (the "Software"), to deal in
9 ** the Software without restriction, including without limitation the rights to use,
10 ** copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
11 ** Software, and to permit persons to whom the Software is furnished to do so,
12 ** subject to the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included in all copies
15 ** or substantial portions of the Software.
16 **
17 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 ** HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 ** CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24 //
25 #ifndef SHKZ_LOOP_SPLITTER_H
26 #define SHKZ_LOOP_SPLITTER_H
27 //
29 #include <functional>
30 //
32 //
37 public:
38  //
39  DEFINE_MODULE(loop_splitter,"Parallel Loop Splitter","Loop","Parallel loop splitter module")
48  virtual const void* new_context ( size_t size, int num_threads ) const = 0;
57  virtual std::function<size_t(const void *context, int thread_index)> get_start_func( const void *context ) const = 0;
66  virtual std::function<bool(const void *context, size_t &n, int thread_index)> get_advance_func( const void *context ) const = 0;
73  virtual void delete_context( const void *context ) const = 0;
74 };
75 //
76 using loop_splitter_ptr = std::unique_ptr<loop_splitter>;
77 //
79 //
80 #endif
81 //
loop_splitter::delete_context
virtual void delete_context(const void *context) const =0
Deallocate the context generated by new_context.
DEFINE_MODULE
#define DEFINE_MODULE(CLASS_T, LNG_NAME, ARG_NAME, DESCRIPTION)
Definition that simplifies the loading module.
Definition: recursive_configurable_module.h:39
SHKZ_BEGIN_NAMESPACE
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
loop_splitter
Abstract class that handles how to distribute loop enumeration for parallel processings....
Definition: loop_splitter.h:36
SHKZ_END_NAMESPACE
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
loop_splitter::get_start_func
virtual std::function< size_t(const void *context, int thread_index)> get_start_func(const void *context) const =0
Get a function that provides us the starting index of a loop for the specific thread.
loop_splitter::get_advance_func
virtual std::function< bool(const void *context, size_t &n, int thread_index)> get_advance_func(const void *context) const =0
Get a function that advances an index of a loop.
recursive_configurable_module.h
loop_splitter::new_context
virtual const void * new_context(size_t size, int num_threads) const =0
Allocate a new context for a loop.
recursive_configurable_module
recursive_configurable class that also inherits module.
Definition: recursive_configurable_module.h:49