12 #include <starpu_opencl.h>
21 #include <OpenCL/opencl.h>
61 template <
typename MapFunc,
typename ReduceFunc,
typename T, skepu::FuncType c_type=UNARY>
67 MapReduce(MapFunc* mapFunc, ReduceFunc* reduceFunc);
77 starpu_data_unregister(scalar_result_handle);
78 isScalarStarPU =
false;
90 void setOutput(T *out)
93 starpu_data_acquire(scalar_result_handle, STARPU_W);
98 starpu_data_release(scalar_result_handle);
106 starpu_data_acquire(scalar_result_handle, STARPU_R);
108 starpu_data_release(scalar_result_handle);
116 void setConstant(T constant1) {m_mapFunc->setConstant(constant1);}
118 void finishAll() {m_environment->
finishAll();}
119 void setExecPlan(
ExecPlan& plan) {m_execPlan = plan;}
124 ReduceFunc* m_reduceFunc;
127 #ifdef USE_STARPU_HISTORY_MODEL
128 starpu_perfmodel *mapred1_perf_model;
132 struct starpu_codelet *codelet;
134 starpu_data_handle_t scalar_result_handle;
144 static void cpu_func(
void *buffers[],
void *arg);
148 static void omp_func(
void *buffers[],
void *arg);
153 static void cuda_func(
void *buffers[],
void *arg);
158 static void opencl_func(
void *buffers[],
void *arg);
161 char kernelNameMap[1024];
162 char kernelNameRed[1024];
164 struct starpu_opencl_program opencl_codelet;
166 void replaceText(std::string& text, std::string find, std::string replace);
171 std::string perfmodel_str;
206 template <
typename MapFunc,
typename ReduceFunc,
typename T>
207 class MapReduce<MapFunc, ReduceFunc, T, skepu::BINARY> :
public Task
212 MapReduce(MapFunc* mapFunc, ReduceFunc* reduceFunc);
222 starpu_data_unregister(scalar_result_handle);
223 isScalarStarPU =
false;
230 void setInput1(Vector<T> *in)
235 void setInput2(Vector<T> *in)
241 void setOutput(T *out)
244 starpu_data_acquire(scalar_result_handle, STARPU_W);
249 starpu_data_release(scalar_result_handle);
257 starpu_data_acquire(scalar_result_handle, STARPU_R);
259 starpu_data_release(scalar_result_handle);
267 void setConstant(T constant1) {m_mapFunc->setConstant(constant1);}
269 void finishAll() {m_environment->
finishAll();}
270 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
273 Environment<int>* m_environment;
275 ReduceFunc* m_reduceFunc;
278 #ifdef USE_STARPU_HISTORY_MODEL
279 starpu_perfmodel *mapred2_perf_model;
281 struct starpu_codelet *codelet;
283 starpu_data_handle_t scalar_result_handle;
288 T
operator()(Vector<T>& input1, Vector<T>& input2);
290 T
operator()(Vector<T>& input1, Vector<T>& input2,
int parts);
293 static void cpu_func(
void *buffers[],
void *arg);
297 static void omp_func(
void *buffers[],
void *arg);
302 static void cuda_func(
void *buffers[],
void *arg);
307 static void opencl_func(
void *buffers[],
void *arg);
310 char kernelNameMap[1024];
311 char kernelNameRed[1024];
313 struct starpu_opencl_program opencl_codelet;
315 void replaceText(std::string& text, std::string find, std::string replace);
320 std::string perfmodel_str;
325 Vector<T> *temp_output;
354 template <
typename MapFunc,
typename ReduceFunc,
typename T>
355 class MapReduce<MapFunc, ReduceFunc, T, TERNARY>:
public Task
360 MapReduce(MapFunc* mapFunc, ReduceFunc* reduceFunc);
362 MapReduce(MapFunc* mapFunc, ReduceFunc* reduceFunc, Vector<T> *in1, Vector<T> *in2, Vector<T> *in3, T *out);
370 starpu_data_unregister(scalar_result_handle);
371 isScalarStarPU =
false;
378 void setInput1(Vector<T> *in)
383 void setInput2(Vector<T> *in)
388 void setInput3(Vector<T> *in)
393 void setOutput(T *out)
396 starpu_data_acquire(scalar_result_handle, STARPU_W);
401 starpu_data_release(scalar_result_handle);
409 starpu_data_acquire(scalar_result_handle, STARPU_R);
411 starpu_data_release(scalar_result_handle);
419 void setConstant(T constant1) {m_mapFunc->setConstant(constant1);}
421 void finishAll() {m_environment->
finishAll();}
422 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
425 Environment<int>* m_environment;
427 ReduceFunc* m_reduceFunc;
430 #ifdef USE_STARPU_HISTORY_MODEL
431 starpu_perfmodel *mapred3_perf_model;
434 struct starpu_codelet *codelet;
436 starpu_data_handle_t scalar_result_handle;
441 T
operator()(Vector<T>& input1, Vector<T>& input2, Vector<T>& input3);
443 T
operator()(Vector<T>& input1, Vector<T>& input2, Vector<T>& input3,
int parts);
446 static void cpu_func(
void *buffers[],
void *arg);
450 static void omp_func(
void *buffers[],
void *arg);
455 static void cuda_func(
void *buffers[],
void *arg);
460 static void opencl_func(
void *buffers[],
void *arg);
463 char kernelNameMap[1024];
464 char kernelNameRed[1024];
466 struct starpu_opencl_program opencl_codelet;
468 void replaceText(std::string& text, std::string find, std::string replace);
473 std::string perfmodel_str;
479 Vector<T> *temp_output;
void replaceText(std::string &text, std::string find, std::string replace)
Definition: mapreduce_cl.inl:28
static void opencl_func(void *buffers[], void *arg)
Definition: mapreduce_cl.inl:130
Includes the macro files needed for the defined backends.
static void cuda_func(void *buffers[], void *arg)
Definition: mapreduce_cu.inl:29
void createOpenCLProgram()
Definition: mapreduce_cl.inl:49
void finishAll()
Definition: environment.inl:119
~MapReduce()
Definition: mapreduce.inl:189
static void cpu_func(void *buffers[], void *arg)
Definition: mapreduce_cpu.inl:21
Contains the definitions of non-backend specific functions for the MapReduce skeleton.
Contains a class declaration for the object that represents an OpenCL device.
static void omp_func(void *buffers[], void *arg)
Definition: mapreduce_omp.inl:28
A vector container class, implemented as a wrapper for std::vector. It is configured to use StarPU DS...
Definition: vector.h:40
void run_async()
Definition: mapreduce.inl:215
A class representing the MapReduce skeleton.
Definition: mapreduce.h:62
A class that describes an execution plan, not used very much in this case as decision is mostly left ...
Definition: exec_plan.h:75
Contains the definitions of OpenMP specific functions for the MapReduce skeleton. ...
Contains a class definition for Task.
A class representing a Task for the farm skeleton.
Definition: task.h:31
Contains a class declaration for the Vector container.
Contains the definitions of OpenCL specific functions for the MapReduce skeleton. ...
Contains a class declaration for Environment class.
MapReduce(MapFunc *mapFunc, ReduceFunc *reduceFunc)
Definition: mapreduce.inl:21
Contains the definitions of CUDA specific functions for the MapReduce skeleton.
Contains the definitions of CPU specific functions for the MapReduce skeleton.
T operator()(Vector< T > &input)
Definition: mapreduce.inl:237
Contains a class that stores information about which back ends to use when executing.