diff --git a/CL/cl_ext.h b/CL/cl_ext.h index 1a48985e..96352023 100644 --- a/CL/cl_ext.h +++ b/CL/cl_ext.h @@ -45,8 +45,10 @@ extern "C" { #endif /*************************************************************** -* cl_khr_command_buffer +* cl_khr_command_buffer (provisional) ***************************************************************/ +#if defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) + #define cl_khr_command_buffer 1 #define CL_KHR_COMMAND_BUFFER_EXTENSION_NAME \ "cl_khr_command_buffer" @@ -555,9 +557,13 @@ clCommandSVMMemFillKHR( #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ +#endif /* defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) */ + /*************************************************************** -* cl_khr_command_buffer_multi_device +* cl_khr_command_buffer_multi_device (provisional) ***************************************************************/ +#if defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) + #define cl_khr_command_buffer_multi_device 1 #define CL_KHR_COMMAND_BUFFER_MULTI_DEVICE_EXTENSION_NAME \ "cl_khr_command_buffer_multi_device" @@ -615,9 +621,13 @@ clRemapCommandBufferKHR( #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ +#endif /* defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) */ + /*************************************************************** -* cl_khr_command_buffer_mutable_dispatch +* cl_khr_command_buffer_mutable_dispatch (provisional) ***************************************************************/ +#if defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) + #define cl_khr_command_buffer_mutable_dispatch 1 #define CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_NAME \ "cl_khr_command_buffer_mutable_dispatch" @@ -736,6 +746,8 @@ clGetMutableCommandInfoKHR( #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ +#endif /* defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) */ + /*************************************************************** * cl_khr_fp64 ***************************************************************/ @@ -2048,8 +2060,10 @@ clReImportSemaphoreSyncFdKHR( #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ /*************************************************************** -* cl_khr_external_semaphore_win32 +* cl_khr_external_semaphore_win32 (provisional) ***************************************************************/ +#if defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) + #define cl_khr_external_semaphore_win32 1 #define CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME \ "cl_khr_external_semaphore_win32" @@ -2062,6 +2076,8 @@ clReImportSemaphoreSyncFdKHR( #define CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR 0x2057 #define CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR 0x2068 +#endif /* defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) */ + /*************************************************************** * cl_khr_semaphore ***************************************************************/ @@ -3987,8 +4003,10 @@ clSetContentSizeBufferPoCL( #define CL_KHR_INT64_EXTENDED_ATOMICS_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) /*************************************************************** -* cl_khr_kernel_clock +* cl_khr_kernel_clock (provisional) ***************************************************************/ +#if defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) + #define cl_khr_kernel_clock 1 #define CL_KHR_KERNEL_CLOCK_EXTENSION_NAME \ "cl_khr_kernel_clock" @@ -4006,6 +4024,8 @@ typedef cl_bitfield cl_device_kernel_clock_capabilities_khr; #define CL_DEVICE_KERNEL_CLOCK_SCOPE_WORK_GROUP_KHR (1 << 1) #define CL_DEVICE_KERNEL_CLOCK_SCOPE_SUB_GROUP_KHR (1 << 2) +#endif /* defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) */ + /*************************************************************** * cl_khr_local_int32_base_atomics ***************************************************************/ diff --git a/README.md b/README.md index 93756c81..d9ccb67c 100644 --- a/README.md +++ b/README.md @@ -115,12 +115,31 @@ to use tagged or released OpenCL API headers. We will do our best to document any breaking changes in the description of each release. The OpenCL API headers are tagged at least as often as each OpenCL specification release. +## Provisional Extensions + +Provisional extensions are extensions that are still in development and are +hence subject to change. To further improve compatibility for applications that +do not use provisional features, support for provisional extension must be +explicitly enabled. Support for provisional extensions is controlled by the +`CL_ENABLE_PROVISIONAL_EXTENSIONS` preprocessor define. + +For example, to enable support for OpenCL 3.0 APIs and all extensions, including +provisional extensions, you may include the OpenCL API headers as follows: + +```c +#define CL_TARGET_OPENCL_VERSION 300 +#define CL_ENABLE_PROVISIONAL_EXTENSIONS +#include +``` + ## Directory Structure ``` README.md This file LICENSE Source license for the OpenCL API headers CL/ Unified OpenCL API headers tree +scripts/ Scripts for generating OpenCL extension headers +tests/ OpenCL API header tests ``` ## Packaging diff --git a/scripts/cl_ext.h.mako b/scripts/cl_ext.h.mako index f42bb1b1..00d07684 100644 --- a/scripts/cl_ext.h.mako +++ b/scripts/cl_ext.h.mako @@ -304,9 +304,26 @@ extern "C" { % if shouldGenerate(extension.get('name')): <% name = extension.get('name') + + # Use re.match to parse semantic major.minor.patch version + sem_ver = match('[0-9]+\.[0-9]+\.?[0-9]+', extension.get('revision')) + if not sem_ver: + raise TypeError(name + + ' XML revision field is not semantically versioned as "major.minor.patch"') + version = sem_ver[0].split('.') + version_major = version[0] + version_minor = version[1] + version_patch = version[2] + + is_provisional = extension.get('provisional') == 'true' + provisional_label = ' (provisional)' if is_provisional else '' %>/*************************************************************** -* ${name} +* ${name}${provisional_label} ***************************************************************/ +%if is_provisional: +#if defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) + +%endif %if extension.get('condition'): #if ${extension.get('condition')} @@ -315,18 +332,8 @@ extern "C" { #define ${name.upper()}_EXTENSION_NAME ${"\\"} "${name}" -<% - # Use re.match to parse semantic major.minor.patch version - sem_ver = match('[0-9]+\.[0-9]+\.?[0-9]+', extension.get('revision')) - if not sem_ver: - raise TypeError(name + - ' XML revision field is not semantically versioned as "major.minor.patch"') - version = sem_ver[0].split('.') - major = version[0] - minor = version[1] - patch = version[2] -%> -#define ${name.upper()}_EXTENSION_VERSION CL_MAKE_VERSION(${major}, ${minor}, ${patch}) + +#define ${name.upper()}_EXTENSION_VERSION CL_MAKE_VERSION(${version_major}, ${version_minor}, ${version_patch}) %for block in extension.findall('require'): % if shouldEmit(block): @@ -437,6 +444,10 @@ ${api.Name}( %if extension.get('condition'): #endif /* ${extension.get('condition')} */ +%endif +%if is_provisional: +#endif /* defined(CL_ENABLE_PROVISIONAL_EXTENSIONS) */ + %endif % endif %endfor diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 24f04330..20231913 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,18 +34,31 @@ function(add_header_test NAME SOURCE) set(LANG c) endif() foreach(VERSION 100 110 120 200 210 220 300) - set(TEST_EXE ${NAME}_${LANG}_${VERSION}) - list(FIND TEST_SKIP_ANSI_TESTING ${NAME} TEST_SKIP_INDEX) - if(NOT (${TEST_SKIP_INDEX} GREATER -1 AND MSVC AND CMAKE_C_FLAGS MATCHES "/Za")) - add_executable(${TEST_EXE} "${SOURCE_PATH}") - target_compile_definitions(${TEST_EXE} - PUBLIC -DCL_TARGET_OPENCL_VERSION=${VERSION} - ) - target_include_directories(${TEST_EXE} - PUBLIC ${PROJECT_SOURCE_DIR} - ) - add_test(NAME ${TEST_EXE} COMMAND ${TEST_EXE}) - endif() + foreach(OPTION "" CL_ENABLE_PROVISIONAL_EXTENSIONS) + if(OPTION STREQUAL "") + # The empty string means we're not setting any special option. + set(UNDERSCORE_OPTION "${OPTION}") + set(DEFINE_OPTION "") + elseif(VERSION EQUAL 300) + # Only test special options for OpenCL 3.0. + set(UNDERSCORE_OPTION "_${OPTION}") + set(DEFINE_OPTION "-D${OPTION}") + else() + continue() + endif() + set(TEST_EXE ${NAME}_${LANG}_${VERSION}${UNDERSCORE_OPTION}) + list(FIND TEST_SKIP_ANSI_TESTING ${NAME} TEST_SKIP_INDEX) + if(NOT (${TEST_SKIP_INDEX} GREATER -1 AND MSVC AND CMAKE_C_FLAGS MATCHES "/Za")) + add_executable(${TEST_EXE} "${SOURCE_PATH}") + target_compile_definitions(${TEST_EXE} + PUBLIC -DCL_TARGET_OPENCL_VERSION=${VERSION} ${DEFINE_OPTION} + ) + target_include_directories(${TEST_EXE} + PUBLIC ${PROJECT_SOURCE_DIR} + ) + add_test(NAME ${TEST_EXE} COMMAND ${TEST_EXE}) + endif() + endforeach(OPTION) endforeach(VERSION) endfunction(add_header_test)