clGetProgramInfo

提供: Tommy6
移動: 案内検索
OpenCL > OpenCLマニュアル > OpenCLランタイム > OpenCLランタイムAPI > プログラムオブジェクト > clGetProgramInfo

cl_int clGetProgramInfo (cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)

プログラムオブジェクトについての情報を取得します。

パラメータ

program
有効なプログラムオブジェクトを指定します。
param_name
取得する情報を指定します。下記の表にある定数からひとつ選んで指定できます。
param_value
下記の表にしたがって param_name に指定した情報についての値が返されるメモリ空間へのポインタです。NULL の場合は無視されます。
param_value_size
param_value が指すメモリのサイズをバイトで指定します。このサイズは、下記の表で示されている戻り値型のサイズ以上でなければなりません。
param_value_size_ret
param_value にコピーされるデータの実際のサイズをバイトで返します。NULL の場合は無視されます。

取得できる情報

param_name で指定できる情報およびこれに対応して param_value に返される情報を以下の表に示しています。

cl_program_info 戻り値型 解説
CL_PROGRAM_REFERENCE_COUNT[1] cl_uint program の参照カウントを返します。
CL_PROGRAM_CONTEXT cl_context program を作成する際に指定したOpenCLコンテキストを返します。
CL_PROGRAM_NUM_DEVICES cl_uint program と関連付けられているデバイスの数を返します。
CL_PROGRAM_DEVICES cl_device_id [] program と関連付けられているデバイスのリストを返します。これは、program を作成したコンテキストに関連付けられたデバイスあるいは clCreateProgramWithBinary を使用して program を作成した際に指定したデバイスのサブセットになります。
CL_PROGRAM_SOURCE char [] Return the program source code specified by clCreateProgramWithSource. The source string returned is a concatenation of all source strings specified to clCreateProgramWithSource with a null terminator. The concatenation strips any nulls in the riginal source strings.

The actual number of characters that represents the program source code including the null terminator is returned in param_value_size_ret.

CL_PROGRAM_BINARY_SIZES size_t [] Returns an array that contains the size in bytes of the program binary for each device associated with program. The size of the array is the number of devices associated with program. If a binary is not available for a device(s), a size of zero is returned.
CL_PROGRAM_BINARIES unsigned char *[] Return the program binaries for all devices associated with program. For each device in program, the binary returned can be the binary specified for the device when program is created with clCreateProgramWithBinary or it can be the executable binary generated by clBuildProgram. If program is created with clCreateProgramWithSource, the binary returned is the binary generated by clBuildProgram. The bits returned can be an implementation-specific intermediate representation (a.k.a. IR) or device specific executable bits or both. The decision on which information is returned in the binary is up to the OpenCL implementation.

param_value points to an array of n pointers allocated by the caller, where n is the number of devices associated with program. The buffer sizes needed to allocate the memory that these n pointers refer to can be queried using the CL_PROGRAM_BINARY_SIZES query as described in this table.

Each entry in this array is used by the implementation as the location in memory where to copy the program binary for a specific device, if there is a binary available. To find out which device the program binary in the array refers to, use the CL_PROGRAM_DEVICES query to get the list of devices. There is a one-toone correspondence between the array of n pointers returned by CL_PROGRAM_BINARIES and array of devices returned by CL_PROGRAM_DEVICES.

If an entry value in the array is NULL, the implementation skips copying the program binary for the specific device identified by the array index.

エラー

実行が成功した場合、clGetProgramInfo は CL_SUCCESS を返します。そうでない場合は以下のエラーのうちひとつを返します。

  • CL_INVALID_PROGRAM - program が有効なプログラムオブジェクトでないとき。
  • CL_INVALID_VALUE - param_name がサポートされている値でない、あるいは、param_value_size で指定されたサイズが上記の表で指定されている戻り値型のサイズより小さくかつ param_value が NULL でないとき。
  • CL_OUT_OF_RESOURCES - デバイス上でのリソース確保に失敗したとき。
  • CL_OUT_OF_HOST_MEMORY - ホスト上でのリソース確保に失敗したとき。

変更記録

脚注

  1. 返された参照カウントの値はすぐに古くなるものと考えるべきです。アプリケーションでの一般的な使用には向いていません。この機能はメモリリークを検出するために提供されています。


―――― Revision 33, Version 1.1, The OpenCL Specification より翻訳