|
1 |
| -//===----------- pi_level_zero.cpp - Level Zero Plugin--------------------------==// |
| 1 | +//===-------- pi_level_zero.cpp - Level Zero Plugin --------------------==// |
2 | 2 | //
|
3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
4 | 4 | // See https://llvm.org/LICENSE.txt for license information.
|
5 | 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
6 | 6 | //
|
7 |
| -//===----------------------------------------------------------------------===// |
| 7 | +//===------------------------------------------------------------------===// |
8 | 8 |
|
9 | 9 | /// \file pi_level_zero.cpp
|
10 | 10 | /// Implementation of Level Zero Plugin.
|
|
26 | 26 |
|
27 | 27 | namespace {
|
28 | 28 |
|
29 |
| -// Controls Level Zero calls serialization to w/a Level Zero driver being not MT ready. |
30 |
| -// Recognized values (can be used as a bit mask): |
| 29 | +// Controls Level Zero calls serialization to w/a Level Zero driver being not MT |
| 30 | +// ready. Recognized values (can be used as a bit mask): |
31 | 31 | enum {
|
32 | 32 | ZeSerializeNone =
|
33 | 33 | 0, // no locking or blocking (except when SYCL RT requested blocking)
|
@@ -754,7 +754,8 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
|
754 | 754 | // cl_khr_3d_image_writes - Extension to enable writes to 3D image memory
|
755 | 755 | // objects.
|
756 | 756 | //
|
757 |
| - // Hardcoding some extensions we know are supported by all Level Zero devices. |
| 757 | + // Hardcoding some extensions we know are supported by all Level Zero |
| 758 | + // devices. |
758 | 759 | SupportedExtensions += (ZE_SUPPORTED_EXTENSIONS);
|
759 | 760 | if (ZeDeviceKernelProperties.fp16Supported)
|
760 | 761 | SupportedExtensions += ("cl_khr_fp16 ");
|
@@ -995,24 +996,24 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
|
995 | 996 | return ReturnValue(pi_uint64{DoubleFPValue});
|
996 | 997 | }
|
997 | 998 | case PI_DEVICE_INFO_IMAGE2D_MAX_WIDTH:
|
998 |
| - // Until Level Zero provides needed info, hardcode default minimum values required |
999 |
| - // by the SYCL specification. |
| 999 | + // Until Level Zero provides needed info, hardcode default minimum values |
| 1000 | + // required by the SYCL specification. |
1000 | 1001 | return ReturnValue(size_t{8192});
|
1001 | 1002 | case PI_DEVICE_INFO_IMAGE2D_MAX_HEIGHT:
|
1002 |
| - // Until Level Zero provides needed info, hardcode default minimum values required |
1003 |
| - // by the SYCL specification. |
| 1003 | + // Until Level Zero provides needed info, hardcode default minimum values |
| 1004 | + // required by the SYCL specification. |
1004 | 1005 | return ReturnValue(size_t{8192});
|
1005 | 1006 | case PI_DEVICE_INFO_IMAGE3D_MAX_WIDTH:
|
1006 |
| - // Until Level Zero provides needed info, hardcode default minimum values required |
1007 |
| - // by the SYCL specification. |
| 1007 | + // Until Level Zero provides needed info, hardcode default minimum values |
| 1008 | + // required by the SYCL specification. |
1008 | 1009 | return ReturnValue(size_t{2048});
|
1009 | 1010 | case PI_DEVICE_INFO_IMAGE3D_MAX_HEIGHT:
|
1010 |
| - // Until Level Zero provides needed info, hardcode default minimum values required |
1011 |
| - // by the SYCL specification. |
| 1011 | + // Until Level Zero provides needed info, hardcode default minimum values |
| 1012 | + // required by the SYCL specification. |
1012 | 1013 | return ReturnValue(size_t{2048});
|
1013 | 1014 | case PI_DEVICE_INFO_IMAGE3D_MAX_DEPTH:
|
1014 |
| - // Until Level Zero provides needed info, hardcode default minimum values required |
1015 |
| - // by the SYCL specification. |
| 1015 | + // Until Level Zero provides needed info, hardcode default minimum values |
| 1016 | + // required by the SYCL specification. |
1016 | 1017 | return ReturnValue(size_t{2048});
|
1017 | 1018 | case PI_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE:
|
1018 | 1019 | return ReturnValue(size_t{ZeDeviceImageProperties.maxImageBufferSize});
|
@@ -1437,9 +1438,9 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size,
|
1437 | 1438 | auto HostPtrOrNull =
|
1438 | 1439 | (Flags & PI_MEM_FLAGS_HOST_PTR_USE) ? pi_cast<char *>(HostPtr) : nullptr;
|
1439 | 1440 | try {
|
1440 |
| - *RetMem = new _pi_buffer(Context->Device->Platform, |
1441 |
| - pi_cast<char *>(Ptr) /* Level Zero Memory Handle */, |
1442 |
| - HostPtrOrNull); |
| 1441 | + *RetMem = new _pi_buffer( |
| 1442 | + Context->Device->Platform, |
| 1443 | + pi_cast<char *>(Ptr) /* Level Zero Memory Handle */, HostPtrOrNull); |
1443 | 1444 | } catch (const std::bad_alloc &) {
|
1444 | 1445 | return PI_OUT_OF_HOST_MEMORY;
|
1445 | 1446 | } catch (...) {
|
@@ -1660,8 +1661,8 @@ pi_result piProgramCreate(pi_context Context, const void *IL, size_t Length,
|
1660 | 1661 | assert(Context);
|
1661 | 1662 | assert(Program);
|
1662 | 1663 |
|
1663 |
| - // NOTE: the Level Zero module creation is also building the program, so we are |
1664 |
| - // deferring it until the program is ready to be built in piProgramBuild |
| 1664 | + // NOTE: the Level Zero module creation is also building the program, so we |
| 1665 | + // are deferring it until the program is ready to be built in piProgramBuild |
1665 | 1666 | // and piProgramCompile. Also it is only then we know the build options.
|
1666 | 1667 | //
|
1667 | 1668 | ze_module_desc_t ZeModuleDesc = {};
|
@@ -1796,7 +1797,8 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices,
|
1796 | 1797 | void (*PFnNotify)(pi_program Program, void *UserData),
|
1797 | 1798 | void *UserData, pi_program *RetProgram) {
|
1798 | 1799 |
|
1799 |
| - // TODO: Level Zero does not [yet] support linking so dummy implementation here. |
| 1800 | + // TODO: Level Zero does not [yet] support linking so dummy implementation |
| 1801 | + // here. |
1800 | 1802 | assert(NumInputPrograms == 1 && InputPrograms);
|
1801 | 1803 | assert(RetProgram);
|
1802 | 1804 | *RetProgram = InputPrograms[0];
|
@@ -2052,9 +2054,9 @@ pi_result piKernelGetInfo(pi_kernel Kernel, pi_kernel_info ParamName,
|
2052 | 2054 | case PI_KERNEL_INFO_PROGRAM:
|
2053 | 2055 | return ReturnValue(pi_program{Kernel->Program});
|
2054 | 2056 | case PI_KERNEL_INFO_FUNCTION_NAME:
|
2055 |
| - // TODO: Replace with the line in the comment once bug in the Level Zero driver will |
2056 |
| - // be fixed. Problem is that currently Level Zero driver truncates name of the |
2057 |
| - // returned kernel if it is longer than 256 symbols. |
| 2057 | + // TODO: Replace with the line in the comment once bug in the Level Zero |
| 2058 | + // driver will be fixed. Problem is that currently Level Zero driver |
| 2059 | + // truncates name of the returned kernel if it is longer than 256 symbols. |
2058 | 2060 | //
|
2059 | 2061 | // return ReturnValue(ZeKernelProperties.name);
|
2060 | 2062 | return ReturnValue(Kernel->KernelName.c_str());
|
@@ -3010,8 +3012,8 @@ piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer, pi_bool BlockingMap,
|
3010 | 3012 | ZE_CALL(zeCommandListAppendWaitOnEvents(ZeCommandList, NumEventsInWaitList,
|
3011 | 3013 | ZeEventWaitList));
|
3012 | 3014 |
|
3013 |
| - // TODO: Level Zero is missing the memory "mapping" capabilities, so we are left |
3014 |
| - // to doing new memory allocation and a copy (read). |
| 3015 | + // TODO: Level Zero is missing the memory "mapping" capabilities, so we are |
| 3016 | + // left to doing new memory allocation and a copy (read). |
3015 | 3017 | //
|
3016 | 3018 | // TODO: check if the input buffer is already allocated in shared
|
3017 | 3019 | // memory and thus is accessible from the host as is. Can we get SYCL RT
|
@@ -3081,8 +3083,8 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
|
3081 | 3083 | ZE_CALL(zeCommandListAppendWaitOnEvents(ZeCommandList, NumEventsInWaitList,
|
3082 | 3084 | ZeEventWaitList));
|
3083 | 3085 |
|
3084 |
| - // TODO: Level Zero is missing the memory "mapping" capabilities, so we are left |
3085 |
| - // to doing copy (write back to the device). |
| 3086 | + // TODO: Level Zero is missing the memory "mapping" capabilities, so we are |
| 3087 | + // left to doing copy (write back to the device). |
3086 | 3088 | //
|
3087 | 3089 | // NOTE: Keep this in sync with the implementation of
|
3088 | 3090 | // piEnqueueMemBufferMap/piEnqueueMemImageMap.
|
@@ -3754,7 +3756,8 @@ pi_result piextProgramSetSpecializationConstant(pi_program Prog,
|
3754 | 3756 | // Pass SpecValue pointer. Spec constant value is retrieved
|
3755 | 3757 | // by Level-Zero when creating the modul
|
3756 | 3758 | //
|
3757 |
| - // NOTE: SpecSize is unused in Level Zero, the size is known from SPIR-V by SpecID. |
| 3759 | + // NOTE: SpecSize is unused in Level Zero, the size is known from SPIR-V by |
| 3760 | + // SpecID. |
3758 | 3761 | Prog->ZeSpecConstants[SpecID] = reinterpret_cast<uint64_t>(SpecValue);
|
3759 | 3762 |
|
3760 | 3763 | return PI_SUCCESS;
|
|
0 commit comments