MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / sort0ByKeyIterative

Function sort0ByKeyIterative

src/backend/opencl/kernel/sort_by_key_impl.hpp:88–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86
87template<typename Tk, typename Tv>
88void sort0ByKeyIterative(Param pKey, Param pVal, bool isAscending) {
89 compute::command_queue c_queue(getQueue()());
90
91 compute::buffer pKey_buf((*pKey.data)());
92 compute::buffer pVal_buf((*pVal.data)());
93
94 for (int w = 0; w < pKey.info.dims[3]; w++) {
95 int pKeyW = w * pKey.info.strides[3];
96 int pValW = w * pVal.info.strides[3];
97 for (int z = 0; z < pKey.info.dims[2]; z++) {
98 int pKeyWZ = pKeyW + z * pKey.info.strides[2];
99 int pValWZ = pValW + z * pVal.info.strides[2];
100 for (int y = 0; y < pKey.info.dims[1]; y++) {
101 int pKeyOffset = pKeyWZ + y * pKey.info.strides[1];
102 int pValOffset = pValWZ + y * pVal.info.strides[1];
103
104 compute::buffer_iterator<type_t<Tk>> start =
105 compute::make_buffer_iterator<type_t<Tk>>(pKey_buf,
106 pKeyOffset);
107 compute::buffer_iterator<type_t<Tk>> end =
108 compute::make_buffer_iterator<type_t<Tk>>(
109 pKey_buf, pKeyOffset + pKey.info.dims[0]);
110 compute::buffer_iterator<type_t<Tv>> vals =
111 compute::make_buffer_iterator<type_t<Tv>>(pVal_buf,
112 pValOffset);
113 if (isAscending) {
114 compute::sort_by_key(start, end, vals, c_queue);
115 } else {
116 compute::sort_by_key(start, end, vals,
117 compute::greater<type_t<Tk>>(),
118 c_queue);
119 }
120 }
121 }
122 }
123
124 CL_DEBUG_FINISH(getQueue());
125}
126
127template<typename Tk_, typename Tv_>
128void sortByKeyBatched(Param pKey, Param pVal, const int dim, bool isAscending) {

Callers

nothing calls this directly

Calls 2

getQueueFunction · 0.50
sort_by_keyFunction · 0.50

Tested by

no test coverage detected