KhronosGroup / KhronosGroup/OpenCL-Docs

Should OpenCL C have a memcpy?

Open
#1,555 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
420
Forks
131
Avg merge
5d 13h
Merged PRs (30d)
11

Description

At the moment the [OpenCL C spec](https://registry.khronos.org/OpenCL/specs/unified/html/OpenCL_C.html#reinterpreting-data-as-another-type) states:

> Of these, only memcpy is strictly correct in C99. Since OpenCL does not provide memcpy, other methods are needed.

Should we provide a type generic (for all OpenCL C scalars and vector types?) `memcpy` in OpenCL C? In SPIR-V we have [OpCopyMemory](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpCopyMemory) and [OpCopyMemorySized](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpCopyMemorySized)?

I think I'd prefer to provide a higher level function to developers rather than them trying to implement `memcpy` with loops or something that are fundamentally more difficult to optimize and more difficult to reason about pointer alignments.

Should we have a `memcpy` extension for this?

Should we have a `memcpy_aligned` version where developers can specify explicit pointer alignment?

Contributor guide

Open the contributing guide

Research direction

Start with the linked OpenCL C specification section on reinterpreting data and compare it with the linked SPIR-V OpCopyMemory and OpCopyMemorySized definitions. Resolve whether memcpy and memcpy_aligned should be specified, including supported scalar or vector types and alignment semantics. Done means the proposal has a settled specification decision and documented scope.

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
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.