@@ -3052,23 +3052,34 @@ int acl_submit_kernel_device_op(cl_event event) {
3052
3052
// to free up old operation slots.
3053
3053
acl_forget_proposed_device_ops (doq);
3054
3054
3055
- bool need_reprogram = true ;
3056
- if (device->last_bin ) {
3057
- // compare hash of last program that went through device op queue and the
3058
- // program required by kernel
3059
- need_reprogram =
3060
- device->last_bin ->get_devdef ().autodiscovery_def .binary_rand_hash !=
3061
- dev_bin->get_devdef ().autodiscovery_def .binary_rand_hash ;
3062
- } else {
3063
- // compare hash of program that is on the device and the program required by
3064
- // kernel
3065
- need_reprogram = device->def .autodiscovery_def .binary_rand_hash !=
3066
- dev_bin->get_devdef ().autodiscovery_def .binary_rand_hash ;
3055
+ // Check if any of the device globals have init_mode:reprogram
3056
+ bool has_reprogram_dev_global = false ;
3057
+ std::unordered_map<std::string, acl_device_global_mem_def_t >
3058
+ device_global_mem_defs =
3059
+ device->def .autodiscovery_def .device_global_mem_defs ;
3060
+ for (auto &it : device_global_mem_defs) {
3061
+ if (it.second .init_mode == ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM) {
3062
+ has_reprogram_dev_global = true ;
3063
+ break ;
3064
+ }
3067
3065
}
3068
3066
3069
- if (event->context ->split_kernel ) {
3070
- // Always reprogram in split kernel mode. This is a temporary workaround.
3071
- need_reprogram = true ;
3067
+ bool need_reprogram = true ;
3068
+ // Force reprogram if there is device global with init_mode:reprogram
3069
+ // or if this is the split kernel mode (split kernel workaround)
3070
+ if (!has_reprogram_dev_global && !event->context ->split_kernel ) {
3071
+ if (device->last_bin ) {
3072
+ // compare hash of last program that went through device op queue and the
3073
+ // program required by kernel
3074
+ need_reprogram =
3075
+ device->last_bin ->get_devdef ().autodiscovery_def .binary_rand_hash !=
3076
+ dev_bin->get_devdef ().autodiscovery_def .binary_rand_hash ;
3077
+ } else {
3078
+ // compare hash of program that is on the device and the program required
3079
+ // by kernel
3080
+ need_reprogram = device->def .autodiscovery_def .binary_rand_hash !=
3081
+ dev_bin->get_devdef ().autodiscovery_def .binary_rand_hash ;
3082
+ }
3072
3083
}
3073
3084
3074
3085
if (need_reprogram) {
0 commit comments