From 6aeb2dc8d618f41c8adf432372d8fa9e5c67552d Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 8 Aug 2016 11:55:41 -0500 Subject: [PATCH] Add initial/partial coding guidelines Change-Id: Ifd8cb3ad74b15d3ab2f38c3daa038a2808af6fa9 --- CONTRIBUTING.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f6e578efd8..adc93f57d4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,6 +90,30 @@ 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. +## Coding Guidelines (in brief) +- Code Indentation: + - Tabs should be expanded to spaces. + - Use 4 spaces indendation. +- Capitilziation and Separators: + - Prefer camelCase for HIP interfaces and internal symbols. Note HCC uses _ for separator. + This guideline is not yet consistently followed in HIP code - eventual compliance is aspirational. +- { placement + - 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) { + doFoo() + } else { + doFooElse(); + } +''' + - Single-line if statement should still use {/} pair (even though C++ does not require). +- Miscellaneous +- All references in function parameter lists should be const. +- "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. + #### Presubmit Testing: Before checking in or submitting a pull request, run all Rodinia tests and ensure pass results match starting point: