-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL]Device lib default link #2277
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
Conversation
Signed-off-by: gejin <ge.jin@intel.com>
Signed-off-by: gejin <ge.jin@intel.com>
Signed-off-by: gejin <ge.jin@intel.com>
Signed-off-by: gejin <ge.jin@intel.com>
Signed-off-by: gejin <ge.jin@intel.com>
Signed-off-by: gejin <ge.jin@intel.com>
Signed-off-by: gejin <ge.jin@intel.com>
StringRef LibLoc, LibSysUtils; | ||
if (isMSVCEnv) { | ||
LibLoc = Args.MakeArgString(TC->getDriver().Dir + "/../bin"); | ||
LibSysUtils = "libsycl-msvc"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the device libs for Windows built in the bin
directory as opposed to the lib
directory like Linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe archive libraries on Windows are not supposed to be in bin
directory. bin
is for DLLs and executables. For OpenMP the BC
libraries are located in lib
(as they are considered archive librareis), and SPV
libraries are located in bin
(as the are considered 'dynamic' libraries, i.e. DLLs). Anyway, I think the BC
libraries must not be located in bin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @mdtoguchi and @vzakhari
Currently, the device libraries on Windows platform are located in bin/ folder for DPC++ compiler. You can find the details in :
https://github.com/intel/llvm/blob/sycl/libdevice/cmake/modules/SYCLLibdevice.cmake#L209
So, I followed it in this patch. I think the reason why put device libraries in bin/ on Windows is we want to put all 'sycl-related' libraries together with libsycl.so/dll? @asavonic , please feel free to correct me.
Thank you very much.
for (const StringRef &Lib : sycl_libs) { | ||
SmallString<128> LibName(LibLoc); | ||
llvm::sys::path::append(LibName, Lib); | ||
llvm::sys::path::replace_extension(LibName, ".o"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.o
is not a standard object name on Windows (typically it is .obj
). Probably can be discussed/addressed separately, but having the naming be inconsistent with expectations is confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @mdtoguchi
As we discussed above, current device libraries use ".o" for both Linux and Windows. I agree that ".obj" should be used for Windows and I think we can address separately in another PR.
Thank you very much.
Hi, all. |
/summary:run |
Signed-off-by: gejin <ge.jin@intel.com>
Having run into the issue of std::complex multiplication not working in device code without an extra lib link (which I discovered how to do only by recursive grep on the source tree and finding the test cases), I think this is a great usability improvement. |
I think adding |
01077c4
to
d436af2
Compare
Signed-off-by: gejin <ge.jin@intel.com>
Signed-off-by: gejin <ge.jin@intel.com>
Signed-off-by: gejin <ge.jin@intel.com>
Hi, @bader , |
@jinge90, I think these are FE bugs. Functions must have proper linkage type to be linked by generic LLVM tools (https://llvm.org/docs/LangRef.html#linkage-types). |
Hi, @bader |
This sounds strange. User kernels has default linkage (see https://github.com/intel/llvm/blob/sycl/clang/lib/Sema/SemaSYCL.cpp#L1512). I think you mean kernels defined in the library. Right? If so, I guess only "fallback" implementation should have "weak_odr" linkage, so linker can override it if another definition with stronger linkage type is provided.
That behavior sounds right to me, but I expect only one definition to have "weak_odr" linkage type.
That's something I didn't get. I suppose with have the same symbol (e.g. |
I guess we want users to have "similar to native CPU programming" experience if possible. Option 1 seems to be aligned with clang/gcc on linking standard C/C++ library. |
/summary:run |
I tried several simple tests and dumped the device IR, all kernel functions are marked as "weak_odr", is it expected behavior? define weak_odr dso_local spir_kernel void @_ZTS10KernelTest(float addrspace(1)....
In my test, both "a.bc" and "b.bc" only include one "weak_odr" function but the functions are totally different(different name, arg list....), after using "llvm-link --only-needed", one of the functions was ignored and not linked into final LLVM bc. In fact this problem is not related to "weak_odr" or any linkage type, it is due to llvm-link's algorithm for implementing "--only-needed". We can reproduce this issue without "weak_odr". When we use: "llvm-link --only-needed src-1.bc, src-2.bc...src-n.bc -o dst.bc", llvm-link's workflow is like following: |
Currently, I haven't envisioned any issues for (1) but there are many scenarios. Current patch supports jit and AOT but "-fintelfpga" and "NVPXT" are not supported as I don't have environment for testing for those targets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SYCL RT changes LGTM
Signed-off-by: gejin <ge.jin@intel.com>
…iceLib_default_link
Signed-off-by: Ge Jin <ge.jin@intel.com>
Signed-off-by: Ge Jin <ge.jin@intel.com>
Signed-off-by: Ge Jin <ge.jin@intel.com>
Hi, @bader |
Signed-off-by: gejin <ge.jin@intel.com>
Signed-off-by: gejin <ge.jin@intel.com>
@@ -21,11 +21,11 @@ | |||
|
|||
/// -fintelfpga -fsycl-link tests | |||
// RUN: touch %t.o | |||
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link %t.o -o libfoo.a 2>&1 \ | |||
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-devicelib -fintelfpga -fsycl-link %t.o -o libfoo.a 2>&1 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @mdtoguchi and @bader
Currently, I added "-fno-sycl-devicelib" to disable devicelib default link in order to not break those lit tests. As those tests depend on the compilation workflow.
I will add some lit test in driver to test devicelib link step later.
Thanks very much.
/summary:run |
We will pend this PR decided to split the work into several steps, the first step is for default link: #2400 |
Add support for load/store operations for a cooperative matrix such that original matrix shape is known and implementations are able to reason about how to deal with the out of bounds. CapabilityCooperativeMatrixCheckedInstructionsINTEL = 6192 CooperativeMatrixLoadCheckedINTEL = 6193 CooperativeMatrixStoreCheckedINTEL = 6194 Original commit: KhronosGroup/SPIRV-LLVM-Translator@b62cb55
[Spec] fix urKernelSuggestMaxCooperativeGroupCountExp
[Spec] fix urKernelSuggestMaxCooperativeGroupCountExp
This PR is the draft patch to enable default device library linking in DPCPP program compiling. The basic idea is:
After doing this, we will simplify the usage of device library. Supposing we have a source file requiring std::complex math in SYCL device, previous building command:
clang++ -fsycl -c test_complex.cpp -o test_complex.o
clang++ -fsycl test_complex.o $sycl_lib_path/libsycl-cmath.o $sycl_lib_path/libsycl-complex.o -o test_complex.out
Now, the building command is:
clang++ -fsycl test_complex.cpp -o test_complex.out
Both jit compilation and AOT are supported and for jit, only "wrapper" libraries are linked as default, for AOT, "wrapper" and "fallback" libraries are linked as default.
Currently, the default linking is not enabled for NVPTX and intelfpga mode because: (1).there are not strong requirement; (2). I don't have environment for testing.
Thank you very much.