What is the algorithm to determine optimal work group size and number of workgroup

前端 未结 2 1043
天命终不由人
天命终不由人 2020-12-03 05:49

OpenCL standard defines the following options to get info about device and compiled kernel:

  • CL_DEVICE_MAX_COMPUTE_UNITS

  • CL_DEVICE_MAX_WORK_G

2条回答
  •  萌比男神i
    2020-12-03 06:09

    As mfa said, you have to discover these experimentally. I wanted to add that depending on what you are computing (particularly size of the jobs, i.e. smaller or larger for each work item), sometimes a good try can be:

    • Lots of work items with small work groups and each job item being small.
    • Less work items with larger work groups and each job item being larger.

    That is, basically check base cases and figure out how it affects the processing pipeline.

    In essence you have to tweak it. I often execute several times for different parameters (profile it) and then generate a surface plot to see how it behaves.

提交回复
热议问题