Skip to content

Guard libdevice code with __SPIR__. #1672

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 7 commits into from
May 27, 2020
Merged

Guard libdevice code with __SPIR__. #1672

merged 7 commits into from
May 27, 2020

Conversation

vzakhari
Copy link
Contributor

libdevice provides standard libc/libm functionality for SPIR devices. It is not SYCL specific, so the use of SYCL specific definitions should be minimal. In most cases we can use __SPIR__ macro instead of __SYCL_DEVICE_ONLY__.

Signed-off-by: Vyacheslav Zakharin [email protected]

Vyacheslav Zakharin added 3 commits May 11, 2020 13:36
Signed-off-by: Vyacheslav Zakharin <[email protected]>
Signed-off-by: Vyacheslav Zakharin <[email protected]>
bader
bader previously approved these changes May 13, 2020
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.

LGTM. You might want to add a clang regression test for __SPIR__ definition.

@asavonic, @Fznamznon, @erichkeane, ping.

Copy link
Contributor

@Fznamznon Fznamznon left a comment

Choose a reason for hiding this comment

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

+1 for FE test, otherwise LGTM.

// required by the wrapper libraries.
#include "spirv_vars.hpp"
#else // __SPIR__
#define __SPIR_TARGET_ONLY__ 0
Copy link
Contributor

@asavonic asavonic May 13, 2020

Choose a reason for hiding this comment

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

Is this macro needed for non-spir targets? Can it be defined only for spir?

Copy link
Contributor

Choose a reason for hiding this comment

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

One more question: why can't just use __SPIR__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this macro needed for non-spir targets? Can it be defined only for spir?

I want to make sure that this header file is the only place to control it, so I want to have this macro defined in all compilations. If it is (accidentally) redefined, then the build will break making the issue evident. This is a devicelib internal macro that I want to have full control over.

Copy link
Contributor Author

@vzakhari vzakhari May 13, 2020

Choose a reason for hiding this comment

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

One more question: why can't just use __SPIR__?

It makes any future manipulations with the implementation guard simpler. Not that I expect any further modifications, but I already did it once (when I removed __SYCL_DEVICE_ONLY__), and it required changes in all files.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it is (accidentally) redefined, then the build will break making the issue evident.

I don't know if it is a real issue. Compiler does not define this macro, users do not define it either. Header defines it in a single place surrounded by include guards.

Macros such as this are usually not defined on "other" platforms. This way __SYCL_DEVICE_ONLY__ is not defined for host compilation (as opposed to be defined to 0) and __X86_64__ is not defined for arm.

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 am not worried about users. I am worried about developers :) __SPIR_TARGET_ONLY__ kind of invades onto FE's territory. If at any point it is end up being defined for whatever reason, I want to be aware of it.

If you do not like #define __SPIR_TARGET_ONLY__ 0, I can replace it with #undef __SPIR_TARGET_ONLY__ in the else clause, but I want to have the controlled behavior in all compilations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not choose a unique prefix, such as __DEVICELIB_DEVICE_ONLY__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no such thing as unique name, unless it is already defined by FE.

I think we waste too much time discussing this. How about I get rid of __SPIR_TARGET_ONLY__ and use just __SPIR__ instead? I believe everybody agrees with that, am I right?

Signed-off-by: Vyacheslav Zakharin <[email protected]>
Fznamznon
Fznamznon previously approved these changes May 14, 2020
@vzakhari
Copy link
Contributor Author

@erichkeane - ping

erichkeane
erichkeane previously approved these changes May 14, 2020
Copy link
Contributor

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

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

The CFE stuff looks fine.

Thanks for the ping, I was with the understanding still I'd been added to this inadvertently.

@bader
Copy link
Contributor

bader commented May 18, 2020

The CFE stuff looks fine.

I suggest submitting CFE stuff to llorg as well.

Signed-off-by: Vyacheslav Zakharin <[email protected]>
@vzakhari vzakhari dismissed stale reviews from erichkeane and Fznamznon via 59882f0 May 18, 2020 18:49
@vzakhari
Copy link
Contributor Author

The CFE stuff looks fine.

I suggest submitting CFE stuff to llorg as well.

I agree. Will do.

@bader bader requested a review from asavonic May 18, 2020 19:04
@vzakhari
Copy link
Contributor Author

@asavonic - ping

@bader bader merged commit 857ee51 into intel:sycl May 27, 2020
@vzakhari
Copy link
Contributor Author

CFE changes uploaded to llorg: https://reviews.llvm.org/D80655

preethi-intel pushed a commit to preethi-intel/llvm that referenced this pull request Oct 26, 2022
The latest changes got interfered with the patch that fixes
blocks ordering. Like this the checks actually make more sense.

Signed-off-by: Sidorov, Dmitry <[email protected]>

Signed-off-by: Sidorov, Dmitry <[email protected]>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@3e6bf42
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.

5 participants