1 // 2 // Copyright (c) 2017 The Khronos Group Inc. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 #include "harness/conversions.h" 17 #include "harness/errorHelpers.h" 18 #include "harness/kernelHelpers.h" 19 #include "harness/mt19937.h" 20 #include "harness/typeWrappers.h" 21 22 // This is a macro rather than a function to be able to use and act like the 23 // existing test_error macro. 24 // 25 // Not all compiler tests need to use this macro, only those that don't use the 26 // test harness compiler helpers. 27 #define check_compiler_available(DEVICE) \ 28 { \ 29 cl_bool compilerAvailable = CL_FALSE; \ 30 cl_int error = clGetDeviceInfo((DEVICE), CL_DEVICE_COMPILER_AVAILABLE, \ 31 sizeof(compilerAvailable), \ 32 &compilerAvailable, NULL); \ 33 test_error(error, "Unable to query CL_DEVICE_COMPILER_AVAILABLE"); \ 34 if (compilerAvailable == CL_FALSE) \ 35 { \ 36 log_info("Skipping test - no compiler is available.\n"); \ 37 return TEST_SKIPPED_ITSELF; \ 38 } \ 39 } 40 41 extern int test_load_program_source(cl_device_id deviceID, cl_context context, 42 cl_command_queue queue, int num_elements); 43 extern int test_load_multistring_source(cl_device_id deviceID, 44 cl_context context, 45 cl_command_queue queue, 46 int num_elements); 47 extern int test_load_two_kernel_source(cl_device_id deviceID, 48 cl_context context, 49 cl_command_queue queue, 50 int num_elements); 51 extern int test_load_null_terminated_source(cl_device_id deviceID, 52 cl_context context, 53 cl_command_queue queue, 54 int num_elements); 55 extern int test_load_null_terminated_multi_line_source(cl_device_id deviceID, 56 cl_context context, 57 cl_command_queue queue, 58 int num_elements); 59 extern int test_load_null_terminated_partial_multi_line_source( 60 cl_device_id deviceID, cl_context context, cl_command_queue queue, 61 int num_elements); 62 extern int test_load_discreet_length_source(cl_device_id deviceID, 63 cl_context context, 64 cl_command_queue queue, 65 int num_elements); 66 extern int test_get_program_source(cl_device_id deviceID, cl_context context, 67 cl_command_queue queue, int num_elements); 68 extern int test_get_program_build_info(cl_device_id deviceID, 69 cl_context context, 70 cl_command_queue queue, 71 int num_elements); 72 extern int test_get_program_info(cl_device_id deviceID, cl_context context, 73 cl_command_queue queue, int num_elements); 74 75 extern int test_large_compile(cl_device_id deviceID, cl_context context, 76 cl_command_queue queue, int num_elements); 77 extern int test_async_build(cl_device_id deviceID, cl_context context, 78 cl_command_queue queue, int num_elements); 79 80 extern int test_options_build_optimizations(cl_device_id deviceID, 81 cl_context context, 82 cl_command_queue queue, 83 int num_elements); 84 extern int test_options_build_macro(cl_device_id deviceID, cl_context context, 85 cl_command_queue queue, int num_elements); 86 extern int test_options_build_macro_existence(cl_device_id deviceID, 87 cl_context context, 88 cl_command_queue queue, 89 int num_elements); 90 extern int test_options_include_directory(cl_device_id deviceID, 91 cl_context context, 92 cl_command_queue queue, 93 int num_elements); 94 extern int test_options_denorm_cache(cl_device_id deviceID, cl_context context, 95 cl_command_queue queue, int num_elements); 96 97 extern int test_preprocessor_define_udef(cl_device_id deviceID, 98 cl_context context, 99 cl_command_queue queue, 100 int num_elements); 101 extern int test_preprocessor_include(cl_device_id deviceID, cl_context context, 102 cl_command_queue queue, int num_elements); 103 extern int test_preprocessor_line_error(cl_device_id deviceID, 104 cl_context context, 105 cl_command_queue queue, 106 int num_elements); 107 extern int test_preprocessor_pragma(cl_device_id deviceID, cl_context context, 108 cl_command_queue queue, int num_elements); 109 110 extern int test_opencl_c_versions(cl_device_id device, cl_context context, 111 cl_command_queue queue, int num_elements); 112 extern int test_compiler_defines_for_extensions(cl_device_id device, 113 cl_context context, 114 cl_command_queue queue, 115 int n_elems); 116 extern int test_image_macro(cl_device_id deviceID, cl_context context, 117 cl_command_queue queue, int num_elements); 118 119 extern int test_simple_compile_only(cl_device_id deviceID, cl_context context, 120 cl_command_queue queue, int num_elements); 121 extern int test_simple_static_compile_only(cl_device_id deviceID, 122 cl_context context, 123 cl_command_queue queue, 124 int num_elements); 125 extern int test_simple_extern_compile_only(cl_device_id deviceID, 126 cl_context context, 127 cl_command_queue queue, 128 int num_elements); 129 extern int test_simple_compile_with_callback(cl_device_id deviceID, 130 cl_context context, 131 cl_command_queue queue, 132 int num_elements); 133 extern int test_simple_embedded_header_compile(cl_device_id deviceID, 134 cl_context context, 135 cl_command_queue queue, 136 int num_elements); 137 138 extern int test_simple_link_only(cl_device_id deviceID, cl_context context, 139 cl_command_queue queue, int num_elements); 140 extern int test_two_file_regular_variable_access(cl_device_id deviceID, 141 cl_context context, 142 cl_command_queue queue, 143 int num_elements); 144 extern int test_two_file_regular_struct_access(cl_device_id deviceID, 145 cl_context context, 146 cl_command_queue queue, 147 int num_elements); 148 extern int test_two_file_regular_function_access(cl_device_id deviceID, 149 cl_context context, 150 cl_command_queue queue, 151 int num_elements); 152 153 extern int test_simple_link_with_callback(cl_device_id deviceID, 154 cl_context context, 155 cl_command_queue queue, 156 int num_elements); 157 extern int test_simple_embedded_header_link(cl_device_id deviceID, 158 cl_context context, 159 cl_command_queue queue, 160 int num_elements); 161 162 extern int test_execute_after_simple_compile_and_link(cl_device_id deviceID, 163 cl_context context, 164 cl_command_queue queue, 165 int num_elements); 166 extern int test_execute_after_simple_compile_and_link_no_device_info( 167 cl_device_id deviceID, cl_context context, cl_command_queue queue, 168 int num_elements); 169 extern int test_execute_after_simple_compile_and_link_with_defines( 170 cl_device_id deviceID, cl_context context, cl_command_queue queue, 171 int num_elements); 172 extern int test_execute_after_simple_compile_and_link_with_callbacks( 173 cl_device_id deviceID, cl_context context, cl_command_queue queue, 174 int num_elements); 175 extern int test_execute_after_simple_library_with_link(cl_device_id deviceID, 176 cl_context context, 177 cl_command_queue queue, 178 int num_elements); 179 extern int test_execute_after_two_file_link(cl_device_id deviceID, 180 cl_context context, 181 cl_command_queue queue, 182 int num_elements); 183 extern int test_execute_after_embedded_header_link(cl_device_id deviceID, 184 cl_context context, 185 cl_command_queue queue, 186 int num_elements); 187 extern int test_execute_after_included_header_link(cl_device_id deviceID, 188 cl_context context, 189 cl_command_queue queue, 190 int num_elements); 191 extern int test_execute_after_serialize_reload_object(cl_device_id deviceID, 192 cl_context context, 193 cl_command_queue queue, 194 int num_elements); 195 extern int test_execute_after_serialize_reload_library(cl_device_id deviceID, 196 cl_context context, 197 cl_command_queue queue, 198 int num_elements); 199 200 extern int test_simple_library_only(cl_device_id deviceID, cl_context context, 201 cl_command_queue queue, int num_elements); 202 extern int test_simple_library_with_callback(cl_device_id deviceID, 203 cl_context context, 204 cl_command_queue queue, 205 int num_elements); 206 extern int test_simple_library_with_link(cl_device_id deviceID, 207 cl_context context, 208 cl_command_queue queue, 209 int num_elements); 210 extern int test_two_file_link(cl_device_id deviceID, cl_context context, 211 cl_command_queue queue, int num_elements); 212 extern int test_multi_file_libraries(cl_device_id deviceID, cl_context context, 213 cl_command_queue queue, int num_elements); 214 extern int test_multiple_libraries(cl_device_id deviceID, cl_context context, 215 cl_command_queue queue, int num_elements); 216 extern int test_multiple_files(cl_device_id deviceID, cl_context context, 217 cl_command_queue queue, int num_elements); 218 extern int test_multiple_files_multiple_libraries(cl_device_id deviceID, 219 cl_context context, 220 cl_command_queue queue, 221 int num_elements); 222 extern int test_multiple_embedded_headers(cl_device_id deviceID, 223 cl_context context, 224 cl_command_queue queue, 225 int num_elements); 226 227 extern int test_program_binary_type(cl_device_id deviceID, cl_context context, 228 cl_command_queue queue, int num_elements); 229 extern int test_compile_and_link_status_options_log(cl_device_id deviceID, 230 cl_context context, 231 cl_command_queue queue, 232 int num_elements); 233 234 extern int test_pragma_unroll(cl_device_id deviceID, cl_context context, 235 cl_command_queue queue, int num_elements); 236 extern int test_features_macro(cl_device_id deviceID, cl_context context, 237 cl_command_queue queue, int num_elements); 238 extern int test_unload_valid(cl_device_id deviceID, cl_context context, 239 cl_command_queue queue, int num_elements); 240 extern int test_unload_invalid(cl_device_id deviceID, cl_context context, 241 cl_command_queue queue, int num_elements); 242 extern int test_unload_repeated(cl_device_id deviceID, cl_context context, 243 cl_command_queue queue, int num_elements); 244 extern int test_unload_compile_unload_link(cl_device_id deviceID, 245 cl_context context, 246 cl_command_queue queue, 247 int num_elements); 248 extern int test_unload_build_unload_create_kernel(cl_device_id deviceID, 249 cl_context context, 250 cl_command_queue queue, 251 int num_elements); 252 extern int test_unload_link_different(cl_device_id deviceID, cl_context context, 253 cl_command_queue queue, int num_elements); 254 extern int test_unload_build_threaded(cl_device_id deviceID, cl_context context, 255 cl_command_queue queue, int num_elements); 256 extern int test_unload_build_info(cl_device_id deviceID, cl_context context, 257 cl_command_queue queue, int num_elements); 258 extern int test_unload_program_binaries(cl_device_id deviceID, 259 cl_context context, 260 cl_command_queue queue, 261 int num_elements); 262