| 196 | } |
| 197 | |
| 198 | kernel_configuration::id_type |
| 199 | kernel_adaptivity_engine::finalize_binary_configuration( |
| 200 | kernel_configuration &config) { |
| 201 | |
| 202 | // At any adaptivity level need to handle function call specializations. |
| 203 | for (int i = 0; i < _kernel_info->get_num_parameters(); ++i) { |
| 204 | auto &annotations = _kernel_info->get_known_annotations(i); |
| 205 | std::size_t arg_size = _kernel_info->get_argument_size(i); |
| 206 | for (auto annotation : annotations) { |
| 207 | if (annotation == |
| 208 | hcf_kernel_info::annotation_type::fcall_specialized_config && |
| 209 | arg_size == sizeof(glue::sscp::fcall_config_kernel_property_t)) { |
| 210 | glue::sscp::fcall_config_kernel_property_t value; |
| 211 | std::memcpy(&value, _arg_mapper.get_mapped_args()[i], arg_size); |
| 212 | config.set_function_call_specialization_config(i, value); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | if(_adaptivity_level > 0) { |
| 218 | // Enter single-kernel code model |
| 219 | config.append_base_configuration( |
| 220 | kernel_base_config_parameter::single_kernel, _kernel_name); |
| 221 | |
| 222 | // Hard-code group sizes into the JIT binary |
| 223 | config.set_build_option(kernel_build_option::known_group_size_x, |
| 224 | _block_size[0]); |
| 225 | config.set_build_option(kernel_build_option::known_group_size_y, |
| 226 | _block_size[1]); |
| 227 | config.set_build_option(kernel_build_option::known_group_size_z, |
| 228 | _block_size[2]); |
| 229 | |
| 230 | // Try to optimize size_t -> i32 for queries if those fit in int |
| 231 | auto global_size = _num_groups * _block_size; |
| 232 | auto int_max = std::numeric_limits<int>::max(); |
| 233 | if (global_size[0] * global_size[1] * global_size[2] < int_max) |
| 234 | config.set_build_flag(kernel_build_flag::global_sizes_fit_in_int); |
| 235 | |
| 236 | // Hard-code local memory size into the JIT binary |
| 237 | config.set_build_option(kernel_build_option::known_local_mem_size, |
| 238 | _local_mem_size); |
| 239 | |
| 240 | // Handle kernel parameter optimization hints |
| 241 | for(int i = 0; i < _kernel_info->get_num_parameters(); ++i) { |
| 242 | std::size_t arg_size = _kernel_info->get_argument_size(i); |
| 243 | if (has_annotation(_kernel_info, i, |
| 244 | hcf_kernel_info::annotation_type::specialized) && |
| 245 | arg_size <= sizeof(uint64_t)) { |
| 246 | uint64_t buffer_value = 0; |
| 247 | std::memcpy(&buffer_value, _arg_mapper.get_mapped_args()[i], arg_size); |
| 248 | config.set_specialized_kernel_argument(i, buffer_value); |
| 249 | } |
| 250 | |
| 251 | if (_kernel_info->get_argument_type(i) == |
| 252 | hcf_kernel_info::argument_type::pointer) { |
| 253 | if (has_annotation(_kernel_info, i, |
| 254 | hcf_kernel_info::annotation_type::noalias)) { |
| 255 | config.set_kernel_param_flag(i, kernel_param_flag::noalias); |
no test coverage detected