Skip to content

[ESIMD] Enable esimd emulator build by default #5058

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 23 commits into from
Jan 19, 2022

Conversation

dongkyunahn-intel
Copy link
Contributor

This PR is to enable ESIMD_EMULATOR build by default.

  • PI_APIs for PI info are updated for check-in tests

@bader bader changed the title Enable esimd emu build [ESIMD] Enable esimd emulator build by default Dec 1, 2021
- Reducing overhead on command creation in specific case from PR#4841

- Same kernel launching flow for ESIMD_EMULATOR is in
ExecCGCommand::enqueueImp() in commands.cpp
@@ -1324,6 +1360,7 @@ pi_result piEnqueueMemBufferReadRect(pi_queue, pi_mem, pi_bool,
pi_result piEnqueueMemBufferWrite(pi_queue, pi_mem, pi_bool, size_t, size_t,
const void *, pi_uint32, const pi_event *,
pi_event *) {
// TODO : intel/llvm_test_suite
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this mean - "// TODO add a test to github.com/intel/llvm-test-suite"?
Please update if so. Even though I don't see much sense in such TODO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

@@ -1623,7 +1674,8 @@ pi_result piextDeviceSelectBinary(pi_device, pi_device_binary *,
pi_result piextUSMEnqueuePrefetch(pi_queue, const void *, size_t,
pi_usm_migration_flags, pi_uint32,
const pi_event *, pi_event *) {
DIE_NO_IMPLEMENTATION;
// NOP for prefetch
Copy link
Contributor

Choose a reason for hiding this comment

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

Please explain in the comment why NOP for prefetch is safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll replace it with TODO like above ones.

@@ -528,7 +538,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
case PI_DEVICE_INFO_VERSION:
// CM_EMU release version from
// https://github.com/intel/cm-cpu-emulation/releases
return ReturnValue("1.0.7-CM_EMU");
return ReturnValue("1.0");
Copy link
Contributor

Choose a reason for hiding this comment

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

this should rather be a query into libcm. at least TODO should be added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll check if the version number can be retrieved from CM and apply it if possible.

And, please note that the device info version format should be 'X.Y'. It is required from one of tests in intel/llvm-test-suite.

@@ -2157,10 +2157,12 @@ cl_int ExecCGCommand::enqueueImp() {
} else {
assert(MQueue->getPlugin().getBackend() ==
backend::ext_intel_esimd_emulator);
// Dims==0 for 'single_task() - void(void) type'
uint32_t Dims = (Args.size() > 0) ? NDRDesc.Dims : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT, single_task is not supported. Should this cause DIE_NO_IMPLEMENTATION?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'single_task()' is widely used in intel/llvm-test-suite. ESIMD/SYCL/printf.cpp uses 'single_task()'. I would like to make sure if it is going to be supported or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

But your code implies it is not supported yet. So DIE_NO_IMPLEMENTATION should happen on attempt to use it.

Copy link
Contributor Author

@dongkyunahn-intel dongkyunahn-intel Dec 21, 2021

Choose a reason for hiding this comment

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

DIE_NO_IMPLEMENTATION is defined in sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp. Maybe execution attempts for single_task() return PI_INVALID_WORK_DIMENSION or PI_INVALID_KERNEL (or some other error code ) here until it is supported?

Are we going to support single_task() or not ESIMD?

@kbobrovs
Copy link
Contributor

Note on running SYCL kernels:
ESIMD emulator by definition is another kind of "gpu" device, which can run only ESIMD kernels, it can't run normal SYCL kernels. We need a way to detect that ESIMD EMU plugin is asked to run a non-ESIMD kernel (i.e. sycl_explicit_simd attribute is missing for it), and issue a meaningful error. This might require extending the PI kernel invocation interface to propagate such kernel attributes/properties. IIRC, we added special new invocation interface to PI to invoke kernels bypassing the "normal" mechanism, so we could extend it further to propagate needed info. @romanovvlad, @smaslov-intel - do you agree or have other comments?

@romanovvlad
Copy link
Contributor

romanovvlad commented Dec 13, 2021

Note on running SYCL kernels: ESIMD emulator by definition is another kind of "gpu" device, which can run only ESIMD kernels, it can't run normal SYCL kernels. We need a way to detect that ESIMD EMU plugin is asked to run a non-ESIMD kernel (i.e. sycl_explicit_simd attribute is missing for it), and issue a meaningful error. This might require extending the PI kernel invocation interface to propagate such kernel attributes/properties. IIRC, we added special new invocation interface to PI to invoke kernels bypassing the "normal" mechanism, so we could extend it further to propagate needed info. @romanovvlad, @smaslov-intel - do you agree or have other comments?

If we convert sycl_explicit_simd attribute to a compile time property(see #4937) and starting report something like piDeviceGetInfo(PI_SUPPORT_ESIMD) == true from plugins that support esimd execution model we can have the wanted diagnostic in the SYCL RT alongside with other checks for kernel requirements vs device capabilities.

BTW.

IIRC, we added special new invocation interface to PI to invoke kernels bypassing the "normal" mechanism

I believe we have avoided adding new invocations interface, could you please share a link to the line where it's defined if we have it?

@kbobrovs
Copy link
Contributor

Note on running SYCL kernels: ESIMD emulator by definition is another kind of "gpu" device, which can run only ESIMD kernels, it can't run normal SYCL kernels. We need a way to detect that ESIMD EMU plugin is asked to run a non-ESIMD kernel (i.e. sycl_explicit_simd attribute is missing for it), and issue a meaningful error. This might require extending the PI kernel invocation interface to propagate such kernel attributes/properties. IIRC, we added special new invocation interface to PI to invoke kernels bypassing the "normal" mechanism, so we could extend it further to propagate needed info. @romanovvlad, @smaslov-intel - do you agree or have other comments?

If we convert sycl_explicit_simd attribute to a compile time property(see #4937) and starting report something like piDeviceGetInfo(PI_SUPPORT_ESIMD) == true from plugins that support esimd execution model we can have the wanted diagnostic in the SYCL RT alongside with other checks for kernel requirements vs device capabilities.

I'm not sure if #4937 will work for emulator, as device code does not go through SPIRV or even device compiler.

BTW.

IIRC, we added special new invocation interface to PI to invoke kernels bypassing the "normal" mechanism

I believe we have avoided adding new invocations interface, could you please share a link to the line where it's defined if we have it?

Looks like my IIRC is wrong. I see we use piEnqueueKernelLaunch.
Maybe SYCL RT could see if there is isESIMD property on device binary being passed to ESIMD emulator BE and report an error if it is missing.

- As esimd_emulator is only for ESIMD kernels, PI_APIs causing
failures for non-ESIMD kernels are not going to be implemented. 'TODO'
comments are removed for such PI_APIs

- CMakeLists change : installtion path fix for headers imported from
CM
@romanovvlad
Copy link
Contributor

Note on running SYCL kernels: ESIMD emulator by definition is another kind of "gpu" device, which can run only ESIMD kernels, it can't run normal SYCL kernels. We need a way to detect that ESIMD EMU plugin is asked to run a non-ESIMD kernel (i.e. sycl_explicit_simd attribute is missing for it), and issue a meaningful error. This might require extending the PI kernel invocation interface to propagate such kernel attributes/properties. IIRC, we added special new invocation interface to PI to invoke kernels bypassing the "normal" mechanism, so we could extend it further to propagate needed info. @romanovvlad, @smaslov-intel - do you agree or have other comments?

If we convert sycl_explicit_simd attribute to a compile time property(see #4937) and starting report something like piDeviceGetInfo(PI_SUPPORT_ESIMD) == true from plugins that support esimd execution model we can have the wanted diagnostic in the SYCL RT alongside with other checks for kernel requirements vs device capabilities.

I'm not sure if #4937 will work for emulator, as device code does not go through SPIRV or even device compiler.

With this properties we could convert all attributes to properties, so they are known to the SYCL RT without compiler assistance.

@kbobrovs
Copy link
Contributor

Note on running SYCL kernels: ESIMD emulator by definition is another kind of "gpu" device, which can run only ESIMD kernels, it can't run normal SYCL kernels. We need a way to detect that ESIMD EMU plugin is asked to run a non-ESIMD kernel (i.e. sycl_explicit_simd attribute is missing for it), and issue a meaningful error. This might require extending the PI kernel invocation interface to propagate such kernel attributes/properties. IIRC, we added special new invocation interface to PI to invoke kernels bypassing the "normal" mechanism, so we could extend it further to propagate needed info. @romanovvlad, @smaslov-intel - do you agree or have other comments?

If we convert sycl_explicit_simd attribute to a compile time property(see #4937) and starting report something like piDeviceGetInfo(PI_SUPPORT_ESIMD) == true from plugins that support esimd execution model we can have the wanted diagnostic in the SYCL RT alongside with other checks for kernel requirements vs device capabilities.

I'm not sure if #4937 will work for emulator, as device code does not go through SPIRV or even device compiler.

With this properties we could convert all attributes to properties, so they are known to the SYCL RT without compiler assistance.

To get properties we need device binary. Device binary is not used with the ESIMD emulator, I believe. Should we at all require presence of device binary when running on host device (ESIMD emulator shares a lot with it) ?

@romanovvlad
Copy link
Contributor

Note on running SYCL kernels: ESIMD emulator by definition is another kind of "gpu" device, which can run only ESIMD kernels, it can't run normal SYCL kernels. We need a way to detect that ESIMD EMU plugin is asked to run a non-ESIMD kernel (i.e. sycl_explicit_simd attribute is missing for it), and issue a meaningful error. This might require extending the PI kernel invocation interface to propagate such kernel attributes/properties. IIRC, we added special new invocation interface to PI to invoke kernels bypassing the "normal" mechanism, so we could extend it further to propagate needed info. @romanovvlad, @smaslov-intel - do you agree or have other comments?

If we convert sycl_explicit_simd attribute to a compile time property(see #4937) and starting report something like piDeviceGetInfo(PI_SUPPORT_ESIMD) == true from plugins that support esimd execution model we can have the wanted diagnostic in the SYCL RT alongside with other checks for kernel requirements vs device capabilities.

I'm not sure if #4937 will work for emulator, as device code does not go through SPIRV or even device compiler.

With this properties we could convert all attributes to properties, so they are known to the SYCL RT without compiler assistance.

To get properties we need device binary. Device binary is not used with the ESIMD emulator, I believe. Should we at all require presence of device binary when running on host device (ESIMD emulator shares a lot with it) ?

I'm referring to sycl::ext::oneapi::property_list and sycl::ext::oneapi::property_value(see https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/PropertyList/SYCL_EXT_ONEAPI_property_list.asciidoc and https://github.com/intel/llvm/pull/4937/files?short_path=8b8203c#diff-8b8203c67c38c950b9c19edd0aa137e67e3683c84fc454fe2982ebb19e7a47b1)

@kbobrovs
Copy link
Contributor

bader
bader previously approved these changes Dec 21, 2021
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

buildbot/configure.py looks okay, but I have one question though: should we have a switch to disable ESIMD emulator build? I suppose it might be useful for developers not involved in ESIMD development.

And,
- Argument sanity check failure revised for piDevicesGet
- DeviceType condition check fix
dongkyunahn-intel added a commit to dongkyunahn-intel/llvm-test-suite that referenced this pull request Jan 16, 2022
- This PR is for clearing failures observed while merging intel/llvm
PR enabling esimd_emulator support by default
(intel/llvm#5058)

- Another PR should be created for actively loading and testing
'esimd_emulator' backend
vladimirlaz pushed a commit to intel/llvm-test-suite that referenced this pull request Jan 17, 2022
- This PR is for clearing failures observed while merging intel/llvm
PR enabling esimd_emulator support by default
(intel/llvm#5058)

- Another PR should be created for actively loading and testing
'esimd_emulator' backend
vladimirlaz
vladimirlaz previously approved these changes Jan 17, 2022
@vladimirlaz vladimirlaz requested review from bader and kbobrovs January 17, 2022 13:57
@bader
Copy link
Contributor

bader commented Jan 18, 2022

buildbot/configure.py looks okay, but I have one question though: should we have a switch to disable ESIMD emulator build? I suppose it might be useful for developers not involved in ESIMD development.

@dongkyunahn-intel, @kbobrovs, what do you think about flipping the switch instead of removing it?

@dongkyunahn-intel
Copy link
Contributor Author

buildbot/configure.py looks okay, but I have one question though: should we have a switch to disable ESIMD emulator build? I suppose it might be useful for developers not involved in ESIMD development.

Do other backend types have disabling option like you suggested? If not, I don't want to have it only for ESIMD emulator.

@bader
Copy link
Contributor

bader commented Jan 18, 2022

buildbot/configure.py looks okay, but I have one question though: should we have a switch to disable ESIMD emulator build? I suppose it might be useful for developers not involved in ESIMD development.

Do other backend types have disabling option like you suggested? If not, I don't want to have it only for ESIMD emulator.

HIP and CUDA backend builds are controlled by dedicated options.

@kbobrovs
Copy link
Contributor

buildbot/configure.py looks okay, but I have one question though: should we have a switch to disable ESIMD emulator build? I suppose it might be useful for developers not involved in ESIMD development.

Do other backend types have disabling option like you suggested? If not, I don't want to have it only for ESIMD emulator.

HIP and CUDA backend builds are controlled by dedicated options.

Makes sense to me too.

@vladimirlaz
Copy link
Contributor

vladimirlaz commented Jan 19, 2022

I am trying to build esimd_emulator locally and got the following error:

llvm/build/tools/sycl/plugins/esimd_emulator/cm-emu-prefix/src/cm-emu/cmake/../common/linux/cm_include.h:22:10: fatal error: va/va.h: No such file or directory
   22 | #include "va/va.h"
      |          ^~~~~~~~~
compilation terminated.

Does this build brings new dependency: libva-dev package to be installed on ?

The problem was resolved locally after installing the package:

apt-get install libva-dev

@bader
Copy link
Contributor

bader commented Jan 19, 2022

AFAIK, libva-dev is not the only dependency. See #5212 for the full list.

Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

buildbot/configure.py changes look good to me.
We need someone from @intel/llvm-reviewers-runtime to approve.

@bader
Copy link
Contributor

bader commented Jan 20, 2022

It looks like required dependencies are not installed for "shared lib" build configuration - https://github.com/intel/llvm/runs/4872502344?check_suite_focus=true.
@alexbatashev, is it possible to unify build configurations and use a docker image to set up worker's environment?

@alexbatashev
Copy link
Contributor

@bader working on it

aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Feb 23, 2023
- This PR is for clearing failures observed while merging intel/llvm
PR enabling esimd_emulator support by default
(intel#5058)

- Another PR should be created for actively loading and testing
'esimd_emulator' backend
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
- This PR is for clearing failures observed while merging intel/llvm
PR enabling esimd_emulator support by default
(intel#5058)

- Another PR should be created for actively loading and testing
'esimd_emulator' backend
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.

7 participants