-
Notifications
You must be signed in to change notification settings - Fork 790
[Driver][SYCL] Provide ability to use an external host compiler #3530
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
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fa29b9b
[Driver][SYCL] Provide ability to use an external host compiler
mdtoguchi 972a6ed
Clang format
mdtoguchi f38a286
Address review comments
mdtoguchi aefc45a
Address additional review comments
mdtoguchi 571e8df
Adjust how to determine using MSVC type compiler
mdtoguchi bc068dd
Address review comments from Artem
mdtoguchi 2ff9dfd
Add additional option test for cl type host compilers
mdtoguchi 7d81f75
Improve error handling for missing compiler arg
mdtoguchi a68debe
Add E2E test
mdtoguchi b998d30
Update test to use -fsycl-host-compiler-options
mdtoguchi 2d66de2
Add E2E for Windows
mdtoguchi b39f7ab
Add sycl default library to link when using -fsycl-host-compiler for …
mdtoguchi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Tests the abilities involved with using an external host compiler | ||
// REQUIRES: clang-driver | ||
|
||
/// enabling with -fsycl-host-compiler | ||
// RUN: %clangxx -fsycl -fsycl-host-compiler=/some/dir/g++ %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_COMPILER %s | ||
// HOST_COMPILER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" | ||
// HOST_COMPILER: g++{{.*}} "-I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"{{.*}} "-o" "[[HOSTOBJ:.+\.o]]"{{.*}} "-include" "[[INTHEADER]]" | ||
// HOST_COMPILER: ld{{.*}} "[[HOSTOBJ]]" | ||
|
||
// RUN: %clang_cl -fsycl -fsycl-host-compiler=/some/dir/cl %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_COMPILER_CL %s | ||
// HOST_COMPILER_CL: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" | ||
// HOST_COMPILER_CL: cl{{.*}} "-Fo[[HOSTOBJ:.+\.obj]]"{{.*}} "-I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"{{.*}} "-FI" "[[INTHEADER]]" | ||
// HOST_COMPILER_CL: link{{.*}} "[[HOSTOBJ]]" | ||
|
||
/// check for additional host options | ||
// RUN: %clangxx -fsycl -fsycl-host-compiler=g++ -fsycl-host-compiler-options="-DFOO -DBAR" %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_OPTIONS %s | ||
// HOST_OPTIONS: g++{{.*}} "-o" "[[HOSTOBJ:.+\.o]]"{{.*}} "-DFOO" "-DBAR" | ||
mdtoguchi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// RUN: %clang_cl -fsycl -fsycl-host-compiler=cl -fsycl-host-compiler-options="/DFOO /DBAR /O2" %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_OPTIONS_CL %s | ||
// HOST_OPTIONS_CL: cl{{.*}} "-Fo[[HOSTOBJ:.+\.obj]]"{{.*}} "/DFOO" "/DBAR" "/O2" | ||
|
||
/// preprocessing | ||
// RUN: %clangxx -fsycl -fsycl-host-compiler=g++ -E %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_PREPROCESS %s | ||
// HOST_PREPROCESS: g++{{.*}} "-E"{{.*}} "-o" "[[PPOUT:.+\.ii]]" | ||
// HOST_PREPROCESS: g++{{.*}} "-E"{{.*}} "-o" "-" | ||
// HOST_PREPROCESS: clang-offload-bundler{{.*}} "-inputs={{.*}}.ii,[[PPOUT]]" | ||
|
||
// RUN: %clang_cl -fsycl -fsycl-host-compiler=cl -E %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_PREPROCESS_CL %s | ||
// HOST_PREPROCESS_CL: cl{{.*}} "-P"{{.*}} "-Fi[[PPOUT:.+\.ii]]" | ||
// HOST_PREPROCESS_CL: cl{{.*}} "-E" | ||
// HOST_PREPROCESS_CL: clang-offload-bundler{{.*}} "-inputs={{.*}}.ii,[[PPOUT]]" | ||
|
||
/// obj output | ||
// RUN: %clangxx -fsycl -fsycl-host-compiler=g++ -c %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_OBJECT %s | ||
// HOST_OBJECT: g++{{.*}} "-c"{{.*}} "-o" "[[OBJOUT:.+\.o]]" | ||
// HOST_OBJECT: clang-offload-bundler{{.*}} "-inputs={{.*}}.bc,[[OBJOUT]]" | ||
|
||
// RUN: %clang_cl -fsycl -fsycl-host-compiler=cl -c %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_OBJECT_CL %s | ||
// HOST_OBJECT_CL: cl{{.*}} "-c"{{.*}} "-Fo[[OBJOUT:.+\.obj]]" | ||
// HOST_OBJECT_CL: clang-offload-bundler{{.*}} "-inputs={{.*}}.bc,[[OBJOUT]]" | ||
|
||
/// assembly output | ||
// RUN: %clangxx -fsycl -fsycl-host-compiler=g++ -S %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_ASSEMBLY %s | ||
// HOST_ASSEMBLY: g++{{.*}} "-S"{{.*}} "-o" "[[ASMOUT:.+\.s]]" | ||
// HOST_ASSEMBLY: clang-offload-bundler{{.*}} "-inputs={{.*}}.bc,[[ASMOUT]]" | ||
|
||
// RUN: %clangxx -fsycl -fsycl-host-compiler=cl -S %s -### 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_ASSEMBLY_CL %s | ||
// HOST_ASSEMBLY_CL: cl{{.*}} "-c"{{.*}} "-Fa[[ASMOUT:.+\.s]]" "-Fo{{.*}}.obj" | ||
// HOST_ASSEMBLY_CL: clang-offload-bundler{{.*}} "-inputs={{.*}}.bc,[[ASMOUT]]" | ||
|
||
/// missing argument error -fsycl-host-compiler= | ||
// RUN: %clangxx -fsycl -fsycl-host-compiler= -c -### %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=HOST_COMPILER_NOARG %s | ||
// HOST_COMPILER_NOARG: missing argument to '-fsycl-host-compiler=' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// RUN: %clang_cl -fsycl -fsycl-host-compiler=cl -DDEFINE_CHECK -fsycl-host-compiler-options="-DDEFINE_CHECK" /Fe%t1.exe %s | ||
// RUN: %RUN_ON_HOST %t1.exe | ||
// REQUIRES: system-windows | ||
// | ||
//==------- fsycl-host-compiler-win.cpp - external host compiler test ------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Uses -fsycl-host-compiler=<compiler> on a simple test, requires 'cl' | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
#ifndef DEFINE_CHECK | ||
#error predefined macro not set | ||
#endif // DEFINE_CHECK | ||
|
||
using namespace cl::sycl; | ||
|
||
int main() { | ||
int data[] = {0, 0, 0}; | ||
|
||
{ | ||
buffer<int, 1> b(data, range<1>(3), {property::buffer::use_host_ptr()}); | ||
queue q; | ||
q.submit([&](handler &cgh) { | ||
auto B = b.get_access<access::mode::write>(cgh); | ||
cgh.parallel_for<class test>(range<1>(3), [=](id<1> idx) { | ||
B[idx] = 1; | ||
}); | ||
}); | ||
} | ||
|
||
bool isSuccess = true; | ||
|
||
for (int i = 0; i < 3; i++) | ||
if (data[i] != 1) isSuccess = false; | ||
|
||
if (!isSuccess) | ||
return -1; | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.