Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jnider airbin #259

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Jnider airbin #259

wants to merge 11 commits into from

Conversation

jnider
Copy link
Collaborator

@jnider jnider commented Jul 20, 2023

End-to-end flow is complete but I haven't validated the results yet.

@jnider jnider force-pushed the jnider-airbin branch 13 times, most recently from d8880d3 to 9114697 Compare July 21, 2023 01:24
@jnider jnider marked this pull request as ready for review July 21, 2023 01:56
@@ -72,6 +72,12 @@ jobs:
- name: Rebuild and Install libxaie
run: utils/github-clone-build-libxaie.sh

- name: Install necessary build tools
run: sudo apt install autoconf flex bison gawk autopoint -y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, I did not even know we can have -y at the end! :-)
Perhaps you could keep it at the beginning to have a clearer statement and sort the package names to be easier to check visually we have already the right package.

Comment on lines 1084 to 1085
// u32 shimDMA0 = (pkt->arg[1] >> 16) & 0xff;
// u32 shimDMA1 = (pkt->arg[1] >> 24) & 0xff;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

not a big deal. This allows us to do only a single pass on the ELF
sections so it seems like a good trade-off.
*/
printf("There are %lu sections\n", shnum);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some extra printf here and below. I think these should all be DBG_PRINT? That is, the runtime should be silent by default.

Comment on lines +1 to +22
# Copyright (C) 2022, Xilinx Inc.
# Copyright (C) 2022, Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

ACDC_AIE = $(dir $(shell which aie-opt))/..
ACDC_AIR = $(dir $(shell which air-opt))/..

all: test.elf

test.elf: aie.mlir test.cpp
aiecc.py -v --host-target=x86_64-amd-linux-gnu --aie-generate-airbin --sysroot= $< \
-I/opt/xaiengine/include -L/opt/xaiengine/lib -Wl,-R/opt/xaiengine/lib \
-I$(ACDC_AIE)/runtime_lib/x86_64/test_lib/include \
-I$(ACDC_AIR)/runtime_lib/airhost/include \
-I$(ACDC_AIE)/runtime_lib \
$(ACDC_AIE)/runtime_lib/x86_64/test_lib/src/test_library.cpp \
-L$(ACDC_AIR)/runtime_lib/airhost \
../../elfutils/libelf/libelf.a \
-Wl,--whole-archive -lairhost -Wl,--no-whole-archive -lstdc++ -ldl -o $@ test.cpp

clean::
rm -rf acdc_project *.elf
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be an automated lit test, not a manual makefile based test.


ret = air_load_airbin(q, "airbin.elf", col);
if (!ret) {
printf("Loading airbin failed: %d\n", ret);
Copy link
Collaborator

@fifield fifield Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exit nonzero on failure

Comment on lines +21 to +34
if [[ ! -d $INSTALL_DIR ]]; then
git clone --branch $HASH --depth 1 https://github.com/jnider/elfutils.git $INSTALL_DIR
fi

cd $INSTALL_DIR
autoreconf -v -f -i
./configure --program-prefix="air-" --disable-debuginfod --disable-libdebuginfod --enable-maintainer-mode


# build libeu.a, required for libelf.so
make -C lib

# build libelf.a, libelf_pic.a and libelf.so
make -C libelf
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these steps should have error handling and reporting. Some of the existing scripts (not changed by this PR) have the same problem.

To control which platforms are built, a top-level Makefile is added.
It calls the child makefiles as needed, to build or clean a specific
platform. All platforms can be built or cleaned together, or each
platform can be addressed individually.

To build a specific platform, call:

make <platform>

To clean a specific platform, call:

make <platform>-clean

To control them all at the same time, use 'make' or 'make clean'
without any additional parameters.

Signed-off-by: Joel Nider <[email protected]>
jnider added 7 commits August 17, 2023 18:56
Signed-off-by: Joel Nider <[email protected]>
Add base addresses to platform.h
Change register offsets into defines so they are easier to read.
Add some helper functions for common operations like resetting a column.

Signed-off-by: Joel Nider <[email protected]>
Libelf (one library inside the 'elfutils' repo) is a library for manipulating
ELF files from C programs. It is used when generating AIRBIN files by the
compiler backend and also when reading them in the runtime for loading to
the device.

Signed-off-by: Joel Nider <[email protected]>
The runtime lib was modified to use libelf for loading airbin files. Since the
runtime lib is built as a static library (.a file), it does not include a link
step and can therefore not be linked directly with libelf. However, it does
call functions in libelf when loading airbin files, which means it has a
dependency on libelf. That forces all applications that link with the runtime
lib to also link with libelf, even if those functions are not used in that
particular application.

The command line options are also put on separate lines and sorted by type
(library path, include path, etc.) to make it easier to modify, diff and
understand what is happening in general.

Signed-off-by: Joel Nider <[email protected]>
Signed-off-by: Joel Nider <[email protected]>
jnider added 3 commits August 17, 2023 19:22
An AIRBIN is an ELF file that contains AIE configuration and executable code.
It is loaded to the device by the runtime by copying it to device memory and
then notifying the device that continues the process.

Add code to read the file, place it in device memory and notify the device.

This depends on libelf (from elfutils) that is built in:
github-clone-build-elfutils.sh

Signed-off-by: Joel Nider <[email protected]>
Signed-off-by: Joel Nider <[email protected]>
Add a new packet type AIR_PKT_TYPE_AIRBIN for loading an AIRBIN. The packet
holds the base address in device memory where the AIRBIN has been loaded by
the runtime_lib on the host. The packet handler builds a CDMA descriptor
chain based on the AIRBIN sections and loads them into AIE memory.

The ARM_CONTROLLER define is set by the compiler so it is available to all
source files.

The CDMA driver is moved to a separate source file. Currently, only the
scatter/gather mode has been implemented. A future patch will add the simple
mode as well, and then the legacy CDMA code can be removed.

Add a function to reset a shim tile. Follows the procedure for shim tile resets.
The reset is a global action but masked by registers belonging to each shim
tile. By unmasking a particular tile, it will participate in the reset. The
actual reset is performed through the NPI interface, then all the registers are
unmasked to prevent accidental reset later.

Signed-off-by: Joel Nider <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants