Skip to content

Commit 63dfb35

Browse files
committed
Merge branch 'adapters' into eliminate-usage-of-regex-in-opencl
2 parents 56f6994 + 612a263 commit 63dfb35

39 files changed

+274
-148
lines changed

.github/workflows/cmake.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ jobs:
203203
run: LD_LIBRARY_PATH=${{github.workspace}}/dpcpp_compiler/lib
204204
cmake --build ${{github.workspace}}/build -j $(nproc)
205205

206+
- name: Test adapter specific
207+
working-directory: ${{github.workspace}}/build
208+
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "adapter-specific" --timeout 180
209+
206210
# Temporarily disabling platform test for L0, because of hang
207211
# See issue: #824
208212
- name: Test L0 adapter

examples/codegen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ if(LLVM_FOUND AND PkgConfig_FOUND AND LLVMSPIRVLib_FOUND)
4343
)
4444
endif()
4545
else()
46-
message(STATUS "The environment did not satisfy dependency requirements (LLVM, PkgConfig, LLVMSPIRVLib) for codegen example (skipping target).")
46+
message(FATAL_ERROR "The environment did not satisfy dependency requirements (LLVM, PkgConfig, LLVMSPIRVLib) for codegen example (skipping target).")
4747
endif()

scripts/generate_code.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,25 @@ def _mako_info_hpp(path, namespace, tags, version, specs, meta):
315315
specs=specs,
316316
meta=meta)
317317

318+
"""
319+
Entry-point:
320+
generates linker version scripts
321+
"""
322+
def _mako_linker_scripts(path, ext, namespace, tags, version, specs, meta):
323+
name = "adapter"
324+
filename = f"{name}.{ext}.in"
325+
fin = os.path.join(templates_dir, f"{filename}.mako")
326+
fout = os.path.join(path, filename)
327+
print("Generating %s..." % fout)
328+
return util.makoWrite(
329+
fin, fout,
330+
name=name,
331+
ver=version,
332+
namespace=namespace,
333+
tags=tags,
334+
specs=specs,
335+
meta=meta)
336+
318337
"""
319338
Entry-point:
320339
generates lib code
@@ -349,6 +368,8 @@ def generate_adapters(path, section, namespace, tags, version, specs, meta):
349368

350369
loc = 0
351370
loc += _mako_null_adapter_cpp(dstpath, namespace, tags, version, specs, meta)
371+
loc += _mako_linker_scripts(dstpath, "map", namespace, tags, version, specs, meta)
372+
loc += _mako_linker_scripts(dstpath, "def", namespace, tags, version, specs, meta)
352373
print("Generated %s lines of code.\n"%loc)
353374

354375
"""

scripts/templates/adapter.def.in.mako

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<%!
2+
import re
3+
from templates import helper as th
4+
%><%
5+
n=namespace
6+
%>\
7+
LIBRARY @TARGET_LIBNAME@
8+
EXPORTS
9+
%for tbl in th.get_pfntables(specs, meta, n, tags):
10+
${tbl['export']['name']}
11+
%endfor

scripts/templates/adapter.map.in.mako

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<%!
2+
import re
3+
from templates import helper as th
4+
%><%
5+
n=namespace
6+
%>\
7+
@TARGET_LIBNAME@ {
8+
global:
9+
%for tbl in th.get_pfntables(specs, meta, n, tags):
10+
${tbl['export']['name']};
11+
%endfor
12+
local:
13+
*;
14+
};

source/adapters/adapter.def.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
LIBRARY @TARGET_LIBNAME@
22
EXPORTS
3+
urGetGlobalProcAddrTable
34
urGetBindlessImagesExpProcAddrTable
45
urGetCommandBufferExpProcAddrTable
56
urGetContextProcAddrTable
6-
urGetDeviceProcAddrTable
77
urGetEnqueueProcAddrTable
88
urGetEventProcAddrTable
9-
urGetGlobalProcAddrTable
109
urGetKernelProcAddrTable
1110
urGetMemProcAddrTable
1211
urGetPhysicalMemProcAddrTable
1312
urGetPlatformProcAddrTable
1413
urGetProgramProcAddrTable
1514
urGetQueueProcAddrTable
1615
urGetSamplerProcAddrTable
16+
urGetUSMProcAddrTable
1717
urGetUSMExpProcAddrTable
1818
urGetUsmP2PExpProcAddrTable
19-
urGetUSMProcAddrTable
2019
urGetVirtualMemProcAddrTable
20+
urGetDeviceProcAddrTable

source/adapters/adapter.map.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
@TARGET_LIBNAME@ {
22
global:
3+
urGetGlobalProcAddrTable;
34
urGetBindlessImagesExpProcAddrTable;
45
urGetCommandBufferExpProcAddrTable;
56
urGetContextProcAddrTable;
6-
urGetDeviceProcAddrTable;
77
urGetEnqueueProcAddrTable;
88
urGetEventProcAddrTable;
9-
urGetGlobalProcAddrTable;
109
urGetKernelProcAddrTable;
1110
urGetMemProcAddrTable;
1211
urGetPhysicalMemProcAddrTable;
1312
urGetPlatformProcAddrTable;
1413
urGetProgramProcAddrTable;
1514
urGetQueueProcAddrTable;
1615
urGetSamplerProcAddrTable;
16+
urGetUSMProcAddrTable;
1717
urGetUSMExpProcAddrTable;
1818
urGetUsmP2PExpProcAddrTable;
19-
urGetUSMProcAddrTable;
2019
urGetVirtualMemProcAddrTable;
20+
urGetDeviceProcAddrTable;
2121
local:
2222
*;
2323
};

source/adapters/cuda/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
set(CUDA_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "CUDA adapter directory")
7-
86
set(TARGET_NAME ur_adapter_cuda)
97

108
add_ur_adapter(${TARGET_NAME}

source/adapters/cuda/device.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
501501
return ReturnValue(
502502
static_cast<uint64_t>(hDevice->getMaxChosenLocalMem()));
503503
} else {
504-
int LocalMemSize = 0;
505-
UR_CHECK_ERROR(cuDeviceGetAttribute(
506-
&LocalMemSize, CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK,
507-
hDevice->get()));
508-
detail::ur::assertion(LocalMemSize >= 0);
509-
return ReturnValue(static_cast<uint64_t>(LocalMemSize));
504+
return ReturnValue(
505+
static_cast<uint64_t>(hDevice->getMaxCapacityLocalMem()));
510506
}
511507
}
512508
case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT: {

source/adapters/cuda/device.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct ur_device_handle_t_ {
4545
UR_CHECK_ERROR(cuDeviceGetAttribute(
4646
&MaxRegsPerBlock, CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK,
4747
cuDevice));
48+
UR_CHECK_ERROR(cuDeviceGetAttribute(
49+
&MaxCapacityLocalMem,
50+
CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN, cuDevice));
4851

4952
// Set local mem max size if env var is present
5053
static const char *LocalMemSizePtrUR =
@@ -56,9 +59,6 @@ struct ur_device_handle_t_ {
5659
: (LocalMemSizePtrPI ? LocalMemSizePtrPI : nullptr);
5760

5861
if (LocalMemSizePtr) {
59-
cuDeviceGetAttribute(
60-
&MaxCapacityLocalMem,
61-
CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN, cuDevice);
6262
MaxChosenLocalMem = std::atoi(LocalMemSizePtr);
6363
MaxLocalMemSizeChosen = true;
6464
}

0 commit comments

Comments
 (0)