add banchmark image alignment
This commit is contained in:
+26
-17
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Created by root on 4/27/21.
|
||||
//
|
||||
#include "cl_class.h"
|
||||
#include <cl_class.h>
|
||||
opencl::opencl() {
|
||||
std::vector<cl::Platform> all_platforms;
|
||||
cl::Platform::get(&all_platforms);
|
||||
@@ -12,7 +12,7 @@ opencl::opencl() {
|
||||
//get default device of the default platform
|
||||
std::vector<cl::Device> all_devices;
|
||||
for(auto i:all_platforms){
|
||||
std::cout << "Find platform: " << i.getInfo<CL_PLATFORM_NAME>() << "\n";
|
||||
std::cout << "Find platform number:"<< i.getInfo<CL_PLATFORM_NAME>() << "\n";
|
||||
i.getDevices(CL_DEVICE_TYPE_GPU, &all_devices);
|
||||
}
|
||||
|
||||
@@ -20,29 +20,38 @@ opencl::opencl() {
|
||||
std::cout << " No devices found. Check OpenCL installation!\n";
|
||||
exit(1);
|
||||
}
|
||||
device = all_devices[0];
|
||||
std::cout << "CL_DEVICE_NAME: " << device.getInfo<CL_DEVICE_NAME>() <<'\n'
|
||||
<< "CL_DEVICE_OPENCL_C_VERSION: " <<device.getInfo<CL_DEVICE_OPENCL_C_VERSION>()<<'\n'
|
||||
<< "CL_DEVICE_BUILT_IN_KERNELS: " <<device.getInfo<CL_DEVICE_BUILT_IN_KERNELS>()<<'\n'
|
||||
<< "CL_DEVICE_COMPILER_AVAILABLE: " <<device.getInfo<CL_DEVICE_COMPILER_AVAILABLE>()<<'\n'
|
||||
<< "CL_DEVICE_LOCAL_MEM_SIZE: " <<device.getInfo<CL_DEVICE_LOCAL_MEM_SIZE>()<<'\n'
|
||||
<< "CL_DEVICE_GLOBAL_MEM_SIZE: " <<device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>()<<'\n';
|
||||
|
||||
context=new cl::Context({ device });
|
||||
device = new cl::Device(all_devices[0]);
|
||||
std::cout << "CL_DEVICE_NAME: " << device->getInfo<CL_DEVICE_NAME>() <<'\n'
|
||||
<< "CL_DEVICE_OPENCL_C_VERSION: " <<device->getInfo<CL_DEVICE_OPENCL_C_VERSION>()<<'\n'
|
||||
<< "CL_DEVICE_BUILT_IN_KERNELS: " <<device->getInfo<CL_DEVICE_BUILT_IN_KERNELS>()<<'\n'
|
||||
<< "CL_DEVICE_COMPILER_AVAILABLE: " <<device->getInfo<CL_DEVICE_COMPILER_AVAILABLE>()<<'\n'
|
||||
<< "CL_DEVICE_LOCAL_MEM_SIZE: " <<device->getInfo<CL_DEVICE_LOCAL_MEM_SIZE>()<<'\n'
|
||||
<< "CL_DEVICE_GLOBAL_MEM_SIZE: " <<device->getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>()<<'\n';
|
||||
context=new cl::Context({ *device });
|
||||
cl::Program::Sources sources;
|
||||
read_cl fast("../kernel/fast-gray.cl");
|
||||
read_cl fast(std::string(KERNEL_DIR)+"/fast-gray.cl");
|
||||
sources.push_back({ fast.src_str, fast.size });
|
||||
read_cl compute_residual(std::string(KERNEL_DIR)+"/compute-residual.cl");
|
||||
sources.push_back({ compute_residual.src_str, compute_residual.size });
|
||||
program=new cl::Program(*context, sources);
|
||||
if(program->build({ device },"-DFAST_THRESH=40") !=0)
|
||||
std::cout << " Error building: " << program->getBuildInfo<CL_PROGRAM_BUILD_STATUS>(device)<<'\n'
|
||||
<<program->getBuildInfo<CL_PROGRAM_BUILD_LOG>(device) << '\n';
|
||||
queue=new cl::CommandQueue(*context,device,0,NULL);
|
||||
//296.724480,395.357280,317.877600,238.752640,1.016870
|
||||
std::string options="-DFAST_THRESH=40 -DPATCH_SIZE=2 -DPATCH_HALFSIZE=1 -DF_X="+ std::to_string((float)296.724480) +
|
||||
" -DF_Y="+std::to_string((float)395.357280)+
|
||||
" -DC_X="+std::to_string((float)317.877600)+
|
||||
" -DC_Y="+std::to_string((float)238.752640)+
|
||||
" -DS="+std::to_string((float)1.016870);
|
||||
if(program->build({ *device },options.c_str()) !=0)
|
||||
std::cout << " Error building: " << program->getBuildInfo<CL_PROGRAM_BUILD_STATUS>(*device)<<'\n'
|
||||
<<program->getBuildInfo<CL_PROGRAM_BUILD_LOG>(*device) << '\n';
|
||||
queue=new cl::CommandQueue(*context,*device,CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,NULL);
|
||||
}
|
||||
opencl::~opencl() {
|
||||
delete context;
|
||||
delete device;
|
||||
}
|
||||
void opencl::clear_buf() {
|
||||
queue->finish();
|
||||
queue->flush();
|
||||
_kernels.clear();
|
||||
delete program;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user