-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Change vec_scal_add examples to vec_scal_mul and cleaned up R…
- Loading branch information
Showing
29 changed files
with
1,685 additions
and
379 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
Binary file not shown.
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
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,70 @@ | ||
# This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# (c) Copyright 2024 Advanced Micro Devices, Inc. | ||
|
||
# parameters | ||
# -DBOOST_ROOT: Path to Boost install | ||
# -DXRT_INC_DIR: Full path to src/runtime_src/core/include in XRT cloned repo | ||
# -DXRT_LIB_DIR: Path to xrt_coreutil.lib | ||
# -DTARGET_NAME: Target name to be built | ||
|
||
# cmake needs this line | ||
cmake_minimum_required(VERSION 3.1) | ||
|
||
find_program(WSL NAMES powershell.exe) | ||
|
||
if (NOT WSL) | ||
set(BOOST_ROOT /usr/include/boost CACHE STRING "Path to Boost install") | ||
set(XRT_INC_DIR /opt/xilinx/xrt/include CACHE STRING "Path to XRT cloned repo") | ||
set(XRT_LIB_DIR /opt/xilinx/xrt/lib CACHE STRING "Path to xrt_coreutil.lib") | ||
else() | ||
set(BOOST_ROOT C:/Technical/thirdParty/boost_1_83_0 CACHE STRING "Path to Boost install") | ||
set(XRT_INC_DIR C:/Technical/XRT/src/runtime_src/core/include CACHE STRING "Path to XRT cloned repo") | ||
set(XRT_LIB_DIR C:/Technical/xrtNPUfromDLL CACHE STRING "Path to xrt_coreutil.lib") | ||
endif() | ||
|
||
set(TARGET_NAME test CACHE STRING "Target to be built") | ||
|
||
SET (ProjectName ${TARGET_NAME}) | ||
SET (currentTarget ${TARGET_NAME}) | ||
|
||
if ( WSL ) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) | ||
endif () | ||
|
||
project(${ProjectName}) | ||
|
||
# Find packages | ||
find_package(Boost REQUIRED) | ||
|
||
add_executable(${currentTarget} | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../runtime_lib/test_lib/test_utils.cpp | ||
test.cpp | ||
) | ||
|
||
target_compile_definitions(${currentTarget} PUBLIC DISABLE_ABI_CHECK=1) | ||
|
||
target_include_directories (${currentTarget} PUBLIC | ||
${XRT_INC_DIR} | ||
${Boost_INCLUDE_DIRS} | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../runtime_lib/test_lib | ||
) | ||
|
||
target_link_directories(${currentTarget} PUBLIC | ||
${XRT_LIB_DIR} | ||
${Boost_LIBRARY_DIRS} | ||
) | ||
|
||
if (NOT WSL) | ||
target_link_libraries(${currentTarget} PUBLIC | ||
xrt_coreutil | ||
boost_program_options | ||
boost_filesystem | ||
) | ||
else() | ||
target_link_libraries(${currentTarget} PUBLIC | ||
xrt_coreutil | ||
) | ||
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,74 @@ | ||
# | ||
# This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# (c) Copyright 2023 AMD Inc. | ||
|
||
from aie.dialects.aie import * # primary mlir-aie dialect definitions | ||
from aie.extras.context import mlir_mod_ctx # mlir-aie context | ||
|
||
from aie.dialects.aiex import * # extended mlir-aie dialect definitions | ||
from aie.dialects.scf import * # scf (strcutred control flow) dialect | ||
from aie.extras.dialects.ext import memref, arith # memref and arithmatic dialects | ||
|
||
|
||
# AI Engine structural design function | ||
def my_first_aie_program(): | ||
|
||
# Dvice declaration - aie2 device NPU | ||
@device(AIEDevice.npu) | ||
def device_body(): | ||
# Memref types | ||
memRef_8_ty = T.memref(8, T.i32()) | ||
memRef_16_ty = T.memref(16, T.i32()) | ||
memRef_32_ty = T.memref(32, T.i32()) | ||
memRef_64_ty = T.memref(64, T.i32()) | ||
|
||
# Tile declarations | ||
ComputeTile = tile(0, 2) | ||
ShimTile = tile(0, 0) | ||
|
||
# Data movement with object FIFOs | ||
# Input (from shim tile to compute tile) | ||
of_in0 = object_fifo("in0", ShimTile, ComputeTile, 2, memRef_8_ty) | ||
|
||
# Output (from compute tile to shim tile) | ||
of_out0 = object_fifo("out0", ComputeTile, ShimTile, 2, memRef_8_ty) | ||
|
||
# Compute tile body | ||
@core(ComputeTile) | ||
def core_body(): | ||
for _ in for_(8): | ||
# Acquire input and output object FIFO objects | ||
elem_in = of_in0.acquire(ObjectFifoPort.Consume, 1) | ||
elem_out = of_out0.acquire(ObjectFifoPort.Produce, 1) | ||
|
||
# Core functionality - load, add 1, store | ||
for i in for_(8): | ||
v0 = memref.load(elem_in, [i]) | ||
v1 = arith.addi(v0, arith.constant(1, T.i32())) | ||
memref.store(v1, elem_out, [i]) | ||
yield_([]) | ||
|
||
# Release input and output object FIFO objects | ||
of_in0.release(ObjectFifoPort.Consume, 1) | ||
of_out0.release(ObjectFifoPort.Produce, 1) | ||
yield_([]) | ||
|
||
# To/from AIE-array data movement | ||
@FuncOp.from_py_func(memRef_64_ty, memRef_64_ty, memRef_64_ty) | ||
def sequence(inTensor, unused, outTensor): | ||
npu_dma_memcpy_nd( | ||
metadata="out0", bd_id=0, mem=outTensor, sizes=[1, 1, 1, 64] | ||
) | ||
npu_dma_memcpy_nd( | ||
metadata="in0", bd_id=1, mem=inTensor, sizes=[1, 1, 1, 64] | ||
) | ||
npu_sync(column=0, row=0, direction=0, channel=0) | ||
|
||
|
||
# Declares that subsequent code is in mlir-aie context | ||
with mlir_mod_ctx() as ctx: | ||
my_first_aie_program() # Call design function within the mlir-aie context | ||
print(ctx.module) # Print the python-to-mlir conversion |
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.