@@ -496,10 +496,16 @@ pi_result OCL(piEnqueueMemBufferMap)(
496
496
// USM
497
497
//
498
498
499
- // Allocates host memory accessible by the device.
500
- pi_result OCL (piHostMemAlloc)(void **result_ptr, pi_context context,
501
- pi_usm_mem_properties *properties, size_t size,
502
- pi_uint32 alignment) {
499
+ // / Allocates host memory accessible by the device.
500
+ // /
501
+ // / @param result_ptr contains the allocated memory
502
+ // / @param context is the pi_context
503
+ // / @param pi_usm_mem_properties are optional allocation properties
504
+ // / @param size_t is the size of the allocation
505
+ // / @param alignment is the desired alignment of the allocation
506
+ pi_result OCL (piextUSMHostAlloc)(void **result_ptr, pi_context context,
507
+ pi_usm_mem_properties *properties, size_t size,
508
+ pi_uint32 alignment) {
503
509
504
510
void *Ptr = nullptr ;
505
511
pi_result RetVal = PI_INVALID_OPERATION;
@@ -522,11 +528,18 @@ pi_result OCL(piHostMemAlloc)(void **result_ptr, pi_context context,
522
528
return RetVal;
523
529
}
524
530
525
- // Allocates device memory.
526
- pi_result OCL (piDeviceMemAlloc)(void **result_ptr, pi_context context,
527
- pi_device device,
528
- pi_usm_mem_properties *properties, size_t size,
529
- pi_uint32 alignment) {
531
+ // / Allocates device memory
532
+ // /
533
+ // / @param result_ptr contains the allocated memory
534
+ // / @param context is the pi_context
535
+ // / @param device is the device the memory will be allocated on
536
+ // / @param pi_usm_mem_properties are optional allocation properties
537
+ // / @param size_t is the size of the allocation
538
+ // / @param alignment is the desired alignment of the allocation
539
+ pi_result OCL (piextUSMDeviceAlloc)(void **result_ptr, pi_context context,
540
+ pi_device device,
541
+ pi_usm_mem_properties *properties,
542
+ size_t size, pi_uint32 alignment) {
530
543
531
544
void *Ptr = nullptr ;
532
545
pi_result RetVal = PI_INVALID_OPERATION;
@@ -549,11 +562,18 @@ pi_result OCL(piDeviceMemAlloc)(void **result_ptr, pi_context context,
549
562
return RetVal;
550
563
}
551
564
552
- // Allocates memory accessible on host and device.
553
- pi_result OCL (piSharedMemAlloc)(void **result_ptr, pi_context context,
554
- pi_device device,
555
- pi_usm_mem_properties *properties, size_t size,
556
- pi_uint32 alignment) {
565
+ // / Allocates memory accessible on both host and device
566
+ // /
567
+ // / @param result_ptr contains the allocated memory
568
+ // / @param context is the pi_context
569
+ // / @param device is the device the memory will be allocated on
570
+ // / @param pi_usm_mem_properties are optional allocation properties
571
+ // / @param size_t is the size of the allocation
572
+ // / @param alignment is the desired alignment of the allocation
573
+ pi_result OCL (piextUSMSharedAlloc)(void **result_ptr, pi_context context,
574
+ pi_device device,
575
+ pi_usm_mem_properties *properties,
576
+ size_t size, pi_uint32 alignment) {
557
577
558
578
void *Ptr = nullptr ;
559
579
pi_result RetVal = PI_INVALID_OPERATION;
@@ -576,7 +596,11 @@ pi_result OCL(piSharedMemAlloc)(void **result_ptr, pi_context context,
576
596
return RetVal;
577
597
}
578
598
579
- pi_result OCL (piMemFree)(pi_context context, void *ptr) {
599
+ // / Frees allocated USM memory
600
+ // /
601
+ // / @param context is the pi_context of the allocation
602
+ // / @param ptr is the memory to be freed
603
+ pi_result OCL (piextUSMFree)(pi_context context, void *ptr) {
580
604
581
605
clMemFreeINTEL_fn FuncPtr;
582
606
pi_result RetVal = getExtFuncFromContext<clMemFreeINTEL_fn>(
@@ -588,10 +612,17 @@ pi_result OCL(piMemFree)(pi_context context, void *ptr) {
588
612
return cast<pi_result>(FuncPtr (cast<cl_context>(context), ptr));
589
613
}
590
614
591
- // Sets up pointer arguments to CL kernels
592
- pi_result OCL (piKernelSetArgMemPointer)(pi_kernel kernel, pi_uint32 arg_index,
593
- size_t arg_size,
594
- const void *arg_value) {
615
+ // / Sets up pointer arguments for CL kernels. An extra indirection
616
+ // / is required due to CL argument conventions.
617
+ // /
618
+ // / @param kernel is the kernel to be launched
619
+ // / @param arg_index is the index of the kernel argument
620
+ // / @param arg_size is the size in bytes of the argument (ignored in CL)
621
+ // / @param arg_value is the pointer argument
622
+ pi_result OCL (piextUSMKernelSetArgMemPointer)(pi_kernel kernel,
623
+ pi_uint32 arg_index,
624
+ size_t arg_size,
625
+ const void *arg_value) {
595
626
596
627
// Size is unused in CL as pointer args are passed by value.
597
628
@@ -617,9 +648,11 @@ pi_result OCL(piKernelSetArgMemPointer)(pi_kernel kernel, pi_uint32 arg_index,
617
648
return cast<pi_result>(FuncPtr (cast<cl_kernel>(kernel), arg_index, DerefPtr));
618
649
}
619
650
620
- // Enables indirect access of pointers in kernels.
621
- // Necessary to avoid telling CL about every pointer that might be used.
622
- pi_result OCL (piKernelSetIndirectAccess)(pi_kernel kernel, pi_queue queue) {
651
+ // / Enables indirect access of pointers in kernels.
652
+ // / Necessary to avoid telling CL about every pointer that might be used.
653
+ // /
654
+ // / @param kernel is the kernel to be launched
655
+ pi_result OCL (piextUSMKernelSetIndirectAccess)(pi_kernel kernel) {
623
656
624
657
// We test that each alloc type is supported before we actually try to
625
658
// set KernelExecInfo.
@@ -660,11 +693,21 @@ pi_result OCL(piKernelSetIndirectAccess)(pi_kernel kernel, pi_queue queue) {
660
693
return PI_SUCCESS;
661
694
}
662
695
663
- // USM memset API
664
- pi_result OCL (piEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value,
665
- size_t count, pi_uint32 num_events_in_waitlist,
666
- const pi_event *events_waitlist,
667
- pi_event *event) {
696
+ // / USM Memset API
697
+ // /
698
+ // / @param queue is the queue to submit to
699
+ // / @param ptr is the ptr to memset
700
+ // / @param value is value to set. It is interpreted as an 8-bit value and the upper
701
+ // / 24 bits are ignored
702
+ // / @param count is the size in bytes to memset
703
+ // / @param num_events_in_waitlist is the number of events to wait on
704
+ // / @param events_waitlist is an array of events to wait on
705
+ // / @param event is the event that represents this operation
706
+ pi_result OCL (piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value,
707
+ size_t count,
708
+ pi_uint32 num_events_in_waitlist,
709
+ const pi_event *events_waitlist,
710
+ pi_event *event) {
668
711
669
712
// Have to look up the context from the kernel
670
713
cl_context CLContext;
@@ -687,12 +730,22 @@ pi_result OCL(piEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value,
687
730
cast<const cl_event *>(events_waitlist), cast<cl_event *>(event)));
688
731
}
689
732
690
- // USM routine to copy data between host and device
691
- pi_result OCL (piEnqueueMemcpy)(pi_queue queue, pi_bool blocking, void *dst_ptr,
692
- const void *src_ptr, pi_int32 size,
693
- pi_uint32 num_events_in_waitlist,
694
- const pi_event *events_waitlist,
695
- pi_event *event) {
733
+ // / USM Memcpy API
734
+ // /
735
+ // / @param queue is the queue to submit to
736
+ // / @param blocking is whether this operation should block the host
737
+ // / @param src_ptr is the data to be copied
738
+ // / @param dst_ptr is the location the data will be copied
739
+ // / @param size is number of bytes to copy
740
+ // / @param num_events_in_waitlist is the number of events to wait on
741
+ // / @param events_waitlist is an array of events to wait on
742
+ // / @param event is the event that represents this operation
743
+ pi_result OCL (piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking,
744
+ void *dst_ptr, const void *src_ptr,
745
+ pi_int32 size,
746
+ pi_uint32 num_events_in_waitlist,
747
+ const pi_event *events_waitlist,
748
+ pi_event *event) {
696
749
697
750
// Have to look up the context from the kernel
698
751
cl_context CLContext;
@@ -716,12 +769,21 @@ pi_result OCL(piEnqueueMemcpy)(pi_queue queue, pi_bool blocking, void *dst_ptr,
716
769
cast<cl_event *>(event)));
717
770
}
718
771
719
- // Hint to migrate memory to the device
720
- pi_result OCL (piEnqueuePrefetch)(pi_queue queue, const void *ptr, size_t size,
721
- pi_usm_migration_flags flags,
722
- pi_uint32 num_events_in_waitlist,
723
- const pi_event *events_waitlist,
724
- pi_event *event) {
772
+ // / Hint to migrate memory to the device
773
+ // /
774
+ // / @param queue is the queue to submit to
775
+ // / @param ptr points to the memory to migrate
776
+ // / @param size is the number of bytes to migrate
777
+ // / @param flags is a bitfield used to specify memory migration options
778
+ // / @param num_events_in_waitlist is the number of events to wait on
779
+ // / @param events_waitlist is an array of events to wait on
780
+ // / @param event is the event that represents this operation
781
+ pi_result OCL (piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr,
782
+ size_t size,
783
+ pi_usm_migration_flags flags,
784
+ pi_uint32 num_events_in_waitlist,
785
+ const pi_event *events_waitlist,
786
+ pi_event *event) {
725
787
726
788
return cast<pi_result>(clEnqueueMarkerWithWaitList (
727
789
cast<cl_command_queue>(queue), num_events_in_waitlist,
@@ -753,9 +815,17 @@ pi_result OCL(piEnqueuePrefetch)(pi_queue queue, const void *ptr, size_t size,
753
815
*/
754
816
}
755
817
818
+ // / USM Memadvise API
819
+ // /
820
+ // / @param queue is the queue to submit to
821
+ // / @param ptr is the data to be advised
822
+ // / @param length is the size in bytes of the meory to advise
823
+ // / @param advice is device specific advice
824
+ // / @param event is the event that represents this operation
756
825
// USM memadvise API to govern behavior of automatic migration mechanisms
757
- pi_result OCL (piEnqueueMemAdvise)(pi_queue queue, const void *ptr,
758
- size_t length, int advice, pi_event *event) {
826
+ pi_result OCL (piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr,
827
+ size_t length, int advice,
828
+ pi_event *event) {
759
829
760
830
return cast<pi_result>(
761
831
clEnqueueMarkerWithWaitList (cast<cl_command_queue>(queue), 0 , nullptr ,
@@ -789,12 +859,25 @@ pi_result OCL(piEnqueueMemAdvise)(pi_queue queue, const void *ptr,
789
859
*/
790
860
}
791
861
792
- // API to query information about USM pointers including type and
793
- // device allocated against
794
- pi_result OCL (piGetMemAllocInfo)(pi_context context, const void *ptr,
795
- pi_mem_info param_name,
796
- size_t param_value_size, void *param_value,
797
- size_t *param_value_size_ret) {
862
+ // / API to query information about USM pointers including type and
863
+ // / device allocated against
864
+ // / Examples include:
865
+ // / PI_MEM_ALLOC_TYPE
866
+ // / PI_MEM_ALLOC_BASE_PTR
867
+ // / PI_MEM_ALLOC_SIZE
868
+ // / PI_MEM_ALLOC_DEVICE
869
+ // /
870
+ // / @param context is the pi_context
871
+ // / @param ptr is the pointer to query
872
+ // / @param param_name is the type of query to perform
873
+ // / @param param_value_size is the size of the result in bytes
874
+ // / @param param_value is the result
875
+ // / @param param_value_ret is how many bytes were written
876
+ pi_result OCL (piextUSMGetMemAllocInfo)(pi_context context, const void *ptr,
877
+ pi_mem_info param_name,
878
+ size_t param_value_size,
879
+ void *param_value,
880
+ size_t *param_value_size_ret) {
798
881
799
882
clGetMemAllocInfoINTEL_fn FuncPtr;
800
883
pi_result RetVal = getExtFuncFromContext<clGetMemAllocInfoINTEL_fn>(
@@ -903,17 +986,17 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
903
986
_PI_CL (piEnqueueMemBufferMap, OCL (piEnqueueMemBufferMap))
904
987
_PI_CL (piEnqueueMemUnmap, clEnqueueUnmapMemObject)
905
988
// USM
906
- _PI_CL (piextUSMHostAlloc, OCL (piHostMemAlloc ))
907
- _PI_CL (piextUSMDeviceAlloc, OCL (piDeviceMemAlloc ))
908
- _PI_CL (piextUSMSharedAlloc, OCL (piSharedMemAlloc ))
909
- _PI_CL (piextUSMFree, OCL (piMemFree ))
910
- _PI_CL (piextUSMKernelSetArgMemPointer, OCL (piKernelSetArgMemPointer ))
911
- _PI_CL (piextUSMKernelSetIndirectAccess, OCL (piKernelSetIndirectAccess ))
912
- _PI_CL (piextUSMEnqueueMemset, OCL (piEnqueueMemset ))
913
- _PI_CL (piextUSMEnqueueMemcpy, OCL (piEnqueueMemcpy ))
914
- _PI_CL (piextUSMEnqueuePrefetch, OCL (piEnqueuePrefetch ))
915
- _PI_CL (piextUSMEnqueueMemAdvise, OCL (piEnqueueMemAdvise ))
916
- _PI_CL (piextUSMGetMemAllocInfo, OCL (piGetMemAllocInfo ))
989
+ _PI_CL (piextUSMHostAlloc, OCL (piextUSMHostAlloc ))
990
+ _PI_CL (piextUSMDeviceAlloc, OCL (piextUSMDeviceAlloc ))
991
+ _PI_CL (piextUSMSharedAlloc, OCL (piextUSMSharedAlloc ))
992
+ _PI_CL (piextUSMFree, OCL (piextUSMFree ))
993
+ _PI_CL (piextUSMKernelSetArgMemPointer, OCL (piextUSMKernelSetArgMemPointer ))
994
+ _PI_CL (piextUSMKernelSetIndirectAccess, OCL (piextUSMKernelSetIndirectAccess ))
995
+ _PI_CL (piextUSMEnqueueMemset, OCL (piextUSMEnqueueMemset ))
996
+ _PI_CL (piextUSMEnqueueMemcpy, OCL (piextUSMEnqueueMemcpy ))
997
+ _PI_CL (piextUSMEnqueuePrefetch, OCL (piextUSMEnqueuePrefetch ))
998
+ _PI_CL (piextUSMEnqueueMemAdvise, OCL (piextUSMEnqueueMemAdvise ))
999
+ _PI_CL (piextUSMGetMemAllocInfo, OCL (piextUSMGetMemAllocInfo ))
917
1000
918
1001
#undef _PI_CL
919
1002
0 commit comments