12 #include <starpu_opencl.h>
20 #include <OpenCL/opencl.h>
30 #include "skepu/matrix.h"
64 template <
typename MapFunc,
typename T, skepu::FuncType c_type=UNARY, skepu_container_type cont_type=VECTOR>
71 typename MapFunc::CONST_TYPE constant;
78 Map(MapFunc* mapFunc);
107 void setPartitions(
int _parts)
118 template <
typename U>
119 void setConstant(U constant1) {m_mapFunc->setConstant(constant1);}
125 void setExecPlan(
ExecPlan& plan) {m_execPlan = plan;}
128 Environment<int>* m_environment;
132 #ifdef USE_STARPU_HISTORY_MODEL
133 starpu_perfmodel *map1_perf_model;
134 starpu_perfmodel *map2_perf_model;
137 struct starpu_codelet *sameIOCodelet;
138 struct starpu_codelet *diffIOCodelet;
145 void operator()(Vector<T>& input, Vector<T>& output);
149 void operator()(Vector<T>& input, Vector<T>& output,
int parts);
152 static void cpu_func(
void *buffers[],
void *arg);
156 static void omp_func(
void *buffer[],
void *arg);
161 static void cuda_func(
void *buffer[],
void *arg);
166 static void opencl_func(
void *buffer[],
void *arg);
169 struct starpu_opencl_program opencl_codelet;
170 char kernelNameArray[1024];
172 void replaceText(std::string& text, std::string find, std::string replace);
177 std::string perfmodel1_str;
178 std::string perfmodel2_str;
212 template <
typename MapFunc,
typename T>
213 class Map<MapFunc, T, BINARY, VECTOR>:
public Task
218 Map<MapFunc, T, BINARY, VECTOR> *pMap;
219 typename MapFunc::CONST_TYPE constant;
228 Map(MapFunc* mapFunc);
230 Map(MapFunc* mapFunc, Vector<T> *in1, Vector<T> *in2, Vector<T> *out,
int parts=1);
234 Vector<T>& getOutput()
244 void setInput1(Vector<T> *in)
249 void setInput2(Vector<T> *in)
254 void setOutput(Vector<T> *out)
259 void setPartitions(
int _parts)
269 template <
typename U>
270 void setConstant(U constant1) {m_mapFunc->setConstant(constant1);}
276 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
279 Environment<int>* m_environment;
283 struct starpu_codelet *singleBuffCodelet;
284 struct starpu_codelet *doubleBuffCodelet;
285 struct starpu_codelet *tripleBuffCodelet;
288 struct starpu_codelet *singleBuffCodelet2;
289 struct starpu_codelet *doubleBuffCodelet2;
290 struct starpu_codelet *tripleBuffCodelet2;
294 #ifdef USE_STARPU_HISTORY_MODEL
295 starpu_perfmodel *map1_perf_model;
296 starpu_perfmodel *map2_perf_model;
297 starpu_perfmodel *map3_perf_model;
301 void operator()(Vector<T>& input1, Vector<T>& input2, Vector<T>& output);
303 void operator()(Vector<T>& input1, Vector<T>& input2, Vector<T>& output,
int parts);
306 static void cpu_func(
void *buffers[],
void *arg);
310 static void omp_func(
void *buffer[],
void *arg);
315 static void cuda_func(
void *buffer[],
void *arg);
320 static void opencl_func(
void *buffer[],
void *arg);
323 struct starpu_opencl_program opencl_codelet;
324 char kernelNameArray[1024];
326 void replaceText(std::string& text, std::string find, std::string replace);
331 std::string perfmodel1_str;
332 std::string perfmodel2_str;
333 std::string perfmodel3_str;
366 template <
typename MapFunc,
typename T>
367 class Map<MapFunc, T, TERNARY, VECTOR>:
public Task
372 Map<MapFunc, T, TERNARY, VECTOR> *pMap;
373 typename MapFunc::CONST_TYPE constant;
381 Map(MapFunc* mapFunc);
383 Map(MapFunc* mapFunc, Vector<T> *in1, Vector<T> *in2, Vector<T> *in3, Vector<T> *out,
int parts=1);
388 Vector<T>& getOutput()
398 void setInput1(Vector<T> *in)
403 void setInput2(Vector<T> *in)
408 void setInput3(Vector<T> *in)
413 void setOutput(Vector<T> *out)
418 void setPartitions(
int _parts)
429 template <
typename U>
430 void setConstant(U constant1) {m_mapFunc->setConstant(constant1);}
436 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
439 Environment<int>* m_environment;
443 struct starpu_codelet *singleBuffCodelet;
444 struct starpu_codelet *doubleBuffCodelet;
445 struct starpu_codelet *tripleBuffCodelet;
446 struct starpu_codelet *fourBuffCodelet;
448 #ifdef USE_STARPU_HISTORY_MODEL
449 starpu_perfmodel *map1_perf_model;
450 starpu_perfmodel *map2_perf_model;
451 starpu_perfmodel *map3_perf_model;
452 starpu_perfmodel *map4_perf_model;
457 void operator()(Vector<T>& input1, Vector<T>& input2, Vector<T>& input3, Vector<T>& output);
459 void operator()(Vector<T>& input1, Vector<T>& input2, Vector<T>& input3, Vector<T>& output,
int parts);
463 static void cpu_func(
void *buffers[],
void *arg);
467 static void omp_func(
void *buffer[],
void *arg);
472 static void cuda_func(
void *buffer[],
void *arg);
477 static void opencl_func(
void *buffer[],
void *arg);
480 struct starpu_opencl_program opencl_codelet;
481 char kernelNameArray[1024];
483 void replaceText(std::string& text, std::string find, std::string replace);
488 std::string perfmodel1_str;
489 std::string perfmodel2_str;
490 std::string perfmodel3_str;
491 std::string perfmodel4_str;
535 template <
typename MapFunc,
typename T>
536 class Map<MapFunc, T, UNARY, MATRIX>:
public Task
541 Map<MapFunc, T, UNARY, MATRIX> *pMap;
542 typename MapFunc::CONST_TYPE constant;
549 Map(MapFunc* mapFunc);
551 Map(MapFunc* mapFunc, Matrix<T> *input, Matrix<T> *output,
int parts=1);
557 Matrix<T>& getOutput()
568 void setInput(Matrix<T> *in)
573 void setOutput(Matrix<T> *out)
578 void setPartitions(
int _parts)
589 template <
typename U>
590 void setConstant(U constant1) {m_mapFunc->setConstant(constant1);}
596 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
599 Environment<int>* m_environment;
603 #ifdef USE_STARPU_HISTORY_MODEL
604 starpu_perfmodel *map1_perf_model;
605 starpu_perfmodel *map2_perf_model;
608 struct starpu_codelet *sameIOCodelet;
609 struct starpu_codelet *diffIOCodelet;
616 void operator()(Matrix<T>& input, Matrix<T>& output);
620 void operator()(Matrix<T>& input, Matrix<T>& output,
int parts);
623 static void cpu_func(
void *buffers[],
void *arg);
627 static void omp_func(
void *buffer[],
void *arg);
632 static void cuda_func(
void *buffer[],
void *arg);
637 static void opencl_func(
void *buffer[],
void *arg);
639 struct starpu_opencl_program opencl_codelet;
640 char kernelNameArray[1024];
642 void replaceText(std::string& text, std::string find, std::string replace);
647 std::string perfmodel1_str;
648 std::string perfmodel2_str;
677 template <
typename MapFunc,
typename T>
678 class Map<MapFunc, T, BINARY, MATRIX>:
public Task
683 Map<MapFunc, T, BINARY, MATRIX> *pMap;
684 typename MapFunc::CONST_TYPE constant;
693 Map(MapFunc* mapFunc);
695 Map(MapFunc* mapFunc, Matrix<T> *in1, Matrix<T> *in2, Matrix<T> *out,
int _parts=1);
698 Matrix<T>& getOutput()
708 void setInput1(Matrix<T> *in)
713 void setInput2(Matrix<T> *in)
718 void setOutput(Matrix<T> *out)
723 void setPartitions(
int _parts)
736 template <
typename U>
737 void setConstant(U constant1) {m_mapFunc->setConstant(constant1);}
743 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
746 Environment<int>* m_environment;
750 struct starpu_codelet *singleBuffCodelet;
751 struct starpu_codelet *doubleBuffCodelet;
752 struct starpu_codelet *tripleBuffCodelet;
754 #ifdef USE_STARPU_HISTORY_MODEL
755 starpu_perfmodel *map1_perf_model;
756 starpu_perfmodel *map2_perf_model;
757 starpu_perfmodel *map3_perf_model;
761 void operator()(Matrix<T>& input1, Matrix<T>& input2, Matrix<T>& output);
763 void operator()(Matrix<T>& input1, Matrix<T>& input2, Matrix<T>& output,
int xparts);
765 void operator()(Matrix<T>& input1, Matrix<T>& input2, Matrix<T>& output,
int xparts,
int yparts);
769 static void cpu_func(
void *buffers[],
void *arg);
773 static void omp_func(
void *buffer[],
void *arg);
778 static void cuda_func(
void *buffer[],
void *arg);
783 static void opencl_func(
void *buffer[],
void *arg);
786 struct starpu_opencl_program opencl_codelet;
787 char kernelNameArray[1024];
789 void replaceText(std::string& text, std::string find, std::string replace);
794 std::string perfmodel1_str;
795 std::string perfmodel2_str;
796 std::string perfmodel3_str;
831 template <
typename MapFunc,
typename T>
832 class Map<MapFunc, T, TERNARY, MATRIX>:
public Task
837 Map<MapFunc, T, TERNARY, MATRIX> *pMap;
838 typename MapFunc::CONST_TYPE constant;
846 Map(MapFunc* mapFunc);
848 Map(MapFunc* mapFunc, Matrix<T> *in1, Matrix<T> *in2, Matrix<T> *in3, Matrix<T> *out,
int parts=1);
853 Matrix<T>& getOutput()
863 void setInput1(Matrix<T> *in)
868 void setInput2(Matrix<T> *in)
873 void setInput3(Matrix<T> *in)
878 void setOutput(Matrix<T> *out)
883 void setPartitions(
int _parts)
894 template <
typename U>
895 void setConstant(U constant1) {m_mapFunc->setConstant(constant1);}
901 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
904 Environment<int>* m_environment;
908 struct starpu_codelet *singleBuffCodelet;
909 struct starpu_codelet *doubleBuffCodelet;
910 struct starpu_codelet *tripleBuffCodelet;
911 struct starpu_codelet *fourBuffCodelet;
913 #ifdef USE_STARPU_HISTORY_MODEL
914 starpu_perfmodel *map1_perf_model;
915 starpu_perfmodel *map2_perf_model;
916 starpu_perfmodel *map3_perf_model;
917 starpu_perfmodel *map4_perf_model;
922 void operator()(Matrix<T>& input1, Matrix<T>& input2, Matrix<T>& input3, Matrix<T>& output);
924 void operator()(Matrix<T>& input1, Matrix<T>& input2, Matrix<T>& input3, Matrix<T>& output,
int parts);
928 static void cpu_func(
void *buffers[],
void *arg);
932 static void omp_func(
void *buffer[],
void *arg);
937 static void cuda_func(
void *buffer[],
void *arg);
942 static void opencl_func(
void *buffer[],
void *arg);
945 struct starpu_opencl_program opencl_codelet;
946 char kernelNameArray[1024];
948 void replaceText(std::string& text, std::string find, std::string replace);
953 std::string perfmodel1_str;
954 std::string perfmodel2_str;
955 std::string perfmodel3_str;
956 std::string perfmodel4_str;
1008 template <
typename MapFunc,
typename T>
1009 class Map<MapFunc, T, UNARY, SPARSE_MATRIX>:
public Task
1014 Map<MapFunc, T, UNARY, SPARSE_MATRIX> *pMap;
1015 typename MapFunc::CONST_TYPE constant;
1022 Map(MapFunc* mapFunc);
1024 Map(MapFunc* mapFunc, SparseMatrix<T> *input, SparseMatrix<T> *output,
int parts=1);
1030 SparseMatrix<T>& getOutput()
1041 void setInput(SparseMatrix<T> *in)
1046 void setOutput(SparseMatrix<T> *out)
1051 void setPartitions(
int _parts)
1062 template <
typename U>
1063 void setConstant(U constant1) { m_mapFunc->setConstant(constant1); }
1069 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
1072 Environment<int>* m_environment;
1074 ExecPlan m_execPlan;
1076 #ifdef USE_STARPU_HISTORY_MODEL
1077 starpu_perfmodel *map1_perf_model;
1078 starpu_perfmodel *map2_perf_model;
1081 struct starpu_codelet *sameIOCodelet;
1082 struct starpu_codelet *diffIOCodelet;
1089 void operator()(SparseMatrix<T>& input, SparseMatrix<T>& output);
1091 void operator()(SparseMatrix<T>& input,
int parts);
1093 void operator()(SparseMatrix<T>& input, SparseMatrix<T>& output,
int parts);
1096 static void cpu_func(
void *buffers[],
void *arg);
1100 static void omp_func(
void *buffer[],
void *arg);
1105 static void cuda_func(
void *buffer[],
void *arg);
1110 static void opencl_func(
void *buffer[],
void *arg);
1113 struct starpu_opencl_program opencl_codelet;
1114 char kernelNameArray[1024];
1116 void replaceText(std::string& text, std::string find, std::string replace);
1121 std::string perfmodel1_str;
1122 std::string perfmodel2_str;
1124 SparseMatrix<T> *input;
1126 SparseMatrix<T> *output;
1151 template <
typename MapFunc,
typename T>
1152 class Map<MapFunc, T, BINARY, SPARSE_MATRIX>:
public Task
1157 Map<MapFunc, T, BINARY, SPARSE_MATRIX> *pMap;
1158 typename MapFunc::CONST_TYPE constant;
1167 Map(MapFunc* mapFunc);
1169 Map(MapFunc* mapFunc, SparseMatrix<T> *in1, SparseMatrix<T> *in2, SparseMatrix<T> *out,
int _parts=1);
1172 SparseMatrix<T>& getOutput()
1182 void setInput1(SparseMatrix<T> *in)
1187 void setInput2(SparseMatrix<T> *in)
1192 void setOutput(SparseMatrix<T> *out)
1197 void setPartitions(
int _parts)
1210 template <
typename U>
1211 void setConstant(U constant1) {m_mapFunc->setConstant(constant1);}
1217 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
1220 Environment<int>* m_environment;
1222 ExecPlan m_execPlan;
1224 struct starpu_codelet *singleBuffCodelet;
1225 struct starpu_codelet *doubleBuffCodelet;
1226 struct starpu_codelet *tripleBuffCodelet;
1228 #ifdef USE_STARPU_HISTORY_MODEL
1229 starpu_perfmodel *map1_perf_model;
1230 starpu_perfmodel *map2_perf_model;
1231 starpu_perfmodel *map3_perf_model;
1235 void operator()(SparseMatrix<T>& input1, SparseMatrix<T>& input2, SparseMatrix<T>& output);
1237 void operator()(SparseMatrix<T>& input1, SparseMatrix<T>& input2, SparseMatrix<T>& output,
int xparts);
1240 static void cpu_func(
void *buffers[],
void *arg);
1244 static void omp_func(
void *buffer[],
void *arg);
1249 static void cuda_func(
void *buffer[],
void *arg);
1254 static void opencl_func(
void *buffer[],
void *arg);
1257 struct starpu_opencl_program opencl_codelet;
1258 char kernelNameArray[1024];
1260 void replaceText(std::string& text, std::string find, std::string replace);
1265 std::string perfmodel1_str;
1266 std::string perfmodel2_str;
1267 std::string perfmodel3_str;
1269 SparseMatrix<T> *input1;
1270 SparseMatrix<T> *input2;
1272 SparseMatrix<T> *output;
1302 template <
typename MapFunc,
typename T>
1303 class Map<MapFunc, T, TERNARY, SPARSE_MATRIX>:
public Task
1308 Map<MapFunc, T, TERNARY, SPARSE_MATRIX> *pMap;
1309 typename MapFunc::CONST_TYPE constant;
1317 Map(MapFunc* mapFunc);
1319 Map(MapFunc* mapFunc, SparseMatrix<T> *in1, SparseMatrix<T> *in2, SparseMatrix<T> *in3, SparseMatrix<T> *out,
int parts=1);
1324 SparseMatrix<T>& getOutput()
1334 void setInput1(SparseMatrix<T> *in)
1339 void setInput2(SparseMatrix<T> *in)
1344 void setInput3(SparseMatrix<T> *in)
1349 void setOutput(SparseMatrix<T> *out)
1354 void setPartitions(
int _parts)
1365 template <
typename U>
1366 void setConstant(U constant1) {m_mapFunc->setConstant(constant1);}
1372 void setExecPlan(ExecPlan& plan) {m_execPlan = plan;}
1375 Environment<int>* m_environment;
1377 ExecPlan m_execPlan;
1379 struct starpu_codelet *singleBuffCodelet;
1380 struct starpu_codelet *doubleBuffCodelet;
1381 struct starpu_codelet *tripleBuffCodelet;
1382 struct starpu_codelet *fourBuffCodelet;
1384 #ifdef USE_STARPU_HISTORY_MODEL
1385 starpu_perfmodel *map1_perf_model;
1386 starpu_perfmodel *map2_perf_model;
1387 starpu_perfmodel *map3_perf_model;
1388 starpu_perfmodel *map4_perf_model;
1393 void operator()(SparseMatrix<T>& input1, SparseMatrix<T>& input2, SparseMatrix<T>& input3, SparseMatrix<T>& output);
1395 void operator()(SparseMatrix<T>& input1, SparseMatrix<T>& input2, SparseMatrix<T>& input3, SparseMatrix<T>& output,
int parts);
1399 static void cpu_func(
void *buffers[],
void *arg);
1403 static void omp_func(
void *buffer[],
void *arg);
1408 static void cuda_func(
void *buffer[],
void *arg);
1413 static void opencl_func(
void *buffer[],
void *arg);
1416 struct starpu_opencl_program opencl_codelet;
1417 char kernelNameArray[1024];
1419 void replaceText(std::string& text, std::string find, std::string replace);
1424 std::string perfmodel1_str;
1425 std::string perfmodel2_str;
1426 std::string perfmodel3_str;
1427 std::string perfmodel4_str;
1429 SparseMatrix<T> *input1;
1430 SparseMatrix<T> *input2;
1431 SparseMatrix<T> *input3;
1433 SparseMatrix<T> *output;
void operator()(Vector< T > &input)
Definition: map.inl:291
Contains the definitions of CPU specific functions for the Map skeleton for vector operands...
void createOpenCLProgram()
Definition: map_cl.inl:50
Contains the definitions of OpenCL specific functions for the Map skeleton for sparse-matrix operands...
Defines a few macros that can be used to output text when debugging. The macros use std::cerr...
Contains the definitions of CUDA specific member functions for the Map skeleton for sparse-matrix ope...
Contains a class declaration for the SparseMatrix container.
static void cuda_func(void *buffer[], void *arg)
Definition: map_cu.inl:31
Contains the definitions of OpenCL specific functions for the Map skeleton for matrix operands...
static void omp_func(void *buffer[], void *arg)
Definition: map_omp.inl:25
void finishAll()
Definition: map.h:124
Includes the macro files needed for the defined backends.
~Map()
Definition: map.inl:227
Contains the definitions of CPU specific functions for the Map skeleton for matrix operands...
void finishAll()
Definition: environment.inl:119
Contains the definitions of OpenCL specific functions for the Map skeleton for vector operands...
Contains the definitions of non-backend specific member functions for the Map skeleton for sparse mat...
Map(MapFunc *mapFunc)
Definition: map.inl:18
Contains the definitions of non-backend specific member functions for the Map skeleton for vector ope...
Contains a class declaration for the object that represents an OpenCL device.
Contains the definitions of OpenMP specific member functions for the Map skeleton for vector operands...
Contains the definitions of non-backend specific member functions for the Map skeleton for dense matr...
Contains the definitions of OpenMP specific member functions for the Map skeleton for sparse-matrix o...
Contains the definitions of CUDA specific member functions for the Map skeleton for matrix operands...
A vector container class, implemented as a wrapper for std::vector. It is configured to use StarPU DS...
Definition: vector.h:40
void replaceText(std::string &text, std::string find, std::string replace)
Definition: map_cl.inl:28
void run_async()
Definition: map.inl:252
static void cpu_func(void *buffers[], void *arg)
Definition: map_cpu.inl:23
Contains the definitions of OpenMP specific member functions for the Map skeleton for matrix operands...
Contains the definitions of CUDA specific member functions for the Map skeleton for vector operands...
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 CPU specific functions for the Map skeleton for SparseMatrix operands...
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 a class declaration for Environment class.
static void opencl_func(void *buffer[], void *arg)
Definition: map_cl.inl:114
A class representing the Map skeleton.
Definition: map.h:65
void setConstant(U constant1)
Definition: map.h:119
Contains a class that stores information about which back ends to use when executing.