--- /dev/null
+__kernel void
+compiler_byte_scatter(__global char *dst)
+{
+ int id = (int) get_global_id(0);
+ dst[id] = (char) id;
+}
+
--- /dev/null
+__kernel void
+compiler_short_scatter(__global short *dst)
+{
+ int id = (int) get_global_id(0);
+ dst[id] = (short) id;
+}
+
static cl_int
cl_set_varying_payload(char *data,
const size_t *local_wk_sz,
- const size_t *id_offset,
- size_t ip_offset,
+ const int32_t *id_offset,
+ int32_t ip_offset,
size_t simd_sz,
size_t cst_sz,
size_t thread_n)
cl_gpgpu_kernel kernel;
const uint32_t simd_sz = cl_kernel_get_simd_width(ker);
size_t i, batch_sz = 0u, local_sz = 0u, cst_sz = ker->curbe_sz;
- size_t thread_n = 0u, id_offset[3], ip_offset;
+ size_t thread_n = 0u;
+ int32_t id_offset[3], ip_offset;
cl_int err = CL_SUCCESS;
/* Setup kernel */
for (i = 0; i < thread_n; ++i)
memcpy(final_curbe + cst_sz * i, curbe, cst_sz);
id_offset[0] = gbe_kernel_get_curbe_offset(ker->opaque, GBE_CURBE_LOCAL_ID_X, 0);
- id_offset[1] = gbe_kernel_get_curbe_offset(ker->opaque, GBE_CURBE_LOCAL_ID_X, 1);
- id_offset[2] = gbe_kernel_get_curbe_offset(ker->opaque, GBE_CURBE_LOCAL_ID_X, 2);
+ id_offset[1] = gbe_kernel_get_curbe_offset(ker->opaque, GBE_CURBE_LOCAL_ID_Y, 0);
+ id_offset[2] = gbe_kernel_get_curbe_offset(ker->opaque, GBE_CURBE_LOCAL_ID_Z, 0);
ip_offset = gbe_kernel_get_curbe_offset(ker->opaque, GBE_CURBE_BLOCK_IP, 0);
assert(id_offset[0] >= 0 &&
id_offset[1] >= 0 &&
static void
intel_gpgpu_upload_constants(intel_gpgpu_t *gpgpu, const void* data, uint32_t size)
{
- unsigned char *constant_buffer = NULL;
+ unsigned char *curbe = NULL;
cl_gpgpu_kernel *k = gpgpu->ker;
uint32_t i, j;
/* Upload the data first */
dri_bo_map(gpgpu->curbe_b.bo, 1);
assert(gpgpu->curbe_b.bo->virtual);
- constant_buffer = (unsigned char *) gpgpu->curbe_b.bo->virtual;
- memcpy(constant_buffer, data, size);
- dri_bo_unmap(gpgpu->curbe_b.bo);
+ curbe = (unsigned char *) gpgpu->curbe_b.bo->virtual;
+ memcpy(curbe, data, size);
/* Now put all the relocations for our flat address space */
for (i = 0; i < k->thread_n; ++i)
- for (j = 0; j < gpgpu->binded_n; ++j)
+ for (j = 0; j < gpgpu->binded_n; ++j) {
+ *(uint32_t*)(curbe + gpgpu->binded_offset[j]+i*k->cst_sz) = gpgpu->binded_buf[j]->offset;
drm_intel_bo_emit_reloc(gpgpu->curbe_b.bo,
gpgpu->binded_offset[j]+i*k->cst_sz,
gpgpu->binded_buf[j],
0,
I915_GEM_DOMAIN_RENDER,
I915_GEM_DOMAIN_RENDER);
+ }
+ dri_bo_unmap(gpgpu->curbe_b.bo);
}
static void
compiler_write_only.cpp
compiler_copy_buffer.cpp
compiler_copy_buffer_row.cpp
- compiler_byte_scatter.cpp
+#compiler_byte_scatter.cpp
compiler_short_scatter.cpp
compiler_if_else.cpp
compiler_unstructured_branch0.cpp
--- /dev/null
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+#include "utest_helper.hpp"
+
+static void compiler_byte_scatter(void)
+{
+ const size_t n = 128;
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("compiler_byte_scatter");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(int8_t), NULL);
+
+ // Run the kernel
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+ globals[0] = n;
+ locals[0] = 16;
+ OCL_NDRANGE(1);
+
+ // Check result
+ OCL_MAP_BUFFER(0);
+ for (int32_t i = 0; i < (int32_t) n; ++i)
+ OCL_ASSERT(((int8_t*)buf_data[0])[i] == (int8_t) i);
+}
+
+MAKE_UTEST_FROM_FUNCTION(compiler_byte_scatter);
+
--- /dev/null
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+#include "utest_helper.hpp"
+
+static void compiler_short_scatter(void)
+{
+ const size_t n = 128;
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("compiler_short_scatter");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(int16_t), NULL);
+
+ // Run the kernel
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+ globals[0] = n;
+ locals[0] = 16;
+ OCL_NDRANGE(1);
+
+ // Check result
+ OCL_MAP_BUFFER(0);
+ for (int32_t i = 0; i < (int32_t) n; ++i)
+ OCL_ASSERT(((int16_t*)buf_data[0])[i] == (int16_t) i);
+}
+
+MAKE_UTEST_FROM_FUNCTION(compiler_short_scatter);
+
+