Consider removing disabled execution spaces from enum
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 111
- Forks
- 23
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
We just hit a case where we were pulling out a raw pointer using chai::ExecutionSpace::GPU, and it was greater than NUM_EXECUTION_SPACES since CHAI was built with CUDA disabled. Totally a bug on our end, but I think it would be preferable for uses of execution spaces that are disabled to not even compile. This would involve the following code:
```
enum ExecutionSpace {
/*! Default, no execution space. */
NONE = 0,
/*! Executing in CPU space */
CPU,
#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP) || defined(CHAI_ENABLE_GPU_SIMULATION_MODE)
/*! Execution in GPU space */
GPU,
#endif
#if defined(CHAI_ENABLE_UM)
UM,
#endif
#if defined(CHAI_ENABLE_PINNED)
PINNED,
#endif
// NUM_EXECUTION_SPACES should always be last!
/*! Used to count total number of spaces */
NUM_EXECUTION_SPACES
#if !defined(CHAI_ENABLE_CUDA) && !defined(CHAI_ENABLE_HIP) && !defined(CHAI_ENABLE_GPU_SIMULATION_MODE)
,GPU
#endif
#if !defined(CHAI_ENABLE_UM)
,UM
#endif
#if !defined(CHAI_ENABLE_PINNED)
,PINNED
#endif
};
```
The new code would remove entries after NUM_EXECUTION_SPACES:
```
enum ExecutionSpace {
/*! Default, no execution space. */
NONE = 0,
/*! Executing in CPU space */
CPU,
#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP) || defined(CHAI_ENABLE_GPU_SIMULATION_MODE)
/*! Execution in GPU space */
GPU,
#endif
#if defined(CHAI_ENABLE_UM)
UM,
#endif
#if defined(CHAI_ENABLE_PINNED)
PINNED,
#endif
// NUM_EXECUTION_SPACES should always be last!
/*! Used to count total number of spaces */
NUM_EXECUTION_SPACES
};
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the repository for the ExecutionSpace enum shown in the issue and inspect the conditional build definitions for CUDA, HIP, GPU simulation, UM, and pinned memory. Remove disabled entries after NUM_EXECUTION_SPACES, then verify configurations without each feature no longer expose those enum values and keep NUM_EXECUTION_SPACES as the final count.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 40/100