Commit 16344ff2 authored by Kazutomo Yoshii's avatar Kazutomo Yoshii
Browse files

prepKernel() uses the basefile name as the kernel name when ommitted

parent 4bc046d5
......@@ -290,7 +290,7 @@ public:
}
}
bool prepKernel(const char *filename, const char *funcname) {
bool prepKernel(const char *filename, const char *funcname = NULL) {
std::string fn = filename;
cl_int err = CL_SUCCESS;
size_t pos = fn.find_last_of(".");
......@@ -299,8 +299,11 @@ public:
prgs.clear();
if (pos == std::string::npos) {
// the file extension is omitted
std::string tmpfn;
if (!funcname) funcname = filename;
for (std::vector<kext_t>::iterator it = kexts.begin(); it != kexts.end(); ++it) {
tmpfn = fn + (*it).first;
if (fexists(tmpfn)) {
......
#include "clwrap.hpp"
#include <sys/time.h>
#include <iomanip>
// A sample code for simpleOCLInit.hpp
// Written by Kaz Yoshii <ky@anl.gov>
......@@ -18,12 +19,12 @@ static void test_clwrap()
cw.listDevices();
int gsiz = 8;
int lsiz = 2;
int lsiz = 4;
int *a0 = new int[gsiz];
int *a1 = new int[gsiz];
bool ret = cw.prepKernel("dummy", "dummy"); // filename w/ ext, kernelname
bool ret = cw.prepKernel("dummy"); // find dummy.cl and use 'dummy' as the kernel name
if (!ret) {
cout << "prepKernel() failed!" << endl;
return;
......@@ -34,12 +35,19 @@ static void test_clwrap()
cw.runKernel(gsiz, lsiz);
cout << "Elapsed [sec]: " << cw.getKernelElapsedNanoSec() * 1e-9 << endl;
cout << "[output]" << endl;
for (int i = 0; i < gsiz; i++)
cout << i << ":" << a0[i] << "," << a1[i] << " ";
cout << "gid: ";
for (int i = 0; i < gsiz; i++)
cout << setw(2) << a0[i];
cout << endl;
cout << "lid: ";
for (int i = 0; i < gsiz; i++)
cout << setw(2) << a1[i];
cout << endl;
cout << "Elapsed [sec]: " << cw.getKernelElapsedNanoSec() * 1e-9 << endl;
};
int main()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment