# Contributing to hipThreads #
We welcome contributions to hipThreads.
Please follow these details to help ensure your contributions will be successfully accepted.
## Issue Discussion ##
Please use the GitHub Issues tab to notify us of issues.
* Use your best judgement for issue creation.
If your issue is already listed, upvote the issue and comment or post to provide additional details, such as how you reproduced this issue.
* If you're not sure if your issue is the same, err on the side of caution and file your issue.
You can add a comment to include the issue number (and link) for the similar issue.
If we evaluate your issue as being the same as the existing issue, we'll close the duplicate.
* If your issue doesn't exist, use the issue template to file a new issue.
* When filing an issue, be sure to provide as much information as possible, including the GPU architecture, ROCm version, and any build or run output, so we can collect information about your configuration.
This helps reduce the time required to reproduce your issue.
* Check your issue regularly, as we may require additional information to successfully reproduce the issue.
* You may also open an issue to ask questions to the maintainers about whether a proposed change meets the acceptance criteria, or to discuss an idea or feature request pertaining to the library.
## Acceptance Criteria ##
hipThreads is a C++-style concurrency library for AMD GPUs.
It implements `std::thread`-like primitives (`hip::wthread`, `hip::mutex`, `hip::lock_guard`, `hip::condition_variable`, ...) that run inside GPU kernels, so existing `std::thread` CPU code can be ported to the GPU with minimal changes.
It is built on [HIP](https://github.com/ROCm/HIP) and [libhipcxx](https://github.com/ROCm/libhipcxx).
Code in hipThreads should keep the public interface compatible with the C++ Standard Library threading facilities wherever practical, so that familiar `std::`-style concurrency code ports to the GPU with minimal changes.
New primitives should mirror their standard-library counterparts in naming and semantics.
Contributions should be in scope for hipThreads — that is, threading and concurrency primitives and their direct supporting code.
Functionality that is not specific to threading/concurrency (general-purpose device utilities, containers, `std::`-style types, or parallel algorithms) is usually better suited to [libhipcxx](https://github.com/ROCm/libhipcxx) or [rocThrust](https://github.com/ROCm/rocThrust).
If you're unsure whether a change fits, open an issue to discuss it before raising a pull request.
In order for a change to be accepted, it must build cleanly, pass the test suite, and undergo a code review.
The GitHub "Issues" tab may also be used to discuss ideas surrounding particular features or changes before raising pull requests.
## Code Structure ##
The deliverable is a static library `libhipthreads.a` plus public headers under `inc/hip/`.
Only `src/hip/thread.cxx` is compiled into the library, everything else is header-only.
* Public umbrella headers (extensionless, libc++ style) live directly in `inc/hip/`: `thread`, `mutex`, `condition_variable`, `pseudo_mutex`, `pseudo_condition_variable`, `thread_config`.
* Implementation headers live under `inc/hip/__thread/`, `inc/hip/__mutex/`, and `inc/hip/__condition_variable/`, with low-level helpers in `inc/hip/__clib/` and `inc/hip/__support/`.
* The persistent scheduler kernel and host-side plumbing live in `src/hip/thread.cxx`.
* Tests live in `test/` (a libc++-style **lit** suite plus standalone unit executables).
* Examples are standalone CMake projects under `examples/`, each laid out as a series of `stepN-*` directories showing an incremental CPU to GPU port.
The examples are also used as integration tests.
See `README.md` for a deeper description of the architecture and build/test workflow, and the full documentation at [https://rocm.docs.amd.com/projects/hipThreads/en/latest/](https://rocm.docs.amd.com/projects/hipThreads/en/latest/).
## Coding Style ##
C and C++ code should be formatted using `clang-format`.
The repository ships a `.clang-format` (LLVM base, 4-space indent, 120 column limit, access modifiers indented).
Please format the code you change before opening a pull request.
Prefer formatting **only the lines you changed**, rather than reformatting whole files (which creates noisy diffs and can reformat unrelated code).
`git clang-format` makes this easy — it formats just the lines in your staged changes:
```bash
# Stage your changes first, then format only the changed lines:
git add