Improve thread handling based on FIXED_LOCAL_SIZE

This commit is contained in:
Jens Steube
2019-05-08 23:30:07 +02:00
parent 3a3df091c7
commit fb82bfc169
4 changed files with 70 additions and 51 deletions
-7
View File
@@ -108,13 +108,6 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY
{
overhead = 4;
}
// no clue yet where this is coming from
if (device_param->is_cuda == true)
{
overhead = 240;
}
}
if (user_options->kernel_threads_chgd == true)
+29 -8
View File
@@ -74,6 +74,11 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY
{
char *jit_build_options = NULL;
// this uses some nice feedback effect.
// based on the device_local_mem_size the reqd_work_group_size in the kernel is set to some value
// which is then is read from the opencl host in the kernel_preferred_wgs_multiple1/2/3 result.
// therefore we do not need to set module_kernel_threads_min/max except for CPU, where the threads are set to fixed 1.
u32 fixed_local_size = 0;
if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)
@@ -82,19 +87,35 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY
}
else
{
if (user_options->kernel_threads_chgd == true)
{
fixed_local_size = user_options->kernel_threads;
}
else
{
u32 overhead = 0;
u32 overhead = 0;
if (device_param->opencl_device_vendor_id == VENDOR_ID_NV)
if (device_param->opencl_device_vendor_id == VENDOR_ID_NV)
{
// note we need to use device_param->device_local_mem_size - 4 because opencl jit returns with:
// Entry function '...' uses too much shared data (0xc004 bytes, 0xc000 max)
// on my development system. no clue where the 4 bytes are spent.
// I did some research on this and it seems to be related with the datatype.
// For example, if i used u8 instead, there's only 1 byte wasted.
if (device_param->is_opencl == true)
{
overhead = 4;
}
}
if (user_options->kernel_threads_chgd == true)
{
fixed_local_size = user_options->kernel_threads;
// otherwise out-of-bound reads
if ((fixed_local_size * 4096) > (device_param->device_local_mem_size - overhead))
{
fixed_local_size = (device_param->device_local_mem_size - overhead) / 4096;
}
}
else
{
fixed_local_size = (device_param->device_local_mem_size - overhead) / 4096;
}
}
+29 -8
View File
@@ -66,6 +66,11 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY
{
char *jit_build_options = NULL;
// this uses some nice feedback effect.
// based on the device_local_mem_size the reqd_work_group_size in the kernel is set to some value
// which is then is read from the opencl host in the kernel_preferred_wgs_multiple1/2/3 result.
// therefore we do not need to set module_kernel_threads_min/max except for CPU, where the threads are set to fixed 1.
u32 fixed_local_size = 0;
if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)
@@ -74,19 +79,35 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY
}
else
{
if (user_options->kernel_threads_chgd == true)
{
fixed_local_size = user_options->kernel_threads;
}
else
{
u32 overhead = 0;
u32 overhead = 0;
if (device_param->opencl_device_vendor_id == VENDOR_ID_NV)
if (device_param->opencl_device_vendor_id == VENDOR_ID_NV)
{
// note we need to use device_param->device_local_mem_size - 4 because opencl jit returns with:
// Entry function '...' uses too much shared data (0xc004 bytes, 0xc000 max)
// on my development system. no clue where the 4 bytes are spent.
// I did some research on this and it seems to be related with the datatype.
// For example, if i used u8 instead, there's only 1 byte wasted.
if (device_param->is_opencl == true)
{
overhead = 4;
}
}
if (user_options->kernel_threads_chgd == true)
{
fixed_local_size = user_options->kernel_threads;
// otherwise out-of-bound reads
if ((fixed_local_size * 4096) > (device_param->device_local_mem_size - overhead))
{
fixed_local_size = (device_param->device_local_mem_size - overhead) / 4096;
}
}
else
{
fixed_local_size = (device_param->device_local_mem_size - overhead) / 4096;
}
}