2020-10-05 13:20:58 -04:00
# Contributor Guidelines
2016-01-26 20:14:33 -06:00
2016-04-27 11:55:09 -05:00
## Make Tips
2023-04-19 05:49:28 +02:00
`ROCM_PATH` is path where ROCM is installed. BY default `ROCM_PATH` is `/opt/rocm` .
When building HIP, you will likely want to build and install to a local user-accessible directory (rather than `<ROCM_PATH>` ).
This can be easily be done by setting the `-DCMAKE_INSTALL_PREFIX` variable when running cmake. Typical use case is to
set `CMAKE_INSTALL_PREFIX` to your HIP git root, and then ensure `HIP_PATH` points to this directory. For example
2016-04-27 11:55:09 -05:00
2023-04-19 05:49:28 +02:00
``` shell
2016-04-27 11:55:09 -05:00
cmake .. -DCMAKE_INSTALL_PREFIX= ..
make install
2020-10-05 13:20:58 -04:00
export HIP_PATH =
2016-04-27 11:55:09 -05:00
```
2016-04-27 17:45:14 -05:00
After making HIP, don't forget the "make install" step !
2016-04-27 11:55:09 -05:00
2016-01-26 20:14:33 -06:00
## Adding a new HIP API
2023-04-19 05:49:28 +02:00
- Add a translation to the hipify-clang tool ; many examples abound.
- For stat tracking purposes, place the API into an appropriate stat category ("dev", "mem", "stream", etc).
- Add a inlined NVIDIA implementation for the function in include/hip/nvidia_detail/hip_runtime_api.h.
- These are typically headers
- Add an HIP_ROCclr definition and Doxygen comments for the function in include/amd_detail/hip_runtime_api.h
- Source implementation typically go in hip/rocclr/hip_*.cpp. The implementation involve calls to HIP runtime (ie for hipStream_t).
2020-10-05 13:20:58 -04:00
## Check HIP-Clang version
In some cases new HIP-Clang features are tied to specified releases, and it can be useful to check the current version is sufficiently new enough to support the desired feature.
HIP runtime version
2016-01-26 20:14:33 -06:00
2023-04-19 05:49:28 +02:00
``` console
2021-11-25 15:10:03 +05:30
> cat <ROCM_PATH>/hip/bin/.hipVersion
2020-10-05 13:20:58 -04:00
# Auto-generated by cmake
HIP_VERSION_MAJOR=3
HIP_VERSION_MINOR=9
HIP_VERSION_PATCH=20345-519ef3f2
2016-01-26 20:14:33 -06:00
```
2020-10-05 13:20:58 -04:00
HIP-Clang compiler version
2023-04-19 05:49:28 +02:00
``` console
2021-11-25 15:10:03 +05:30
$ <ROCM_PATH>/llvm/bin/clang -v
2020-10-05 13:20:58 -04:00
clang version 11.0.0 (/src/external/llvm-project/clang 075fedd3fd2f4d9d8cca79d0cd51f64c5ef21432)
2016-01-26 20:14:33 -06:00
Target: x86_64-unknown-linux-gnu
Thread model: posix
2021-11-25 15:10:03 +05:30
InstalledDir: <ROCM_PATH>/llvm/bin
2020-10-05 13:20:58 -04:00
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
2016-01-26 20:14:33 -06:00
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
```
## Unit Testing Environment
2023-09-13 18:02:31 +01:00
Tests for HIP are hosted at [ROCm-Developer-Tools/hip-tests ](https://github.com/ROCm-Developer-Tools/hip-tests ).
To run `hip-tests` please go to the repo and follow the steps.
2016-03-24 13:33:07 -05:00
## Development Flow
2020-10-05 13:20:58 -04:00
2023-09-13 18:02:31 +01:00
`hip-tests` provide a great place to develop new features alongside the associated test.
2016-03-24 13:33:07 -05:00
2023-09-13 18:02:31 +01:00
For applications and benchmarks outside the hip-tests environment, developments should use a two-step development flow:
- #1 . Compile, link, and install HIP/ROCclr. See [Installation ](README.md#Installation ) notes.
2020-10-05 13:20:58 -04:00
- #2 . Relink the target application to include changes in HIP runtime file.
2016-03-24 13:33:07 -05:00
## Environment Variables
2020-10-05 13:20:58 -04:00
- **HIP_PATH** : Location of HIP include, src, bin, lib directories.
2021-11-25 15:10:03 +05:30
- **HCC_ROCCLR_HOME** : Path to HIP/ROCclr directory, used on AMD platforms. Default <ROCM_PATH>/rocclr.
- **HSA_PATH** : Path to HSA include, lib. Default <ROCM_PATH>/hsa.
2016-03-24 13:33:07 -05:00
- **CUDA_PATH* : On nvcc system, this points to root of CUDA installation.
2016-01-26 20:14:33 -06:00
2020-10-05 13:20:58 -04:00
## Contribution guidelines ##
2016-01-26 20:14:33 -06:00
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.
2020-10-05 13:20:58 -04:00
Differences or limitations of HIP APIs as compared to CUDA APIs should be clearly documented and described.
2016-01-26 20:14:33 -06:00
2020-10-05 13:20:58 -04:00
### Coding Guidelines (in brief)
2016-08-08 11:55:41 -05:00
- Code Indentation:
- Tabs should be expanded to spaces.
2016-12-14 00:13:30 +01:00
- Use 4 spaces indentation.
2016-09-02 09:15:49 -05:00
- Capitalization and Naming
2020-10-05 13:20:58 -04:00
- Prefer camelCase for HIP interfaces and internal symbols. Note HCC uses _ for separator.
2016-08-08 11:55:41 -05:00
This guideline is not yet consistently followed in HIP code - eventual compliance is aspirational.
2016-08-08 13:12:22 -05:00
- Member variables should begin with a leading "_". This allows them to be easily distinguished from other variables or functions.
- {} placement
2016-08-08 11:55:41 -05:00
- For functions, the opening { should be placed on a new line.
- For if/else blocks, the opening { is placed on same line as the if/else. Use a space to separate {/" from if/else. Example
'''
if (foo) {
2020-10-05 13:20:58 -04:00
doFoo()
} else {
2016-08-08 11:55:41 -05:00
doFooElse();
}
'''
2016-09-02 09:15:49 -05:00
- namespace should be on same line as { and separated by a space.
2016-08-08 11:55:41 -05:00
- Single-line if statement should still use {/} pair (even though C++ does not require).
- Miscellaneous
2020-10-05 13:20:58 -04:00
- All references in function parameter lists should be const.
2016-08-08 13:12:22 -05:00
- "ihip" = internal hip structures. These should not be exposed through the HIP API.
- Keyword TODO refers to a note that should be addressed in long-term. Could be style issue, software architecture, or known bugs.
- FIXME refers to a short-term bug that needs to be addressed.
2016-08-08 11:55:41 -05:00
2016-08-29 18:40:23 -05:00
- HIP_INIT_API() should be placed at the start of each top-level HIP API. This function will make sure the HIP runtime is initialized,
and also constructs an appropriate API string for tracing and CodeXL marker tracing. The arguments to HIP_INIT_API should match
2020-10-05 13:20:58 -04:00
those of the parent function.
- ihipLogStatus should only be called from top-level HIP APIs,and should be called to log and return the error code. The error code
2016-09-01 17:58:24 -05:00
is used by the GetLastError and PeekLastError functions - if a HIP API simply returns, then the error will not be logged correctly.
2016-08-29 18:40:23 -05:00
2016-10-20 10:06:17 -05:00
- All HIP environment variables should begin with the keyword HIP_
Environment variables should be long enough to describe their purpose but short enough so they can be remembered - perhaps 10-20 characters, with 3-4 parts separated by underscores.
2016-12-19 17:36:07 -08:00
To see the list of current environment variables, along with their values, set HIP_PRINT_ENV and run any hip applications on ROCm platform .
2020-10-05 13:20:58 -04:00
HIPCC or other tools may support additional environment variables which should follow the above convention.
2016-01-26 20:14:33 -06:00
2016-10-15 11:51:20 -05:00
2020-10-05 13:20:58 -04:00
### Presubmit Testing:
2023-09-13 18:02:31 +01:00
Before checking in or submitting a pull request, run all hip-tests (see [ROCm-Developer-Tools/hip-tests ](https://github.com/ROCm-Developer-Tools/hip-tests )).
2016-01-26 20:14:33 -06:00
2020-10-05 13:20:58 -04:00
### Checkin messages
2016-10-15 11:51:20 -05:00
Follow existing best practice for writing a good Git commit message. Some tips:
http://chris.beams.io/posts/git-commit/
https://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message
2020-10-05 13:20:58 -04:00
In particular :
- Use imperative voice, ie "Fix this bug", "Refactor the XYZ routine", "Update the doc".
2016-10-15 11:51:20 -05:00
Not : "Fixing the bug", "Fixed the bug", "Bug fix", etc.
- Subject should summarize the commit. Do not end subject with a period. Use a blank line
after the subject.
2016-01-26 20:14:33 -06:00
## 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
2016-12-14 00:13:30 +01:00
Recommended to use an offline Markdown viewer to review documentation, such as Markdown Preview Plus extension in Chrome browser, or Remarkable.