get rid of piForeach
apply some code analyzer recommendations ICU flag now check if libicu exists prepare for more accurate growth of containers (limited PoT, then constantly increase size)
This commit is contained in:
@@ -48,7 +48,7 @@ const PIVector<PIOpenCL::Platform> & PIOpenCL::platforms() {
|
||||
const PIVector<PIOpenCL::Device> PIOpenCL::devices() {
|
||||
PIVector<PIOpenCL::Device> ret;
|
||||
PIVector<PIOpenCL::Platform> pl = platforms();
|
||||
piForeachC(PIOpenCL::Platform & p, pl)
|
||||
for (const auto & p: pl)
|
||||
ret << p.devices;
|
||||
return ret;
|
||||
}
|
||||
@@ -56,8 +56,8 @@ const PIVector<PIOpenCL::Device> PIOpenCL::devices() {
|
||||
|
||||
PIOpenCL::Device PIOpenCL::deviceByID(void * id) {
|
||||
PIVector<PIOpenCL::Platform> pl = platforms();
|
||||
piForeachC(PIOpenCL::Platform & p, pl) {
|
||||
piForeachC(PIOpenCL::Device & d, p.devices) {
|
||||
for (const auto & p: pl) {
|
||||
for (const auto & d: p.devices) {
|
||||
if (d.id == id) return d;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ void PIOpenCL::Context::deletePrograms() {
|
||||
piCout << "context: delete" << programs_.size() << "programs";
|
||||
PIVector<Program *> ptdl = programs_;
|
||||
programs_.clear();
|
||||
piForeach(Program * p, ptdl) {
|
||||
for (auto * p: ptdl) {
|
||||
if (p) delete p;
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ void PIOpenCL::Context::deleteBuffers() {
|
||||
piCout << "context: delete" << buffers_.size() << "buffers";
|
||||
PIVector<Buffer *> btdl = buffers_;
|
||||
buffers_.clear();
|
||||
piForeach(Buffer * b, btdl) {
|
||||
for (auto * b: btdl) {
|
||||
if (b) delete b;
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ PIOpenCL::Context * PIOpenCL::Context::create(const PIOpenCL::DeviceList & dl) {
|
||||
PIOpenCL::Context * PIOpenCL::Context::create(const PIString & part_name) {
|
||||
PIString pn = part_name.toLowerCase();
|
||||
PIVector<Device> dl = PIOpenCL::devices();
|
||||
piForeachC(Device & d, dl) {
|
||||
for (const auto & d: dl) {
|
||||
if (d.displayText().toLowerCase().contains(pn)) return create(d);
|
||||
}
|
||||
return 0;
|
||||
@@ -283,13 +283,13 @@ PIOpenCL::Program * PIOpenCL::Context::createProgram(const PIString & source, co
|
||||
}
|
||||
PIStringList knl = PIString(knames).trim().split(";");
|
||||
PIVector<void *> kerns;
|
||||
piForeachC(PIString & k, knl) {
|
||||
for (const auto & k: knl) {
|
||||
cl_kernel kern = clCreateKernel(prog, k.dataAscii(), &ret);
|
||||
if (ret != 0) {
|
||||
piCout << "[PIOpenCL::Context]"
|
||||
<< "clCreateKernel" << k << "error" << ret;
|
||||
if (error) (*error) += "clCreateKernel(\"" + k + "\") error " + ret;
|
||||
piForeach(void * _k, kerns)
|
||||
for (auto * _k: kerns)
|
||||
clReleaseKernel((cl_kernel)_k);
|
||||
clReleaseProgram(prog);
|
||||
return 0;
|
||||
@@ -472,7 +472,7 @@ PIOpenCL::Program::Program() {
|
||||
PIOpenCL::Program::~Program() {
|
||||
// piCout << "destroy program" << this;
|
||||
if (context_) context_->programs_.removeAll(this);
|
||||
piForeach(Kernel * k, kernels_)
|
||||
for (auto * k: kernels_)
|
||||
delete k;
|
||||
if (PRIVATE->program) clReleaseProgram(PRIVATE->program);
|
||||
zero();
|
||||
@@ -487,7 +487,7 @@ void PIOpenCL::Program::zero() {
|
||||
|
||||
|
||||
bool PIOpenCL::Program::initKernels(PIVector<void *> kerns) {
|
||||
piForeach(void * _k, kerns) {
|
||||
for (auto * _k: kerns) {
|
||||
cl_kernel k = (cl_kernel)_k;
|
||||
// piCout << "init kernel" << k;
|
||||
Kernel * kern = new Kernel();
|
||||
@@ -635,7 +635,7 @@ int PIOpenCL::Kernel::argIndex(const PIString & an) const {
|
||||
|
||||
|
||||
PIOpenCL::KernelArg PIOpenCL::Kernel::argByName(const PIString & an) const {
|
||||
piForeachC(KernelArg & a, args_)
|
||||
for (const auto & a: args_)
|
||||
if (a.arg_name == an) return a;
|
||||
return KernelArg();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user