Skip to content

Commit

Permalink
Merge from 'sycl' to 'sycl-web' (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
iclsrc committed Oct 25, 2019
2 parents fc89011 + 84992a5 commit a8fe49f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
21 changes: 11 additions & 10 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3309,7 +3309,7 @@ class OffloadingActionBuilder final {
if (auto *IA = dyn_cast<InputAction>(HostAction)) {
SYCLDeviceActions.clear();

std::string InputName = IA->getInputArg().getValue();
std::string InputName = IA->getInputArg().getAsString(Args);
// Objects should already be consumed with -foffload-static-lib
if (Args.hasArg(options::OPT_foffload_static_lib_EQ) &&
IA->getType() == types::TY_Object && isObjectFile(InputName))
Expand Down Expand Up @@ -3791,7 +3791,7 @@ class OffloadingActionBuilder final {
if (CanUseBundler && isa<InputAction>(HostAction) &&
InputArg->getOption().getKind() == llvm::opt::Option::InputClass &&
!types::isSrcFile(HostAction->getType())) {
std::string InputName = InputArg->getValue();
std::string InputName = InputArg->getAsString(Args);
// Do not create an unbundling action for an object when we know a fat
// static library is being used. A separate unbundling action is created
// for all objects and the fat static library.
Expand Down Expand Up @@ -5963,12 +5963,13 @@ bool clang::driver::isOptimizationLevelFast(const ArgList &Args) {
}

bool clang::driver::isObjectFile(std::string FileName) {
if (llvm::sys::path::has_extension(FileName)) {
std::string Ext(llvm::sys::path::extension(FileName).drop_front());
// We cannot rely on lookupTypeForExtension solely as that has 'lib'
// marked as an object.
return (Ext != "lib" &&
types::lookupTypeForExtension(Ext) == types::TY_Object);
}
return false;
if (!llvm::sys::path::has_extension(FileName))
// Any file with no extension should be considered an Object. Take into
// account -lsomelib library filenames.
return FileName.rfind("-l", 0) != 0;
std::string Ext(llvm::sys::path::extension(FileName).drop_front());
// We cannot rely on lookupTypeForExtension solely as that has 'lib'
// marked as an object.
return (Ext != "lib" &&
types::lookupTypeForExtension(Ext) == types::TY_Object);
}
8 changes: 6 additions & 2 deletions clang/test/Driver/sycl-offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,13 @@
/// Check separate compilation with offloading - unbundling actions
// RUN: touch %t.o
// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -o %t.out -lsomelib -fsycl-targets=spir64-unknown-linux-sycldevice %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-UBACTIONS %s
// RUN: | FileCheck -DINPUT=%t.o -check-prefix=CHK-UBACTIONS %s
// RUN: mkdir -p %t_dir
// RUN: touch %t_dir/dummy
// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -o %t.out -lsomelib -fsycl-targets=spir64-unknown-linux-sycldevice %t_dir/dummy 2>&1 \
// RUN: | FileCheck -DINPUT=%t_dir/dummy -check-prefix=CHK-UBACTIONS %s
// CHK-UBACTIONS: 0: input, "somelib", object, (host-sycl)
// CHK-UBACTIONS: 1: input, "[[INPUT:.+\.o]]", object, (host-sycl)
// CHK-UBACTIONS: 1: input, "[[INPUT]]", object, (host-sycl)
// CHK-UBACTIONS: 2: clang-offload-unbundler, {1}, object, (host-sycl)
// CHK-UBACTIONS: 3: linker, {0, 2}, image, (host-sycl)
// CHK-UBACTIONS: 4: linker, {2}, spirv, (device-sycl)
Expand Down
1 change: 1 addition & 0 deletions llvm-spirv/lib/SPIRV/libSPIRV/SPIRVStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "SPIRVExtInst.h"
#include "SPIRVModule.h"
#include <algorithm>
#include <cctype>
#include <cstdint>
#include <iostream>
#include <iterator>
Expand Down
7 changes: 2 additions & 5 deletions sycl/test/basic_tests/half_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,7 @@ inline bool bitwise_comparison_fp32(const half val, const uint32_t exp) {
}

int main() {
// We assert that the length is 1 because we use env to select the device
assert(device::get_devices().size() == 1);

auto dev = device::get_devices()[0];
device dev{default_selector()};
if (!dev.is_host() && !dev.has_extension("cl_khr_fp16")) {
std::cout << "This device doesn't support the extension cl_khr_fp16"
<< std::endl;
Expand All @@ -210,7 +207,7 @@ int main() {
buffer<half, 1> a{vec_a.data(), r};
buffer<half, 1> b{vec_b.data(), r};

queue q;
queue q {dev};

verify_add(q, a, b, r, 7.0);
verify_min(q, a, b, r, 3.0);
Expand Down

0 comments on commit a8fe49f

Please sign in to comment.