如果我们将 NULL 传递给 device_list 参数,clBuildProgram 会为哪些设备构建?
Which devices does clBuildProgram build for, if we pass NULL to device_list parameter?
clBuildProgram
允许给出一个设备列表来构建程序。这就是声明中 num_devices
和 device_list
参数的原因:
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)
如果我们这样使用它会发生什么?
cl_int clBuildProgram(program, 0, NULL, ...
- 是否为 PC 中的所有设备构建?
- 它是否只为我为其创建上下文的那些设备构建? (我的意思是我用
clCreateProgramWithSource
创建 program
时使用的上下文。)
文档说:
device_list: A pointer to a list of devices associated with program. If device_list is NULL value, the program executable is built for all devices associated with program for which a source or binary has been loaded. If device_list is a non-NULL value, the program executable is built for devices specified in this list for which a source or binary has been loaded.
我觉得这里的措辞有点复杂,但据此,我猜是数字 2。对吗?
我问是因为在第 1 种情况下,我需要将设备列表传递给此函数以避免对所有设备进行多余的编译。
2) 是正确的。编译仅限于与程序上下文关联的设备。这不可能是系统中的每个单独的设备,除非上下文是使用每个单独的设备创建的。
clBuildProgram
允许给出一个设备列表来构建程序。这就是声明中 num_devices
和 device_list
参数的原因:
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)
如果我们这样使用它会发生什么?
cl_int clBuildProgram(program, 0, NULL, ...
- 是否为 PC 中的所有设备构建?
- 它是否只为我为其创建上下文的那些设备构建? (我的意思是我用
clCreateProgramWithSource
创建program
时使用的上下文。)
文档说:
device_list: A pointer to a list of devices associated with program. If device_list is NULL value, the program executable is built for all devices associated with program for which a source or binary has been loaded. If device_list is a non-NULL value, the program executable is built for devices specified in this list for which a source or binary has been loaded.
我觉得这里的措辞有点复杂,但据此,我猜是数字 2。对吗?
我问是因为在第 1 种情况下,我需要将设备列表传递给此函数以避免对所有设备进行多余的编译。
2) 是正确的。编译仅限于与程序上下文关联的设备。这不可能是系统中的每个单独的设备,除非上下文是使用每个单独的设备创建的。