forked from ROCm/HIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
384 changed files
with
38,024 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.* | ||
*.o | ||
*.exe | ||
*.swp | ||
*.Po | ||
hip-amdinternal | ||
HIP-Examples | ||
|
||
bin/hipInfo | ||
samples/1_Utils/hipInfo/hipInfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# Contributor Guidelines | ||
|
||
|
||
## Adding a new HIP API | ||
|
||
- Add a translation to the bin/hipify tool ; many examples abound. | ||
- For stat tracking purposes, place the API into an appropriate stat category ("dev", "mem", "stream", etc). | ||
- Add a inlined NVCC implementation for the function in include/nvcc_detail/hip_runtime_api.h. | ||
- These are typically headers | ||
- Add an HCC definition and Doxygen comments for the function in include/hcc_detail/hip_runtime_api.h | ||
- Source implementation typically go in src/hcc_detail/hip_hcc.cpp. The implementation may involve | ||
calls to HCC runtime or HSA runtime, or interact with other pieces of the HIP runtime (ie for | ||
hipStream_t). | ||
|
||
#### Testing HCC version | ||
In some cases new HIP features are tied to specified releases of HCC, and it can be useful to determine at compile-time | ||
if the current HCC compiler is sufficiently new enough to support the desired feature. The `__hcc_workweek__` compiler | ||
define is a monotonically increasing integer value that combines the year + workweek + day-of-week (0-6, Sunday is 0) | ||
(ie 15403, 16014, etc). | ||
The granularity is one day, so __hcc_workweek__ can only be used to distinguish compiler builds that are at least one day apart. | ||
|
||
``` | ||
#ifdef __hcc_workweek_ > 16014 | ||
// use cool new HCC feature here | ||
#endif | ||
``` | ||
|
||
Additionally, hcc binary can print the work-week to stdout: ("16014" in the version info below.)4 | ||
``` | ||
> /opt/hcc/bin/hcc -v | ||
HCC clang version 3.5.0 (based on HCC 0.8.16014-81f8a3f-f155163-5a1009a LLVM 3.5.0svn) | ||
Target: x86_64-unknown-linux-gnu | ||
Thread model: posix | ||
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 | ||
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4 | ||
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9 | ||
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1 | ||
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 | ||
Candidate multilib: .;@m64 | ||
Candidate multilib: 32;@m32 | ||
Candidate multilib: x32;@mx32 | ||
Selected multilib: .;@m64 | ||
``` | ||
|
||
The unix `date` command can print the HCC-format work-week for a specific date , ie: | ||
``` | ||
> date --utc +%y%W%w -d 2015-11-09 | ||
15451 | ||
``` | ||
|
||
## Unit Testing Environment | ||
|
||
HIP includes unit tests in the tests/src directory. | ||
When adding a new HIP feature, add a new unit test as well. | ||
The tests/src/hipMemtest.cpp file contains a simple unit test and is a good starting point for other tests. | ||
Modify tests/src/CMakefiles.txt to add the test to the build environment. | ||
|
||
### Contribution guidelines ### | ||
|
||
Features (ie functions, classes, types) defined in hip*.h should resemble CUDA APIs. | ||
The HIP interface is designed to be very familiar for CUDA programmers. | ||
|
||
Differences or limitations of HIP APIs as compared to CUDA APIs should be clearly documented and described. | ||
|
||
|
||
#### Presubmit Testing: | ||
Before checking in or submitting a pull request, run all Rodinia tests and ensure pass results match starting point: | ||
|
||
```shell | ||
> cd examples/ | ||
> ./run_all.sh | ||
``` | ||
|
||
Recent results : | ||
|
||
``` | ||
hip2/examples/rodinia_3.0/hip$ make test | ||
--TESTING: b+tree | ||
executing: ../../test/b+tree/run0.cmd... PASSED! | ||
--TESTING: backprop | ||
executing: ../../test/backprop/run0.cmd... PASSED! | ||
--TESTING: bfs | ||
executing: ../../test/bfs/run0.cmd... PASSED! | ||
executing: ../../test/bfs/run1.cmd... PASSED! | ||
--TESTING: cfd | ||
executing: ../../test/cfd/run0.cmd... PASSED! | ||
executing: ../../test/cfd/run1.cmd... PASSED! | ||
--TESTING: gaussian | ||
executing: ../../test/gaussian/run0.cmd... PASSED! | ||
--TESTING: heartwall | ||
executing: ../../test/heartwall/run0.cmd... PASSED! | ||
--TESTING: hotspot | ||
executing: ../../test/hotspot/run0.cmd... PASSED! | ||
--TESTING: kmeans | ||
executing: ../../test/kmeans/run0.cmd... PASSED! | ||
executing: ../../test/kmeans/run1.cmd... PASSED! | ||
executing: ../../test/kmeans/run2.cmd... PASSED! | ||
executing: ../../test/kmeans/run3.cmd... PASSED! | ||
--TESTING: lavaMD | ||
executing: ../../test/lavaMD/run0.cmd... PASSED! | ||
executing: ../../test/lavaMD/run1.cmd... PASSED! | ||
executing: ../../test/lavaMD/run2.cmd... PASSED! | ||
executing: ../../test/lavaMD/run3.cmd... PASSED! | ||
executing: ../../test/lavaMD/run4.cmd... PASSED! | ||
--TESTING: lud | ||
executing: ../../test/lud/run0.cmd... PASSED! | ||
--TESTING: myocyte | ||
executing: ../../test/myocyte/run0.cmd... PASSED! | ||
--TESTING: nn | ||
executing: ../../test/nn/run0.cmd... PASSED! | ||
--TESTING: nw | ||
executing: ../../test/nw/run0.cmd... PASSED! | ||
--TESTING: particlefilter | ||
executing: ../../test/particlefilter/run0.cmd... *** Error in `./particlefilter_naive': free(): invalid next size (fast): 0x0000000001ad89d0 *** | ||
FAILED! | ||
executing: ../../test/particlefilter/run1.cmd... *** Error in `./particlefilter_float': free(): invalid next size (fast): 0x0000000001a7e890 *** | ||
FAILED! | ||
--TESTING: pathfinder | ||
executing: ../../test/pathfinder/run0.cmd... PASSED! | ||
--TESTING: srad | ||
executing: ../../test/srad/run0.cmd... PASSED! | ||
--TESTING: streamcluster | ||
executing: ../../test/streamcluster/run0.cmd... PASSED! | ||
``` | ||
|
||
## Doxygen Editing Guidelines | ||
|
||
- bugs should be marked with @bugs near the code where the bug might be fixed. The @bug message will appear in the API description and also in the | ||
doxygen bug list. | ||
|
||
## Other Tips: | ||
### Markdown Editing | ||
Recommended to use an offline Markown viewer to review documentation, such as Markdown Preview Plus extension in Chrome browser, or Remarkable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#must also be specified in doxygen-input/doxy.cfg, | ||
|
||
HIP_PATH ?= . | ||
HIPCC = $(HIP_PATH)/bin/hipcc | ||
HSA_PATH ?= /opt/hsa | ||
|
||
|
||
HIP_SOURCES = $(HIP_PATH)/src/hip_hcc.cpp | ||
HIP_OBJECTS = $(HIP_SOURCES:.cpp=.o) | ||
|
||
$(HIP_OBJECTS): HIPCC_FLAGS += -I$(HSA_PATH)/include | ||
|
||
$(HIP_OBJECTS): | ||
|
||
%.o:: %.cpp | ||
$(HIPCC) $(HIPCC_FLAGS) $< -c -o $@ | ||
|
||
|
||
clean: | ||
rm -f $(HIP_OBJECTS) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,82 @@ | ||
# HIP | ||
HIP : Convert CUDA to Portable C++ Code | ||
## What is this repository for? ### | ||
|
||
HIP allows developers to convert CUDA code to portable C++. The same source code can be compiled to run on NVIDIA or AMD GPUs. | ||
Key features include: | ||
|
||
* HIP is very thin and has little or no performance impact over coding directly in CUDA or HCC "HC" mode. | ||
* HIP allows coding in a single-source C++ programming language including features such as templates, C++11 lambdas, classes, namespaces, and more. | ||
* HIP allows developers to use the "best" development environment and tools on each target platform. | ||
* The "hipify" script automatically converts source from CUDA to HIP. | ||
* Developers can specialize for the platform (CUDA or HCC) to tune for performance or handle tricky cases | ||
|
||
HIP is intended to support new developments in a portable C++ language that can run on either NVIDIA or AMD platforms. Additionally, HIP provides porting tools which make it easy to port existing CUDA codes to the portable HIP layer, with no loss of performance as compared to the original CUDA application. HIP is not intended to be a drop-in replacement for CUDA, and developers should expect to do some manual coding and performance tuning work to complete the port. | ||
|
||
## More Info: | ||
- [HIP FAQ](docs/markdown/hip_faq.md) | ||
- [HIP Kernel Language](docs/markdown/hip_kernel_language.md) | ||
- [HIP Runtime API (Doxygen)](docs/RuntimeAPI/html/group__API.html) | ||
- [HIP Porting Guide](docs/markdown/hip_porting_guide.md) | ||
- [HIP Terminology](docs/markdown/hip_terms.md) (including Rosetta Stone of GPU computing terms across CUDA/HIP/HC/AMP/OpenL) | ||
|
||
|
||
## How do I get set up? | ||
|
||
### Prerequisites - Choose Your Platform | ||
HIP code can be developed either on AMD HSA or Boltzmann platform using HCC compiler, or a CUDA platform with NVCC installed: | ||
|
||
#### AMD (HCC): | ||
|
||
* Install HCC including supporting HSA kernel and runtime driver stack (https://bitbucket.org/multicoreware/hcc/wiki/Home). | ||
* By default HIP looks for HCC in /opt/hcc (can be overridden by setting HCC_HOME environment variable) | ||
* By default HIP looks for HSA in /opt/hsa (can be overridden by setting HSA_PATH environment variable) | ||
|
||
#### NVIDIA (NVCC) | ||
* Install CUDA SDK from manufacturer website. | ||
* By default HIP looks for CUDA SDK in /usr/local/cuda (can be overriden by setting CUDA_PATH env variable) | ||
|
||
### Add HIP/bin to your path. | ||
For example, if this repot is clones to ~/HIP, and you are running bash: | ||
``` | ||
> export PATH=$PATH:~/HIP/bin | ||
``` | ||
Verify we can find hipconfig (one of the hip tools in bin dir): | ||
``` | ||
> hipconfig -pn | ||
/home/me/HIP | ||
``` | ||
|
||
## Examples and Getting Started: | ||
|
||
* A sample that uses hipify to convert from CUDA to HIP: | ||
|
||
```shell | ||
> cd samples/01_Intro/square | ||
# follow README / blog steps to hipify the application. | ||
``` | ||
|
||
* A sample written directly in HIP, showing platform specialization: | ||
```shell | ||
> cd samples/01_Intro/bit_extract | ||
> make | ||
``` | ||
|
||
* Guide to [Porting a New Cuda Project](docs/markdown/hip_porting_guide.md#porting-a-new-cuda-project" aria-hidden="true"><span aria-hidden="true) | ||
|
||
|
||
## More Examples | ||
The GitHub repot [HIP-Examples](https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP-Examples.git) contains a hipified vesion of the popular Rodinia benchmark suite. | ||
The README with the procedures and tips the team used during this porting effort is here: [Rodinia Porting Guide](https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP-Examples/blob/master/rodinia_3.0/hip/README.hip_porting) | ||
|
||
## Tour of the HIP Directories | ||
* **include**: | ||
* **hip_runtime_api.h** : Defines HIP runtime APIs and can be compiled with many standard Linux compilers (HCC, GCC, ICC, CLANG, etc), in either C or C++ mode. | ||
* **hip_runtime.h** : Includes everything in hip_runtime_api.h PLUS hipLaunchKernel and syntax for writing device kernels and device functions. hip_runtime.h can only be compiled with HCC. | ||
* **hcc_detail/**** , **nvcc_detail/**** : Implementation details for specific platforms. HIP applications should not include these files directly. | ||
|
||
* **bin**: Tools and scripts to help with hip porting | ||
* **hipify** : Tool to convert CUDA code to portable CPP. Converts CUDA APIs and kernel builtins. | ||
* **hipcc** : Compiler driver that can be used to replace NVCC in existing CUDA code. hipcc ill call NVCC or HCC depending on platform, and include appropriate platform-specific headers and libraries. | ||
* **hipconfig** : Print HIP configuration (HIP_PATH, HIP_PLATFORM, CXX config flags, etc) | ||
* **hipexamine.sh** : Script to scan directory, find all code, and report statistics on how much can be ported with HIP (and identify likely features not yet supported) | ||
|
||
* **doc**: Documentation - markdown and doxygen info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Release notes | ||
|
||
Since this is an early access release and we are still in development towards the production ready version Boltzmann Driver and runtime we recommend this release be used for research and early application development. | ||
|
||
We have attempted to document known bugs and limitations - in particular the [HIP Kernel Language](docs/markdown/hip_kernel_language.md) doc uses the phrase "Under Development", and the [HIP Runtime API](docs/RuntimeAPI/html/bug.html) lists know bugs. Some of the key items we are working on: | ||
- Async memory copies. | ||
- hipStream support. | ||
- Multi-GPU | ||
- shared-scope atomic operations. (due to compiler limitation, shared-scope map atomics map to global scope) | ||
- Tuning built-in functions, including shfl. | ||
- Performance optimization. | ||
|
||
|
||
Stay tuned - the work for many of these features is already in-flight. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
SEARCH_DIR=$1 | ||
|
||
find $SEARCH_DIR -name '*.cpp' -o -name '*.h' -o -name '*.cu' -o -name '*.cuh' -o -name '*.c' -o -name '*.hpp' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
SEARCH_DIR=$1 | ||
|
||
find $SEARCH_DIR -not -name '*.cpp' -and -not -name '*.h' -and -not -name '*.cu' -and -not -name '*.cuh' -and -not -name '*.c' -and -not -name '*.hpp' |
Oops, something went wrong.