18 #ifndef KTEST_PATTERN_H__
19 #define KTEST_PATTERN_H__
22 #include <OpenCL/cl.h>
30 #include <clblas-internal.h>
31 #include <blas_funcs.h>
32 #include <granulation.h>
33 #include <kernel_extra.h>
34 #include <solution_seq.h>
42 typedef struct StepKargs {
73 typedef std::list<Variable*> VarList;
74 typedef std::list<ArrayVariableInterface*> ArrayVarList;
75 typedef std::map<unsigned int, const Variable*> KArgMap;
92 CLBLASKernExtra kextra_;
93 cl_platform_id platform_;
107 std::string dumpMemoryPattern();
108 std::string dumpSubdim(
const SubproblemDim *subdim);
109 std::string dumpPgran();
110 std::string dumpKextra();
112 cl_device_id device() {
return step_.device.id; };
113 void setKernelArg(
unsigned int index,
const Variable *var);
125 MemoryPattern* pattern_;
133 std::string naiveCall_;
141 std::string compareCall_;
149 std::string postRandomCall_;
154 std::string kernelName_;
163 Variable* addVar(
const std::string& name,
const std::string& type,
164 const std::string& defaultValue =
"");
171 Variable* addVar(
const std::string& name,
const std::string& type,
179 Variable* addVar(
const std::string& name,
const std::string& type,
187 Variable* addConst(
const std::string& name,
const std::string& type,
188 const std::string& defaultValue);
195 Variable* addConst(
const std::string& name,
const std::string& type,
203 Variable* addConst(
const std::string& name,
const std::string& type,
209 MatrixVariable* addMatrix(
const std::string& name,
const std::string& type,
210 Variable *rows, Variable *columns, Variable *ld, Variable *off = NULL);
215 VectorVariable* addVector(
const std::string& name,
const std::string& type,
216 Variable *N, Variable *inc, Variable *off = NULL);
221 Variable* addBuffer(BufferID bufID,
const std::string& name,
222 const std::string& type, cl_mem_flags flags,
223 ArrayVariableInterface* hostPtr);
233 void assignKargs(
const Kargs& kargs);
239 static std::string deviceVendor(cl_device_id device);
253 Step(BlasFunctionID funcID, cl_device_id device);
265 Step(ListNode *node);
276 const VarList& vars()
const {
return vars_; };
281 const ArrayVarList& arrays()
const {
return arrays_; };
286 const VarList& buffers()
const {
return buffers_; };
292 virtual void fixLD() = 0;
304 virtual void declareVars(Step *masterStep) = 0;
315 Variable* getBuffer(BufferID bufID);
324 void completeDecompositionSingle();
335 void makeSolutionSequence(ListHead *seq, cl_platform_id platform);
344 void freeSolutionSequence(ListHead *seq);
351 std::string generate();
358 std::string globalWorkSize();
365 BlasFunctionID blasFunctionID()
const {
return step_.funcID; };
371 const CLBlasKargs& kargs()
const {
return step_.args; };
377 const PGranularity& pgran()
const {
return step_.pgran; };
386 const std::string& naiveCall()
const {
return naiveCall_; };
395 const std::string& compareCall()
const {
return compareCall_; };
404 const std::string& postRandomCall()
const {
return postRandomCall_; };
410 const std::string& kernelName()
const {
return kernelName_; };
417 const char* getBlasFunctionName();
424 const std::map<unsigned int, const Variable*>& kargMap()
const {
return kargMap_; }
430 void setKargs(
const CLBlasKargs& kargs);
436 void setDecomposition(
const SubproblemDim *subdims);
442 void setKernelName(std::string name);
449 std::string matrixSize(MatrixVariable *var);
456 std::string vectorSize(VectorVariable *vector);
466 static std::string multiplierToString(DataType dtype, ArgMultiplier arg);
473 static std::string dtypeToString(DataType dtype);
480 static BlasFunctionID getStepNodeFuncID(ListNode *node);
485 #endif // KTEST_PATTERN_H__