Skip to content

Commit 7eda565

Browse files
committed
change if statement to asserts
1 parent c0a4ea6 commit 7eda565

File tree

1 file changed

+7
-37
lines changed

1 file changed

+7
-37
lines changed

src/acl_kernel_if.cpp

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -874,26 +874,13 @@ int acl_kernel_if_update(const acl_device_def_autodiscovery_t &devdef,
874874
// Allocations for each kernel
875875
kern->accel_csr = (acl_kernel_if_addr_range *)acl_malloc(
876876
kern->num_accel * sizeof(acl_kernel_if_addr_range));
877-
if (!(kern->accel_csr)) {
878-
ACL_KERNEL_IF_DEBUG_MSG(kern,
879-
"Failed to allocate memory for kernel csr.\n");
880-
return 1;
881-
}
877+
assert(kern->accel_csr);
882878
kern->accel_perf_mon = (acl_kernel_if_addr_range *)acl_malloc(
883879
kern->num_accel * sizeof(acl_kernel_if_addr_range));
884-
if (!(kern->accel_perf_mon)) {
885-
ACL_KERNEL_IF_DEBUG_MSG(
886-
kern, "Failed to allocate memory for kernel performance monitor.\n");
887-
return 1;
888-
}
880+
assert(kern->accel_perf_mon);
889881
kern->accel_num_printfs =
890882
(unsigned int *)acl_malloc(kern->num_accel * sizeof(unsigned int));
891-
if (!(kern->accel_num_printfs)) {
892-
ACL_KERNEL_IF_DEBUG_MSG(
893-
kern,
894-
"Failed to allocate memory for kernel number of printf tracker.\n");
895-
return 1;
896-
}
883+
assert(kern->accel_num_printfs);
897884

898885
// The Kernel CSR registers
899886
// The new and improved config ROM give us the address *offsets* from
@@ -962,35 +949,18 @@ int acl_kernel_if_update(const acl_device_def_autodiscovery_t &devdef,
962949
if (kern->num_accel > 0) {
963950
kern->accel_job_ids =
964951
(int volatile **)acl_malloc(kern->num_accel * sizeof(int *));
965-
if (!(kern->accel_job_ids)) {
966-
ACL_KERNEL_IF_DEBUG_MSG(kern,
967-
"Failed to allocate memory for kernel id.\n");
968-
return 1;
969-
}
952+
assert(kern->accel_job_ids)
970953

971954
kern->accel_invoc_queue_depth =
972955
(unsigned int *)acl_malloc(kern->num_accel * sizeof(unsigned int));
973-
if (!(kern->accel_invoc_queue_depth)) {
974-
ACL_KERNEL_IF_DEBUG_MSG(
975-
kern,
976-
"Failed to allocate memory for kernel invocation queue depth.\n");
977-
return 1;
978-
}
956+
assert(kern->accel_invoc_queue_depth)
979957

980958
// Kernel IRQ is a separate thread. Need to use circular buffer to make this
981959
// multithread safe.
982960
kern->accel_queue_front = (int *)acl_malloc(kern->num_accel * sizeof(int));
983-
if (!(kern->accel_queue_front)) {
984-
ACL_KERNEL_IF_DEBUG_MSG(
985-
kern, "Failed to allocate memory for kernel IRQ circular buffer.\n");
986-
return 1;
987-
}
961+
assert(kern->accel_queue_front)
988962
kern->accel_queue_back = (int *)acl_malloc(kern->num_accel * sizeof(int));
989-
if (!(kern->accel_queue_back)) {
990-
ACL_KERNEL_IF_DEBUG_MSG(
991-
kern, "Failed to allocate memory for kernel IRQ circular buffer.\n");
992-
return 1;
993-
}
963+
assert(kern->accel_queue_back)
994964

995965
for (unsigned a = 0; a < kern->num_accel; ++a) {
996966
unsigned int max_same_accel_launches =

0 commit comments

Comments
 (0)