Skip to content

Commit 43606b9

Browse files
AndraBiscaabisca
andauthored
Enable aie_kernels includes + cleanup cmake scripts (#2596)
Co-authored-by: AndraBisca <[email protected]>
1 parent 4623a97 commit 43606b9

File tree

7 files changed

+48
-62
lines changed

7 files changed

+48
-62
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
285285
PATTERN "CMakeFiles" EXCLUDE
286286
PATTERN "config.h" EXCLUDE)
287287

288+
include("${AIE_SOURCE_DIR}/cmake/install_headers.cmake")
289+
install_headers(${CMAKE_CURRENT_SOURCE_DIR}/aie_kernels
290+
${AIE_BINARY_DIR}/include
291+
${CMAKE_INSTALL_PREFIX}/include
292+
"aie_kernels"
293+
)
294+
288295
if(NOT LLVM_ENABLE_IDE)
289296
add_llvm_install_targets(install-aie-headers DEPENDS aie-headers COMPONENT
290297
aie-headers)

cmake/install_headers.cmake

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
3+
# See https://llvm.org/LICENSE.txt for license information.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
#
6+
# (c) Copyright 2025 Advanced Micro Devices Inc.
7+
8+
function(install_headers SRCPATH BUILDPATH INSTALLPATH HEADERS_NAME)
9+
message("Installing ${HEADERS_NAME} includes from ${SRCPATH} in ${INSTALLPATH}/${HEADERS_NAME}")
10+
11+
# copy header files into install area
12+
install(DIRECTORY ${SRCPATH}/ DESTINATION ${INSTALLPATH}/${HEADERS_NAME})
13+
14+
message("Copying ${HEADERS_NAME} includes from ${SRCPATH} to ${BUILDPATH}/${HEADERS_NAME}")
15+
16+
# copy header files into build area
17+
file(GLOB_RECURSE headers_to_copy ${SRCPATH}/*.h ${SRCPATH}/*.hpp)
18+
foreach(header ${headers_to_copy})
19+
file(RELATIVE_PATH rel_path ${SRCPATH} ${header})
20+
21+
# create target name from file's path to avoid duplication
22+
get_filename_component(file_name "${header}" NAME)
23+
get_filename_component(parent_dir ${header} DIRECTORY)
24+
get_filename_component(module_name ${parent_dir} NAME)
25+
26+
set(dest ${BUILDPATH}/${HEADERS_NAME}/${rel_path})
27+
add_custom_target(aie-copy-runtime-libs-${module_name}-${file_name} ALL DEPENDS ${dest})
28+
add_custom_command(OUTPUT ${dest}
29+
COMMAND ${CMAKE_COMMAND} -E copy ${header} ${dest}
30+
DEPENDS ${header}
31+
)
32+
endforeach()
33+
34+
endfunction()

programming_examples/getting_started/00_memcpy/passThrough.cc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,7 @@
1414
#include <stdlib.h>
1515

1616
#include <aie_api/aie.hpp>
17-
18-
#if defined(__chess__)
19-
#define AIE_PREPARE_FOR_PIPELINING [[chess::prepare_for_pipelining]]
20-
#define AIE_LOOP_MIN_ITERATION_COUNT(x) [[chess::min_loop_count(x)]]
21-
#elif defined(__AIECC__)
22-
#ifndef __STRINGIFY
23-
#define __STRINGIFY(a) #a
24-
#endif
25-
#define AIE_LOOP_MIN_ITERATION_COUNT(x) \
26-
_Pragma(__STRINGIFY(clang loop min_iteration_count(x)))
27-
#define AIE_PREPARE_FOR_PIPELINING
28-
#else
29-
#define AIE_LOOP_MIN_ITERATION_COUNT(x)
30-
#define AIE_PREPARE_FOR_PIPELINING
31-
#endif
17+
#include <aie_kernels/aie_kernel_utils.h>
3218

3319
template <typename T, int N>
3420
__attribute__((noinline)) void passThrough_aie(T *restrict in, T *restrict out,

programming_examples/getting_started/02_vector_reduce_max/reduce_max_vector.cc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,7 @@
1515
#include <type_traits>
1616

1717
#include <aie_api/aie.hpp>
18-
19-
#if defined(__chess__)
20-
#define AIE_PREPARE_FOR_PIPELINING [[chess::prepare_for_pipelining]]
21-
#define AIE_LOOP_MIN_ITERATION_COUNT(x) [[chess::min_loop_count(x)]]
22-
#elif defined(__AIECC__)
23-
#ifndef __STRINGIFY
24-
#define __STRINGIFY(a) #a
25-
#endif
26-
#define AIE_LOOP_MIN_ITERATION_COUNT(x) \
27-
_Pragma(__STRINGIFY(clang loop min_iteration_count(x)))
28-
#define AIE_PREPARE_FOR_PIPELINING
29-
#else
30-
#define AIE_LOOP_MIN_ITERATION_COUNT(x)
31-
#define AIE_PREPARE_FOR_PIPELINING
32-
#endif
18+
#include <aie_kernels/aie_kernel_utils.h>
3319

3420
template <typename T, typename V>
3521
void _reduce_max_vector(T *restrict in, T *restrict out,

programming_examples/getting_started/03_matrix_multiplication_single_core/matrix_multiplication.cc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,7 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
#include <aie_api/aie.hpp>
13-
14-
#if defined(__chess__)
15-
#define AIE_PREPARE_FOR_PIPELINING [[chess::prepare_for_pipelining]]
16-
#define AIE_LOOP_MIN_ITERATION_COUNT(x) [[chess::min_loop_count(x)]]
17-
#elif defined(__AIECC__)
18-
#ifndef __STRINGIFY
19-
#define __STRINGIFY(a) #a
20-
#endif
21-
#define AIE_LOOP_MIN_ITERATION_COUNT(x) \
22-
_Pragma(__STRINGIFY(clang loop min_iteration_count(x)))
23-
#define AIE_PREPARE_FOR_PIPELINING
24-
#else
25-
#define AIE_LOOP_MIN_ITERATION_COUNT(x)
26-
#define AIE_PREPARE_FOR_PIPELINING
27-
#endif
13+
#include <aie_kernels/aie_kernel_utils.h>
2814

2915
// Make sure the following tile and intrinsic sizes match the sizes in the
3016
// data layout transformations described in

runtime_lib/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ install(TARGETS xaienginecdo_static DESTINATION lib EXPORT xaienginecdo_static)
141141
install(EXPORT xaienginecdo_static DESTINATION lib/cmake/aie)
142142
target_include_directories(xaienginecdo_static SYSTEM PRIVATE ${BOOTGEN_SOURCE_DIR}/cdo-driver)
143143

144-
include("aie_api/aieapi.cmake")
145-
set(AIEAPI_SOURCE_DIR "../third_party/aie_api/include/aie_api")
146-
add_aie_api_headers(${AIEAPI_SOURCE_DIR}
144+
include("${AIE_SOURCE_DIR}/cmake/install_headers.cmake")
145+
set(AIEAPI_SOURCE_DIR "${AIE_SOURCE_DIR}/third_party/aie_api/include/aie_api")
146+
install_headers(${AIEAPI_SOURCE_DIR}
147147
${AIE_BINARY_DIR}/include
148148
${CMAKE_INSTALL_PREFIX}/include
149+
"aie_api"
149150
)
150-

runtime_lib/aie_api/aieapi.cmake

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)