Skip to content

Commit 5591736

Browse files
committed
chipstar: New recipe for chipStar 1.2.1
Signed-off-by: Zoltán Böszörményi <[email protected]>
1 parent b012d24 commit 5591736

11 files changed

+523
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 4588e6b9f77e94211cdfedea095e2a7747c9b501 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3+
4+
Date: Tue, 26 Nov 2024 13:36:31 +0100
5+
Subject: [PATCH 1/7] Allow detecting LLVM and CLang without explicit paths
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
Upstream-Status: Inappropriate [cross compiler specific]
11+
Signed-off-by: Zoltán Böszörményi <[email protected]>
12+
---
13+
cmake/FindLLVM.cmake | 8 ++++----
14+
1 file changed, 4 insertions(+), 4 deletions(-)
15+
16+
diff --git a/cmake/FindLLVM.cmake b/cmake/FindLLVM.cmake
17+
index a12bd476..ac04bab4 100644
18+
--- a/cmake/FindLLVM.cmake
19+
+++ b/cmake/FindLLVM.cmake
20+
@@ -72,13 +72,13 @@ endif()
21+
include_directories(${LLVM_INCLUDE_DIRS})
22+
23+
# Set the compilers
24+
-find_program(CMAKE_CXX_COMPILER_PATH NAMES clang++ NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH_BIN})
25+
+find_program(CMAKE_CXX_COMPILER_PATH NAMES ${TARGET_SYS}-clang++ clang++)
26+
if(NOT CMAKE_CXX_COMPILER_PATH)
27+
message(FATAL_ERROR "Could not find clang++ in ${CLANG_ROOT_PATH_BIN}. Please provide CMake argument -DCMAKE_CXX_COMPILER_PATH=/path/to/clang++<-version>")
28+
endif()
29+
message(STATUS "Using CMAKE_CXX_COMPILER_PATH: ${CMAKE_CXX_COMPILER_PATH}")
30+
31+
-find_program(CMAKE_C_COMPILER_PATH NAMES clang NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH_BIN})
32+
+find_program(CMAKE_C_COMPILER_PATH NAMES ${TARGET_SYS}-clang clang)
33+
if(NOT CMAKE_C_COMPILER_PATH)
34+
message(FATAL_ERROR "Could not find clang in ${CLANG_ROOT_PATH_BIN}. Please provide CMake argument -DCMAKE_C_COMPILER_PATH=/path/to/clang<-version>")
35+
endif()
36+
@@ -143,5 +143,5 @@ endif()
37+
38+
enable_language(C CXX)
39+
# required by ROCm-Device-Libs, must be after project() call
40+
-find_package(LLVM REQUIRED CONFIG NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH}/lib/cmake/llvm)
41+
-find_package(Clang REQUIRED CONFIG NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH}/lib/cmake/clang)
42+
+find_package(LLVM REQUIRED CONFIG)
43+
+find_package(Clang REQUIRED CONFIG)
44+
--
45+
2.47.0
46+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From bd3fd0a630762cda06e06208cf4ab0a300cb7424 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3+
4+
Date: Tue, 26 Nov 2024 15:46:51 +0100
5+
Subject: [PATCH 1/3] Fix llvm-link command
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
Upstream-Status: Inappropriate [cross compiler specific]
11+
Signed-off-by: Zoltán Böszörményi <[email protected]>
12+
---
13+
irif/CMakeLists.txt | 2 +-
14+
1 file changed, 1 insertion(+), 1 deletion(-)
15+
16+
diff --git a/irif/CMakeLists.txt b/irif/CMakeLists.txt
17+
index a874772..47f7616 100644
18+
--- a/irif/CMakeLists.txt
19+
+++ b/irif/CMakeLists.txt
20+
@@ -19,7 +19,7 @@ set(irif_lib_file ${CMAKE_CURRENT_BINARY_DIR}/irif.bc)
21+
# set_target_properties(llvm-link PROPERTIES IMPORTED_LOCATION ${LLVM_LINK_EXECUTABLE})
22+
23+
add_custom_command(OUTPUT ${irif_lib_file}
24+
- COMMAND $<TARGET_FILE:llvm-link> ${sources} -o ${irif_lib_file}
25+
+ COMMAND llvm-link ${sources} -o ${irif_lib_file}
26+
DEPENDS ${sources})
27+
28+
add_custom_target(irif DEPENDS ${irif_lib_file}
29+
--
30+
2.47.0
31+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 21456b0816af8e80ee03f4ea5e73111195431948 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3+
4+
Date: Wed, 27 Nov 2024 11:19:54 +0100
5+
Subject: [PATCH 2/7] Use TARGET_SYS for offload compile options
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
Upstream-Status: Inappropriate [cross compiler specific]
11+
Signed-off-by: Zoltán Böszörményi <[email protected]>
12+
---
13+
CMakeLists.txt | 2 +-
14+
1 file changed, 1 insertion(+), 1 deletion(-)
15+
16+
diff --git a/CMakeLists.txt b/CMakeLists.txt
17+
index c9cd19b2..59a7822b 100644
18+
--- a/CMakeLists.txt
19+
+++ b/CMakeLists.txt
20+
@@ -520,7 +520,7 @@ endif()
21+
# For use by hipcc
22+
execute_process(COMMAND ${LLVM_CONFIG_BIN} --host-target
23+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE HOST_ARCH)
24+
-set(HOST_ARCH "--target=${HOST_ARCH}")
25+
+set(HOST_ARCH "--target=${TARGET_SYS}")
26+
27+
set(HIP_OFFLOAD_COMPILE_OPTIONS_INSTALL_
28+
${HIP_ENABLE_SPIRV}
29+
--
30+
2.47.0
31+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
From bf8832d0b004b2c6a6ddaa074dd72a6c023ebeca Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3+
4+
Date: Tue, 26 Nov 2024 16:00:00 +0100
5+
Subject: [PATCH 2/3] Use target clang compiler for generating bitcode files
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
Also fix other COMMAND statements in the same macro
11+
12+
Upstream-Status: Inappropriate [cross compiler specific]
13+
Signed-off-by: Zoltán Böszörményi <[email protected]>
14+
---
15+
cmake/OCL.cmake | 8 ++++----
16+
1 file changed, 4 insertions(+), 4 deletions(-)
17+
18+
diff --git a/cmake/OCL.cmake b/cmake/OCL.cmake
19+
index 2eaf44e..c6005d2 100644
20+
--- a/cmake/OCL.cmake
21+
+++ b/cmake/OCL.cmake
22+
@@ -99,7 +99,7 @@ macro(opencl_bc_lib)
23+
if (fext STREQUAL ".cl")
24+
set(output "${CMAKE_CURRENT_BINARY_DIR}/${fname_we}${BC_EXT}")
25+
add_custom_command(OUTPUT "${output}"
26+
- COMMAND ${CLANG_ROOT_PATH_BIN}/clang ${inc_options} ${CLANG_OCL_FLAGS}
27+
+ COMMAND ${CMAKE_C_COMPILER_PATH} ${inc_options} ${CLANG_OCL_FLAGS}
28+
-emit-llvm -Xclang -mlink-builtin-bitcode -Xclang "${irif_lib_output}"
29+
-c "${file}" -o "${output}"
30+
DEPENDS "${file}" "${irif_lib_output}" "${CLANG}"
31+
@@ -130,12 +130,12 @@ macro(opencl_bc_lib)
32+
33+
add_custom_command(OUTPUT ${OUTPUT_BC_LIB}
34+
# Link regular library dependencies
35+
- COMMAND ${CLANG_ROOT_PATH_BIN}/llvm-link
36+
+ COMMAND llvm-link
37+
-o "${OUT_NAME}.link0${LIB_SUFFIX}" "@${OUT_NAME}_response"
38+
# Extra link step with internalize
39+
- COMMAND ${CLANG_ROOT_PATH_BIN}/llvm-link -internalize -only-needed "${name}.link0${LIB_SUFFIX}"
40+
+ COMMAND llvm-link -internalize -only-needed "${name}.link0${LIB_SUFFIX}"
41+
-o "${OUT_NAME}${LIB_SUFFIX}" ${internal_link_libs}
42+
- COMMAND ${CLANG_ROOT_PATH_BIN}/opt -passes=strip
43+
+ COMMAND opt -passes=strip
44+
-o "${OUT_NAME}${STRIP_SUFFIX}" "${OUT_NAME}${LIB_SUFFIX}"
45+
COMMAND "${PREPARE_BUILTINS}"
46+
-o ${OUTPUT_BC_LIB} "${OUT_NAME}${STRIP_SUFFIX}"
47+
--
48+
2.47.0
49+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
From 2ae94496af84f2cfed2e2bf46312b601dedfbeee Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3+
4+
Date: Wed, 27 Nov 2024 11:58:32 +0100
5+
Subject: [PATCH 3/7] Remove ->dump() usage from the LLVM pass
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
Release builds of LLVM do not have the Elt->dump() method
11+
which Yocto uses for LLVM and CLang. This fixes the error:
12+
13+
chipstar/1.2.1/build/lib/libLLVMHipSpvPasses.so: undefined symbol: _ZNK4llvm5Value4dumpEv
14+
15+
Upstream-Status: Inappropriate [oe specific]
16+
Signed-off-by: Zoltán Böszörményi <[email protected]>
17+
---
18+
llvm_passes/HipPrintf.cpp | 3 ---
19+
llvm_passes/HipTextureLowering.cpp | 17 +----------------
20+
2 files changed, 1 insertion(+), 19 deletions(-)
21+
22+
diff --git a/llvm_passes/HipPrintf.cpp b/llvm_passes/HipPrintf.cpp
23+
index 18a8441c..5aa83984 100644
24+
--- a/llvm_passes/HipPrintf.cpp
25+
+++ b/llvm_passes/HipPrintf.cpp
26+
@@ -303,7 +303,6 @@ PreservedAnalyses HipPrintfToOpenCLPrintfPass::run(Module &Mod,
27+
// 1 use if the "printf" is only used by "_cl_printf"
28+
if (Printf == nullptr || Printf->getNumUses() == 1)
29+
return PreservedAnalyses::all();
30+
- LLVM_DEBUG(dbgs() << "Found printf decl: "; Printf->dump());
31+
32+
Function *PrintfF = cast<Function>(Printf);
33+
34+
@@ -351,8 +350,6 @@ PreservedAnalyses HipPrintfToOpenCLPrintfPass::run(Module &Mod,
35+
if (!Callee->hasName() || Callee->getName() != ORIG_PRINTF_FUNC_NAME)
36+
continue;
37+
38+
- LLVM_DEBUG(dbgs() << "Original printf call: "; CI->dump());
39+
-
40+
CallInst &OrigCall = cast<CallInst>(I);
41+
unsigned TotalFmtSpecCount;
42+
auto FmtSpecPieces =
43+
diff --git a/llvm_passes/HipTextureLowering.cpp b/llvm_passes/HipTextureLowering.cpp
44+
index c363010c..d2d799ac 100644
45+
--- a/llvm_passes/HipTextureLowering.cpp
46+
+++ b/llvm_passes/HipTextureLowering.cpp
47+
@@ -136,22 +136,7 @@ public:
48+
}
49+
};
50+
51+
-void TextureUseGroup::dump() const {
52+
-#define DOIT(_container, _desc) \
53+
- do { \
54+
- dbgs() << _desc << ":" << (_container.empty() ? " none" : "") << "\n"; \
55+
- for (auto *Elt : _container) { \
56+
- dbgs() << "- "; \
57+
- Elt->dump(); \
58+
- } \
59+
- } while (0)
60+
-
61+
- DOIT(DirectTexSources_, "Direct tex sources");
62+
- DOIT(IndirectTexSources_, "Indirect tex sources");
63+
- DOIT(TexFunctionCalls_, "Tex function calls");
64+
- DOIT(UnknownTexUsers_, "Unknown tex users");
65+
-#undef DOIT
66+
-}
67+
+void TextureUseGroup::dump() const {}
68+
69+
using TextureUseGroupList = std::vector<TextureUseGroup>;
70+
using TextureUseGroupMap = std::map<Value *, TextureUseGroup *>;
71+
--
72+
2.47.0
73+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From db7e15fbeb04d5b78b7573006aedfebedb66868c Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3+
4+
Date: Tue, 26 Nov 2024 16:44:40 +0100
5+
Subject: [PATCH 3/3] Use native build of prepare-builtins
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
Upstream-Status: Inappropriate [cross compiler specific]
11+
Signed-off-by: Zoltán Böszörményi <[email protected]>
12+
---
13+
cmake/OCL.cmake | 2 +-
14+
1 file changed, 1 insertion(+), 1 deletion(-)
15+
16+
diff --git a/cmake/OCL.cmake b/cmake/OCL.cmake
17+
index c6005d2..fa99889 100644
18+
--- a/cmake/OCL.cmake
19+
+++ b/cmake/OCL.cmake
20+
@@ -137,7 +137,7 @@ macro(opencl_bc_lib)
21+
-o "${OUT_NAME}${LIB_SUFFIX}" ${internal_link_libs}
22+
COMMAND opt -passes=strip
23+
-o "${OUT_NAME}${STRIP_SUFFIX}" "${OUT_NAME}${LIB_SUFFIX}"
24+
- COMMAND "${PREPARE_BUILTINS}"
25+
+ COMMAND prepare-builtins
26+
-o ${OUTPUT_BC_LIB} "${OUT_NAME}${STRIP_SUFFIX}"
27+
DEPENDS "${deps}" "${CMAKE_CURRENT_BINARY_DIR}/${OUT_NAME}_response" "${PREPARE_BUILTINS}" ${internal_link_libs})
28+
29+
--
30+
2.47.0
31+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From 08e03e096bbd0672d2532d6965fb0c53caec0b9b Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3+
4+
Date: Wed, 27 Nov 2024 13:02:35 +0100
5+
Subject: [PATCH 4/7] Execute the native hipcc in samples/ccompat
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
Upstream-Status: Inappropriate [cross compiler specific]
11+
Signed-off-by: Zoltán Böszörményi <[email protected]>
12+
---
13+
samples/ccompat/CMakeLists.txt | 6 +++---
14+
1 file changed, 3 insertions(+), 3 deletions(-)
15+
16+
diff --git a/samples/ccompat/CMakeLists.txt b/samples/ccompat/CMakeLists.txt
17+
index 2c0e7648..7afe1216 100644
18+
--- a/samples/ccompat/CMakeLists.txt
19+
+++ b/samples/ccompat/CMakeLists.txt
20+
@@ -1,18 +1,18 @@
21+
add_custom_command(
22+
OUTPUT saxpy.o DEPENDS ${CMAKE_SOURCE_DIR}/samples/ccompat/saxpy.hip
23+
- COMMAND ${CMAKE_BINARY_DIR}/bin/hipcc
24+
+ COMMAND hipcc
25+
${CMAKE_SOURCE_DIR}/samples/ccompat/saxpy.hip -c -g -pthread
26+
-I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/HIP/include)
27+
28+
add_custom_command(
29+
OUTPUT ccompat.o DEPENDS ${CMAKE_SOURCE_DIR}/samples/ccompat/ccompat.c
30+
- COMMAND ${CMAKE_BINARY_DIR}/bin/hipcc
31+
+ COMMAND hipcc
32+
${CMAKE_SOURCE_DIR}/samples/ccompat/ccompat.c -c -g -pthread
33+
-I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/HIP/include)
34+
35+
add_custom_command(
36+
OUTPUT ccompat DEPENDS ccompat.o saxpy.o
37+
-COMMAND ${CMAKE_BINARY_DIR}/bin/hipcc
38+
+COMMAND hipcc
39+
./ccompat.o ./saxpy.o -o ccompat -g -pthread)
40+
41+
add_custom_target(ccompatBuild ALL
42+
--
43+
2.47.0
44+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From a2f46d748c9af2144374bf99626ffa25419ef2f5 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3+
4+
Date: Wed, 27 Nov 2024 13:15:41 +0100
5+
Subject: [PATCH 5/7] Use native hipcc in add_custom_command()
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
Upstream-Status: Inappropriate [cross compiler specific]
11+
Signed-off-by: Zoltán Böszörményi <[email protected]>
12+
---
13+
CMakeLists.txt | 2 +-
14+
1 file changed, 1 insertion(+), 1 deletion(-)
15+
16+
diff --git a/CMakeLists.txt b/CMakeLists.txt
17+
index 59a7822b..aeb25580 100644
18+
--- a/CMakeLists.txt
19+
+++ b/CMakeLists.txt
20+
@@ -428,7 +428,7 @@ endif()
21+
# once hipcc.bin is built, execute hipcc ./samples/hipSample.cpp
22+
add_custom_command(
23+
OUTPUT ${CMAKE_BINARY_DIR}/hipInfo
24+
- COMMAND ${HIPCC_BUILD_PATH}/hipcc ${CMAKE_SOURCE_DIR}/samples/hipInfo/hipInfo.cpp -o ${CMAKE_BINARY_DIR}/hipInfo
25+
+ COMMAND hipcc ${CMAKE_SOURCE_DIR}/samples/hipInfo/hipInfo.cpp -o ${CMAKE_BINARY_DIR}/hipInfo
26+
DEPENDS ${CMAKE_SOURCE_DIR}/samples/hipInfo/hipInfo.cpp hipcc.bin CHIP devicelib_bc
27+
)
28+
29+
--
30+
2.47.0
31+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From 8e2f9062d1b5e4c78d6cd9574659d5f6d71ff289 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
3+
4+
Date: Wed, 27 Nov 2024 14:26:32 +0100
5+
Subject: [PATCH 6/7] Hide source and build directory
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
Upstream-Status: Inappropriate [cross compiler specific]
11+
Signed-off-by: Zoltán Böszörményi <[email protected]>
12+
---
13+
chipStarConfig.hh.in | 4 ++--
14+
1 file changed, 2 insertions(+), 2 deletions(-)
15+
16+
diff --git a/chipStarConfig.hh.in b/chipStarConfig.hh.in
17+
index a836cd8e..326d1b9b 100644
18+
--- a/chipStarConfig.hh.in
19+
+++ b/chipStarConfig.hh.in
20+
@@ -32,9 +32,9 @@
21+
// not implemented yet
22+
#undef OCML_BASIC_ROUNDED_OPERATIONS
23+
24+
-#cmakedefine CHIP_SOURCE_DIR "@CHIP_SOURCE_DIR@"
25+
+#cmakedefine CHIP_SOURCE_DIR "@EXT_SOURCE_DIR@"
26+
27+
-#cmakedefine CHIP_BUILD_DIR "@CHIP_BUILD_DIR@"
28+
+#cmakedefine CHIP_BUILD_DIR "@EXT_BUILD_DIR@"
29+
30+
#cmakedefine CHIP_INSTALL_DIR "@CHIP_INSTALL_DIR@"
31+
32+
--
33+
2.47.0
34+

0 commit comments

Comments
 (0)