I am testing the clImportMemoryARM function of opencl. ## env- android C++ - CPU MTK G99- GPU: Mali-G57 MC2 r0p1- EXTENSIONS: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp16 cl_khr_icd cl_khr_egl_image cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_subgroups cl_khr_subgroup_extended_types cl_khr_subgroup_non_uniform_vote cl_khr_subgroup_ballot cl_khr_il_program cl_khr_priority_hints cl_khr_create_command_queue cl_khr_spirv_no_integer_wrap_decoration cl_khr_extended_versioning cl_khr_device_uuid cl_arm_core_id cl_arm_printf cl_arm_non_uniform_work_group_size cl_arm_import_memory cl_arm_import_memory_dma_buf cl_arm_import_memory_host cl_arm_import_memory_protected cl_arm_import_memory_android_hardware_buffer cl_arm_integer_dot_product_int8 cl_arm_integer_dot_product_accumulate_int8 cl_arm_integer_dot_product_accumulate_saturate_int8 cl_arm_job_slot_selection cl_arm_scheduling_controls cl_arm_controlled_kernel_termination cl_ext_cxx_for_opencl
## code``` cl_int error; cl_uint num_devices; cl_device_id devices[1]; cl_platform_id platforms[1]; clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, 1, devices, &num_devices); cl_context context = clCreateContext( NULL, 1, devices, NULL, NULL, &error ); cl_command_queue queue = clCreateCommandQueue(context, devices[0], 0, NULL);
int Length = 1024; char *allocptr = (char *)malloc( Length*sizeof(char));
const cl_import_properties_arm importProperties[] = { CL_IMPORT_TYPE_ARM, CL_IMPORT_TYPE_HOST_ARM, 0 }; cl_mem buffer = clImportMemoryARM( context, CL_MEM_READ_WRITE, importProperties, allocptr, Length*sizeof(char), &error );```
when length is 1024,sometimes `clImportMemoryARM` return error -6 which means `CL_OUT_OF_HOST_MEMORY`,when I set length = 1024x512x2 which fellows [khronos/cl_arm_import_memory.txt](registry.khronos.org/.../cl_arm_import_memory.txt) no error ever occurred. I want know why.
Hi,
This may happen if the pointer you are trying to import is not aligned to the size of a cache line (i.e. 64 bytes). The specification you linked states:
>Though the application is free to provide allocations without any specific alignment on coherent systems, there is a requirement to provide pointers aligned to a cache line on systems where there is no HW-managed coherency between CPU and GPU.
You could align the pointer yourself or use a function such as posix_memalign.
Hope this helps.
Regards,
Kevin