Skip to content

Commit

Permalink
Initial HIP support (#284)
Browse files Browse the repository at this point in the history
* add hip context & evaluator

* add hip platform detection

* fix some hip compile error

* add install hip script

* add hip tests

* add hip workflow

* fixes for hip compilations

* add hip toolchain

* add sudo when install hip

* try to fix hip install

* try to fix hip install

* try to fix hip install

* try to fix hip install

* try to fix hip install

* try to fix hip install

* try to fix hip install
  • Loading branch information
alifahrri committed Jun 8, 2024
1 parent 8103661 commit c9641a8
Show file tree
Hide file tree
Showing 119 changed files with 14,707 additions and 258 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/hip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: hip

on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- '*'

jobs:
hip:
name: hip-6.1
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: install hip
run: sudo bash scripts/install_hip.sh
- name: setup doctest
run: bash scripts/download_doctest_header.sh -d include/
- name: build
run: |
export PATH=$PATH:/opt/rocm/bin/
mkdir -p build/hip && cd build/hip
cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/hip.cmake -DNMTOOLS_BUILD_HIP_TESTS=ON ../..
make -j2
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ pocl
*.bc
*.ll
llvm.sh
install
install
amdgpu-*
2 changes: 2 additions & 0 deletions cmake/toolchains/hip.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(CMAKE_C_COMPILER hipcc)
set(CMAKE_CXX_COMPILER hipcc)
5 changes: 3 additions & 2 deletions include/nmtools/array/as_static.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ namespace nmtools::array

auto operator()() const noexcept
{
if constexpr (meta::is_dynamic_index_array_v<attribute_type>) {
// TODO: return maybe when size > max_dim
if constexpr (meta::is_resizable_v<attribute_type>) {
using element_type = meta::get_element_type_t<attribute_t>;
using result_type = utl::static_vector<element_type,max_dim>;
auto result = result_type{};
result.resize(attribute.size());
result.resize(nmtools::size(attribute));
for (size_t i=0; i<len(result); i++) {
at(result,i) = at(attribute,i);
}
Expand Down
7 changes: 7 additions & 0 deletions include/nmtools/array/eval/hip.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef NMTOOLS_ARRAY_EVAL_HIP_HPP
#define NMTOOLS_ARRAY_EVAL_HIP_HPP

#include "nmtools/array/eval/hip/context.hpp"
#include "nmtools/array/eval/hip/evaluator.hpp"

#endif // NMTOOLS_ARRAY_EVAL_HIP_HPP
Loading

0 comments on commit c9641a8

Please sign in to comment.