Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xpu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computing
xpu
Commits
ccb1ecd3
Commit
ccb1ecd3
authored
2 years ago
by
Felix Weiglhofer
Browse files
Options
Downloads
Patches
Plain Diff
Revisit detail::image_context.
- Simplify class. - Fix undefined-var-template warning in clang.
parent
bf4b8857
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+2
-1
2 additions, 1 deletion
CMakeLists.txt
src/xpu/detail/dynamic_loader.h
+25
-21
25 additions, 21 deletions
src/xpu/detail/dynamic_loader.h
src/xpu/detail/runtime.h
+1
-1
1 addition, 1 deletion
src/xpu/detail/runtime.h
with
28 additions
and
23 deletions
CMakeLists.txt
+
2
−
1
View file @
ccb1ecd3
...
...
@@ -130,7 +130,8 @@ function(xpu_attach Library)
get_filename_component
(
KernelDeclFullPath
"
${
KernelDecl
}
"
REALPATH
)
target_compile_definitions
(
${
Library
}
PRIVATE XPU_IMAGE_FILE=
"
${
Library
}
"
)
target_compile_options
(
${
Library
}
PUBLIC -fPIC -Wno-undefined-var-template
)
# target_compile_options(${Library} PUBLIC -fPIC -Wno-undefined-var-template)
target_compile_options
(
${
Library
}
PUBLIC -fPIC
)
target_link_libraries
(
${
Library
}
xpu
)
if
(
TARGET OpenMP::OpenMP_CXX
)
target_link_libraries
(
${
Library
}
OpenMP::OpenMP_CXX
)
...
...
This diff is collapsed.
Click to expand it.
src/xpu/detail/dynamic_loader.h
+
25
−
21
View file @
ccb1ecd3
...
...
@@ -61,29 +61,29 @@ using action_interface_t = typename action_interface<typename A::tag, A>::type;
using
symbol_table
=
std
::
vector
<
std
::
pair
<
std
::
string
,
void
*>>
;
template
<
typename
I
>
struct
image_file_name
{
const
char
*
operator
()()
const
;
};
template
<
typename
I
>
class
image_context
{
public:
static
const
char
*
file_name
;
static
std
::
unordered_map
<
std
::
string
,
size_t
>
&
ids
();
static
image_context
<
I
>
*
instance
();
image_context
()
{
name
=
type_name
<
I
>
();
}
image_context
()
{
name
=
type_name
<
I
>
();
}
symbol_table
&
get_symbols
()
{
return
symbols
;
}
std
::
string
get_name
()
const
{
return
name
;
}
template
<
typename
A
>
void
add_symbol
(
void
*
symbol
)
{
auto
it
=
ids
()
.
find
(
type_name
<
A
>
());
if
(
it
==
ids
()
.
end
())
{
ids
()
[
type_name
<
A
>
()]
=
grouped_type_id
<
A
,
typename
A
::
image
>::
get
();
auto
it
=
ids
.
find
(
type_name
<
A
>
());
if
(
it
==
ids
.
end
())
{
ids
[
type_name
<
A
>
()]
=
grouped_type_id
<
A
,
typename
A
::
image
>::
get
();
}
size_t
id
=
ids
()
[
type_name
<
A
>
()];
size_t
id
=
ids
[
type_name
<
A
>
()];
if
(
symbols
.
size
()
<=
id
)
{
symbols
.
resize
(
id
+
1
);
}
...
...
@@ -91,6 +91,7 @@ public:
}
private
:
std
::
unordered_map
<
std
::
string
,
size_t
>
ids
;
symbol_table
symbols
;
std
::
string
name
;
...
...
@@ -397,17 +398,20 @@ struct register_kernel {
}
// namespace xpu::detail
#if XPU_IS_CPU
#define XPU_DETAIL_TYPE_ID_MAP(image) \
template<> \
const char *xpu::detail::image_context<image>::file_name = XPU_IMAGE_FILE; \
\
template<> \
std::unordered_map<std::string, size_t> &xpu::detail::image_context<image>::ids() { \
static std::unordered_map<std::string, size_t> ids; \
return ids; \
}
#else
const char *xpu::detail::image_file_name<image>::operator()() const { return XPU_IMAGE_FILE; }
#define XPU_DETAIL_IMAGE_CONTEXT_GETTER(image)
#else // HIP OR CUDA
#define XPU_DETAIL_TYPE_ID_MAP(image)
#define XPU_DETAIL_IMAGE_CONTEXT_GETTER(image) \
extern "C" xpu::detail::image_context<image> *xpu_detail_get_context() { \
return xpu::detail::image_context<image>::instance(); \
}
#endif
#define XPU_DETAIL_IMAGE(image) \
...
...
@@ -417,9 +421,9 @@ struct register_kernel {
static image_context<image> ctx; \
return &ctx; \
} \
extern "C" xpu::detail::image_context<image> *xpu_detail_get_context() {
\
return
xpu
::
detail
::image_context<image>::instance(); \
}
XPU_DETAIL_IMAGE_CONTEXT_GETTER(image)
\
void
xpu
_
detail
_dummy_func() // Force semicolon at the end of macro
#define XPU_DETAIL_EXPORT_FUNC(image, name, ...) \
struct name : xpu::detail::action<image, xpu::detail::function_tag> { \
...
...
This diff is collapsed.
Click to expand it.
src/xpu/detail/runtime.h
+
1
−
1
View file @
ccb1ecd3
...
...
@@ -138,7 +138,7 @@ private:
break
;
case
cuda
:
case
hip
:
i
=
new
image
<
I
>
(
complete_file_name
(
image_
context
<
I
>::
file_name
,
d
).
c_str
());
i
=
new
image
<
I
>
(
complete_file_name
(
image_file_name
<
I
>
{}()
,
d
).
c_str
());
break
;
}
m_images
.
add
(
i
,
d
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment