1 /******************************************************************
2 Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved.
3
4 This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc.
5 This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to
6 third parties, and may not be reproduced, republished, distributed, transmitted, displayed,
7 broadcast or otherwise exploited in any manner without the express prior written permission
8 of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce,
9 disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe,
10 in whole or in part other than under the terms of the Khronos Adopters Agreement
11 or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient.
12 ******************************************************************/
13
14 #include "testBase.h"
15 #include "types.hpp"
16
TEST_SPIRV_FUNC(op_type_opaque_simple)17 TEST_SPIRV_FUNC(op_type_opaque_simple)
18 {
19 const char *name = "opaque";
20 cl_int err = CL_SUCCESS;
21 std::vector<unsigned char> buffer_vec = readSPIRV(name);
22
23 int file_bytes = buffer_vec.size();
24 if (file_bytes == 0) {
25 log_error("File not found\n");
26 return -1;
27 }
28 unsigned char *buffer = &buffer_vec[0];
29
30 clProgramWrapper prog;
31
32 if (gCoreILProgram)
33 {
34 prog = clCreateProgramWithIL(context, buffer, file_bytes, &err);
35 SPIRV_CHECK_ERROR(
36 err, "Failed to create program with clCreateProgramWithIL");
37 }
38 else
39 {
40 cl_platform_id platform;
41 err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM,
42 sizeof(cl_platform_id), &platform, NULL);
43 SPIRV_CHECK_ERROR(err,
44 "Failed to get platform info with clGetDeviceInfo");
45 clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL;
46
47 clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)
48 clGetExtensionFunctionAddressForPlatform(
49 platform, "clCreateProgramWithILKHR");
50 if (clCreateProgramWithILKHR == NULL)
51 {
52 log_error(
53 "ERROR: clGetExtensionFunctionAddressForPlatform failed\n");
54 return -1;
55 }
56 prog = clCreateProgramWithILKHR(context, buffer, file_bytes, &err);
57 SPIRV_CHECK_ERROR(
58 err, "Failed to create program with clCreateProgramWithILKHR");
59 }
60
61 err = clCompileProgram(prog, 1, &deviceID,
62 NULL, // options
63 0, // num headers
64 NULL, // input headers
65 NULL, // header include names
66 NULL, // callback
67 NULL // User data
68 );
69 SPIRV_CHECK_ERROR(err, "Failed to compile spv program");
70 return 0;
71 }
72