forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsampler_ocl.cpp
More file actions
56 lines (48 loc) · 1.83 KB
/
sampler_ocl.cpp
File metadata and controls
56 lines (48 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// REQUIRES: opencl, opencl_icd
// RUN: %{build} -D__SYCL_INTERNAL_API -o %t.out %opencl_lib
// RUN: %{run} %t.out
//==--------------- sampler.cpp - SYCL sampler basic 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
//
//===----------------------------------------------------------------------===//
#include <cassert>
#include <sycl/context.hpp>
#include <sycl/detail/core.hpp>
namespace sycl {
using namespace sycl;
}
int main() {
sycl::queue Queue;
sycl::sampler B(sycl::coordinate_normalization_mode::unnormalized,
sycl::addressing_mode::clamp, sycl::filtering_mode::nearest);
// OpenCL sampler
cl_int Err = CL_SUCCESS;
#ifdef CL_VERSION_2_0
const cl_sampler_properties sprops[] = {
CL_SAMPLER_NORMALIZED_COORDS,
static_cast<cl_sampler_properties>(true),
CL_SAMPLER_ADDRESSING_MODE,
static_cast<cl_sampler_properties>(CL_ADDRESS_REPEAT),
CL_SAMPLER_FILTER_MODE,
static_cast<cl_sampler_properties>(CL_FILTER_LINEAR),
0};
cl_sampler ClSampler =
clCreateSamplerWithProperties(Queue.get_context().get(), sprops, &Err);
#else
cl_sampler ClSampler =
clCreateSampler(Queue.get_context().get(), true, CL_ADDRESS_REPEAT,
CL_FILTER_LINEAR, &Err);
#endif
// If device doesn't support sampler - skip it
if (Err == CL_INVALID_OPERATION)
return 0;
assert(Err == CL_SUCCESS);
B = sycl::sampler(ClSampler, Queue.get_context());
assert(B.get_addressing_mode() == sycl::addressing_mode::repeat);
assert(B.get_coordinate_normalization_mode() ==
sycl::coordinate_normalization_mode::normalized);
assert(B.get_filtering_mode() == sycl::filtering_mode::linear);
}