|
64 | 64 |
|
65 | 65 | #include <vector>
|
66 | 66 |
|
67 |
| -static inline cl_platform_id _get_platform(cl_platform_id platform) |
68 |
| -{ |
69 |
| - return platform; |
70 |
| -} |
71 |
| - |
72 | 67 | static inline cl_platform_id _get_platform(cl_device_id device)
|
73 | 68 | {
|
74 | 69 | if (device == nullptr) return nullptr;
|
@@ -756,6 +751,42 @@ typedef cl_int (CL_API_CALL* clTerminateContextKHR_clextfn)(
|
756 | 751 | #pragma message("Define for cl_khr_terminate_context was not found! Please update your headers.")
|
757 | 752 | #endif // defined(cl_khr_terminate_context)
|
758 | 753 |
|
| 754 | +#if defined(cl_khr_unified_svm) |
| 755 | + |
| 756 | +typedef void* (CL_API_CALL* clSVMAllocWithPropertiesKHR_clextfn)( |
| 757 | + cl_context context, |
| 758 | + const cl_svm_alloc_properties_khr* properties, |
| 759 | + cl_uint svm_type_index, |
| 760 | + size_t size, |
| 761 | + cl_int* errcode_ret); |
| 762 | + |
| 763 | +typedef cl_int (CL_API_CALL* clSVMFreeWithPropertiesKHR_clextfn)( |
| 764 | + cl_context context, |
| 765 | + const cl_svm_free_properties_khr* properties, |
| 766 | + cl_svm_free_flags_khr flags, |
| 767 | + void* ptr); |
| 768 | + |
| 769 | +typedef cl_int (CL_API_CALL* clGetSVMPointerInfoKHR_clextfn)( |
| 770 | + cl_context context, |
| 771 | + cl_device_id device, |
| 772 | + const void* ptr, |
| 773 | + cl_svm_pointer_info_khr param_name, |
| 774 | + size_t param_value_size, |
| 775 | + void* param_value, |
| 776 | + size_t* param_value_size_ret); |
| 777 | + |
| 778 | +typedef cl_int (CL_API_CALL* clGetSVMSuggestedTypeIndexKHR_clextfn)( |
| 779 | + cl_context context, |
| 780 | + cl_svm_capabilities_khr required_capabilities, |
| 781 | + cl_svm_capabilities_khr desired_capabilities, |
| 782 | + const cl_svm_alloc_properties_khr* properties, |
| 783 | + size_t size, |
| 784 | + cl_uint* suggested_svm_type_index); |
| 785 | + |
| 786 | +#else |
| 787 | +#pragma message("Define for cl_khr_unified_svm was not found! Please update your headers.") |
| 788 | +#endif // defined(cl_khr_unified_svm) |
| 789 | + |
759 | 790 | #if defined(cl_ext_device_fission)
|
760 | 791 |
|
761 | 792 | typedef cl_int (CL_API_CALL* clReleaseDeviceEXT_clextfn)(
|
@@ -1445,6 +1476,13 @@ struct openclext_dispatch_table {
|
1445 | 1476 | clTerminateContextKHR_clextfn clTerminateContextKHR;
|
1446 | 1477 | #endif // defined(cl_khr_terminate_context)
|
1447 | 1478 |
|
| 1479 | +#if defined(cl_khr_unified_svm) |
| 1480 | + clSVMAllocWithPropertiesKHR_clextfn clSVMAllocWithPropertiesKHR; |
| 1481 | + clSVMFreeWithPropertiesKHR_clextfn clSVMFreeWithPropertiesKHR; |
| 1482 | + clGetSVMPointerInfoKHR_clextfn clGetSVMPointerInfoKHR; |
| 1483 | + clGetSVMSuggestedTypeIndexKHR_clextfn clGetSVMSuggestedTypeIndexKHR; |
| 1484 | +#endif // defined(cl_khr_unified_svm) |
| 1485 | + |
1448 | 1486 | #if defined(cl_ext_device_fission)
|
1449 | 1487 | clReleaseDeviceEXT_clextfn clReleaseDeviceEXT;
|
1450 | 1488 | clRetainDeviceEXT_clextfn clRetainDeviceEXT;
|
@@ -1721,6 +1759,13 @@ static void _init(cl_platform_id platform, openclext_dispatch_table* dispatch_pt
|
1721 | 1759 | CLEXT_GET_EXTENSION(clTerminateContextKHR);
|
1722 | 1760 | #endif // defined(cl_khr_terminate_context)
|
1723 | 1761 |
|
| 1762 | +#if defined(cl_khr_unified_svm) |
| 1763 | + CLEXT_GET_EXTENSION(clSVMAllocWithPropertiesKHR); |
| 1764 | + CLEXT_GET_EXTENSION(clSVMFreeWithPropertiesKHR); |
| 1765 | + CLEXT_GET_EXTENSION(clGetSVMPointerInfoKHR); |
| 1766 | + CLEXT_GET_EXTENSION(clGetSVMSuggestedTypeIndexKHR); |
| 1767 | +#endif // defined(cl_khr_unified_svm) |
| 1768 | + |
1724 | 1769 | #if defined(cl_ext_device_fission)
|
1725 | 1770 | CLEXT_GET_EXTENSION(clReleaseDeviceEXT);
|
1726 | 1771 | CLEXT_GET_EXTENSION(clRetainDeviceEXT);
|
@@ -3414,6 +3459,91 @@ cl_int CL_API_CALL clTerminateContextKHR(
|
3414 | 3459 |
|
3415 | 3460 | #endif // defined(cl_khr_terminate_context)
|
3416 | 3461 |
|
| 3462 | +#if defined(cl_khr_unified_svm) |
| 3463 | + |
| 3464 | +void* CL_API_CALL clSVMAllocWithPropertiesKHR( |
| 3465 | + cl_context context, |
| 3466 | + const cl_svm_alloc_properties_khr* properties, |
| 3467 | + cl_uint svm_type_index, |
| 3468 | + size_t size, |
| 3469 | + cl_int* errcode_ret) |
| 3470 | +{ |
| 3471 | + struct openclext_dispatch_table* dispatch_ptr = _get_dispatch(context); |
| 3472 | + if (dispatch_ptr == nullptr || dispatch_ptr->clSVMAllocWithPropertiesKHR == nullptr) { |
| 3473 | + if (errcode_ret) *errcode_ret = CL_INVALID_OPERATION; |
| 3474 | + return nullptr; |
| 3475 | + } |
| 3476 | + return dispatch_ptr->clSVMAllocWithPropertiesKHR( |
| 3477 | + context, |
| 3478 | + properties, |
| 3479 | + svm_type_index, |
| 3480 | + size, |
| 3481 | + errcode_ret); |
| 3482 | +} |
| 3483 | + |
| 3484 | +cl_int CL_API_CALL clSVMFreeWithPropertiesKHR( |
| 3485 | + cl_context context, |
| 3486 | + const cl_svm_free_properties_khr* properties, |
| 3487 | + cl_svm_free_flags_khr flags, |
| 3488 | + void* ptr) |
| 3489 | +{ |
| 3490 | + struct openclext_dispatch_table* dispatch_ptr = _get_dispatch(context); |
| 3491 | + if (dispatch_ptr == nullptr || dispatch_ptr->clSVMFreeWithPropertiesKHR == nullptr) { |
| 3492 | + return CL_INVALID_OPERATION; |
| 3493 | + } |
| 3494 | + return dispatch_ptr->clSVMFreeWithPropertiesKHR( |
| 3495 | + context, |
| 3496 | + properties, |
| 3497 | + flags, |
| 3498 | + ptr); |
| 3499 | +} |
| 3500 | + |
| 3501 | +cl_int CL_API_CALL clGetSVMPointerInfoKHR( |
| 3502 | + cl_context context, |
| 3503 | + cl_device_id device, |
| 3504 | + const void* ptr, |
| 3505 | + cl_svm_pointer_info_khr param_name, |
| 3506 | + size_t param_value_size, |
| 3507 | + void* param_value, |
| 3508 | + size_t* param_value_size_ret) |
| 3509 | +{ |
| 3510 | + struct openclext_dispatch_table* dispatch_ptr = _get_dispatch(context); |
| 3511 | + if (dispatch_ptr == nullptr || dispatch_ptr->clGetSVMPointerInfoKHR == nullptr) { |
| 3512 | + return CL_INVALID_OPERATION; |
| 3513 | + } |
| 3514 | + return dispatch_ptr->clGetSVMPointerInfoKHR( |
| 3515 | + context, |
| 3516 | + device, |
| 3517 | + ptr, |
| 3518 | + param_name, |
| 3519 | + param_value_size, |
| 3520 | + param_value, |
| 3521 | + param_value_size_ret); |
| 3522 | +} |
| 3523 | + |
| 3524 | +cl_int CL_API_CALL clGetSVMSuggestedTypeIndexKHR( |
| 3525 | + cl_context context, |
| 3526 | + cl_svm_capabilities_khr required_capabilities, |
| 3527 | + cl_svm_capabilities_khr desired_capabilities, |
| 3528 | + const cl_svm_alloc_properties_khr* properties, |
| 3529 | + size_t size, |
| 3530 | + cl_uint* suggested_svm_type_index) |
| 3531 | +{ |
| 3532 | + struct openclext_dispatch_table* dispatch_ptr = _get_dispatch(context); |
| 3533 | + if (dispatch_ptr == nullptr || dispatch_ptr->clGetSVMSuggestedTypeIndexKHR == nullptr) { |
| 3534 | + return CL_INVALID_OPERATION; |
| 3535 | + } |
| 3536 | + return dispatch_ptr->clGetSVMSuggestedTypeIndexKHR( |
| 3537 | + context, |
| 3538 | + required_capabilities, |
| 3539 | + desired_capabilities, |
| 3540 | + properties, |
| 3541 | + size, |
| 3542 | + suggested_svm_type_index); |
| 3543 | +} |
| 3544 | + |
| 3545 | +#endif // defined(cl_khr_unified_svm) |
| 3546 | + |
3417 | 3547 | #if defined(cl_ext_device_fission)
|
3418 | 3548 |
|
3419 | 3549 | cl_int CL_API_CALL clReleaseDeviceEXT(
|
|
0 commit comments