INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../include)
-ADD_EXECUTABLE(run
- utest_error.c
- utest_helper.cpp
- utest_file_map.cpp
- utest_assert.cpp
- utest.cpp
- utest_run.cpp
- compiler_write_only.cpp
- compiler_copy_buffer.cpp
- compiler_copy_buffer_row.cpp)
-TARGET_LINK_LIBRARIES(run cl m)
+ADD_LIBRARY(utests SHARED
+ utest_error.c
+ utest_helper.cpp
+ utest_file_map.cpp
+ utest_assert.cpp
+ utest.cpp
+ compiler_write_only.cpp
+ compiler_copy_buffer.cpp
+ compiler_copy_buffer_row.cpp)
+TARGET_LINK_LIBRARIES(utests cl m)
+
+ADD_EXECUTABLE(run utest_run.cpp)
+TARGET_LINK_LIBRARIES(run utests)
+
+ADD_EXECUTABLE(flat_address_space runtime_flat_address_space.cpp)
+TARGET_LINK_LIBRARIES(flat_address_space utests)
+++ /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 "cl_test.h"
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main (int argc, char *argv[])
-{
- const size_t n = 1024;
- const size_t global_work_size = n;
- const size_t local_work_size = 16;
- int status = 0;
-
- if ((status = cl_test_init("dummy.ll", "hop", LLVM)) != 0) goto error;
-
- /* Run the kernel */
- CALL (clEnqueueNDRangeKernel, queue,
- kernel,
- 1,
- NULL,
- &global_work_size,
- &local_work_size,
- 0,
- NULL,
- NULL);
-
- cl_test_destroy();
- printf("%i memory leaks\n", clIntelReportUnfreed());
- assert(clIntelReportUnfreed() == 0);
-
-error:
- cl_report_error(status);
- return status;
-}
-
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#include "cl_test.h"
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include "utest_helper.hpp"
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
cl_mem dst[24];
int *dst_buffer;
const size_t n = 32 * 1024 * 1024;
const size_t global_work_size = n;
const size_t local_work_size = 16;
- int status = 0, i, j;
+ int status = 0;
if ((status = cl_test_init("test_write_only.cl", "test_write_only", SOURCE)) != 0)
goto error;
- for (j = 0; j < 24; ++j) {
- /* Allocate the two buffers */
+ for (uint32_t j = 0; j < 24; ++j)
+ {
+ // Allocate the two buffers
dst[j] = clCreateBuffer(ctx, 0, n * sizeof(uint32_t), NULL, &status);
if (status != CL_SUCCESS) goto error;
- /* Set source and destination */
- CALL (clSetKernelArg, kernel, 0, sizeof(cl_mem), &dst[j]);
+ // Set source and destination
+ OCL_CALL (clSetKernelArg, kernel, 0, sizeof(cl_mem), &dst[j]);
- /* Run the kernel */
- CALL (clEnqueueNDRangeKernel, queue,
+ // Run the kernel
+ OCL_CALL (clEnqueueNDRangeKernel, queue,
kernel,
1,
NULL,
NULL,
NULL);
- /* Be sure that everything run fine */
+ // Be sure that everything run fine
dst_buffer = (int *) clIntelMapBuffer(dst[j], &status);
if (status != CL_SUCCESS)
goto error;
- for (i = 0; i < n; ++i) assert(dst_buffer[i] == i);
- CALL (clIntelUnmapBuffer, dst[j]);
+ for (uint32_t i = 0; i < n; ++i) assert(dst_buffer[i] == int(i));
+ OCL_CALL (clIntelUnmapBuffer, dst[j]);
}
- for (j = 0; j < 24; ++j) CALL (clReleaseMemObject, dst[j]);
+ for (uint32_t j = 0; j < 24; ++j) OCL_CALL (clReleaseMemObject, dst[j]);
cl_test_destroy();
printf("%i memory leaks\n", clIntelReportUnfreed());
assert(clIntelReportUnfreed() == 0);
error:
- cl_report_error(status);
return status;
}
#define __UTEST_FILE_MAP_HPP__
#include "CL/cl.h"
-#include <stdlib.h>
+#include <cstdlib>
/* Map a file into memory for direct / cached / simple accesses */
typedef struct cl_file_map {
#include "CL/cl.h"
#include "CL/cl_intel.h"
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <assert.h>
+#include <cstdio>
+#include <cstdint>
+#include <cstring>
+#include <casserth>
#define FATAL(...) \
do { \
#include "utest.hpp"
#include "utest_assert.hpp"
#include "utest_error.h"
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
#define OCL_THROW_ERROR(FN, STATUS) \
do { \
#define OCL_UNMAP_BUFFER(ID) \
do { \
- OCL_CALL (clIntelUnmapBuffer, buf[ID]); \
- buf_data[ID] = NULL; \
+ if (buf[ID] != NULL) { \
+ OCL_CALL (clIntelUnmapBuffer, buf[ID]); \
+ buf_data[ID] = NULL; \
+ } \
} while (0)
#define OCL_NDRANGE(DIM_N) \