table of contents
CLBUILDPROGRAM(3clc) | OpenCL Manual | CLBUILDPROGRAM(3clc) |
NAME¶
clBuildProgram - Builds (compiles and links) a program executable from the program source or binary.
¶
cl_int clBuildProgram(cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), void *user_data);
PARAMETERS¶
program
device_list
num_devices
options
pfn_notify
user_data
NOTES¶
Builds (compiles & links) a program executable from the program source or binary for all the devices or a specific device(s) in the OpenCL context associated with program. OpenCL allows program executables to be built using the source or the binary. clBuildProgram must be called for program created using either clCreateProgramWithSource(3clc) or clCreateProgramWithBinary(3clc) to build the program executable for one or more devices associated with program. If program is created with clCreateProgramWithBinary(3clc), then the program binary must be an executable binary (not a compiled binary or library).
The executable binary can be queried using clGetProgramInfo(3clc)(program, CL_PROGRAM_BINARIES, ...) and can be specified to clCreateProgramWithBinary(3clc) to create a new program object. Compiler Options.PP The compiler options are categorized as pre-processor options, options for math intrinsics, options that control optimization and miscellaneous options. This specification defines a standard set of options that must be supported by the OpenCL C compiler when building program executables online or offline. These may be extended by a set of vendor- or platform specific options. Preprocessor Options.PP These options control the OpenCL C preprocessor which is run on each program source before actual compilation.
-D options are processed in the order they are given in the options argument to clBuildProgram or or clCompileProgram.
-D name
-D name=definition
-I dir
These options control compiler behavior regarding floating-point arithmetic. These options trade off between speed and correctness.
-cl-single-precision-constant
-cl-denorms-are-zero
This option is ignored for single precision numbers if the device does not support single precision denormalized numbers i.e. CL_FP_DENORM bit is not set in CL_DEVICE_SINGLE_FP_CONFIG.
This option is ignored for double precision numbers if the device does not support double precision or if it does support double precison but CL_FP_DENORM bit is not set in CL_DEVICE_DOUBLE_FP_CONFIG.
This flag only applies for scalar and vector single precision floating-point variables and computations on these floating-point variables inside a program. It does not apply to reading from or writing to image objects.
-cl-fp32-correctly-rounded-divide-sqrt
This build option can only be specified if the CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT is set in CL_DEVICE_SINGLE_FP_CONFIG (as defined in in the table of allowed values for param_name for clGetDeviceInfo(3clc)) for devices that the program is being build. clBuildProgram or clCompileProgram will fail to compile the program for a device if the -cl-fp32-correctly-rounded-divide-sqrt option is specified and CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT is not set for the device.
-cl-opt-disable
The following options control compiler behavior regarding floating-point arithmetic. These options trade off between performance and correctness and must be specifically enabled. These options are not turned on by default since it can result in incorrect output for programs which depend on an exact implementation of IEEE 754 rules/specifications for math functions.
-cl-mad-enable
-cl-no-signed-zeros
-cl-unsafe-math-optimizations
-cl-finite-math-only
-cl-fast-relaxed-math
Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there may have been an error. The following languageindependent options do not enable specific warnings but control the kinds of diagnostics produced by the OpenCL compiler.
-w
-Werror
The following option controls the version of OpenCL C that the compiler accepts.
-cl-std=
CL1.1 - Support all OpenCL C programs that use the OpenCL C language features defined in section 6 of the OpenCL 1.1 specification.
CL1.2 – Support all OpenCL C programs that use the OpenCL C language features defined in section 6 of the OpenCL 1.2 specification.
Calls to clBuildProgram or clCompileProgram with the -cl-std=CL1.1 option will fail to compile the program for any devices with CL_DEVICE_OPENCL_C_VERSION = OpenCL C 1.0. Calls to clBuildProgram or clCompileProgram with the -cl-std=CL1.2 option will fail to compile the program for any devices with CL_DEVICE_OPENCL_C_VERSION = OpenCL C 1.0 or OpenCL C 1.1.
If the -cl-std build option is not specified, the CL_DEVICE_OPENCL_C_VERSION is used to select the version of OpenCL C to be used when compiling the program for each device. Options for Querying Kernel Argument Information
-cl-kernel-arg-info
This specification defines a standard set of linker options that must be supported by the OpenCL C compiler when linking compiled programs online or offline. These linker options are categorized as library linking options and program linking options. These may be extended by a set of vendor- or platform-specific options.
Library Linking Options
The following options can be specified when creating a library of compiled binaries.
-create-library
-enable-link-options
The following options can be specified when linking a program executable.
The linker may apply these options to all compiled program objects specified to clLinkProgram(3clc). The linker may apply these options only to libraries which were created with the –enable-link-option.
Separate Compilation and Linking of Programs.PP OpenCL 1.2 extends how programs are compiled and linked to support the following:
ERRORS¶
clBuildProgram returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
SPECIFICATION¶
OpenCL Specification[1]
SEE ALSO¶
clGetDeviceInfo(3clc)
AUTHORS¶
The Khronos Group
COPYRIGHT¶
Copyright © 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and/or associated documentation files (the
"Materials"), to deal in the Materials without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Materials, and to
permit persons to whom the Materials are furnished to do so, subject to the
condition that this copyright notice and permission notice shall be included
in all copies or substantial portions of the Materials.
NOTES¶
- 1.
- OpenCL Specification
11/18/2024 | The Khronos Group |