Skip to content

[SYCL] Enable devicelib when using -fsycl-link to generate partially … #2625

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 2 commits into from
Oct 15, 2020

Conversation

jinge90
Copy link
Contributor

@jinge90 jinge90 commented Oct 12, 2020

…linked device object

Signed-off-by: gejin [email protected]

@jinge90 jinge90 requested review from AGindinson, mdtoguchi and a team as code owners October 12, 2020 09:13
@jinge90 jinge90 requested a review from rbegam October 12, 2020 09:13
@jinge90
Copy link
Contributor Author

jinge90 commented Oct 12, 2020

Hi, @mdtoguchi
We have enabled devicelib default link previously. However, devicelib hasn't been linked by default in "-fsycl-link"(without -fintelfpga) mode. This PR is used to add support for this unorthodox way of creating device binary.
Thanks very much.

C.getDefaultToolChain()
.getTriple()
.isWindowsMSVCEnvironment());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a current issue where usage of -fintelfpga is too liberal, where we should be using the spir64_fpga triple instead. Should that be the case here? Downside would be that regular -fsycl-link usage would not be possible with FPGA and usage of -fsycl-link would be only to create FPGA specific device libraries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @mdtoguchi
According to latest user manual, -fsycl-link has 2 different user scenario which depends on whether it is used together with -fintelfpga. In this PR, we only want to toch the "pure" fsycl-link mode which is used to create a device object which is later used in host link.
Do you mean compiler driver will change the behavior of "-fsycl-link", it will only be used to create FPGA specific device libraries? If so, what option/command should we use to create device object used for host link?
Thanks very much.

Copy link
Contributor

Choose a reason for hiding this comment

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

Use of -fsycl-link is not changing. What I mean is that use of -fintelfpga and -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice should be equivalent sans a couple implied defaults with -fintelfpga.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I need to have a more solid check for FPGA in the patch? Checking -fintelfpga seems not to be enough, we need to check whether spir64_fpga triple is specified too. Did I get your point correctly?
Thanks very much.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say just checking for SPIRSubArch_fpga should be sufficient, as -fintelfpga implies it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @mdtoguchi
If -fsycl-link is used together with -fintelfpga, sycl device libraries will be added via: https://github.com/intel/llvm/blob/sycl/clang/lib/Driver/Driver.cpp#L4094
in the function appendLinkDependences.
If -fsycl-link is used without -fintelfpga, the code path is different, we will step into getDeviceDependences. I am not sure whether we have real world scenario for the combination: "-fsycl-link -fsycl-targets=spir64_fpga-unknown-unknwon-sycldevice", I tried this combination and found the we still need to add sycl device libraries in getDeviceDependences.
In a word, although -fintelfpga and -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice may be equivalent, we have different code paths in driver. I suggest to keep the check for fintelfpga here.
Thanks very much.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. You can continue to use -fintelfpga for this path, as the behavioral trigger is currently -fsycl-link -fintelfpga. We may need to weigh in on -fsycl-link behaviors with -fsycl-targets=spir64_fpga as we look to keed a differentiator other than use of the FPGA triple. Thanks

@jinge90
Copy link
Contributor Author

jinge90 commented Oct 15, 2020

Hi, @intel/llvm-reviewers-runtime @AGindinson
Could you help review this PR?
Thanks very much.

Copy link
Contributor

@s-kanaev s-kanaev left a comment

Choose a reason for hiding this comment

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

RT test looks good.

@s-kanaev
Copy link
Contributor

/summary:run

Comment on lines +1 to +15
// RUN: %clangxx -fsycl -fsycl-link %S/std_complex_math_test.cpp -o %t_device.o
// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-int-header=std_complex_math_test_ihdr.h %S/std_complex_math_test.cpp -I %sycl_include -Wno-sycl-strict
// >> host compilation...
// RUN: %clangxx -include std_complex_math_test_ihdr.h -c %S/std_complex_math_test.cpp -o %t_host.o -I %sycl_include -Wno-sycl-strict
// RUN: %clangxx %t_host.o %t_device.o -o %t.out -lsycl
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out

// RUN: %clangxx -fsycl -fsycl-link -fsycl-device-lib=all %S/std_complex_math_fp64_test.cpp -o %t_fp64_device.o
// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-int-header=std_complex_math_fp64_test_ihdr.h %S/std_complex_math_fp64_test.cpp -I %sycl_include -Wno-sycl-strict
// >> host compilation...
// RUN: %clangxx -include std_complex_math_fp64_test_ihdr.h -c %S/std_complex_math_fp64_test.cpp -o %t_fp64_host.o -I %sycl_include -Wno-sycl-strict
// RUN: %clangxx %t_fp64_host.o %t_fp64_device.o -o %t_fp64.out -lsycl
// RUN: %CPU_RUN_PLACEHOLDER %t_fp64.out
// RUN: %ACC_RUN_PLACEHOLDER %t_fp64.out
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm only curious: are there any other use-cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @s-kanaev
Do you mean are there any other use cases for device libraries?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, exactly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have supported for normal jit and aot including fintelfpga mode. However, there are many other use cases which is not so "popular", I believe we do have some use cases which have not been handled, for example: it seems that "-fsycl-link-targets=<T1,...,Tn>" also needs the support.
We need to review all options in https://github.com/intel/llvm/blob/sycl/sycl/doc/UsersManual.md to see if anything missed.
Thanks very much.

@romanovvlad romanovvlad merged commit 8471e7a into intel:sycl Oct 15, 2020
@jinge90 jinge90 deleted the devicelib_default_link_fsyc-link branch October 15, 2020 23:44
kbenzie pushed a commit to kbenzie/intel-llvm that referenced this pull request Feb 17, 2025
…CLSkip

Remove unnecessary OpenCL KNOWN_FAILURE from urKernelGetInfoTest.
Chenyang-L pushed a commit that referenced this pull request Feb 18, 2025
Remove unnecessary OpenCL KNOWN_FAILURE from urKernelGetInfoTest.
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.

4 participants