// // Copyright (c) 2017 The Khronos Group Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #include "allocation_fill.h" #define BUFFER_CHUNK_SIZE 8*1024*1024 #define IMAGE_LINES 8 #include "harness/compat.h" int fill_buffer_with_data(cl_context context, cl_device_id device_id, cl_command_queue *queue, cl_mem mem, size_t size, MTdata d, cl_bool blocking_write) { size_t i, j; cl_uint *data; int error, result; cl_uint checksum_delta = 0; cl_event event; size_t size_to_use = BUFFER_CHUNK_SIZE; if (size_to_use > size) size_to_use = size; data = (cl_uint*)malloc(size_to_use); if (data == NULL) { log_error("Failed to malloc host buffer for writing into buffer.\n"); return FAILED_ABORT; } for (i=0; i height) image_lines_to_use = height; data = (cl_uint*)malloc(width*4*sizeof(cl_uint)*image_lines_to_use); if (data == NULL) { log_error("Failed to malloc host buffer for writing into image.\n"); return FAILED_ABORT; } origin[0] = 0; origin[1] = 0; origin[2] = 0; region[0] = width; region[1] = image_lines_to_use; region[2] = 1; for (origin[1] = 0; origin[1] < height - image_lines_to_use; origin[1] += image_lines_to_use) { // Put values in the data, and keep a checksum as we go along. for (j=0; j