T2345: Replace instances of NULL with nullptr

The following changes have been applied to src and lib folders:
regex replace: ([^"_])NULL ⇒ \1nullptr (8968 chgs in src, 1153 in lib)
Manually find/change: (void \*) nullptr ⇒ nullptr (1 case)
regex find: ".*?nullptr.*?"
  Manually ~14 cases back to "NULL" in src, ~2 in lib
  regex finds a few false positive where nullptr appears between two
  strings in a function call
This commit is contained in:
Anne Gunn
2020-09-11 07:39:46 -06:00
parent 101d39142e
commit f1ef7d85a8
1217 changed files with 8531 additions and 8531 deletions

View File

@ -261,7 +261,7 @@ class UCL_Device {
/// Select the platform that has accelerators (for compatibility with OpenCL)
inline int set_platform_accelerator(int pid=-1) { return UCL_SUCCESS; }
inline int load_module(const void* program, hipModule_t& module, std::string *log=NULL){
inline int load_module(const void* program, hipModule_t& module, std::string *log=nullptr){
auto it = _loaded_modules.emplace(program, hipModule_t());
if(!it.second){
module = it.first->second;
@ -281,7 +281,7 @@ class UCL_Device {
hipError_t err=hipModuleLoadDataEx(&module,program,num_opts, options,(void **)values);
if (log!=NULL)
if (log!=nullptr)
*log=std::string(clog);
if (err != hipSuccess) {

View File

@ -30,7 +30,7 @@ class UCL_Program {
public:
inline UCL_Program(UCL_Device &device) { _device_ptr = &device; _cq=device.cq(); }
inline UCL_Program(UCL_Device &device, const void *program,
const char *flags="", std::string *log=NULL) {
const char *flags="", std::string *log=nullptr) {
_device_ptr = &device; _cq=device.cq();
init(device);
load_string(program,flags,log);
@ -46,7 +46,7 @@ class UCL_Program {
inline void clear() { }
/// Load a program from a file and compile with flags
inline int load(const char *filename, const char *flags="", std::string *log=NULL) {
inline int load(const char *filename, const char *flags="", std::string *log=nullptr) {
std::ifstream in(filename);
if (!in || in.is_open()==false) {
#ifndef UCL_NO_EXIT
@ -64,7 +64,7 @@ class UCL_Program {
}
/// Load a program from a string and compile with flags
inline int load_string(const void *program, const char *flags="", std::string *log=NULL) {
inline int load_string(const void *program, const char *flags="", std::string *log=nullptr) {
return _device_ptr->load_module(program, _module, log);
}
@ -263,7 +263,7 @@ class UCL_Kernel {
};
const auto res = hipModuleLaunchKernel(_kernel,_num_blocks[0],_num_blocks[1],
_num_blocks[2],_block_size[0],_block_size[1],
_block_size[2],0,_cq, NULL, config);
_block_size[2],0,_cq, nullptr, config);
CU_SAFE_CALL(res);
//#endif
}

View File

@ -55,7 +55,7 @@ inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n,
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocWriteCombined);
else
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocDefault);
if (err!=hipSuccess || *(mat.host_ptr())==NULL)
if (err!=hipSuccess || *(mat.host_ptr())==nullptr)
return UCL_MEMORY_ERROR;
mat.cq()=cm.cq();
return UCL_SUCCESS;
@ -71,7 +71,7 @@ inline int _host_alloc(mat_type &mat, UCL_Device &dev, const size_t n,
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocWriteCombined);
else
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocDefault);
if (err!=hipSuccess || *(mat.host_ptr())==NULL)
if (err!=hipSuccess || *(mat.host_ptr())==nullptr)
return UCL_MEMORY_ERROR;
mat.cq()=dev.cq();
return UCL_SUCCESS;
@ -97,7 +97,7 @@ inline int _host_resize(mat_type &mat, const size_t n) {
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocWriteCombined);
else
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocDefault);
if (err!=hipSuccess || *(mat.host_ptr())==NULL)
if (err!=hipSuccess || *(mat.host_ptr())==nullptr)
return UCL_MEMORY_ERROR;
return UCL_SUCCESS;
}

View File

@ -99,7 +99,7 @@ class UCL_Texture {
else
CU_SAFE_CALL(hipTexRefSetFormat(_tex,HIP_AD_FORMAT_SIGNED_INT32,numel*2));
}
CU_SAFE_CALL(hipTexRefSetAddress(NULL, _tex, vec.cbegin(), vec.numel()*vec.element_size()));
CU_SAFE_CALL(hipTexRefSetAddress(nullptr, _tex, vec.cbegin(), vec.numel()*vec.element_size()));
#else
void* data_ptr = (void*)vec.cbegin();
CU_SAFE_CALL(hipMemcpyHtoD(hipDeviceptr_t(_device_ptr_to_global_var), &data_ptr, sizeof(void*)));

View File

@ -41,7 +41,7 @@ class UCL_Program {
public:
inline UCL_Program(UCL_Device &device) { _cq=device.cq(); }
inline UCL_Program(UCL_Device &device, const void *program,
const char *flags="", std::string *log=NULL) {
const char *flags="", std::string *log=nullptr) {
_cq=device.cq();
init(device);
load_string(program,flags,log);
@ -58,7 +58,7 @@ class UCL_Program {
/// Load a program from a file and compile with flags
inline int load(const char *filename, const char *flags="",
std::string *log=NULL) {
std::string *log=nullptr) {
std::ifstream in(filename);
if (!in || in.is_open()==false) {
#ifndef UCL_NO_EXIT
@ -77,7 +77,7 @@ class UCL_Program {
/// Load a program from a string and compile with flags
inline int load_string(const void *program, const char *flags="",
std::string *log=NULL) {
std::string *log=nullptr) {
if (std::string(flags)=="BINARY")
return load_binary((const char *)program);
const unsigned int num_opts=2;
@ -95,7 +95,7 @@ class UCL_Program {
CUresult err=cuModuleLoadDataEx(&_module,program,num_opts,
options,(void **)values);
if (log!=NULL)
if (log!=nullptr)
*log=std::string(clog);
if (err != CUDA_SUCCESS) {
@ -361,7 +361,7 @@ class UCL_Kernel {
#if CUDA_VERSION >= 4000
CU_SAFE_CALL(cuLaunchKernel(_kernel,_num_blocks[0],_num_blocks[1],
_num_blocks[2],_block_size[0],_block_size[1],
_block_size[2],0,_cq,_kernel_args,NULL));
_block_size[2],0,_cq,_kernel_args,nullptr));
#else
CU_SAFE_CALL(cuParamSetSize(_kernel,_param_size));
CU_SAFE_CALL(cuLaunchGridAsync(_kernel,_num_blocks[0],_num_blocks[1],_cq));

View File

@ -55,7 +55,7 @@ inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n,
err=cuMemHostAlloc((void **)mat.host_ptr(),n,CU_MEMHOSTALLOC_WRITECOMBINED);
else
err=cuMemAllocHost((void **)mat.host_ptr(),n);
if (err!=CUDA_SUCCESS || *(mat.host_ptr())==NULL)
if (err!=CUDA_SUCCESS || *(mat.host_ptr())==nullptr)
return UCL_MEMORY_ERROR;
mat.cq()=cm.cq();
return UCL_SUCCESS;
@ -71,7 +71,7 @@ inline int _host_alloc(mat_type &mat, UCL_Device &dev, const size_t n,
err=cuMemHostAlloc((void **)mat.host_ptr(),n,CU_MEMHOSTALLOC_WRITECOMBINED);
else
err=cuMemAllocHost((void **)mat.host_ptr(),n);
if (err!=CUDA_SUCCESS || *(mat.host_ptr())==NULL)
if (err!=CUDA_SUCCESS || *(mat.host_ptr())==nullptr)
return UCL_MEMORY_ERROR;
mat.cq()=dev.cq();
return UCL_SUCCESS;
@ -97,7 +97,7 @@ inline int _host_resize(mat_type &mat, const size_t n) {
err=cuMemHostAlloc((void **)mat.host_ptr(),n,CU_MEMHOSTALLOC_WRITECOMBINED);
else
err=cuMemAllocHost((void **)mat.host_ptr(),n);
if (err!=CUDA_SUCCESS || *(mat.host_ptr())==NULL)
if (err!=CUDA_SUCCESS || *(mat.host_ptr())==nullptr)
return UCL_MEMORY_ERROR;
return UCL_SUCCESS;
}

View File

@ -80,7 +80,7 @@ class UCL_Texture {
#ifdef UCL_DEBUG
assert(numel!=0 && numel<5);
#endif
CU_SAFE_CALL(cuTexRefSetAddress(NULL, _tex, vec.cbegin(),
CU_SAFE_CALL(cuTexRefSetAddress(nullptr, _tex, vec.cbegin(),
vec.numel()*vec.element_size()));
if (vec.element_size()==sizeof(float))
CU_SAFE_CALL(cuTexRefSetFormat(_tex, CU_AD_FORMAT_FLOAT, numel));

View File

@ -360,7 +360,7 @@ int UCL_Device::set_platform(int pid) {
// --- Get Number of Devices
cl_uint n;
errorv=clGetDeviceIDs(_cl_platform,CL_DEVICE_TYPE_ALL,0,NULL,&n);
errorv=clGetDeviceIDs(_cl_platform,CL_DEVICE_TYPE_ALL,0,nullptr,&n);
_num_devices=n;
if (errorv!=CL_SUCCESS || _num_devices==0) {
_num_devices=0;
@ -385,7 +385,7 @@ int UCL_Device::create_context() {
props[0]=CL_CONTEXT_PLATFORM;
props[1]=_platform;
props[2]=0;
_context=clCreateContext(0,1,&_cl_device,NULL,NULL,&errorv);
_context=clCreateContext(0,1,&_cl_device,nullptr,nullptr,&errorv);
if (errorv!=CL_SUCCESS) {
#ifndef UCL_NO_EXIT
std::cerr << "UCL Error: Could not access accelerator number " << _device
@ -404,36 +404,36 @@ void UCL_Device::add_properties(cl_device_id device_list) {
char buffer[1024];
cl_bool ans_bool;
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_NAME,1024,buffer,NULL));
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_NAME,1024,buffer,nullptr));
op.name=buffer;
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_GLOBAL_MEM_SIZE,
sizeof(op.global_mem),&op.global_mem,NULL));
sizeof(op.global_mem),&op.global_mem,nullptr));
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_LOCAL_MEM_SIZE,
sizeof(op.shared_mem),&op.shared_mem,NULL));
sizeof(op.shared_mem),&op.shared_mem,nullptr));
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE,
sizeof(op.const_mem),&op.const_mem,NULL));
sizeof(op.const_mem),&op.const_mem,nullptr));
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_TYPE,
sizeof(op.device_type),&op.device_type,NULL));
sizeof(op.device_type),&op.device_type,nullptr));
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_MAX_COMPUTE_UNITS,
sizeof(op.compute_units),&op.compute_units,
NULL));
nullptr));
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_MAX_CLOCK_FREQUENCY,
sizeof(op.clock),&op.clock,NULL));
sizeof(op.clock),&op.clock,nullptr));
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_MAX_WORK_GROUP_SIZE,
sizeof(op.work_group_size),&op.work_group_size,
NULL));
nullptr));
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_MAX_WORK_ITEM_SIZES,
3*sizeof(op.work_item_size[0]),op.work_item_size,
NULL));
nullptr));
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_MEM_BASE_ADDR_ALIGN,
sizeof(cl_uint),&op.alignment,NULL));
sizeof(cl_uint),&op.alignment,nullptr));
op.alignment/=8;
// Determine if double precision is supported
cl_uint double_width;
CL_SAFE_CALL(clGetDeviceInfo(device_list,
CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
sizeof(double_width),&double_width,NULL));
sizeof(double_width),&double_width,nullptr));
if (double_width==0)
op.double_precision=false;
else
@ -441,13 +441,13 @@ void UCL_Device::add_properties(cl_device_id device_list) {
CL_SAFE_CALL(clGetDeviceInfo(device_list,
CL_DEVICE_PROFILING_TIMER_RESOLUTION,
sizeof(size_t),&op.timer_resolution,NULL));
sizeof(size_t),&op.timer_resolution,nullptr));
op.ecc_support=false;
CL_SAFE_CALL(clGetDeviceInfo(device_list,
CL_DEVICE_ERROR_CORRECTION_SUPPORT,
sizeof(ans_bool),&ans_bool,NULL));
sizeof(ans_bool),&ans_bool,nullptr));
if (ans_bool==CL_TRUE)
op.ecc_support=true;
@ -459,7 +459,7 @@ void UCL_Device::add_properties(cl_device_id device_list) {
#ifdef CL_VERSION_1_2
size_t return_bytes;
CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_OPENCL_C_VERSION,1024,
buffer,NULL));
buffer,nullptr));
op.c_version=buffer;
cl_device_partition_property pinfo[4];
@ -479,7 +479,7 @@ void UCL_Device::add_properties(cl_device_id device_list) {
CL_SAFE_CALL(clGetDeviceInfo(device_list,
CL_DEVICE_PARTITION_MAX_SUB_DEVICES,
sizeof(cl_uint),&op.max_sub_devices,NULL));
sizeof(cl_uint),&op.max_sub_devices,nullptr));
#endif
_properties.push_back(op);
@ -489,15 +489,15 @@ std::string UCL_Device::platform_name() {
char info[1024];
CL_SAFE_CALL(clGetPlatformInfo(_cl_platform,CL_PLATFORM_VENDOR,1024,info,
NULL));
nullptr));
std::string ans=std::string(info)+' ';
CL_SAFE_CALL(clGetPlatformInfo(_cl_platform,CL_PLATFORM_NAME,1024,info,
NULL));
nullptr));
ans+=std::string(info)+' ';
CL_SAFE_CALL(clGetPlatformInfo(_cl_platform,CL_PLATFORM_VERSION,1024,info,
NULL));
nullptr));
ans+=std::string(info);
return ans;

View File

@ -42,7 +42,7 @@ class UCL_Program {
inline UCL_Program() : _init_done(false) {}
inline UCL_Program(UCL_Device &device) : _init_done(false) { init(device); }
inline UCL_Program(UCL_Device &device, const void *program,
const char *flags="", std::string *log=NULL) :
const char *flags="", std::string *log=nullptr) :
_init_done(false) {
init(device);
load_string(program,flags,log);
@ -74,7 +74,7 @@ class UCL_Program {
/// Load a program from a file and compile with flags
inline int load(const char *filename, const char *flags="",
std::string *log=NULL) {
std::string *log=nullptr) {
std::ifstream in(filename);
if (!in || in.is_open()==false) {
#ifndef UCL_NO_EXIT
@ -93,29 +93,29 @@ class UCL_Program {
/// Load a program from a string and compile with flags
inline int load_string(const void *program, const char *flags="",
std::string *log=NULL) {
std::string *log=nullptr) {
cl_int error_flag;
const char *prog=(const char *)program;
_program=clCreateProgramWithSource(_context,1,&prog,NULL,&error_flag);
_program=clCreateProgramWithSource(_context,1,&prog,nullptr,&error_flag);
CL_CHECK_ERR(error_flag);
error_flag = clBuildProgram(_program,1,&_device,flags,NULL,NULL);
error_flag = clBuildProgram(_program,1,&_device,flags,nullptr,nullptr);
if (error_flag!=-11)
CL_CHECK_ERR(error_flag);
cl_build_status build_status;
CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,
CL_PROGRAM_BUILD_STATUS,
sizeof(cl_build_status),&build_status,
NULL));
nullptr));
if (build_status != CL_SUCCESS || log!=NULL) {
if (build_status != CL_SUCCESS || log!=nullptr) {
size_t ms;
CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,CL_PROGRAM_BUILD_LOG,0,
NULL, &ms));
nullptr, &ms));
char *build_log = new char[ms];
CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,CL_PROGRAM_BUILD_LOG,ms,
build_log, NULL));
build_log, nullptr));
if (log!=NULL)
if (log!=nullptr)
*log=std::string(build_log);
if (build_status != CL_SUCCESS) {
@ -363,7 +363,7 @@ inline int UCL_Kernel::set_function(UCL_Program &program, const char *function)
_kernel_info_name=function;
cl_uint nargs;
CL_SAFE_CALL(clGetKernelInfo(_kernel,CL_KERNEL_NUM_ARGS,sizeof(cl_uint),
&nargs,NULL));
&nargs,nullptr));
_kernel_info_nargs=nargs;
#ifdef NOT_TEST_CL_VERSION_1_2
char tname[256];
@ -380,8 +380,8 @@ inline int UCL_Kernel::set_function(UCL_Program &program, const char *function)
}
void UCL_Kernel::run() {
CL_SAFE_CALL(clEnqueueNDRangeKernel(_cq,_kernel,_dimensions,NULL,
_num_blocks,_block_size,0,NULL,NULL));
CL_SAFE_CALL(clEnqueueNDRangeKernel(_cq,_kernel,_dimensions,nullptr,
_num_blocks,_block_size,0,nullptr,nullptr));
}
} // namespace

View File

@ -58,7 +58,7 @@ inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n,
cl_int error_flag;
cl_context context;
CL_SAFE_CALL(clGetMemObjectInfo(cm.cbegin(),CL_MEM_CONTEXT,sizeof(context),
&context,NULL));
&context,nullptr));
cl_mem_flags buffer_perm;
cl_map_flags map_perm;
@ -103,12 +103,12 @@ inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n,
map_perm=CL_MAP_READ | CL_MAP_WRITE;
}
mat.cbegin()=clCreateBuffer(context,buffer_perm,n,NULL,&error_flag);
mat.cbegin()=clCreateBuffer(context,buffer_perm,n,nullptr,&error_flag);
if (error_flag != CL_SUCCESS)
return UCL_MEMORY_ERROR;
*mat.host_ptr() = (typename mat_type::data_type*)
clEnqueueMapBuffer(cm.cq(),mat.cbegin(),CL_TRUE,
map_perm,0,n,0,NULL,NULL,NULL);
map_perm,0,n,0,nullptr,nullptr,nullptr);
mat.cq()=cm.cq();
CL_SAFE_CALL(clRetainCommandQueue(mat.cq()));
@ -120,10 +120,10 @@ inline int _host_view(mat_type &mat, copy_type &cm, const size_t n) {
cl_int error_flag;
cl_context context;
CL_SAFE_CALL(clGetMemObjectInfo(cm.cbegin(),CL_MEM_CONTEXT,sizeof(context),
&context,NULL));
&context,nullptr));
cl_mem_flags orig_flags;
CL_SAFE_CALL(clGetMemObjectInfo(cm.cbegin(),CL_MEM_FLAGS,sizeof(orig_flags),
&orig_flags,NULL));
&orig_flags,nullptr));
orig_flags=orig_flags & ~CL_MEM_ALLOC_HOST_PTR;
mat.cbegin()=clCreateBuffer(context, CL_MEM_USE_HOST_PTR | orig_flags, n,
@ -159,13 +159,13 @@ inline int _host_alloc(mat_type &mat, UCL_Device &dev, const size_t n,
}
cl_int error_flag;
mat.cbegin()=clCreateBuffer(dev.context(),buffer_perm,n,NULL,&error_flag);
mat.cbegin()=clCreateBuffer(dev.context(),buffer_perm,n,nullptr,&error_flag);
if (error_flag != CL_SUCCESS)
return UCL_MEMORY_ERROR;
*mat.host_ptr() = (typename mat_type::data_type*)
clEnqueueMapBuffer(dev.cq(),mat.cbegin(),CL_TRUE,
map_perm,0,n,0,NULL,NULL,NULL);
map_perm,0,n,0,nullptr,nullptr,nullptr);
mat.cq()=dev.cq();
CL_SAFE_CALL(clRetainCommandQueue(mat.cq()));
return UCL_SUCCESS;
@ -194,10 +194,10 @@ inline int _host_resize(mat_type &mat, const size_t n) {
cl_int error_flag;
cl_context context;
CL_SAFE_CALL(clGetMemObjectInfo(mat.cbegin(),CL_MEM_CONTEXT,sizeof(context),
&context,NULL));
&context,nullptr));
cl_mem_flags buffer_perm;
CL_SAFE_CALL(clGetMemObjectInfo(mat.cbegin(),CL_MEM_FLAGS,sizeof(buffer_perm),
&buffer_perm,NULL));
&buffer_perm,nullptr));
CL_DESTRUCT_CALL(clReleaseMemObject(mat.cbegin()));
@ -209,12 +209,12 @@ inline int _host_resize(mat_type &mat, const size_t n) {
else
map_perm=CL_MAP_READ | CL_MAP_WRITE;
mat.cbegin()=clCreateBuffer(context,buffer_perm,n,NULL,&error_flag);
mat.cbegin()=clCreateBuffer(context,buffer_perm,n,nullptr,&error_flag);
if (error_flag != CL_SUCCESS)
return UCL_MEMORY_ERROR;
*mat.host_ptr() = (typename mat_type::data_type*)
clEnqueueMapBuffer(mat.cq(),mat.cbegin(),CL_TRUE,
map_perm,0,n,0,NULL,NULL,NULL);
map_perm,0,n,0,nullptr,nullptr,nullptr);
return UCL_SUCCESS;
}
@ -229,7 +229,7 @@ inline int _device_alloc(mat_type &mat, copy_type &cm, const size_t n,
cl_context context;
CL_SAFE_CALL(clGetMemObjectInfo(cm.cbegin(),CL_MEM_CONTEXT,sizeof(context),
&context,NULL));
&context,nullptr));
cl_mem_flags flag;
if (kind==UCL_READ_WRITE)
flag=CL_MEM_READ_WRITE;
@ -247,7 +247,7 @@ inline int _device_alloc(mat_type &mat, copy_type &cm, const size_t n,
#endif
else
assert(0==1);
mat.cbegin()=clCreateBuffer(context,flag,n,NULL,&error_flag);
mat.cbegin()=clCreateBuffer(context,flag,n,nullptr,&error_flag);
if (error_flag != CL_SUCCESS)
return UCL_MEMORY_ERROR;
mat.cq()=cm.cq();
@ -276,7 +276,7 @@ inline int _device_alloc(mat_type &mat, UCL_Device &dev, const size_t n,
#endif
else
assert(0==1);
mat.cbegin()=clCreateBuffer(dev.context(),flag,n,NULL,
mat.cbegin()=clCreateBuffer(dev.context(),flag,n,nullptr,
&error_flag);
if (error_flag != CL_SUCCESS)
return UCL_MEMORY_ERROR;
@ -321,7 +321,7 @@ inline int _device_resize(mat_type &mat, const size_t n) {
cl_context context;
CL_SAFE_CALL(clGetMemObjectInfo(mat.cbegin(),CL_MEM_CONTEXT,sizeof(context),
&context,NULL));
&context,nullptr));
CL_DESTRUCT_CALL(clReleaseMemObject(mat.cbegin()));
cl_mem_flags flag;
@ -341,7 +341,7 @@ inline int _device_resize(mat_type &mat, const size_t n) {
#endif
else
assert(0==1);
mat.cbegin()=clCreateBuffer(context,flag,n,NULL,&error_flag);
mat.cbegin()=clCreateBuffer(context,flag,n,nullptr,&error_flag);
if (error_flag != CL_SUCCESS)
return UCL_MEMORY_ERROR;
return UCL_SUCCESS;
@ -359,7 +359,7 @@ inline int _device_resize(mat_type &mat, const size_t rows,
cl_context context;
CL_SAFE_CALL(clGetMemObjectInfo(mat.cbegin(),CL_MEM_CONTEXT,sizeof(context),
&context,NULL));
&context,nullptr));
CL_DESTRUCT_CALL(clReleaseMemObject(mat.cbegin()));
cl_mem_flags flag;
@ -379,7 +379,7 @@ inline int _device_resize(mat_type &mat, const size_t rows,
#endif
else
assert(0==1);
mat.cbegin()=clCreateBuffer(context,flag,pitch*rows,NULL,&error_flag);
mat.cbegin()=clCreateBuffer(context,flag,pitch*rows,nullptr,&error_flag);
if (error_flag != CL_SUCCESS)
return UCL_MEMORY_ERROR;
return UCL_SUCCESS;
@ -395,21 +395,21 @@ inline void _host_zero(void *ptr, const size_t n) {
inline void _ocl_build(cl_program &program, cl_device_id &device,
const char* options = "") {
clBuildProgram(program,1,&device,options,NULL,NULL);
clBuildProgram(program,1,&device,options,nullptr,nullptr);
cl_build_status build_status;
CL_SAFE_CALL(clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS,
sizeof(cl_build_status),&build_status,
NULL));
nullptr));
if (build_status == CL_SUCCESS)
return;
size_t ms;
CL_SAFE_CALL(clGetProgramBuildInfo(program, device,CL_PROGRAM_BUILD_LOG, 0,
NULL, &ms));
nullptr, &ms));
char *build_log = new char[ms];
CL_SAFE_CALL(clGetProgramBuildInfo(program,device,CL_PROGRAM_BUILD_LOG,ms,
build_log, NULL));
build_log, nullptr));
std::cerr << std::endl
<< "----------------------------------------------------------\n"
@ -426,7 +426,7 @@ inline void _ocl_kernel_from_source(cl_context &context, cl_device_id &device,
cl_int error_flag;
cl_program program=clCreateProgramWithSource(context,lines,source,
NULL,&error_flag);
nullptr,&error_flag);
CL_CHECK_ERR(error_flag);
_ocl_build(program,device,options);
kernel=clCreateKernel(program,function,&error_flag);
@ -444,15 +444,15 @@ inline void _device_zero(mat_type &mat, const size_t n, command_queue &cq) {
#ifdef UCL_CL_ZERO
cl_int zeroint=0;
CL_SAFE_CALL(clEnqueueFillBuffer(cq,mat.begin(),&zeroint,sizeof(cl_int),
mat.byteoff(),n,0,NULL,NULL));
mat.byteoff(),n,0,nullptr,nullptr));
#else
cl_context context;
CL_SAFE_CALL(clGetMemObjectInfo(mat.cbegin(),CL_MEM_CONTEXT,sizeof(context),
&context,NULL));
&context,nullptr));
cl_device_id device;
CL_SAFE_CALL(clGetContextInfo(context,CL_CONTEXT_DEVICES,
sizeof(cl_device_id),&device,NULL));
sizeof(cl_device_id),&device,nullptr));
const char * szero[3]={
"#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n",
@ -585,7 +585,7 @@ template <> struct _ucl_memcpy<1,0> {
std::cerr << "UCL_COPY 1NS\n";
#endif
CL_SAFE_CALL(clEnqueueReadBuffer(cq,src.cbegin(),block,src_offset,n,
dst.begin(),0,NULL,NULL));
dst.begin(),0,nullptr,nullptr));
}
template <class p1, class p2>
static inline void mc(p1 &dst, const size_t dpitch, const p2 &src,
@ -607,13 +607,13 @@ template <> struct _ucl_memcpy<1,0> {
src.cols()==cols/src.element_size())
CL_SAFE_CALL(clEnqueueReadBuffer(cq,src.cbegin(),block,src_offset,
spitch*rows,
(char *)dst.begin()+dst_offset,0,NULL,
NULL));
(char *)dst.begin()+dst_offset,0,nullptr,
nullptr));
else
for (size_t i=0; i<rows; i++) {
CL_SAFE_CALL(clEnqueueReadBuffer(cq,src.cbegin(),block,src_offset,cols,
(char *)dst.begin()+dst_offset,0,NULL,
NULL));
(char *)dst.begin()+dst_offset,0,nullptr,
nullptr));
src_offset+=spitch;
dst_offset+=dpitch;
}
@ -637,7 +637,7 @@ template <> struct _ucl_memcpy<0,1> {
std::cerr << "UCL_COPY 3NS\n";
#endif
CL_SAFE_CALL(clEnqueueWriteBuffer(cq,dst.cbegin(),block,dst_offset,n,
src.begin(),0,NULL,NULL));
src.begin(),0,nullptr,nullptr));
}
template <class p1, class p2>
static inline void mc(p1 &dst, const size_t dpitch, const p2 &src,
@ -659,13 +659,13 @@ template <> struct _ucl_memcpy<0,1> {
src.cols()==cols/src.element_size())
CL_SAFE_CALL(clEnqueueWriteBuffer(cq,dst.cbegin(),block,dst_offset,
spitch*rows,
(char *)src.begin()+src_offset,0,NULL,
NULL));
(char *)src.begin()+src_offset,0,nullptr,
nullptr));
else
for (size_t i=0; i<rows; i++) {
CL_SAFE_CALL(clEnqueueWriteBuffer(cq,dst.cbegin(),block,dst_offset,cols,
(char *)src.begin()+src_offset,0,NULL,
NULL));
(char *)src.begin()+src_offset,0,nullptr,
nullptr));
src_offset+=spitch;
dst_offset+=dpitch;
}
@ -680,7 +680,7 @@ template <int mem1, int mem2> struct _ucl_memcpy {
const size_t dst_offset, const size_t src_offset) {
if (src.cbegin()!=dst.cbegin() || src_offset!=dst_offset) {
CL_SAFE_CALL(clEnqueueCopyBuffer(cq,src.cbegin(),dst.cbegin(),src_offset,
dst_offset,n,0,NULL,NULL));
dst_offset,n,0,nullptr,nullptr));
#ifdef UCL_DBG_MEM_TRACE
std::cerr << "UCL_COPY 6NS\n";
#endif
@ -704,13 +704,13 @@ template <int mem1, int mem2> struct _ucl_memcpy {
if (spitch==dpitch && dst.cols()==src.cols() &&
src.cols()==cols/src.element_size())
CL_SAFE_CALL(clEnqueueCopyBuffer(cq,src.cbegin(),dst.cbegin(),src_offset,
dst_offset,spitch*rows,0,NULL,NULL));
dst_offset,spitch*rows,0,nullptr,nullptr));
else
for (size_t i=0; i<rows; i++) {
CL_SAFE_CALL(clEnqueueCopyBuffer(cq,src.cbegin(),dst.cbegin(),
src_offset,dst_offset,cols,0,
NULL,NULL));
nullptr,nullptr));
src_offset+=spitch;
dst_offset+=dpitch;
}

View File

@ -28,7 +28,7 @@
#include "ocl_device.h"
#ifdef CL_VERSION_1_2
#define UCL_OCL_MARKER(cq,event) clEnqueueMarkerWithWaitList(cq,0,NULL,event)
#define UCL_OCL_MARKER(cq,event) clEnqueueMarkerWithWaitList(cq,0,nullptr,event)
#else
#define UCL_OCL_MARKER clEnqueueMarker
#endif
@ -117,10 +117,10 @@ class UCL_Timer {
CL_SAFE_CALL(clWaitForEvents(1,&stop_event));
CL_SAFE_CALL(clGetEventProfilingInfo(stop_event,
CL_PROFILING_COMMAND_START,
sizeof(cl_ulong), &tend, NULL));
sizeof(cl_ulong), &tend, nullptr));
CL_SAFE_CALL(clGetEventProfilingInfo(start_event,
CL_PROFILING_COMMAND_END,
sizeof(cl_ulong), &tstart, NULL));
sizeof(cl_ulong), &tstart, nullptr));
clReleaseEvent(start_event);
clReleaseEvent(stop_event);
has_measured_time = false;

View File

@ -75,10 +75,10 @@ class UCL_BaseMat {
#ifdef _OCL_MAT
cl_device_id device;
CL_SAFE_CALL(clGetCommandQueueInfo(_cq,CL_QUEUE_DEVICE,
sizeof(cl_device_id),&device,NULL));
sizeof(cl_device_id),&device,nullptr));
cl_device_type device_type;
CL_SAFE_CALL(clGetDeviceInfo(device,CL_DEVICE_TYPE,
sizeof(device_type),&device_type,NULL));
sizeof(device_type),&device_type,nullptr));
return _shared_mem_device(device_type);
#else
return false;

View File

@ -438,7 +438,7 @@ class UCL_D_Vec : public UCL_BaseMat {
(*_tex_ptr).addressMode[1] = cudaAddressModeClamp;
(*_tex_ptr).filterMode = cudaFilterModePoint;
(*_tex_ptr).normalized = false;
CUDA_SAFE_CALL(cudaBindTexture(NULL,_tex_ptr,_array,&_channel));
CUDA_SAFE_CALL(cudaBindTexture(nullptr,_tex_ptr,_array,&_channel));
}
/// For CUDA-RT, unbind texture
inline void unbind() { CUDA_SAFE_CALL(cudaUnbindTexture(_tex_ptr)); }