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

chipstar: New recipe for chipStar 1.2.1 #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From 4588e6b9f77e94211cdfedea095e2a7747c9b501 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
<zboszor@gmail.com>
Date: Tue, 26 Nov 2024 13:36:31 +0100
Subject: [PATCH 1/7] Allow detecting LLVM and CLang without explicit paths
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upstream-Status: Inappropriate [cross compiler specific]
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
cmake/FindLLVM.cmake | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmake/FindLLVM.cmake b/cmake/FindLLVM.cmake
index a12bd476..ac04bab4 100644
--- a/cmake/FindLLVM.cmake
+++ b/cmake/FindLLVM.cmake
@@ -72,13 +72,13 @@ endif()
include_directories(${LLVM_INCLUDE_DIRS})

# Set the compilers
-find_program(CMAKE_CXX_COMPILER_PATH NAMES clang++ NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH_BIN})
+find_program(CMAKE_CXX_COMPILER_PATH NAMES ${TARGET_SYS}-clang++ clang++)
if(NOT CMAKE_CXX_COMPILER_PATH)
message(FATAL_ERROR "Could not find clang++ in ${CLANG_ROOT_PATH_BIN}. Please provide CMake argument -DCMAKE_CXX_COMPILER_PATH=/path/to/clang++<-version>")
endif()
message(STATUS "Using CMAKE_CXX_COMPILER_PATH: ${CMAKE_CXX_COMPILER_PATH}")

-find_program(CMAKE_C_COMPILER_PATH NAMES clang NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH_BIN})
+find_program(CMAKE_C_COMPILER_PATH NAMES ${TARGET_SYS}-clang clang)
if(NOT CMAKE_C_COMPILER_PATH)
message(FATAL_ERROR "Could not find clang in ${CLANG_ROOT_PATH_BIN}. Please provide CMake argument -DCMAKE_C_COMPILER_PATH=/path/to/clang<-version>")
endif()
@@ -143,5 +143,5 @@ endif()

enable_language(C CXX)
# required by ROCm-Device-Libs, must be after project() call
-find_package(LLVM REQUIRED CONFIG NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH}/lib/cmake/llvm)
-find_package(Clang REQUIRED CONFIG NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH}/lib/cmake/clang)
+find_package(LLVM REQUIRED CONFIG)
+find_package(Clang REQUIRED CONFIG)
--
2.47.0

31 changes: 31 additions & 0 deletions recipes-support/chipstar/chipstar/0001-Fix-llvm-link-command.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From bd3fd0a630762cda06e06208cf4ab0a300cb7424 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
<zboszor@gmail.com>
Date: Tue, 26 Nov 2024 15:46:51 +0100
Subject: [PATCH 1/3] Fix llvm-link command
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upstream-Status: Inappropriate [cross compiler specific]
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
irif/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/irif/CMakeLists.txt b/irif/CMakeLists.txt
index a874772..47f7616 100644
--- a/irif/CMakeLists.txt
+++ b/irif/CMakeLists.txt
@@ -19,7 +19,7 @@ set(irif_lib_file ${CMAKE_CURRENT_BINARY_DIR}/irif.bc)
# set_target_properties(llvm-link PROPERTIES IMPORTED_LOCATION ${LLVM_LINK_EXECUTABLE})

add_custom_command(OUTPUT ${irif_lib_file}
- COMMAND $<TARGET_FILE:llvm-link> ${sources} -o ${irif_lib_file}
+ COMMAND llvm-link ${sources} -o ${irif_lib_file}
DEPENDS ${sources})

add_custom_target(irif DEPENDS ${irif_lib_file}
--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 21456b0816af8e80ee03f4ea5e73111195431948 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
<zboszor@gmail.com>
Date: Wed, 27 Nov 2024 11:19:54 +0100
Subject: [PATCH 2/7] Use TARGET_SYS for offload compile options
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upstream-Status: Inappropriate [cross compiler specific]
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c9cd19b2..59a7822b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -520,7 +520,7 @@ endif()
# For use by hipcc
execute_process(COMMAND ${LLVM_CONFIG_BIN} --host-target
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE HOST_ARCH)
-set(HOST_ARCH "--target=${HOST_ARCH}")
+set(HOST_ARCH "--target=${TARGET_SYS}")

set(HIP_OFFLOAD_COMPILE_OPTIONS_INSTALL_
${HIP_ENABLE_SPIRV}
--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From bf8832d0b004b2c6a6ddaa074dd72a6c023ebeca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
<zboszor@gmail.com>
Date: Tue, 26 Nov 2024 16:00:00 +0100
Subject: [PATCH 2/3] Use target clang compiler for generating bitcode files
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Also fix other COMMAND statements in the same macro

Upstream-Status: Inappropriate [cross compiler specific]
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
cmake/OCL.cmake | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmake/OCL.cmake b/cmake/OCL.cmake
index 2eaf44e..c6005d2 100644
--- a/cmake/OCL.cmake
+++ b/cmake/OCL.cmake
@@ -99,7 +99,7 @@ macro(opencl_bc_lib)
if (fext STREQUAL ".cl")
set(output "${CMAKE_CURRENT_BINARY_DIR}/${fname_we}${BC_EXT}")
add_custom_command(OUTPUT "${output}"
- COMMAND ${CLANG_ROOT_PATH_BIN}/clang ${inc_options} ${CLANG_OCL_FLAGS}
+ COMMAND ${CMAKE_C_COMPILER_PATH} ${inc_options} ${CLANG_OCL_FLAGS}
-emit-llvm -Xclang -mlink-builtin-bitcode -Xclang "${irif_lib_output}"
-c "${file}" -o "${output}"
DEPENDS "${file}" "${irif_lib_output}" "${CLANG}"
@@ -130,12 +130,12 @@ macro(opencl_bc_lib)

add_custom_command(OUTPUT ${OUTPUT_BC_LIB}
# Link regular library dependencies
- COMMAND ${CLANG_ROOT_PATH_BIN}/llvm-link
+ COMMAND llvm-link
-o "${OUT_NAME}.link0${LIB_SUFFIX}" "@${OUT_NAME}_response"
# Extra link step with internalize
- COMMAND ${CLANG_ROOT_PATH_BIN}/llvm-link -internalize -only-needed "${name}.link0${LIB_SUFFIX}"
+ COMMAND llvm-link -internalize -only-needed "${name}.link0${LIB_SUFFIX}"
-o "${OUT_NAME}${LIB_SUFFIX}" ${internal_link_libs}
- COMMAND ${CLANG_ROOT_PATH_BIN}/opt -passes=strip
+ COMMAND opt -passes=strip
-o "${OUT_NAME}${STRIP_SUFFIX}" "${OUT_NAME}${LIB_SUFFIX}"
COMMAND "${PREPARE_BUILTINS}"
-o ${OUTPUT_BC_LIB} "${OUT_NAME}${STRIP_SUFFIX}"
--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
From 2ae94496af84f2cfed2e2bf46312b601dedfbeee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
<zboszor@gmail.com>
Date: Wed, 27 Nov 2024 11:58:32 +0100
Subject: [PATCH 3/7] Remove ->dump() usage from the LLVM pass
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Release builds of LLVM do not have the Elt->dump() method
which Yocto uses for LLVM and CLang. This fixes the error:

chipstar/1.2.1/build/lib/libLLVMHipSpvPasses.so: undefined symbol: _ZNK4llvm5Value4dumpEv

Upstream-Status: Inappropriate [oe specific]
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
llvm_passes/HipPrintf.cpp | 3 ---
llvm_passes/HipTextureLowering.cpp | 17 +----------------
2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/llvm_passes/HipPrintf.cpp b/llvm_passes/HipPrintf.cpp
index 18a8441c..5aa83984 100644
--- a/llvm_passes/HipPrintf.cpp
+++ b/llvm_passes/HipPrintf.cpp
@@ -303,7 +303,6 @@ PreservedAnalyses HipPrintfToOpenCLPrintfPass::run(Module &Mod,
// 1 use if the "printf" is only used by "_cl_printf"
if (Printf == nullptr || Printf->getNumUses() == 1)
return PreservedAnalyses::all();
- LLVM_DEBUG(dbgs() << "Found printf decl: "; Printf->dump());

Function *PrintfF = cast<Function>(Printf);

@@ -351,8 +350,6 @@ PreservedAnalyses HipPrintfToOpenCLPrintfPass::run(Module &Mod,
if (!Callee->hasName() || Callee->getName() != ORIG_PRINTF_FUNC_NAME)
continue;

- LLVM_DEBUG(dbgs() << "Original printf call: "; CI->dump());
-
CallInst &OrigCall = cast<CallInst>(I);
unsigned TotalFmtSpecCount;
auto FmtSpecPieces =
diff --git a/llvm_passes/HipTextureLowering.cpp b/llvm_passes/HipTextureLowering.cpp
index c363010c..d2d799ac 100644
--- a/llvm_passes/HipTextureLowering.cpp
+++ b/llvm_passes/HipTextureLowering.cpp
@@ -136,22 +136,7 @@ public:
}
};

-void TextureUseGroup::dump() const {
-#define DOIT(_container, _desc) \
- do { \
- dbgs() << _desc << ":" << (_container.empty() ? " none" : "") << "\n"; \
- for (auto *Elt : _container) { \
- dbgs() << "- "; \
- Elt->dump(); \
- } \
- } while (0)
-
- DOIT(DirectTexSources_, "Direct tex sources");
- DOIT(IndirectTexSources_, "Indirect tex sources");
- DOIT(TexFunctionCalls_, "Tex function calls");
- DOIT(UnknownTexUsers_, "Unknown tex users");
-#undef DOIT
-}
+void TextureUseGroup::dump() const {}

using TextureUseGroupList = std::vector<TextureUseGroup>;
using TextureUseGroupMap = std::map<Value *, TextureUseGroup *>;
--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From db7e15fbeb04d5b78b7573006aedfebedb66868c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
<zboszor@gmail.com>
Date: Tue, 26 Nov 2024 16:44:40 +0100
Subject: [PATCH 3/3] Use native build of prepare-builtins
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upstream-Status: Inappropriate [cross compiler specific]
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
cmake/OCL.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/OCL.cmake b/cmake/OCL.cmake
index c6005d2..fa99889 100644
--- a/cmake/OCL.cmake
+++ b/cmake/OCL.cmake
@@ -137,7 +137,7 @@ macro(opencl_bc_lib)
-o "${OUT_NAME}${LIB_SUFFIX}" ${internal_link_libs}
COMMAND opt -passes=strip
-o "${OUT_NAME}${STRIP_SUFFIX}" "${OUT_NAME}${LIB_SUFFIX}"
- COMMAND "${PREPARE_BUILTINS}"
+ COMMAND prepare-builtins
-o ${OUTPUT_BC_LIB} "${OUT_NAME}${STRIP_SUFFIX}"
DEPENDS "${deps}" "${CMAKE_CURRENT_BINARY_DIR}/${OUT_NAME}_response" "${PREPARE_BUILTINS}" ${internal_link_libs})

--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 08e03e096bbd0672d2532d6965fb0c53caec0b9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
<zboszor@gmail.com>
Date: Wed, 27 Nov 2024 13:02:35 +0100
Subject: [PATCH 4/7] Execute the native hipcc in samples/ccompat
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upstream-Status: Inappropriate [cross compiler specific]
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
samples/ccompat/CMakeLists.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/samples/ccompat/CMakeLists.txt b/samples/ccompat/CMakeLists.txt
index 2c0e7648..7afe1216 100644
--- a/samples/ccompat/CMakeLists.txt
+++ b/samples/ccompat/CMakeLists.txt
@@ -1,18 +1,18 @@
add_custom_command(
OUTPUT saxpy.o DEPENDS ${CMAKE_SOURCE_DIR}/samples/ccompat/saxpy.hip
- COMMAND ${CMAKE_BINARY_DIR}/bin/hipcc
+ COMMAND hipcc
${CMAKE_SOURCE_DIR}/samples/ccompat/saxpy.hip -c -g -pthread
-I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/HIP/include)

add_custom_command(
OUTPUT ccompat.o DEPENDS ${CMAKE_SOURCE_DIR}/samples/ccompat/ccompat.c
- COMMAND ${CMAKE_BINARY_DIR}/bin/hipcc
+ COMMAND hipcc
${CMAKE_SOURCE_DIR}/samples/ccompat/ccompat.c -c -g -pthread
-I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/HIP/include)

add_custom_command(
OUTPUT ccompat DEPENDS ccompat.o saxpy.o
-COMMAND ${CMAKE_BINARY_DIR}/bin/hipcc
+COMMAND hipcc
./ccompat.o ./saxpy.o -o ccompat -g -pthread)

add_custom_target(ccompatBuild ALL
--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From a2f46d748c9af2144374bf99626ffa25419ef2f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
<zboszor@gmail.com>
Date: Wed, 27 Nov 2024 13:15:41 +0100
Subject: [PATCH 5/7] Use native hipcc in add_custom_command()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upstream-Status: Inappropriate [cross compiler specific]
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 59a7822b..aeb25580 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -428,7 +428,7 @@ endif()
# once hipcc.bin is built, execute hipcc ./samples/hipSample.cpp
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/hipInfo
- COMMAND ${HIPCC_BUILD_PATH}/hipcc ${CMAKE_SOURCE_DIR}/samples/hipInfo/hipInfo.cpp -o ${CMAKE_BINARY_DIR}/hipInfo
+ COMMAND hipcc ${CMAKE_SOURCE_DIR}/samples/hipInfo/hipInfo.cpp -o ${CMAKE_BINARY_DIR}/hipInfo
DEPENDS ${CMAKE_SOURCE_DIR}/samples/hipInfo/hipInfo.cpp hipcc.bin CHIP devicelib_bc
)

--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 8e2f9062d1b5e4c78d6cd9574659d5f6d71ff289 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
<zboszor@gmail.com>
Date: Wed, 27 Nov 2024 14:26:32 +0100
Subject: [PATCH 6/7] Hide source and build directory
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upstream-Status: Inappropriate [cross compiler specific]
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
chipStarConfig.hh.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/chipStarConfig.hh.in b/chipStarConfig.hh.in
index a836cd8e..326d1b9b 100644
--- a/chipStarConfig.hh.in
+++ b/chipStarConfig.hh.in
@@ -32,9 +32,9 @@
// not implemented yet
#undef OCML_BASIC_ROUNDED_OPERATIONS

-#cmakedefine CHIP_SOURCE_DIR "@CHIP_SOURCE_DIR@"
+#cmakedefine CHIP_SOURCE_DIR "@EXT_SOURCE_DIR@"

-#cmakedefine CHIP_BUILD_DIR "@CHIP_BUILD_DIR@"
+#cmakedefine CHIP_BUILD_DIR "@EXT_BUILD_DIR@"

#cmakedefine CHIP_INSTALL_DIR "@CHIP_INSTALL_DIR@"

--
2.47.0

Loading