Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader/icd_cmake_config.h.in
set (OPENCL_ICD_LOADER_SOURCES
loader/icd.c
loader/icd.h
loader/icd_version.h
loader/cl_icdl_private.h
loader/icd_dispatch.c
loader/icd_dispatch.h
loader/icd_dispatch_generated.c
Expand Down Expand Up @@ -148,6 +150,11 @@ endif ()
target_compile_definitions (OpenCL
PRIVATE
CL_TARGET_OPENCL_VERSION=300
OPENCL_ICD_LOADER_VERSION_MAJOR=3
OPENCL_ICD_LOADER_VERSION_MINOR=0
OPENCL_ICD_LOADER_VERSION_REV=5
OPENCL_ICD_LOADER_NAME_STRING="Khronos OpenCL ICD Loader"
OPENCL_ICD_LOADER_VENDOR_STRING="Khronos Group"
$<$<BOOL:${ENABLE_OPENCL_LAYERS}>:CL_ENABLE_LAYERS>
)

Expand Down
46 changes: 46 additions & 0 deletions loader/cl_icdl_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2016-2020 The Khronos Group Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* OpenCL is a trademark of Apple Inc. used under license by Khronos.
*/

#ifndef OPENCL_CL_ICDL_H
#define OPENCL_CL_ICDL_H

#include <CL/cl.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef cl_uint cl_icdl_info;

#define CL_ICDL_OCL_VERSION 1
#define CL_ICDL_VERSION 2
#define CL_ICDL_NAME 3
#define CL_ICDL_VENDOR 4

typedef cl_int
(CL_API_CALL * pfn_clGetICDLoaderInfoOCLICD)(cl_icdl_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret);

#ifdef __cplusplus
}
#endif


#endif /* OPENCL_CL_ICDL_H */
46 changes: 46 additions & 0 deletions loader/icd_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,53 @@

#include "icd.h"
#include "icd_dispatch.h"
#include "cl_icdl_private.h"
#include "icd_version.h"

#include <stdlib.h>
#include <string.h>

static cl_int
clGetICDLoaderInfoOCLICD(
cl_icdl_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret)
{
static const char cl_icdl_OCL_VERSION[] = OPENCL_ICD_LOADER_OCL_VERSION_STRING;
static const char cl_icdl_VERSION[] = OPENCL_ICD_LOADER_VERSION_STRING;
static const char cl_icdl_NAME[] = OPENCL_ICD_LOADER_NAME_STRING;
static const char cl_icdl_VENDOR[] = OPENCL_ICD_LOADER_VENDOR_STRING;
size_t pvs;
void * pv;

#define KHR_ICD_CASE_STRING_PARAM_NAME(name) \
case CL_ICDL_ ## name: \
pvs = strlen(cl_icdl_ ## name) + 1; \
pv = (void *)cl_icdl_ ## name; \
break

switch (param_name) {
KHR_ICD_CASE_STRING_PARAM_NAME(OCL_VERSION);
KHR_ICD_CASE_STRING_PARAM_NAME(VERSION);
KHR_ICD_CASE_STRING_PARAM_NAME(NAME);
KHR_ICD_CASE_STRING_PARAM_NAME(VENDOR);
default:
return CL_INVALID_VALUE;
}

#undef KHR_ICD_CASE_PARAM_NAME

if (param_value) {
if (param_value_size < pvs)
return CL_INVALID_VALUE;
memcpy(param_value, pv, pvs);
}
if (param_value_size_ret != NULL)
*param_value_size_ret = pvs;
return CL_SUCCESS;
}

static void* khrIcdGetExtensionFunctionAddress(const char* function_name)
{
// Most extensions, including multi-vendor KHR and EXT extensions,
Expand Down Expand Up @@ -93,6 +136,9 @@ static void* khrIcdGetExtensionFunctionAddress(const char* function_name)
// cl_khr_sub_groups
KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetKernelSubGroupInfoKHR);

// cl_icdl
KHR_ICD_CHECK_EXTENSION_FUNCTION(clGetICDLoaderInfoOCLICD);

#undef KHR_ICD_CHECK_EXTENSION_FUNCTION

return NULL;
Expand Down
54 changes: 54 additions & 0 deletions loader/icd_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2016-2020 The Khronos Group Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* OpenCL is a trademark of Apple Inc. used under license by Khronos.
*/

#ifndef _ICD_VERSION_H_
#define _ICD_VERSION_H_

#define OPENCL_ICD_LOADER_VAL(_v) #_v
#define OPENCL_ICD_LOADER_TOSTRING(_d) OPENCL_ICD_LOADER_VAL(_d)
#define OPENCL_ICD_LOADER_VERSION_STRING \
OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_MAJOR) "." \
OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_MINOR) "." \
OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_REV)

#if CL_TARGET_OPENCL_VERSION == 100
#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "1.0"
#endif
#if CL_TARGET_OPENCL_VERSION == 110
#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "1.1"
#endif
#if CL_TARGET_OPENCL_VERSION == 120
#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "1.2"
#endif
#if CL_TARGET_OPENCL_VERSION == 200
#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "2.0"
#endif
#if CL_TARGET_OPENCL_VERSION == 210
#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "2.1"
#endif
#if CL_TARGET_OPENCL_VERSION == 220
#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "2.2"
#endif
#if CL_TARGET_OPENCL_VERSION == 300
#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "3.0"
#endif

#define OPENCL_ICD_LOADER_OCL_VERSION_STRING \
"OpenCL " OPENCL_ICD_LOADER_OCL_VERSION_NUMBER

#endif
16 changes: 3 additions & 13 deletions loader/windows/OpenCL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,10 @@
*/

#include <windows.h>

#define OPENCL_ICD_LOADER_VERSION_MAJOR 3
#define OPENCL_ICD_LOADER_VERSION_MINOR 0
#define OPENCL_ICD_LOADER_VERSION_REV 4
#include <icd_version.h>

#ifdef RC_INVOKED

#define OPENCL_ICD_LOADER_VAL(_v) #_v
#define OPENCL_ICD_LOADER_TOSTRING(_d) OPENCL_ICD_LOADER_VAL(_d)
#define OPENCL_ICD_LOADER_VERSION_STRING \
OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_MAJOR) "." \
OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_MINOR) "." \
OPENCL_ICD_LOADER_TOSTRING(OPENCL_ICD_LOADER_VERSION_REV)

VS_VERSION_INFO VERSIONINFO
FILEVERSION OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0
PRODUCTVERSION OPENCL_ICD_LOADER_VERSION_MAJOR,OPENCL_ICD_LOADER_VERSION_MINOR,OPENCL_ICD_LOADER_VERSION_REV,0
Expand All @@ -42,10 +32,10 @@ BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription" ,"OpenCL Client DLL"
VALUE "ProductName" ,"Khronos OpenCL ICD Loader"
VALUE "ProductName" ,OPENCL_ICD_LOADER_NAME_STRING
VALUE "LegalCopyright" ,"Copyright \251 The Khronos Group Inc 2016-2020"
VALUE "FileVersion" ,OPENCL_ICD_LOADER_VERSION_STRING ".0"
VALUE "CompanyName" ,"Khronos Group"
VALUE "CompanyName" ,OPENCL_ICD_LOADER_VENDOR_STRING
VALUE "InternalName" ,"OpenCL"
VALUE "OriginalFilename","OpenCL.dll"
END
Expand Down