KhronosGroup / KhronosGroup/OpenCL-Docs

Subscript in vectors

Open
#309 3 comments 0 reactions 0 assignees View on GitHub
OpenCL C Spec
Dominant language
Python
Stars
420
Forks
131
Avg merge
5d 13h
Merged PRs (30d)
11

Description

Clang allows to use subscript operator on vectors in core OpenCL mode (without any extension). The areas it can be useful is dynamic indexing:
https://godbolt.org/z/8yn9LY

That can help to write more concise code using loops:
https://godbolt.org/z/FMvi5v
FYI for loops with static bounds LLVM can unroll the loop and change into static indexing i.e. there will be no performance loss compared to regular vector component access (see generated IR in example).

Accesses out of bounds result in undefined behavior.

Is this something we could adopt as part of the language specification, extension, etc? If else we need to change the implementation to either disallow this or make clang extension.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the two linked Godbolt examples and the existing OpenCL vector-access specification. The issue asks for a decision among standardizing subscripting, documenting it as an extension, or changing the implementation, so done requires a settled direction rather than a single obvious edit.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.