Skip to content

[SYCL] Always warn when -fno-sycl-libspirv opt used. #7378

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 3 commits into from
Nov 21, 2022

Conversation

JackAKirk
Copy link
Contributor

This PR addresses #7238

The -fno-sycl-libspirv flag only has an effect when using nvptx64-nvidia-cuda or amdgcn-amd-amdhsa triples.
The effect is to not link the libspirv libraries built by libclc that are only used by CUDA/HIP backends.
This flag is never recommended for normal DPC++ use because both CUDA and HIP backends require linking with libspirv for lots of the basic functionality.

However the option is there in case someone for whatever reason doesn't want to link libspirv, so this PR adds (triple dependent) warnings whenever the -fno-sycl-libspirv option is used.

If used with CUDA/HIP the warning is:

"warning: no-sycl-libspirv option is not meant for regular application development and severely limits the correct behavior of DPC++ when using the 'triple' triple"

For other triples the warning is:

"warning: no-sycl-libspirv option has no effect when compiled with the 'triple' triple"

JackAKirk added 2 commits November 11, 2022 17:04
"when using the '%0' triple">,
InGroup<NoLibspirvHipCuda>;
def warn_flag_no_sycl_libspirv_has_no_effect
: Warning<"no-sycl-libspirv option has no effect when compiled with the "
Copy link
Contributor

Choose a reason for hiding this comment

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

How about - ignoring option 'fno-sycl-libspirv' for triple "%0"

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe generalize even more for possible usage in the future: ignoring option '%0' for triple '%1'.
We have an existing warn_drv_unsupported_option_for_target but the verbiage may not match what we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah makes sense to me. I'll make this change.

@@ -1316,6 +1316,9 @@ def CudaUnknownVersion: DiagGroup<"unknown-cuda-version">;
// ignored by CUDA.
def HIPOnly : DiagGroup<"hip-only">;

// A warning used when compiling for HIP or CUDA without linking LIBSPIRV.
Copy link
Contributor

Choose a reason for hiding this comment

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

A warning generated when compiling SYCL applications for HIP or CUDA backends without linking LIBSPIRV

"when using the '%0' triple">,
InGroup<NoLibspirvHipCuda>;
def warn_flag_no_sycl_libspirv_has_no_effect
: Warning<"no-sycl-libspirv option has no effect when compiled with the "
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe generalize even more for possible usage in the future: ignoring option '%0' for triple '%1'.
We have an existing warn_drv_unsupported_option_for_target but the verbiage may not match what we want.

@@ -96,6 +96,15 @@ def err_drv_cuda_host_arch : Error<
def err_drv_no_sycl_libspirv : Error<
"cannot find '%0'; provide path to libspirv library via '-fsycl-libspirv-path', or "
"pass '-fno-sycl-libspirv' to build without linking with libspirv">;
def warn_flag_no_sycl_libspirv
: Warning<"no-sycl-libspirv option is not meant for regular application "
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
: Warning<"no-sycl-libspirv option is not meant for regular application "
: Warning<"`-fno-sycl-libspirv` is not meant for regular application "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. I think warn_drv_unsupported_option_for_target actually is appropriate so I have used it here.

@@ -1230,6 +1230,17 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
addSYCLDefaultTriple(C, UniqueSYCLTriplesVec);
}
}
// -fno_sycl_libspirv flag is reserved for very unusual cases where the libspirv
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// -fno_sycl_libspirv flag is reserved for very unusual cases where the libspirv
// -fno-sycl-libspirv flag is reserved for very unusual cases where the libspirv

Diag(diag::warn_flag_no_sycl_libspirv_has_no_effect) << TT.getTriple();
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be indented a step in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes thanks I've corrected this now.

@JackAKirk
Copy link
Contributor Author

Thanks for the reviews, I've applied the suggested changes.

Copy link
Contributor

@mdtoguchi mdtoguchi left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@pvchupin pvchupin merged commit 83d3448 into intel:sycl Nov 21, 2022
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