@@ -959,6 +959,68 @@ cl_bool l_load_board_libraries(cl_bool load_libraries) {
959
959
}
960
960
#endif
961
961
962
+ void l_get_physical_devices (acl_mmd_dispatch_t *mmd_dispatch,
963
+ unsigned &num_phys_devices) {
964
+ int num_boards;
965
+ char *ptr, *saveptr;
966
+ // This is a bit subtle, pointers to device names might get cached by
967
+ // various routines
968
+ static char buf[MAX_BOARD_NAMES_LEN];
969
+
970
+ mmd_dispatch->aocl_mmd_get_offline_info (AOCL_MMD_VERSION, sizeof (buf), buf,
971
+ NULL );
972
+ buf[sizeof (buf) - 1 ] = 0 ;
973
+ mmd_dispatch->mmd_version = atof (buf);
974
+ min_MMD_version =
975
+ (!MMDVERSION_LESSTHAN (min_MMD_version, mmd_dispatch->mmd_version ))
976
+ ? mmd_dispatch->mmd_version
977
+ : min_MMD_version;
978
+ ACL_HAL_DEBUG_MSG_VERBOSE (1 , " HAL : Getting info version: %s\n " , buf);
979
+
980
+ if (MMDVERSION_LESSTHAN (atof (AOCL_MMD_VERSION_STRING),
981
+ mmd_dispatch->mmd_version ) || // MMD newer than HAL
982
+ MMDVERSION_LESSTHAN (mmd_dispatch->mmd_version ,
983
+ 14.0 )) // Before this wasn't forward compatible
984
+ {
985
+ printf (" Runtime version: %s\n " , AOCL_MMD_VERSION_STRING);
986
+ printf (" MMD version: %s\n " , buf);
987
+ fflush (stdout);
988
+ assert (0 && " MMD version mismatch" );
989
+ }
990
+
991
+ // Disable yield as initialization
992
+ acl_hal_mmd.yield = NULL ;
993
+
994
+ // Dump offline info
995
+ if (debug_verbosity > 0 ) {
996
+ mmd_dispatch->aocl_mmd_get_offline_info (AOCL_MMD_VENDOR_NAME, sizeof (buf),
997
+ buf, NULL );
998
+ buf[sizeof (buf) - 1 ] = 0 ;
999
+ ACL_HAL_DEBUG_MSG_VERBOSE (1 , " HAL : Getting info vendor: %s\n " , buf);
1000
+ mmd_dispatch->aocl_mmd_get_offline_info (AOCL_MMD_NUM_BOARDS, sizeof (int ),
1001
+ &num_boards, NULL );
1002
+ ACL_HAL_DEBUG_MSG_VERBOSE (1 , " HAL : Getting info num_boards: %d\n " ,
1003
+ num_boards);
1004
+ mmd_dispatch->aocl_mmd_get_offline_info (AOCL_MMD_BOARD_NAMES, sizeof (buf),
1005
+ buf, NULL );
1006
+ buf[sizeof (buf) - 1 ] = 0 ;
1007
+ ACL_HAL_DEBUG_MSG_VERBOSE (1 , " HAL : Getting info boards: %s\n " , buf);
1008
+ }
1009
+
1010
+ mmd_dispatch->aocl_mmd_get_offline_info (AOCL_MMD_BOARD_NAMES,
1011
+ MAX_BOARD_NAMES_LEN, buf, NULL );
1012
+ buf[MAX_BOARD_NAMES_LEN - 1 ] = 0 ;
1013
+ // Probe the platform devices by going through all the possibilities in the
1014
+ // semicolon delimited list
1015
+ ptr = acl_strtok (buf, " ;" , &saveptr);
1016
+ while (ptr != NULL ) {
1017
+ num_phys_devices++;
1018
+ ptr = acl_strtok (NULL , " ;" , &saveptr);
1019
+ }
1020
+
1021
+ ACL_HAL_DEBUG_MSG_VERBOSE (1 , " Found %d devices\n " , num_phys_devices);
1022
+ }
1023
+
962
1024
// Simulator MMD helpers
963
1025
static acl_mmd_dispatch_t *l_get_msim_mmd_layer () {
964
1026
#ifdef _WIN32
@@ -1318,11 +1380,6 @@ ACL_HAL_EXPORT const acl_hal_t *
1318
1380
acl_mmd_get_system_definition (acl_system_def_t *sys,
1319
1381
acl_mmd_library_names_t *_libraries_to_load) {
1320
1382
char *hal_debug_var;
1321
- int num_boards;
1322
- static char
1323
- buf[MAX_BOARD_NAMES_LEN]; // This is a bit subtle, pointers to device
1324
- // names might get cached by various routines
1325
- char *ptr, *saveptr;
1326
1383
int use_offline_only;
1327
1384
1328
1385
#ifdef _WIN32
@@ -1474,62 +1531,9 @@ acl_mmd_get_system_definition(acl_system_def_t *sys,
1474
1531
sys->num_devices = 0 ;
1475
1532
num_physical_devices = 0 ;
1476
1533
for (unsigned iboard = 0 ; iboard < num_board_pkgs; ++iboard) {
1477
- internal_mmd_dispatch[iboard].aocl_mmd_get_offline_info (
1478
- AOCL_MMD_VERSION, sizeof (buf), buf, NULL );
1479
- buf[sizeof (buf) - 1 ] = 0 ;
1480
- internal_mmd_dispatch[iboard].mmd_version = atof (buf);
1481
- min_MMD_version =
1482
- (!MMDVERSION_LESSTHAN (min_MMD_version,
1483
- internal_mmd_dispatch[iboard].mmd_version ))
1484
- ? internal_mmd_dispatch[iboard].mmd_version
1485
- : min_MMD_version;
1486
- ACL_HAL_DEBUG_MSG_VERBOSE (1 , " HAL : Getting info version: %s\n " , buf);
1487
-
1488
- if (MMDVERSION_LESSTHAN (
1489
- atof (AOCL_MMD_VERSION_STRING),
1490
- internal_mmd_dispatch[iboard].mmd_version ) || // MMD newer than HAL
1491
- MMDVERSION_LESSTHAN (internal_mmd_dispatch[iboard].mmd_version ,
1492
- 14.0 )) // Before this wasn't forward compatible
1493
- {
1494
- printf (" Runtime version: %s\n " , AOCL_MMD_VERSION_STRING);
1495
- printf (" MMD version: %s\n " , buf);
1496
- fflush (stdout);
1497
- assert (0 && " MMD version mismatch" );
1498
- }
1499
-
1500
- // Disable yield as initialization
1501
- acl_hal_mmd.yield = NULL ;
1502
-
1503
- // Dump offline info
1504
- if (debug_verbosity > 0 ) {
1505
- internal_mmd_dispatch[iboard].aocl_mmd_get_offline_info (
1506
- AOCL_MMD_VENDOR_NAME, sizeof (buf), buf, NULL );
1507
- buf[sizeof (buf) - 1 ] = 0 ;
1508
- ACL_HAL_DEBUG_MSG_VERBOSE (1 , " HAL : Getting info vendor: %s\n " , buf);
1509
- internal_mmd_dispatch[iboard].aocl_mmd_get_offline_info (
1510
- AOCL_MMD_NUM_BOARDS, sizeof (int ), &num_boards, NULL );
1511
- ACL_HAL_DEBUG_MSG_VERBOSE (1 , " HAL : Getting info num_boards: %d\n " ,
1512
- num_boards);
1513
- internal_mmd_dispatch[iboard].aocl_mmd_get_offline_info (
1514
- AOCL_MMD_BOARD_NAMES, sizeof (buf), buf, NULL );
1515
- buf[sizeof (buf) - 1 ] = 0 ;
1516
- ACL_HAL_DEBUG_MSG_VERBOSE (1 , " HAL : Getting info boards: %s\n " , buf);
1517
- }
1518
-
1519
- internal_mmd_dispatch[iboard].aocl_mmd_get_offline_info (
1520
- AOCL_MMD_BOARD_NAMES, MAX_BOARD_NAMES_LEN, buf, NULL );
1521
- buf[MAX_BOARD_NAMES_LEN - 1 ] = 0 ;
1522
- // Probe the platform devices by going through all the possibilities in the
1523
- // semicolon delimited list
1524
- sys->num_devices = 0 ;
1525
- ptr = acl_strtok (buf, " ;" , &saveptr);
1526
- while (ptr != NULL ) {
1527
- num_physical_devices++;
1528
- ptr = acl_strtok (NULL , " ;" , &saveptr);
1529
- }
1534
+ l_get_physical_devices (&(internal_mmd_dispatch[iboard]),
1535
+ num_physical_devices);
1530
1536
sys->num_devices = num_physical_devices;
1531
-
1532
- ACL_HAL_DEBUG_MSG_VERBOSE (1 , " Found %d devices\n " , sys->num_devices );
1533
1537
}
1534
1538
return &acl_hal_mmd;
1535
1539
}
0 commit comments