Skip to content

Commit a4d95a0

Browse files
committed
instruction improvements
1 parent ffaa535 commit a4d95a0

15 files changed

+243
-98
lines changed

.github/instructions/cython.instructions.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,16 @@ applyTo:
77

88
# Cython Instructions
99

10-
See [dpctl/AGENTS.md](/dpctl/AGENTS.md) for conventions and patterns.
10+
See `dpctl/AGENTS.md` for full conventions.
1111

12-
## Quick Reference
13-
14-
### Required Directives (after license header)
12+
## Required Directives (after license)
1513
```cython
1614
# distutils: language = c++
1715
# cython: language_level=3
1816
# cython: linetrace=True
1917
```
2018

21-
### Key Rules
22-
- `cimport` for C-level declarations, `import` for Python
23-
- Store C refs as `_*_ref`, clean up in `__dealloc__`
19+
## Key Rules
20+
- `cimport` for C-level, `import` for Python-level
21+
- Store C refs as `_*_ref`, clean up in `__dealloc__` with NULL check
2422
- Use `with nogil:` for blocking C operations
25-
- Check NULL before using C API returns

.github/instructions/dpctl.instructions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ applyTo:
1010

1111
# DPCTL General Instructions
1212

13-
See [/AGENTS.md](/AGENTS.md) for project overview and architecture.
13+
See `AGENTS.md` at repository root for project overview and architecture.
14+
Each major directory has its own `AGENTS.md` with specific conventions.
1415

1516
## Key References
1617

17-
- **Code style:** See `.pre-commit-config.yaml` for tool versions, `.clang-format` for C++ style
18-
- **License:** Apache 2.0 with Intel copyright - see existing files for header format
19-
- **Directory guides:** Each major directory has its own `AGENTS.md`
18+
- **Code style:** `.pre-commit-config.yaml`, `.clang-format`, `.flake8`
19+
- **License:** Apache 2.0 with Intel copyright - match existing file headers
2020

2121
## Critical Rules
2222

23-
1. **Device compatibility:** Not all devices support fp64/fp16 - check capabilities
24-
2. **Queue consistency:** All arrays in an operation must share compatible queues
25-
3. **Resource cleanup:** Always clean up C resources in `__dealloc__`
23+
1. **Device compatibility:** Not all devices support fp64/fp16 - never assume availability
24+
2. **Queue consistency:** Arrays in same operation must share compatible queues
25+
3. **Resource cleanup:** Clean up C resources in `__dealloc__` with NULL check
2626
4. **NULL checks:** Always check C API returns before use
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
applyTo:
3-
- "dpctl/tensor/libtensor/**/elementwise_functions/**"
3+
- "dpctl/tensor/libtensor/include/kernels/elementwise_functions/**"
4+
- "dpctl/tensor/libtensor/source/elementwise_functions/**"
45
- "dpctl/tensor/_elementwise_*.py"
56
- "dpctl/tests/elementwise/**"
67
---
@@ -10,16 +11,14 @@ applyTo:
1011
Full stack: C++ kernel → pybind11 → Python wrapper → tests
1112

1213
## References
14+
- C++ kernels: `dpctl/tensor/libtensor/AGENTS.md`
15+
- Python wrappers: `dpctl/tensor/AGENTS.md`
16+
- Tests: `dpctl/tests/AGENTS.md`
1317

14-
- **C++ kernels:** [dpctl/tensor/libtensor/AGENTS.md](/dpctl/tensor/libtensor/AGENTS.md)
15-
- **Python wrappers:** [dpctl/tensor/AGENTS.md](/dpctl/tensor/AGENTS.md)
16-
- **Tests:** [dpctl/tests/AGENTS.md](/dpctl/tests/AGENTS.md)
17-
18-
## Adding New Operation Checklist
19-
18+
## Adding New Operation
2019
1. `libtensor/include/kernels/elementwise_functions/op.hpp` - functor
2120
2. `libtensor/source/elementwise_functions/op.cpp` - dispatch tables
2221
3. Register in `tensor_elementwise.cpp`
2322
4. `_elementwise_funcs.py` - Python wrapper
2423
5. Export in `__init__.py`
25-
6. `tests/elementwise/test_op.py` - full coverage
24+
6. `tests/elementwise/test_op.py` - full dtype/usm coverage

.github/instructions/libsyclinterface.instructions.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ applyTo:
77

88
# C API Instructions
99

10-
See [libsyclinterface/AGENTS.md](/libsyclinterface/AGENTS.md) for conventions.
10+
See `libsyclinterface/AGENTS.md` for conventions.
1111

12-
## Quick Reference
13-
14-
### Naming
12+
## Naming
1513
`DPCTL<ClassName>_<MethodName>` (e.g., `DPCTLDevice_Create`)
1614

17-
### Ownership annotations (from `Support/MemOwnershipAttrs.h`)
15+
## Ownership annotations (see `include/syclinterface/Support/MemOwnershipAttrs.h`)
1816
- `__dpctl_give` - caller must free
1917
- `__dpctl_take` - function takes ownership
2018
- `__dpctl_keep` - function only observes
2119

22-
### Key Rules
20+
## Key Rules
2321
- Annotate all parameters and returns
2422
- Return NULL on failure
2523
- Use `DPCTL_API` for exports

.github/instructions/libtensor-cpp.instructions.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ applyTo:
66

77
# C++ SYCL Kernel Instructions
88

9-
See [dpctl/tensor/libtensor/AGENTS.md](/dpctl/tensor/libtensor/AGENTS.md) for patterns and structure.
9+
See `dpctl/tensor/libtensor/AGENTS.md` for patterns and directory structure.
1010

11-
## Quick Reference
12-
13-
### Type dispatch
14-
See `include/utils/type_dispatch_building.hpp` for the 14 supported types.
15-
16-
### Key Rules
17-
- Kernel class names must be unique
11+
## Key Rules
12+
- Kernel class names must be globally unique
1813
- Use `if constexpr` for compile-time type branching
1914
- Complex types don't support vectorization
2015
- Return `nullptr` from factory for unsupported types
16+
- Check `include/kernels/elementwise_functions/common.hpp` for base patterns

.github/instructions/memory.instructions.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ applyTo:
66

77
# USM Memory Instructions
88

9-
See [dpctl/memory/AGENTS.md](/dpctl/memory/AGENTS.md) for details.
9+
See `dpctl/memory/AGENTS.md` for details.
1010

11-
## Quick Reference
12-
13-
### USM Types
11+
## USM Types
1412
- `MemoryUSMDevice` - device-only (fastest)
1513
- `MemoryUSMShared` - host and device accessible
1614
- `MemoryUSMHost` - host memory, device accessible
1715

18-
### Lifetime Rules
16+
## Lifetime Rules
1917
1. Memory is queue-bound
2018
2. Keep memory alive until operations complete
2119
3. Views extend base memory lifetime

.github/instructions/tensor-python.instructions.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ applyTo:
66

77
# Tensor Python Instructions
88

9-
See [dpctl/tensor/AGENTS.md](/dpctl/tensor/AGENTS.md) for patterns.
9+
See `dpctl/tensor/AGENTS.md` for patterns.
1010

11-
## Quick Reference
12-
13-
### Queue validation (required for all operations)
11+
## Queue validation (required)
1412
```python
1513
exec_q = dpctl.utils.get_execution_queue([x.sycl_queue, y.sycl_queue])
1614
if exec_q is None:
1715
raise ExecutionPlacementError("...")
1816
```
1917

20-
### Adding operations
21-
See checklist in [dpctl/tensor/AGENTS.md](/dpctl/tensor/AGENTS.md).
18+
## Adding operations
19+
See checklist in `dpctl/tensor/AGENTS.md`.

.github/instructions/testing.instructions.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,18 @@ applyTo:
66

77
# Testing Instructions
88

9-
See [dpctl/tests/AGENTS.md](/dpctl/tests/AGENTS.md) for patterns and dtype lists.
9+
See `dpctl/tests/AGENTS.md` for patterns.
1010

11-
## Quick Reference
12-
13-
### Essential helpers (from `helper/_helper.py`)
11+
## Essential helpers (from `helper/_helper.py`)
1412
```python
1513
get_queue_or_skip() # Create queue or skip
1614
skip_if_dtype_not_supported() # Skip if device lacks dtype
1715
```
1816

19-
### Dtype lists (from `elementwise/utils.py`)
20-
Use `_all_dtypes`, `_usm_types` for parametrization.
17+
## Dtype/USM lists
18+
Import from `elementwise/utils.py` - do not hardcode.
2119

22-
### Coverage requirements
23-
- All supported dtypes
24-
- All USM types (device, shared, host)
25-
- Edge cases: empty arrays, scalars
20+
## Coverage
21+
- All dtypes from `_all_dtypes`
22+
- All USM types: device, shared, host
23+
- Edge cases: empty, scalar, broadcast

AGENTS.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
## Architecture
1111

1212
```
13-
Python API → Cython Bindings → C API → C++ Kernels → SYCL Runtime
14-
dpctl/ _sycl_*.pyx libsycl- libtensor/
15-
interface/
13+
Python API → Cython Bindings → C API → SYCL Runtime
14+
dpctl/ _sycl_*.pyx libsyclinterface/
15+
16+
dpctl.tensor → pybind11 → C++ Kernels (libtensor/) → SYCL Runtime
1617
```
1718

1819
## Directory Guide
@@ -23,33 +24,36 @@ Python API → Cython Bindings → C API → C++ Kernels → SYCL Runtim
2324
| `dpctl/tensor/` | [dpctl/tensor/AGENTS.md](dpctl/tensor/AGENTS.md) | Array API tensor operations |
2425
| `dpctl/tensor/libtensor/` | [dpctl/tensor/libtensor/AGENTS.md](dpctl/tensor/libtensor/AGENTS.md) | C++ SYCL kernels |
2526
| `dpctl/memory/` | [dpctl/memory/AGENTS.md](dpctl/memory/AGENTS.md) | USM memory management |
27+
| `dpctl/program/` | [dpctl/program/AGENTS.md](dpctl/program/AGENTS.md) | SYCL kernel compilation |
28+
| `dpctl/utils/` | [dpctl/utils/AGENTS.md](dpctl/utils/AGENTS.md) | Utility functions |
2629
| `dpctl/tests/` | [dpctl/tests/AGENTS.md](dpctl/tests/AGENTS.md) | Test suite |
2730
| `libsyclinterface/` | [libsyclinterface/AGENTS.md](libsyclinterface/AGENTS.md) | C API layer |
2831

2932
## Code Style
3033

31-
Style tools and configuration are defined in:
32-
- **Python/Cython:** `.pre-commit-config.yaml` (black, isort, flake8, cython-lint)
34+
Configuration files (do not hardcode versions - check these files):
35+
- **Python/Cython:** `.pre-commit-config.yaml`
3336
- **C/C++:** `.clang-format`
34-
- **Linting config:** `.flake8`
37+
- **Linting:** `.flake8`
3538

3639
## License Header
3740

38-
All source files require Apache 2.0 header with Intel copyright. See existing files for format.
41+
All source files require Apache 2.0 header with Intel copyright. Reference existing files for exact format.
3942

4043
## Quick Reference
4144

4245
```python
4346
import dpctl
4447
import dpctl.tensor as dpt
4548

46-
q = dpctl.SyclQueue("gpu") # Create queue
47-
x = dpt.ones((100, 100), dtype="f4", device=q) # Create array
48-
np_array = dpt.asnumpy(x) # Transfer to host
49+
q = dpctl.SyclQueue("gpu") # Create queue
50+
x = dpt.ones((100, 100), dtype="f4", sycl_queue=q) # Create array
51+
np_array = dpt.asnumpy(x) # Transfer to host
4952
```
5053

5154
## Key Concepts
5255

5356
- **Queue:** Execution context binding device + context
5457
- **USM:** Unified Shared Memory (device/shared/host types)
5558
- **Filter string:** Device selector syntax `"backend:device_type:num"`
59+
- **Array API:** Python standard for array operations (https://data-apis.org/array-api/)

dpctl/AGENTS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ Python/Cython wrappers for SYCL runtime objects: Device, Queue, Context, Event,
1313
| `_sycl_context.pyx` | `SyclContext` wrapping `sycl::context` |
1414
| `_sycl_event.pyx` | `SyclEvent` wrapping `sycl::event` |
1515
| `_sycl_platform.pyx` | `SyclPlatform` wrapping `sycl::platform` |
16+
| `_sycl_device_factory.pyx` | Device enumeration and selection |
17+
| `_sycl_queue_manager.pyx` | Queue management utilities |
1618
| `_backend.pxd` | C API declarations from libsyclinterface |
1719
| `enum_types.py` | Python enums for SYCL types |
1820

1921
## Cython Conventions
2022

21-
### Required Directives
23+
### Required Directives (after license header)
2224
```cython
2325
# distutils: language = c++
2426
# cython: language_level=3
@@ -40,7 +42,7 @@ cdef class SyclDevice:
4042

4143
### Key Rules
4244
- Store C references as `_*_ref` attributes
43-
- Always clean up in `__dealloc__`
45+
- Always clean up in `__dealloc__` with NULL check
4446
- Use `with nogil:` for blocking C calls
4547
- Check NULL before using C API returns
4648

0 commit comments

Comments
 (0)