Skip to content

Commit 2029df2

Browse files
committed
accel/ze: initial pass at intel zero-level
api support for Intel PV and other accelerators related to issue #11763 Signed-off-by: Howard Pritchard <[email protected]>
1 parent 6aa55b8 commit 2029df2

File tree

8 files changed

+1312
-0
lines changed

8 files changed

+1312
-0
lines changed

config/opal_check_ze.m4

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
dnl
2+
dnl Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
3+
dnl Copyright (c) 2023 Triad National Security, LLC. All rights reserved.
4+
dnl $COPYRIGHT$
5+
dnl
6+
dnl Additional copyrights may follow
7+
dnl
8+
dnl $HEADER$
9+
dnl
10+
11+
12+
# OPAL_CHECK_ZE(prefix, [action-if-found], [action-if-not-found])
13+
# --------------------------------------------------------
14+
# check if Intel ZE support can be found. sets prefix_{CPPFLAGS,
15+
# LDFLAGS, LIBS} as needed and runs action-if-found if there is
16+
# support, otherwise executes action-if-not-found
17+
18+
19+
#
20+
# Check for ZE support
21+
#
22+
AC_DEFUN([OPAL_CHECK_ZE],[
23+
24+
OPAL_VAR_SCOPE_PUSH([opal_check_ze_happy ze_save_CPPFLAGS ze_save_LDFLAGS ze_save_LIBS ze_CPPFLAGS ze_LDFLAGS ze_LIBS])
25+
26+
ze_save_CPPFLAGS="$CPPFLAGS"
27+
ze_save_LDFLAGS="$LDFLAGS"
28+
ze_save_LIBS="$LIBS"
29+
30+
# Get some configuration information
31+
AC_ARG_WITH([ze],
32+
[AS_HELP_STRING([--with-ze(=DIR)],
33+
[Build Intel ZE support, optionally adding DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries])])
34+
35+
36+
AS_IF([ test -n "$with_ze" && test "$with_ze" = "yes" ],
37+
[ with_ze="/opt/ze"] )
38+
39+
m4_define([ze_pkgconfig_module], [level-zero])
40+
OAC_CHECK_PACKAGE([ze],
41+
[$1],
42+
[level_zero/ze_api.h],
43+
[ze_loader],
44+
[zeInit],
45+
[opal_check_ze_happy="yes"],
46+
[opal_check_ze_happy="no"])
47+
48+
LDFLAGS="$ze_save_LDFLAGS"
49+
LIBS="$ze_save_LIBS"
50+
OPAL_APPEND([CPPFLAGS], [${$1_CPPFLAGS}] )
51+
OPAL_APPEND([LDFLAGS], [${$1_LDFLAGS}] )
52+
OPAL_APPEND([LIBS], [${$1_LIBS}] )
53+
54+
AS_IF([ test "$opal_check_ze_happy" = "no" ],
55+
[ CPPFLAGS="$ze_save_CPPFLAGS"])
56+
57+
AS_IF([ test "$opal_check_ze_happy" = "yes" ],
58+
[ AC_DEFINE_UNQUOTED([OPAL_ZE_SUPPORT], [1], [Enable Intel ZE support])
59+
ZE_SUPPORT=1 ],
60+
[ AC_DEFINE_UNQUOTED([OPAL_ZE_SUPPORT], [0], [Disable Intel ZE support])
61+
ZE_SUPPORT=0 ])
62+
63+
AS_IF([ test "$opal_check_ze_happy" = "yes" ],
64+
[$2],
65+
[AS_IF([test -n "$with_ze" && test "$with_ze" != "no"],
66+
[AC_MSG_ERROR([Intel ZE support requested but not found. Aborting])])
67+
$3])
68+
69+
AM_CONDITIONAL([OPAL_ze_support], [test "$opal_check_ze_happy" = "yes"])
70+
OPAL_VAR_SCOPE_POP
71+
])

opal/mca/accelerator/ze/Makefile.am

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#
2+
# Copyright (c) 2014 Intel, Inc. All rights reserved.
3+
# Copyright (c) 2017 IBM Corporation. All rights reserved.
4+
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
5+
# All Rights reserved.
6+
# Copyright (c) 2022 Advanced Micro Devices, Inc.
7+
# All Rights reserved.
8+
# $COPYRIGHT$
9+
#
10+
# Additional copyrights may follow
11+
#
12+
# $HEADER$
13+
#
14+
15+
16+
AM_CPPFLAGS = $(common_ze_CPPFLAGS)
17+
18+
sources = \
19+
accelerator_ze.h \
20+
accelerator_ze_component.c \
21+
accelerator_ze_module.c
22+
23+
# Make the output library in this directory, and name it either
24+
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
25+
# (for static builds).
26+
27+
if MCA_BUILD_opal_accelerator_ze_DSO
28+
component_noinst =
29+
component_install = mca_accelerator_ze.la
30+
else
31+
component_noinst = libmca_accelerator_ze.la
32+
component_install =
33+
endif
34+
35+
mcacomponentdir = $(opallibdir)
36+
mcacomponent_LTLIBRARIES = $(component_install)
37+
mca_accelerator_ze_la_SOURCES = $(sources)
38+
mca_accelerator_ze_la_LDFLAGS = -module -avoid-version $(opal_ze_LDFLAGS)
39+
mca_accelerator_ze_la_LIBADD = $(top_builddir)/opal/lib@[email protected] \
40+
$(opal_ze_LIBS)
41+
42+
noinst_LTLIBRARIES = $(component_noinst)
43+
libmca_accelerator_ze_la_SOURCES =$(sources)
44+
libmca_accelerator_ze_la_LDFLAGS = -module -avoid-version $(opal_ze_LDFLAGS)
45+
libmca_accelerator_ze_la_LIBADD = $(opal_ze_LIBS)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
3+
* Copyright (c) 2023 Triad National Security, LLC. All rights reserved.
4+
*
5+
* $COPYRIGHT$
6+
*
7+
* Additional copyrights may follow
8+
*
9+
* $HEADER$
10+
*/
11+
12+
#ifndef OPAL_ACCELERATOR_ZE_H
13+
#define OPAL_ACCELERATOR_ZE_H
14+
15+
#include "opal_config.h"
16+
17+
#include "level_zero/ze_api.h"
18+
19+
#include "opal/mca/accelerator/accelerator.h"
20+
#include "opal/mca/threads/mutex.h"
21+
22+
typedef struct {
23+
opal_accelerator_base_component_t super;
24+
} opal_accelerator_ze_component_t;
25+
26+
OPAL_DECLSPEC extern opal_accelerator_ze_component_t mca_accelerator_ze_component;
27+
OPAL_DECLSPEC extern opal_accelerator_base_module_t opal_accelerator_ze_module;
28+
29+
struct opal_accelerator_ze_stream_t {
30+
opal_accelerator_stream_t base;
31+
ze_command_queue_handle_t hCommandQueue;
32+
ze_command_list_handle_t hCommandList;
33+
int dev_id;
34+
};
35+
typedef struct opal_accelerator_ze_stream_t opal_accelerator_ze_stream_t;
36+
OBJ_CLASS_DECLARATION(opal_accelerator_ze_stream_t);
37+
38+
struct opal_accelerator_ze_event_t {
39+
opal_accelerator_event_t base;
40+
};
41+
typedef struct opal_accelerator_ze_event_t opal_accelerator_ze_event_t;
42+
OBJ_CLASS_DECLARATION(opal_accelerator_ze_event_t);
43+
44+
OPAL_DECLSPEC extern uint32_t opal_accelerator_ze_device_count;
45+
OPAL_DECLSPEC extern ze_device_handle_t *opal_accelerator_ze_devices_handle;
46+
OPAL_DECLSPEC extern ze_driver_handle_t opal_accelerator_ze_driver_handle;
47+
OPAL_DECLSPEC extern ze_context_handle_t opal_accelerator_ze_context;
48+
OPAL_DECLSPEC extern ze_event_pool_handle_t opal_accelerator_ze_event_pool;
49+
OPAL_DECLSPEC extern opal_accelerator_stream_t **opal_accelerator_ze_MemcpyStream;
50+
51+
OPAL_DECLSPEC extern int opal_accelerator_ze_memcpy_async;
52+
OPAL_DECLSPEC extern int opal_accelerator_ze_verbose;
53+
54+
OPAL_DECLSPEC extern int opal_accelerator_ze_lazy_init(void);
55+
56+
#endif

0 commit comments

Comments
 (0)