-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'adapters' into ewan/L0_internal_event_fix
- Loading branch information
Showing
31 changed files
with
5,330 additions
and
63 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: LLVM | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
//===-------------- adapter.cpp - OpenCL Adapter ---------------------===// | ||
// | ||
// Copyright (C) 2023 Intel Corporation | ||
// | ||
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM | ||
// Exceptions. See LICENSE.TXT | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "common.hpp" | ||
|
||
struct ur_adapter_handle_t_ { | ||
std::atomic<uint32_t> RefCount = 0; | ||
}; | ||
|
||
ur_adapter_handle_t_ adapter{}; | ||
|
||
UR_APIEXPORT ur_result_t UR_APICALL urInit(ur_device_init_flags_t, | ||
ur_loader_config_handle_t) { | ||
cl_ext::ExtFuncPtrCache = new cl_ext::ExtFuncPtrCacheT(); | ||
return UR_RESULT_SUCCESS; | ||
} | ||
|
||
UR_APIEXPORT ur_result_t UR_APICALL urTearDown(void *) { | ||
if (cl_ext::ExtFuncPtrCache) { | ||
delete cl_ext::ExtFuncPtrCache; | ||
cl_ext::ExtFuncPtrCache = nullptr; | ||
} | ||
return UR_RESULT_SUCCESS; | ||
} | ||
|
||
UR_APIEXPORT ur_result_t UR_APICALL | ||
urAdapterGet(uint32_t NumEntries, ur_adapter_handle_t *phAdapters, | ||
uint32_t *pNumAdapters) { | ||
if (NumEntries > 0 && phAdapters) { | ||
*phAdapters = &adapter; | ||
} | ||
|
||
if (pNumAdapters) { | ||
*pNumAdapters = 1; | ||
} | ||
|
||
return UR_RESULT_SUCCESS; | ||
} | ||
|
||
UR_APIEXPORT ur_result_t UR_APICALL urAdapterRetain(ur_adapter_handle_t) { | ||
++adapter.RefCount; | ||
return UR_RESULT_SUCCESS; | ||
} | ||
|
||
UR_APIEXPORT ur_result_t UR_APICALL urAdapterRelease(ur_adapter_handle_t) { | ||
--adapter.RefCount; | ||
return UR_RESULT_SUCCESS; | ||
} | ||
|
||
UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetLastError( | ||
ur_adapter_handle_t, const char **ppMessage, int32_t *pError) { | ||
*ppMessage = cl_adapter::ErrorMessage; | ||
*pError = cl_adapter::ErrorMessageCode; | ||
|
||
return UR_RESULT_SUCCESS; | ||
} | ||
|
||
UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t, | ||
ur_adapter_info_t propName, | ||
size_t propSize, | ||
void *pPropValue, | ||
size_t *pPropSizeRet) { | ||
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet); | ||
|
||
switch (propName) { | ||
case UR_ADAPTER_INFO_BACKEND: | ||
return ReturnValue(UR_ADAPTER_BACKEND_CUDA); | ||
case UR_ADAPTER_INFO_REFERENCE_COUNT: | ||
return ReturnValue(adapter.RefCount.load()); | ||
default: | ||
return UR_RESULT_ERROR_INVALID_ENUMERATION; | ||
} | ||
|
||
return UR_RESULT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//===-------------- adapter.hpp - OpenCL Adapter ---------------------===// | ||
// | ||
// Copyright (C) 2023 Intel Corporation | ||
// | ||
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM | ||
// Exceptions. See LICENSE.TXT | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
struct ur_adapter_handle_t_; | ||
|
||
extern ur_adapter_handle_t_ adapter; |
Oops, something went wrong.