MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / operator()

Method operator()

src/backend/oneapi/kernel/assign.hpp:54–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 , nBBS1_(nBBS1) {}
53
54 void operator()(sycl::nd_item<2> it) const {
55 // retrive booleans that tell us which index to use
56 const bool s0 = p_.isSeq[0];
57 const bool s1 = p_.isSeq[1];
58 const bool s2 = p_.isSeq[2];
59 const bool s3 = p_.isSeq[3];
60
61 sycl::group g = it.get_group();
62 const int gz = g.get_group_id(0) / nBBS0_;
63 const int gw = g.get_group_id(1) / nBBS1_;
64 const int gx =
65 g.get_local_range(0) * (g.get_group_id(0) - gz * nBBS0_) +
66 it.get_local_id(0);
67 const int gy =
68 g.get_local_range(1) * (g.get_group_id(1) - gw * nBBS1_) +
69 it.get_local_id(1);
70
71 size_t idims0 = iInfo_.dims[0];
72 size_t idims1 = iInfo_.dims[1];
73 size_t idims2 = iInfo_.dims[2];
74 size_t idims3 = iInfo_.dims[3];
75
76 if (gx < idims0 && gy < idims1 && gz < idims2 && gw < idims3) {
77 // calculate pointer offsets for input
78 int i =
79 p_.strds[0] *
80 trimIndex(s0 ? gx + p_.offs[0] : p_.ptr[0][gx], oInfo_.dims[0]);
81 int j =
82 p_.strds[1] *
83 trimIndex(s1 ? gy + p_.offs[1] : p_.ptr[1][gy], oInfo_.dims[1]);
84 int k =
85 p_.strds[2] *
86 trimIndex(s2 ? gz + p_.offs[2] : p_.ptr[2][gz], oInfo_.dims[2]);
87 int l =
88 p_.strds[3] *
89 trimIndex(s3 ? gw + p_.offs[3] : p_.ptr[3][gw], oInfo_.dims[3]);
90
91 const T* iptr = in_.get_pointer();
92 // offset input and output pointers
93 const T* src =
94 iptr + (gx * iInfo_.strides[0] + gy * iInfo_.strides[1] +
95 gz * iInfo_.strides[2] + gw * iInfo_.strides[3] +
96 iInfo_.offset);
97
98 T* optr = out_.get_pointer();
99 T* dst = optr + (i + j + k + l) + oInfo_.offset;
100 // set the output
101 dst[0] = src[0];
102 }
103 }
104
105 protected:
106 write_accessor<T> out_;

Callers

nothing calls this directly

Calls 1

trimIndexFunction · 0.70

Tested by

no test coverage detected