Skip to content

Commit d547628

Browse files
committed
l_copy_and_adjust_arguments_for_device: constify variables
This improves readability and potentially avoids future mistakes. Signed-off-by: Peter Colberg <peter.colberg@intel.com>
1 parent 35e61a6 commit d547628

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/acl_kernel.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,8 +2755,8 @@ l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
27552755
// with a base address of 0
27562756

27572757
// Need to determine sizeof device's pointers.
2758-
cl_uint dev_local_ptr_size = 4; // Always.
2759-
cl_uint dev_global_ptr_size = device->address_bits >> 3;
2758+
const cl_uint dev_local_ptr_size = 4; // Always.
2759+
const cl_uint dev_global_ptr_size = device->address_bits >> 3;
27602760

27612761
// Bump allocator pointer for each local aspace
27622762
// Maps the aspace ID to the next available local memory address.
@@ -2790,7 +2790,7 @@ l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
27902790
printf("local");
27912791
#endif
27922792

2793-
unsigned this_aspace = kernel->accel_def->iface.args[iarg].aspace_number;
2793+
const unsigned int this_aspace = kernel->accel_def->iface.args[iarg].aspace_number;
27942794

27952795
// This arg is a pointer to __local.
27962796
cl_ulong local_size = 0;
@@ -2812,7 +2812,7 @@ l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
28122812

28132813
// On the emulator, the argument size of a pipe (which is a mem object) is
28142814
// 0. Since we copy in 0 bytes, we should read out 0 bytes.
2815-
size_t copy_sz = (arg_info->size == 0) ? arg_info->size : sizeof(cl_mem);
2815+
const size_t copy_sz = (arg_info->size == 0) ? arg_info->size : sizeof(cl_mem);
28162816
safe_memcpy(&mem_obj, &(kernel->arg_value[host_idx]), copy_sz,
28172817
sizeof(cl_mem), copy_sz);
28182818

@@ -2832,7 +2832,7 @@ l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
28322832
value for the argument declared as a pointer to global or constant
28332833
memory in the kernel."
28342834
*/
2835-
cl_ulong null_ptr = 0;
2835+
const cl_ulong null_ptr = 0;
28362836
safe_memcpy(buf + device_idx, &null_ptr, dev_global_ptr_size,
28372837
dev_global_ptr_size, dev_global_ptr_size);
28382838
// Shared physical memory:
@@ -2902,7 +2902,7 @@ l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
29022902

29032903
// copy the address of the reserved allocation into the invocation
29042904
// image:
2905-
void *mem_addr =
2905+
const void *mem_addr =
29062906
mem_obj->reserved_allocations[needed_physical_id][needed_mem_id]
29072907
->range.begin;
29082908
safe_memcpy(buf + device_idx, &mem_addr, dev_global_ptr_size,
@@ -2911,7 +2911,7 @@ l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
29112911
if (memory_migration->num_mem_objects == 0) {
29122912
// First time allocation, 128 was chosen because previously, number of
29132913
// kernel arguments were set to an hardcoded limit of 128
2914-
const unsigned initial_alloc = 128;
2914+
const unsigned int initial_alloc = 128;
29152915

29162916
memory_migration->src_mem_list =
29172917
(acl_mem_migrate_wrapper_t *)acl_malloc(
@@ -2923,7 +2923,7 @@ l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
29232923
memory_migration->num_alloc = initial_alloc;
29242924
} else if (memory_migration->num_mem_objects >=
29252925
memory_migration->num_alloc) {
2926-
const unsigned next_alloc = memory_migration->num_alloc * 2;
2926+
const unsigned int next_alloc = memory_migration->num_alloc * 2;
29272927
// check for overflow, num_alloc is a 32-bit unsigned integer and
29282928
// unsigned integer overflow is defined behaviour
29292929
if (next_alloc < memory_migration->num_alloc)

0 commit comments

Comments
 (0)