@@ -437,6 +437,64 @@ CL_API_ENTRY cl_mem clCreateBufferWithPropertiesINTEL(
437
437
} break ;
438
438
case CL_MEM_ALLOC_BUFFER_LOCATION_INTEL: {
439
439
tmp_mem_id = (cl_uint) * (properties + 1 );
440
+
441
+ // In FullSystem flow, buffer location is always the index of the global
442
+ // memories. Therefore, there is no additional handling needed for FS.
443
+
444
+ // However, in SYCL_HLS(IPA) flow, the user passed buffer_location<id>
445
+ // maps to the global memory with the same id. Runtime needs to find the
446
+ // correct index of the global memory with that id. The id filed is
447
+ // introduced in 2024.2 in auto-discovery string. This change is for
448
+ // accessor only and the USM buffer location change is done in the
449
+ // simulator.
450
+
451
+ // Runtime needs to determine whether it's FS or SYCL_HLS first by
452
+ // checking if the global memory id exist or not. If exists, then it's
453
+ // SYCL_HLS flow.
454
+ bool is_SYCL_HLS = false ;
455
+
456
+ // We document the limitation here:
457
+ // https://www.intel.com/content/www/us/en/docs/oneapi-fpga-add-on/
458
+ // developer-guide/2024-0/targeting-multiple-homogeneous-fpga-devices.html
459
+ // All FPGA devices used must be of the same FPGA card (same -Xstarget
460
+ // target). There might be some workaround supporting multi-device with
461
+ // different boards but they are for FS, not for SYCL_HLS.
462
+
463
+ // Therefore, we can safely assume all devices have the same
464
+ // global_mem_defs in SYCL_HLS flow as of 2024.2. So we can just check
465
+ // acl_platform.device[0].
466
+
467
+ auto global_mem_defs =
468
+ acl_platform.device [0 ].def .autodiscovery_def .global_mem_defs ;
469
+
470
+ for (const auto &global_mem_def : global_mem_defs) {
471
+ if (global_mem_def.id != " -" ) {
472
+ is_SYCL_HLS = true ;
473
+ break ;
474
+ }
475
+ }
476
+
477
+ if (is_SYCL_HLS) {
478
+ // find the correct index in the global memory
479
+ long index = -1 ;
480
+ for (auto it = begin (global_mem_defs); it != end (global_mem_defs);
481
+ ++it) {
482
+ if (stoul (it->id ) == tmp_mem_id) {
483
+ index = it - global_mem_defs.begin ();
484
+ break ;
485
+ }
486
+ }
487
+
488
+ if (index == -1 ) {
489
+ BAIL_INFO (CL_INVALID_VALUE, context,
490
+ " Invalid Buffer Location id provided" );
491
+ }
492
+
493
+ // Update the tmp_mem_id to the corect index in the global memories
494
+ // vector.
495
+ tmp_mem_id = static_cast <cl_uint>(index);
496
+ }
497
+
440
498
} break ;
441
499
default : {
442
500
BAIL_INFO (CL_INVALID_DEVICE, context, " Invalid properties" );
0 commit comments