@@ -185,10 +185,6 @@ int acl_hal_mmd_simulation_device_global_interface_write(
185
185
unsigned int physical_device_id, const char *interface_name,
186
186
const void *host_addr, size_t dev_addr, size_t size);
187
187
188
- void *acl_hal_mmd_hostchannel_get_sideband_buffer (
189
- unsigned int physical_device_id, unsigned int port_name, int channel_handle,
190
- size_t *buffer_size, int *status);
191
-
192
188
size_t acl_hal_mmd_hostchannel_sideband_pull_no_ack (
193
189
unsigned int physical_device_id, unsigned int port_name, int channel_handle,
194
190
void *host_buffer, size_t read_size, int *status);
@@ -209,6 +205,8 @@ static time_ns acl_bsp_get_timestamp(void);
209
205
210
206
int acl_hal_mmd_has_svm_support (unsigned int physical_device_id, int *value);
211
207
int acl_hal_mmd_has_physical_mem (unsigned int physical_device_id);
208
+ int acl_hal_mmd_support_buffer_location (
209
+ const std::vector<cl_device_id> &devices);
212
210
213
211
static void *
214
212
acl_hal_get_board_extension_function_address (const char *func_name,
@@ -296,6 +294,7 @@ static acl_hal_t acl_hal_mmd = {
296
294
acl_hal_mmd_set_profile_stop_count, // set_profile_stop_cycle
297
295
acl_hal_mmd_has_svm_support, // has_svm_memory_support
298
296
acl_hal_mmd_has_physical_mem, // has_physical_mem
297
+ acl_hal_mmd_support_buffer_location, // support_buffer_location
299
298
acl_hal_get_board_extension_function_address, // get_board_extension_function_address
300
299
acl_hal_mmd_pll_reconfigure, // pll_reconfigure
301
300
acl_hal_mmd_reset_kernels, // reset_kernels
@@ -319,9 +318,8 @@ static acl_hal_t acl_hal_mmd = {
319
318
acl_hal_mmd_write_csr, // write_csr
320
319
acl_hal_mmd_simulation_device_global_interface_read, // simulation_device_global_interface_read
321
320
acl_hal_mmd_simulation_device_global_interface_write, // simulation_device_global_interface_write
322
- acl_hal_mmd_hostchannel_get_sideband_buffer, // hostchannel_get_sideband_buffer
323
- acl_hal_mmd_hostchannel_sideband_pull_no_ack, // hostchannel_sideband_push
324
- acl_hal_mmd_hostchannel_sideband_push_no_ack, // hostchannel_sideband_push
321
+ acl_hal_mmd_hostchannel_sideband_pull_no_ack, // hostchannel_sideband_pull_no_ack
322
+ acl_hal_mmd_hostchannel_sideband_push_no_ack, // hostchannel_sideband_push_no_ack
325
323
acl_hal_mmd_hostchannel_pull_no_ack, // hostchannel_pull_no_ack
326
324
acl_hal_mmd_hostchannel_push_no_ack, // hostchannel_push_no_ack
327
325
};
@@ -419,6 +417,39 @@ static int debug_verbosity = 0;
419
417
// ************************** Helper functions ******************************
420
418
// **************************************************************************
421
419
420
+ // Version string format should be MAJOR.MINOR(.PATCH)
421
+ // To compare the MMD/HAL versions we will only compare the last two digits
422
+ // of the MAJOR field together with the MINOR field, and ignore the PATCH field
423
+ // if that exists. This function truncates the version string to exactly that
424
+ // and convert it to double to be compared. Returns -1 if input is invalid.
425
+ double l_parse_mmd_version_str (std::string version_str) {
426
+ size_t start_idx, length;
427
+
428
+ // Find the '.' between the MAJOR and MINOR field
429
+ std::string::size_type i = version_str.find (' .' );
430
+ if (i == std::string::npos || i < 2 ) {
431
+ return -1 ;
432
+ } else {
433
+ start_idx = i - 2 ;
434
+ }
435
+ // Check if there is a '.' for PATCH field
436
+ std::string::size_type j = version_str.find (' .' , i + 1 );
437
+ length = (j == std::string::npos ? version_str.length () : j) - start_idx;
438
+
439
+ // Get the part of the MMD version string that will be used to compare
440
+ // for compatibility with the runtime HAL
441
+ std::string version_substr = version_str.substr (start_idx, length);
442
+ double mmd_version_num = 0 ;
443
+ try {
444
+ mmd_version_num = std::stod (version_substr);
445
+ } catch (const std::exception &) {
446
+ // Just return error and let the caller handle failure
447
+ return -1 ;
448
+ }
449
+
450
+ return mmd_version_num;
451
+ }
452
+
422
453
// MMD dynamic load helpers
423
454
#ifdef _WIN32
424
455
char *acl_strtok (char *str, const char *delim, char **saveptr) {
@@ -965,22 +996,40 @@ void l_get_physical_devices(acl_mmd_dispatch_t *mmd_dispatch,
965
996
mmd_dispatch->aocl_mmd_get_offline_info (AOCL_MMD_VERSION, sizeof (buf), buf,
966
997
NULL );
967
998
buf[sizeof (buf) - 1 ] = 0 ;
968
- mmd_dispatch->mmd_version = atof (buf);
999
+ mmd_dispatch->mmd_version = l_parse_mmd_version_str (std::string (buf));
1000
+ if (mmd_dispatch->mmd_version < 0 ) {
1001
+ printf (" Invalid MMD version: %s\n " , buf);
1002
+ printf (" Contact the board package support vendor for resolution.\n " );
1003
+ fflush (stdout);
1004
+ assert (0 );
1005
+ }
969
1006
min_MMD_version =
970
1007
(!MMDVERSION_LESSTHAN (min_MMD_version, mmd_dispatch->mmd_version ))
971
1008
? mmd_dispatch->mmd_version
972
1009
: min_MMD_version;
973
1010
ACL_HAL_DEBUG_MSG_VERBOSE (1 , " HAL : Getting info version: %s\n " , buf);
974
1011
975
- if (MMDVERSION_LESSTHAN (atof (AOCL_MMD_VERSION_STRING),
1012
+ static double hal_version = 0 ;
1013
+ if (hal_version == 0 ) { // Just parse once at start-up
1014
+ hal_version = l_parse_mmd_version_str (AOCL_MMD_VERSION_STRING);
1015
+ if (hal_version < 0 ) { // This should theoretically never happen
1016
+ printf (" Invalid runtime version: %s\n " , AOCL_MMD_VERSION_STRING);
1017
+ fflush (stdout);
1018
+ assert (0 );
1019
+ }
1020
+ }
1021
+ if (MMDVERSION_LESSTHAN (hal_version,
976
1022
mmd_dispatch->mmd_version ) || // MMD newer than HAL
977
1023
MMDVERSION_LESSTHAN (mmd_dispatch->mmd_version ,
978
1024
14.0 )) // Before this wasn't forward compatible
979
1025
{
980
1026
printf (" Runtime version: %s\n " , AOCL_MMD_VERSION_STRING);
981
1027
printf (" MMD version: %s\n " , buf);
1028
+ printf (" MMD version is newer than the runtime version! Use the runtime "
1029
+ " with version greater or equal to the MMD version, or contact the "
1030
+ " board support package vendors if mismatch is unexpected.\n " );
982
1031
fflush (stdout);
983
- assert (0 && " MMD version mismatch " );
1032
+ assert (0 );
984
1033
}
985
1034
986
1035
// Disable yield as initialization
@@ -2496,23 +2545,6 @@ size_t acl_hal_mmd_hostchannel_ack_buffer(unsigned int physical_device_id,
2496
2545
pcie_dev_handle, channel_handle, ack_size, status);
2497
2546
}
2498
2547
2499
- void *acl_hal_mmd_hostchannel_get_sideband_buffer (
2500
- unsigned int physical_device_id, unsigned int port_name, int channel_handle,
2501
- size_t *buffer_size, int *status) {
2502
-
2503
- int pcie_dev_handle;
2504
-
2505
- pcie_dev_handle = device_info[physical_device_id].handle ;
2506
- *status = 0 ;
2507
-
2508
- // get the pointer to host channel mmd buffer
2509
- assert (device_info[physical_device_id]
2510
- .mmd_dispatch ->aocl_mmd_hostchannel_get_sideband_buffer );
2511
- return device_info[physical_device_id]
2512
- .mmd_dispatch ->aocl_mmd_hostchannel_get_sideband_buffer (
2513
- pcie_dev_handle, channel_handle, port_name, buffer_size, status);
2514
- }
2515
-
2516
2548
size_t acl_hal_mmd_hostchannel_sideband_pull_no_ack (
2517
2549
unsigned int physical_device_id, unsigned int port_name, int channel_handle,
2518
2550
void *host_buffer, size_t read_size, int *status) {
@@ -2527,10 +2559,11 @@ size_t acl_hal_mmd_hostchannel_sideband_pull_no_ack(
2527
2559
2528
2560
assert (device_info[physical_device_id]
2529
2561
.mmd_dispatch ->aocl_mmd_hostchannel_get_sideband_buffer );
2530
- pull_buffer =
2531
- device_info[physical_device_id]
2532
- .mmd_dispatch ->aocl_mmd_hostchannel_get_sideband_buffer (
2533
- pcie_dev_handle, channel_handle, port_name, &buffer_size, status);
2562
+ pull_buffer = device_info[physical_device_id]
2563
+ .mmd_dispatch ->aocl_mmd_hostchannel_get_sideband_buffer (
2564
+ pcie_dev_handle, channel_handle,
2565
+ static_cast <aocl_mmd_hostchannel_port_id_t >(port_name),
2566
+ &buffer_size, status);
2534
2567
2535
2568
if ((NULL == pull_buffer) || (0 == buffer_size)) {
2536
2569
return 0 ;
@@ -2563,10 +2596,11 @@ size_t acl_hal_mmd_hostchannel_sideband_push_no_ack(
2563
2596
assert (device_info[physical_device_id]
2564
2597
.mmd_dispatch ->aocl_mmd_hostchannel_get_sideband_buffer );
2565
2598
2566
- push_buffer =
2567
- device_info[physical_device_id]
2568
- .mmd_dispatch ->aocl_mmd_hostchannel_get_sideband_buffer (
2569
- pcie_dev_handle, channel_handle, port_name, &buffer_size, status);
2599
+ push_buffer = device_info[physical_device_id]
2600
+ .mmd_dispatch ->aocl_mmd_hostchannel_get_sideband_buffer (
2601
+ pcie_dev_handle, channel_handle,
2602
+ static_cast <aocl_mmd_hostchannel_port_id_t >(port_name),
2603
+ &buffer_size, status);
2570
2604
2571
2605
if ((NULL == push_buffer) || (0 == buffer_size)) {
2572
2606
return 0 ;
@@ -2688,6 +2722,27 @@ int acl_hal_mmd_has_physical_mem(unsigned int physical_device_id) {
2688
2722
}
2689
2723
}
2690
2724
2725
+ /* *
2726
+ * Returns if a set of devices all support buffer location mem property
2727
+ * @param a vector of devices on which to query
2728
+ * @return 1 if supported, else 0
2729
+ */
2730
+ int acl_hal_mmd_support_buffer_location (
2731
+ const std::vector<cl_device_id> &devices) {
2732
+ acl_assert_locked ();
2733
+
2734
+ int bl_supported = 1 ;
2735
+ for (const auto &device : devices) {
2736
+ unsigned int physical_device_id = device->def .physical_device_id ;
2737
+ if (MMDVERSION_LESSTHAN (
2738
+ device_info[physical_device_id].mmd_dispatch ->mmd_version , 24.2 )) {
2739
+ bl_supported = 0 ;
2740
+ }
2741
+ }
2742
+
2743
+ return bl_supported;
2744
+ }
2745
+
2691
2746
#ifdef _WIN32
2692
2747
// Query the system timer, return a timer value in ns
2693
2748
cl_ulong acl_hal_mmd_get_timestamp () {
0 commit comments