forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tests after move of Scheduler out of Basic (intel#38)
- Loading branch information
1 parent
c9eb12f
commit 4a54111
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,76 @@ | ||
//==------------------- helpers.hpp - test helpers ------------------------==// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
|
||
using namespace cl; | ||
|
||
template <class VecT, int EndIdx = VecT::get_count(), int StartIdx = 0> | ||
class VecPrinter { | ||
public: | ||
VecPrinter(const VecT &Vec) : MVec(Vec) {} | ||
|
||
void print(std::ostream &Out) const { | ||
std::cout << "[ "; | ||
printHelper<StartIdx>(Out, MVec); | ||
std::cout << " ]"; | ||
} | ||
|
||
static void print(const VecT &Elem1) { | ||
std::cout << "[ "; | ||
printHelper<StartIdx>(std::cout, Elem1); | ||
std::cout << " ]"; | ||
} | ||
|
||
private: | ||
template <int Idx> | ||
static void printHelper(std::ostream &Out, const VecT &Elem1) { | ||
std::cout << (typename VecT::element_type)(Elem1.template swizzle<Idx>()); | ||
if (Idx + 1 != EndIdx) | ||
std::cout << ", "; | ||
printHelper<Idx + 1>(Out, Elem1); | ||
} | ||
template <> | ||
static void printHelper<EndIdx>(std::ostream &Out, const VecT &Elem1) {} | ||
|
||
VecT MVec; | ||
}; | ||
|
||
template <class VecT, int EndIdx = VecT::get_count(), int StartIdx = 0> | ||
VecPrinter<VecT, EndIdx, StartIdx> printableVec(const VecT &Vec) { | ||
return VecPrinter<VecT, EndIdx, StartIdx>(Vec); | ||
} | ||
|
||
template <class VecT, int EndIdx, int StartIdx> | ||
std::ostream &operator<<(std::ostream &Out, | ||
const VecPrinter<VecT, EndIdx, StartIdx> &VecP) { | ||
VecP.print(Out); | ||
return Out; | ||
} | ||
|
||
class TestQueue : public sycl::queue { | ||
public: | ||
TestQueue(const sycl::device_selector &DevSelector, | ||
const sycl::property_list &PropList = {}) | ||
: sycl::queue(DevSelector, | ||
[](sycl::exception_list ExceptionList) { | ||
for (sycl::exception_ptr_class ExceptionPtr : | ||
ExceptionList) { | ||
try { | ||
std::rethrow_exception(ExceptionPtr); | ||
} catch (sycl::exception &E) { | ||
std::cerr << E.what() << std::endl; | ||
} | ||
} | ||
abort(); | ||
}, | ||
PropList) {} | ||
|
||
~TestQueue() { wait_and_throw(); } | ||
}; |