| 114 | } |
| 115 | |
| 116 | int doTest(cl_device_id device, cl_context context, cl_command_queue queue, |
| 117 | AllocType alloc_type) |
| 118 | { |
| 119 | int error; |
| 120 | int failure_counts = 0; |
| 121 | size_t final_size; |
| 122 | size_t current_test_size; |
| 123 | cl_mem mems[MAX_NUMBER_TO_ALLOCATE]; |
| 124 | int number_of_mems_used; |
| 125 | cl_ulong max_individual_allocation_size = g_max_individual_allocation_size; |
| 126 | cl_ulong global_mem_size = g_global_mem_size; |
| 127 | unsigned int number_of_work_items; |
| 128 | const bool allocate_image = |
| 129 | (alloc_type != BUFFER) && (alloc_type != BUFFER_NON_BLOCKING); |
| 130 | |
| 131 | static const char *alloc_description[] = { |
| 132 | "buffer(s)", "read-only image(s)", "write-only image(s)", |
| 133 | "buffer(s)", "read-only image(s)", "write-only image(s)", |
| 134 | }; |
| 135 | |
| 136 | // Skip image tests if we don't support images on the device |
| 137 | if (allocate_image && checkForImageSupport(device)) |
| 138 | { |
| 139 | log_info("Can not test image allocation because device does not " |
| 140 | "support images.\n"); |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | // This section was added in order to fix a bug in the test |
| 145 | // If CL_DEVICE_MAX_MEM_ALLOC_SIZE is much grater than |
| 146 | // CL_DEVICE_IMAGE2D_MAX_WIDTH * CL_DEVICE_IMAGE2D_MAX_HEIGHT The test will |
| 147 | // fail in image allocations as the size requested for the allocation will |
| 148 | // be much grater than the maximum size allowed for image |
| 149 | if (allocate_image) |
| 150 | { |
| 151 | size_t max_width, max_height; |
| 152 | |
| 153 | error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH, |
| 154 | sizeof(max_width), &max_width, NULL); |
| 155 | test_error_abort( |
| 156 | error, "clGetDeviceInfo failed for CL_DEVICE_IMAGE2D_MAX_WIDTH"); |
| 157 | |
| 158 | error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, |
| 159 | sizeof(max_height), &max_height, NULL); |
| 160 | test_error_abort( |
| 161 | error, "clGetDeviceInfo failed for CL_DEVICE_IMAGE2D_MAX_HEIGHT"); |
| 162 | |
| 163 | cl_ulong max_image2d_size = |
| 164 | (cl_ulong)max_height * max_width * 4 * sizeof(cl_uint); |
| 165 | |
| 166 | if (max_individual_allocation_size > max_image2d_size) |
| 167 | { |
| 168 | max_individual_allocation_size = max_image2d_size; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | // Pick the baseline size based on whether we are doing a single large or |
| 173 | // multiple allocations |
no test coverage detected