pip_code_model macro now automatic add CMAKE_CURRENT_SOURCE_DIR to relative pathes, no ABSOLUTE need
PIOpenCL first working version
This commit is contained in:
@@ -50,6 +50,12 @@ public:
|
||||
AccessNone,
|
||||
};
|
||||
|
||||
enum Direction {
|
||||
Input = 0x01,
|
||||
Output = 0x02,
|
||||
InputOutput = Input | Output,
|
||||
};
|
||||
|
||||
enum TypeQualifier {
|
||||
TypeConst,
|
||||
TypeRestrict,
|
||||
@@ -74,6 +80,7 @@ public:
|
||||
KernelArg();
|
||||
AddressQualifier address_qualifier;
|
||||
AccessQualifier access_qualifier;
|
||||
Direction direction;
|
||||
TypeQualifier type_qualifier;
|
||||
PIString arg_name;
|
||||
PIString type_name;
|
||||
@@ -84,6 +91,8 @@ public:
|
||||
private:
|
||||
friend class Kernel;
|
||||
void init(void * _k, uint index);
|
||||
int bytes;
|
||||
void * buffer, * data;
|
||||
};
|
||||
|
||||
struct PIP_OPENCL_EXPORT Device {
|
||||
@@ -116,10 +125,12 @@ public:
|
||||
|
||||
class PIP_OPENCL_EXPORT Context {
|
||||
friend class Program;
|
||||
friend class Kernel;
|
||||
public:
|
||||
~Context();
|
||||
static Context * create(const DeviceList & dl);
|
||||
static Context * create(const Device & d) {return create(DeviceList() << d);}
|
||||
static Context * create(const PIString & part_name);
|
||||
Program * createProgram(const PIString & source, PIString * error = 0);
|
||||
private:
|
||||
Context();
|
||||
@@ -135,7 +146,7 @@ public:
|
||||
public:
|
||||
~Program();
|
||||
const PIString & sourceCode() const {return source_;}
|
||||
const Kernel * kernel(int index = 0) const {return kernels_[index];}
|
||||
Kernel * kernel(int index = 0) const {return kernels_[index];}
|
||||
const PIVector<Kernel * > & kernels() const {return kernels_;}
|
||||
private:
|
||||
Program();
|
||||
@@ -150,22 +161,49 @@ public:
|
||||
class PIP_OPENCL_EXPORT Kernel {
|
||||
friend class Program;
|
||||
public:
|
||||
bool execute();
|
||||
void setExecuteRange(int size) {setExecuteRanges(PIVector<int>() << size);}
|
||||
void setExecuteRanges(const PIVector<int> & ranges);
|
||||
const PIString & name() const {return name_;}
|
||||
const PIVector<KernelArg> & args() const {return args_;}
|
||||
template <typename T> bool setArgValue(int index, const T & value) {return setArgValueV(index, PIVariant::fromValue(value));}
|
||||
template <typename T> bool setArgValue(int index, const T & value) {return setArgValueS(index, PIVariant::fromValue(value));}
|
||||
template <typename T> bool setArgValue(const PIString & arg, const T & value) {return setArgValue(argIndex(arg), value);}
|
||||
template <typename T> bool bindArgValue(int index, PIVector<T> & value, PIOpenCL::Direction dir) {
|
||||
T def;
|
||||
return bindArgValueV(index, value.size() * sizeof(T), value.data(), sizeof(def), &def, dir);
|
||||
}
|
||||
template <typename T> bool bindArgValue(const PIString & arg, PIVector<T> & value, PIOpenCL::Direction dir) {
|
||||
return bindArgValue(argIndex(arg), value, dir);
|
||||
}
|
||||
template <typename T> bool bindArgValue(int index, PIDeque<T> & value, PIOpenCL::Direction dir) {
|
||||
T def;
|
||||
return bindArgValueV(index, value.size() * sizeof(T), value.data(), sizeof(def), &def, dir);
|
||||
}
|
||||
template <typename T> bool bindArgValue(const PIString & arg, PIDeque<T> & value, PIOpenCL::Direction dir) {
|
||||
return bindArgValue(argIndex(arg), value, dir);
|
||||
}
|
||||
template <typename T> bool bindArgValue(int index, PIVector2D<T> & value, PIOpenCL::Direction dir) {
|
||||
T def;
|
||||
return bindArgValueV(index, value.size() * sizeof(T), value.data(), sizeof(def), &def, dir);
|
||||
}
|
||||
template <typename T> bool bindArgValue(const PIString & arg, PIVector2D<T> & value, PIOpenCL::Direction dir) {
|
||||
return bindArgValue(argIndex(arg), value, dir);
|
||||
}
|
||||
private:
|
||||
Kernel();
|
||||
~Kernel();
|
||||
void zero();
|
||||
bool init();
|
||||
bool setArgValueV(int index, const PIVariant & value);
|
||||
bool setArgValueS(int index, const PIVariant & value);
|
||||
bool bindArgValueV(int index, uint bytes, void * value, uint def_bytes, void * def_data, PIOpenCL::Direction dir);
|
||||
int argIndex(const PIString & an) const;
|
||||
KernelArg argByName(const PIString & an) const;
|
||||
Context * context_;
|
||||
Program * program_;
|
||||
PIString name_;
|
||||
PIVector<KernelArg> args_;
|
||||
PIVector<void*> buffers_;
|
||||
PIVector<size_t> dims;
|
||||
PRIVATE_DECLARATION(PIP_OPENCL_EXPORT)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user