@@ -2670,10 +2670,6 @@ inline pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags,
2670
2670
PI_ASSERT (Context, PI_ERROR_INVALID_CONTEXT);
2671
2671
PI_ASSERT (RetMem, PI_ERROR_INVALID_VALUE);
2672
2672
2673
- if (properties != nullptr ) {
2674
- die (" piMemBufferCreate: no mem properties goes to Level-Zero RT yet" );
2675
- }
2676
-
2677
2673
ur_context_handle_t UrContext =
2678
2674
reinterpret_cast <ur_context_handle_t >(Context);
2679
2675
@@ -2697,6 +2693,44 @@ inline pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags,
2697
2693
ur_buffer_properties_t UrProps{};
2698
2694
UrProps.stype = UR_STRUCTURE_TYPE_BUFFER_PROPERTIES;
2699
2695
UrProps.pHost = HostPtr;
2696
+
2697
+ ur_buffer_channel_properties_t bufferChannelProperties{};
2698
+ bufferChannelProperties.stype = UR_STRUCTURE_TYPE_BUFFER_CHANNEL_PROPERTIES;
2699
+ ur_buffer_alloc_location_properties_t bufferLocationProperties{};
2700
+ bufferLocationProperties.stype =
2701
+ UR_STRUCTURE_TYPE_BUFFER_ALLOC_LOCATION_PROPERTIES;
2702
+ if (properties != nullptr ) {
2703
+ bool bufferLocationPropertySet = false ;
2704
+ bool bufferMemChannelPropertySet = false ;
2705
+ uint64_t allocBufferLocation = 0 ;
2706
+ uint32_t allocBufferMemChannel = 0 ;
2707
+ // pi mem properties must ended by 0
2708
+ size_t I = 0 ;
2709
+ while (properties[I] != 0 ) {
2710
+ if (properties[I] == PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION) {
2711
+ allocBufferLocation = properties[I + 1 ];
2712
+ bufferLocationPropertySet = true ;
2713
+ } else if (properties[I] == PI_MEM_PROPERTIES_CHANNEL) {
2714
+ allocBufferMemChannel = properties[I + 1 ];
2715
+ bufferMemChannelPropertySet = true ;
2716
+ }
2717
+ I += 2 ;
2718
+ }
2719
+ void *extensionProperties = nullptr ;
2720
+ if (bufferLocationPropertySet) {
2721
+ bufferLocationProperties.location = allocBufferLocation;
2722
+ extensionProperties = &bufferLocationProperties;
2723
+ }
2724
+ if (bufferMemChannelPropertySet) {
2725
+ bufferChannelProperties.channel = allocBufferMemChannel;
2726
+ extensionProperties = &bufferChannelProperties;
2727
+ }
2728
+ if (bufferLocationPropertySet && bufferMemChannelPropertySet) {
2729
+ bufferLocationProperties.pNext = &bufferChannelProperties;
2730
+ extensionProperties = &bufferLocationProperties;
2731
+ }
2732
+ UrProps.pNext = extensionProperties;
2733
+ }
2700
2734
ur_mem_handle_t *UrBuffer = reinterpret_cast <ur_mem_handle_t *>(RetMem);
2701
2735
HANDLE_ERRORS (
2702
2736
urMemBufferCreate (UrContext, UrBufferFlags, Size , &UrProps, UrBuffer));
0 commit comments