Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ __pycache__/
# IDE files
.vscode/*
.theia/*
*.code-workspace

# Container files
**/.docker/*
Expand Down
23 changes: 16 additions & 7 deletions CppAPICodingStyle.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ We define three API layers as illustrated below:
│ Audience: Hardware vendors + core developers │
│ (NOT for users / external libs to depend on) │
│ Headers: "cudaq_internal/<module>/<hdr>.h" (or cudaq_dev/...) │
│ Namespace: cudaq::<module>::... (module lowercase)
cudaq::<module>::detail = NON-public
│ Namespace: cudaq_internal::<module>::... (module lowercase) │
cudaq_internal::<module>::detail = private
│ Naming: CamelCase (or consistent module convention) │
└────────────────────────────────────────────────────────────────────┘
Expand All @@ -78,8 +78,8 @@ We define three API layers as illustrated below:
│ Level 3: Internal Private APIs │
├────────────────────────────────────────────────────────────────────┤
│ Audience: Module implementers only │
│ Headers: module-local (e.g., <module>/src/, include-private/) │
│ Namespace: typically in cudaq::<module>::detail (recommended)
│ Headers: module local (e.g., <module>/src/, include-private/) │
│ Namespace: typically in cudaq_internal::<module>::detail
│ Naming: unconstrained; keep consistent within module │
└────────────────────────────────────────────────────────────────────┘
```
Expand Down Expand Up @@ -167,9 +167,9 @@ shipped user headers as required by `nvq++` compilation.

#### 3.2.4 Namespaces

- Declarations live under a module namespace nested in `cudaq`:
- Declarations live under a module namespace nested in `cudaq_internal`:
- `namespace cudaq::<module_name> { ... }` where `<module_name>` is lowercase
Examples: `cudaq::compiler`, `cudaq::cudaq_fmt`
Examples: `cudaq_internal::compiler`, `cudaq_internal::device_code`
- Nested namespaces follow the same visibility convention: they are public
except for the `detail` namespace.

Expand Down Expand Up @@ -256,11 +256,20 @@ namespace cudaq {
Internal module API:

```cpp
namespace cudaq::compiler {
namespace cudaq_internal::compiler {
class PassPipeline;

namespace detail {
// not public
}
}
```

## 5. Additional conventions

This documented primarily aims at defining conventions on APIs and modules.
Of particular relevance are the following rules from the LLVM coding standard
that we shall strive to follow.

- [Use Namespace Qualifiers to Define Previously Declared Symbols](https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-define-previously-declared-symbols)
- [Restrict Visibility](https://llvm.org/docs/CodingStandards.html#restrict-visibility)
Loading