-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for static linking of the L0 adapter
This patch adds a cmake option that builds the L0 adapter as a static library and then embeds its in the loader. The mechanim itself is fairly generic and, when a need arises, the same can be done for other adapters.
- Loading branch information
Showing
40 changed files
with
2,803 additions
and
1,608 deletions.
There are no files selected for viewing
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
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,88 @@ | ||
<%! | ||
import re | ||
from templates import helper as th | ||
%><% | ||
n=namespace | ||
N=n.upper() | ||
x=tags['$x'] | ||
X=x.upper() | ||
Adapter=adapter.upper() | ||
%>//===--------- ${n}_interface_loader.cpp - Level Zero Adapter ------------===// | ||
// | ||
// Copyright (C) 2024 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 <${n}_api.h> | ||
#include <${n}_ddi.h> | ||
|
||
#include "ur_interface_loader.hpp" | ||
|
||
static ur_result_t validateProcInputs(ur_api_version_t version, void *pDdiTable) { | ||
if (nullptr == pDdiTable) { | ||
return UR_RESULT_ERROR_INVALID_NULL_POINTER; | ||
} | ||
// Pre 1.0 we enforce loader and adapter must have same version. | ||
// Post 1.0 only major version match should be required. | ||
if (version != UR_API_VERSION_CURRENT) { | ||
return UR_RESULT_ERROR_UNSUPPORTED_VERSION; | ||
} | ||
return UR_RESULT_SUCCESS; | ||
} | ||
|
||
#ifdef UR_STATIC_ADAPTER_${Adapter} | ||
namespace ${n}::${adapter} { | ||
#elif defined(__cplusplus) | ||
extern "C" { | ||
#endif | ||
|
||
%for tbl in th.get_pfntables(specs, meta, n, tags): | ||
${X}_APIEXPORT ${x}_result_t ${X}_APICALL ${tbl['export']['name']}( | ||
%for line in th.make_param_lines(n, tags, tbl['export'], format=["type", "name", "delim"]): | ||
${line} | ||
%endfor | ||
) | ||
{ | ||
auto result = validateProcInputs(version, pDdiTable); | ||
if (UR_RESULT_SUCCESS != result) { | ||
return result; | ||
} | ||
|
||
%for obj in tbl['functions']: | ||
pDdiTable->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = ${n}::${adapter}::${th.make_func_name(n, tags, obj)}; | ||
%endfor | ||
|
||
return result; | ||
} | ||
|
||
%endfor | ||
|
||
#ifdef UR_STATIC_ADAPTER_${Adapter} | ||
} // namespace ur::${adapter} | ||
#elif defined(__cplusplus) | ||
} // extern "C" | ||
#endif | ||
|
||
#ifdef UR_STATIC_ADAPTER_${Adapter} | ||
namespace ur::${adapter} { | ||
ur_result_t urAdapterGetDdiTables(ur_dditable_t *ddi) { | ||
if (ddi == nullptr) { | ||
return UR_RESULT_ERROR_INVALID_NULL_POINTER; | ||
} | ||
|
||
ur_result_t result; | ||
|
||
%for tbl in th.get_pfntables(specs, meta, n, tags): | ||
result = ${n}::${adapter}::${tbl['export']['name']}( ${X}_API_VERSION_CURRENT, &ddi->${tbl['name']} ); | ||
if (result != UR_RESULT_SUCCESS) | ||
return result; | ||
%endfor | ||
|
||
return result; | ||
} | ||
} | ||
#endif |
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,38 @@ | ||
<%! | ||
import re | ||
from templates import helper as th | ||
%><% | ||
n=namespace | ||
N=n.upper() | ||
x=tags['$x'] | ||
X=x.upper() | ||
Adapter=adapter.upper() | ||
%>//===--------- ${n}_interface_loader.hpp - Level Zero Adapter ------------===// | ||
// | ||
// Copyright (C) 2024 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 <${n}_api.h> | ||
#include <${n}_ddi.h> | ||
|
||
namespace ${n}::${adapter} { | ||
%for s in specs: | ||
%for obj in th.filter_items(s['objects'], 'type', 'function'): | ||
%if not th.obj_traits.is_loader_only(obj): | ||
${x}_result_t ${th.make_func_name(n, tags, obj)}( | ||
%for line in th.make_param_lines(n, tags, obj, format=["type", "name", "delim"]): | ||
${line} | ||
%endfor | ||
); | ||
%endif | ||
%endfor | ||
%endfor | ||
#ifdef UR_STATIC_ADAPTER_LEVEL_ZERO | ||
ur_result_t urAdapterGetDdiTables(ur_dditable_t *ddi); | ||
#endif | ||
} |
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
Oops, something went wrong.