Description

The OpenCL C programming language implements the following built-in functions that read from or write to a pipe. We use the generic type name gentype to indicate the built-in OpenCL C scalar or vector integer or floating-point data types61 or any user defined type built from these scalar and vector data types can be used as the type for the arguments to the pipe functions listed in the following table.

[61] The half scalar and vector types can only be used if the cl_khr_fp16 extension is supported and has been enabled. The double scalar and vector types can only be used if double precision is supported.

Table 1. Built-in Pipe Functions

Function

Description

int read_pipe(read_only pipe gentype p, gentype *ptr)

Read packet from pipe p into ptr. Returns 0 if read_pipe is successful and a negative value if the pipe is empty.

int write_pipe(write_only pipe gentype p, const gentype *ptr)

Write packet specified by ptr to pipe p. Returns 0 if write_pipe is successful and a negative value if the pipe is full.

int read_pipe(read_only pipe gentype p, reserve_id_t reserve_id, uint index, gentype *ptr)

Read packet from the reserved area of the pipe referred to by reserve_id and index into ptr.

The reserved pipe entries are referred to by indices that go from 0 …​ num_packets - 1.

Returns 0 if read_pipe is successful and a negative value otherwise.

int write_pipe(write_only pipe gentype p, reserve_id_t reserve_id, uint index, const gentype *ptr)

Write packet specified by ptr to the reserved area of the pipe referred to by reserve_id and index.

The reserved pipe entries are referred to by indices that go from 0 …​ num_packets - 1.

Returns 0 if write_pipe is successful and a negative value otherwise.

reserve_id_t reserve_read_pipe(read_only pipe gentype p, uint num_packets)
reserve_id_t reserve_write_pipe(write_only pipe gentype p, uint num_packets)

Reserve num_packets entries for reading from or writing to pipe p. Returns a valid reservation ID if the reservation is successful.

void commit_read_pipe(read_only pipe gentype p, reserve_id_t reserve_id)
void commit_write_pipe(write_only pipe gentype p, reserve_id_t reserve_id)

Indicates that all reads and writes to num_packets associated with reservation reserve_id are completed.

bool is_valid_reserve_id(reserve_id_t reserve_id)

Return true if reserve_id is a valid reservation ID and false otherwise.

See Also

Document Notes

For more information, see the OpenCL C Specification

This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.