KhronosGroup / KhronosGroup/OpenCL-Docs

printf z format qualifier

Open
#654 2 comments 1 reaction 0 assignees View on GitHub
needs-new-opencl-minor-version OpenCL C Spec
Dominant language
Python
Stars
420
Forks
131
Avg merge
5d 13h
Merged PRs (30d)
11

Description

OpenCL C has a `size_t` type, but the OpenCL C printf [excludes the z format qualifier](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#differences-between-opencl-c-and-c99-printf). This makes it slightly harder to use printf to print things such as `get_global_id(...)` values.

> The ll, j, z, t, and L length modifiers are not supported by OpenCL C but are reserved.

This can't be changed in an an existing version of OpenCL, but it is a small issue that could be considered in the future.

In terms of specification I think it would just be necessary to drop the restriction from the OpenCL C spec, and extend a few modifier lists. The SPIR-V extension instruction just takes a format string as well, so no additional changes.

For implementations that implement printf by sending a buffer of data back to the host that makes the size of the contents of the buffer device-dependent, but that is already the case for the p format qualifier.

Contributor guide

Open the contributing guide

Research direction

Start with the OpenCL C printf specification and the modifier lists referenced in the issue. Check how the SPIR-V extension instruction handles the format string, and compare the existing p qualifier discussion. Done means the z restriction and related lists are consistently updated without requiring SPIR-V changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
documentation
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.