Skip to content

Level zero codegen #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jan 26, 2021
Merged

Conversation

diptorupd
Copy link
Contributor

Fixes few left over things from level zero changes.

@diptorupd
Copy link
Contributor Author

diptorupd commented Jan 23, 2021

@oleksandr-pavlyk I made the change you suggested by dynamically opening libze_loader.so. To test if it works, I tried importing dpctl without having libze_loader.so as a target_link_library for libDPCTLSyclInterface.so and it works (earlier it used to throw an import error).

@oleksandr-pavlyk
Copy link
Contributor

Used

# sasha_test.py
with open('dpctl/tests/input_files/multi_kernel.spv', 'br') as fh:
    sprv_pr = fh.read()
import dpctl, dpctl.memory as dpmem, dpctl.program as dppro
import numpy as np
import ctypes

q = dpctl.get_current_queue()

pr = dppro.create_program_from_spirv(q, sprv_pr)

k = pr.get_sycl_kernel('axpy')

s = np.dtype('i4').itemsize
a = dpmem.MemoryUSMShared(1024 * s)
b = dpmem.MemoryUSMShared(1024 * s)
c = dpmem.MemoryUSMShared(1024 * s)

ha = np.arange(0, 1024, dtype='i4')
hb = np.arange(1024-1, -1, -1, dtype='i4')
hc = np.zeros(1024, dtype='i4')

a.copy_from_host(ha.view(dtype='|u1'))
b.copy_from_host(hb.view(dtype='|u1'))
c.copy_from_host(hc.view(dtype='|u1'))

ev = q.submit(k, [a, b, c, ctypes.c_int(3)], [1024])
ev.wait()

res = c.copy_to_host().view(dtype='i4')
print(np.array_equal(res, ha + 3*hb))

q.get_sycl_device().dump_device_info()

Verified that libze_loader has been loaded and initialized:

(idp) [15:20:02 nuc dpctl]$ LD_DEBUG=libs python sasha_test.py |& grep ze_lo | grep init
   4085652:     calling init: /lib/x86_64-linux-gnu/libze_loader.so.1

The test passed, outputting

$ python sasha_test.py
True
    Name            Intel(R) Graphics [0x9bca]
    Driver version  1.0.18820
    Vendor          Intel(R) Corporation
    Profile         FULL_PROFILE
    Device type     gpu

Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tried to build and run dpctl on a machine without level-zero installed, say any older machine with older than Gen9 GPU.

@diptorupd diptorupd merged commit d10dd68 into IntelPython:master Jan 26, 2021
@diptorupd diptorupd deleted the level_zero_codegen branch January 26, 2021 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants