Skip to content

Commit

Permalink
Merge branch 'dot-prod'
Browse files Browse the repository at this point in the history
  • Loading branch information
monofuel committed Jul 6, 2024
2 parents efbf6df + 1124306 commit 75d6f9f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,27 @@ handleError(hipFree(dev_c))

- very much WORK IN PROGRESS
- very basic kernels work that use block/thread indices
- no support for shared memory yet
- no support for shared memory yet (almost there)

- hippo *requires* that you use cpp. it will not work with c
- `nim cpp -r tests/hip/vector_sum.nim`
- The HIP Runtime is a C++ library, and so is the CUDA Runtime. As such, we can't do anything about this.
- You can make separate projects for the C and C++ parts and link them together. (I have not tested this yet, would love examples if you do this!)
- there are examples for several different targets in the examples directory.
- building for HIP requires that `hipcc` is in your PATH
- [vector_sum_cuda.nims](examples/vector_sum_hippo.nims) example .nims for building with hipcc
- [vector_sum_hippo.nims](examples/vector_sum_cuda.nims) example .nims for building with nvcc for cuda
- [vector_sum_hip_nvidia.nims](examples/vector_sum_hip_nvidia.nims) example .nims for building with hipcc with the cuda backend
- tell nim that you want the 'nvcc' compiler settings to get the right arguments, but swap out the compiler executable for hipcc
- you might also need to have HIP_PLATFORM=nvidia set in your environment
- [vector_sum_cpu.nims](examples/vector_sum_cpu.nims) example .nims for building with the HIP-CPU backend (no hipcc required)

- building for GPU requires that `hipcc` is in your PATH
- HIP supports both CUDA and ROCM, so you can use this with either
- for CUDA, you will need to have `nvcc` in your PATH as well as `hipcc`
- set the environment variable HIP_PLATFORM=nvidia for hipcc to build for nvidia
- HIP nvidia compiling still needs work: https://github.com/monofuel/hippo/pull/1
- I got a hacky fix to work, but it needs to be polished up and requires small changes in the nim compiler
- HIP-CPU is supported with the `-d:HippoRuntime=HIP_CPU` flag
- note: you need to pull the HIP-CPU git submodule to use this feature
- does not require hipcc. works with gcc.
- you can write kernels and test them on cpu with echos and breakpoints and everything!

- hippo *requires* that you use cpp. it will not work with c
- `nim cpp -r tests/hip/vector_sum.nim`
- The HIP Runtime is a C++ library, and so is the CUDA Runtime. As such, we can't do anything about this.
- You can make separate projects for the C and C++ parts and link them together. (I have not tested this yet, would love examples if you do this!)

## Motivation

- I want GPU compute (HIP / CUDA) to be a first-class citizen in Nim.
Expand Down
4 changes: 3 additions & 1 deletion examples/vector_sum_hip_nvidia.nims
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
--path:"../src"
--cc:hipcc
--cc:nvcc
--nvcc.cpp.exe:hipcc
--nvcc.cpp.linkerexe:hipcc
--define:"useMalloc"
--passL:"-lstdc++"

0 comments on commit 75d6f9f

Please sign in to comment.