Skip to content

Commit caa7def

Browse files
committed
kernelforce reprogram if kernel device has device global with init_mode reprogram
1 parent 961dfd1 commit caa7def

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/acl_kernel.cpp

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,23 +3052,34 @@ int acl_submit_kernel_device_op(cl_event event) {
30523052
// to free up old operation slots.
30533053
acl_forget_proposed_device_ops(doq);
30543054

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+
}
30673065
}
30683066

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+
}
30723083
}
30733084

30743085
if (need_reprogram) {

0 commit comments

Comments
 (0)