diff --git a/clang/lib/Driver/ToolChains/VXX.cpp b/clang/lib/Driver/ToolChains/VXX.cpp index f67f1c6f20cf..9d2d7bd5b596 100644 --- a/clang/lib/Driver/ToolChains/VXX.cpp +++ b/clang/lib/Driver/ToolChains/VXX.cpp @@ -248,18 +248,17 @@ void SYCL::SYCLPostLinkVXX::constructSYCLVXXPLCommand( //// V++ Toolchain /////////////////////////////////////////////////////////////////////////////// +static llvm::Triple getLinuxTriple(const llvm::Triple &Triple) { + if (Triple.getArch() == llvm::Triple::vitis_ip) + return llvm::Triple(llvm::sys::getProcessTriple()); + return Triple; +} + VXXToolChain::VXXToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) - : Generic_GCC(D, Triple, Args) { - if (Triple.getArch() == llvm::Triple::vitis_ip) { - /// If we are targeting vitis_ip we cannot rely on sycl setting up the - /// standard library. So we do it ourselves by configuring gcc to find - /// native system libraries. - GCCInstallation.init(llvm::Triple(llvm::sys::getProcessTriple()), Args); - } else { - /// Otherwise we initialize gcc with our triple and gcc will find nothing. - GCCInstallation.init(Triple, Args); - } + : ToolChain(D, Triple, Args) { + InnerTC = + std::make_unique(D, getLinuxTriple(Triple), Args); // Lookup binaries into the driver directory, this is used to // discover the clang-offload-bundler executable. getProgramPaths().push_back(getDriver().Dir); diff --git a/clang/lib/Driver/ToolChains/VXX.h b/clang/lib/Driver/ToolChains/VXX.h index 96061fe88ef6..e47029aee69b 100644 --- a/clang/lib/Driver/ToolChains/VXX.h +++ b/clang/lib/Driver/ToolChains/VXX.h @@ -9,7 +9,7 @@ #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VXX_H #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VXX_H -#include "ToolChains/Gnu.h" +#include "ToolChains/Linux.h" #include "clang/Driver/ToolChain.h" #include "clang/Driver/Tool.h" #include "llvm/ADT/Triple.h" @@ -76,9 +76,10 @@ class LLVM_LIBRARY_VISIBILITY SYCLPostLinkVXX : public Tool { namespace toolchains { -/// The VXXToolChain inherits from Generic_GCC because the logic for detecting -/// and using libstdc++ are inside Generic_GCC -class LLVM_LIBRARY_VISIBILITY VXXToolChain : public Generic_GCC { +/// The VXXToolChain inherits from Linux because the logic for detecting +/// and using libstdc++ are inside Linux +class LLVM_LIBRARY_VISIBILITY VXXToolChain : public ToolChain { + std::unique_ptr InnerTC; public: VXXToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); @@ -107,6 +108,17 @@ class LLVM_LIBRARY_VISIBILITY VXXToolChain : public Generic_GCC { const ToolChain* HostTC; + virtual void + AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override { + InnerTC->AddClangSystemIncludeArgs(DriverArgs, CC1Args); + } + virtual void AddClangCXXStdlibIncludeArgs( + const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override { + InnerTC->AddClangCXXStdlibIncludeArgs(DriverArgs, CC1Args); + } + protected: Tool *buildLinker() const override; virtual Tool *getTool(Action::ActionClass AC) const override; diff --git a/llvm/lib/SYCL/LowerSYCLMetaData.cpp b/llvm/lib/SYCL/LowerSYCLMetaData.cpp index ccbc5aa00009..cb03dff6585f 100644 --- a/llvm/lib/SYCL/LowerSYCLMetaData.cpp +++ b/llvm/lib/SYCL/LowerSYCLMetaData.cpp @@ -269,8 +269,10 @@ struct LSMDState { HasChanged = true; Function *SideEffect = Intrinsic::getDeclaration(&M, Intrinsic::sideeffect); - OperandBundleDef OpBundle( - XclId.str(), std::vector{F->arg_begin(), F->arg_end()}); + std::vector Args; + for (auto &A : F->args()) + Args.push_back(&A); + OperandBundleDef OpBundle(XclId.str(), Args); Instruction *I = CallInst::Create(SideEffect, {}, {OpBundle}); I->insertBefore(F->getEntryBlock().getTerminator()); diff --git a/sycl/plugins/xrt/pi_xrt.cpp b/sycl/plugins/xrt/pi_xrt.cpp index 5858e1ce58a7..767365141afc 100644 --- a/sycl/plugins/xrt/pi_xrt.cpp +++ b/sycl/plugins/xrt/pi_xrt.cpp @@ -330,7 +330,7 @@ to_native_handle(From &&from) { struct _pi_device /// TODO: _pi_device should be ref-counted , but the SYCL runtime -/// seems to be expected piDevicesGet to return objects with a ref-count +/// seems to expect piDevicesGet to return objects with a ref-count /// of 0 so we do not destroy _pi_device for now. /// (https://github.com/intel/llvm/issues/6034) /// : ref_counted_base<_pi_device> @@ -339,7 +339,9 @@ struct _pi_device private: native_type xrtDevice_; - ref_counted_ref<_pi_platform> platform_; + /// _pi_platform holds a counting reference onto all its _pi_device so we do + /// not keep counting reference on devices to prevent circular dependency. + _pi_platform *platform_; public: _pi_device(native_type dev, _pi_platform *platform) @@ -358,18 +360,23 @@ struct _pi_device /// struct _pi_platform : ref_counted_base<_pi_platform>, unique<_pi_platform> { private: - /// _pi_device hold a counting reference onto _pi_platform so we do not keep - /// counting reference on devices to prevent circular dependency. - std::vector<_pi_device*> devices_; + std::vector> devices_; public: + _pi_platform() { + int device_count = xrt::system::enumerate_devices(); + devices_.reserve(device_count); + for (int idx = 0; idx < device_count; idx++) + devices_.emplace_back( + make_ref_counted<_pi_device>(REPRODUCE_CALL(xrt::device, idx), this)); + } unsigned get_num_device() { return devices_.size(); } ref_counted_ref<_pi_device> get_device(unsigned idx) { return devices_[idx]; } /// Add a device if it inst't already in the list template ref_counted_ref<_pi_device> make_device(Ts &&...ts) { auto new_dev = REPRODUCE_CALL(xrt::device, std::forward(ts)...); auto bdf = new_dev.template get_info(); - for (auto *dev : devices_) + for (ref_counted_ref<_pi_device> dev : devices_) if (bdf == dev->get_native().get_info()) return dev; auto dev_ref = make_ref_counted<_pi_device>(std::move(new_dev), this); @@ -704,21 +711,11 @@ pi_result xrt_piDevicesGet(pi_platform platform, pi_device_type device_type, uint32_t *num_devices) { assert_valid_obj(platform); - unsigned device_count = std::max(1, platform->get_num_device()); - if (num_devices) { - *num_devices = device_count; + *num_devices = platform->get_num_device(); } if (devices) { - /// We keep the reference to the device to insure it doesn't get destroyed - /// before re call give_externally - ref_counted_ref<_pi_device> new_device; - - // If the platform is empty add a device - if (platform->get_num_device() == 0) - new_device = platform->make_device(0); - for (size_t i = 0; i < platform->get_num_device(); ++i) devices[i] = platform->get_device(i).give_externally(); } diff --git a/sycl/test/vitis/simple_tests/vitis_ip_export.cpp b/sycl/test/vitis/simple_tests/vitis_ip_export.cpp index 0143c5fe7622..d63e124bf186 100644 --- a/sycl/test/vitis/simple_tests/vitis_ip_export.cpp +++ b/sycl/test/vitis/simple_tests/vitis_ip_export.cpp @@ -3,7 +3,7 @@ // RUN: %clangxx -std=c++20 --target=vitis_ip-xilinx %s -o %t.zip --vitis-ip-part=xc7vx330t-ffg1157-1 -### 2>&1 | FileCheck %s // RUN: %clangxx -std=c++20 --target=vitis_ip-xilinx %s -o %t.zip --vitis-ip-part=xc7vx330t-ffg1157-1 -// CHECK: clang-{{.*}}"-cc1" "-triple" "vitis_ip-xilinx" "-O3" "-disable-llvm-passes" {{.*}} "-emit-llvm" +// CHECK: clang-{{.*}}"-cc1" "-triple" "vitis_ip-xilinx" "-O3" "-disable-llvm-passes" {{.*}} // CHECK-NEXT: sycl_vxx.py" "ipexport" "--clang_path" {{.*}} "--target" "xc7vx330t-ffg1157-1" // CHECK-NOT: clang diff --git a/sycl/tools/CMakeLists.txt b/sycl/tools/CMakeLists.txt index 5c1b63aa0387..ebe07b2472ed 100644 --- a/sycl/tools/CMakeLists.txt +++ b/sycl/tools/CMakeLists.txt @@ -67,7 +67,7 @@ if(SYCL_BUILD_PI_HIP) ${SYCL_BUILD_PI_HIP_INCLUDE_DIR}) endif() -if(SYCL_BUILD_PI_HIP) +if(SYCL_BUILD_PI_XRT) target_include_directories(get_device_count_by_type PRIVATE ${XILINX_RT_INCLUDE})