spla
Loading...
Searching...
No Matches
auto_vxm.hpp
Go to the documentation of this file.
1
2// Copyright (c) 2021 - 2023 SparseLinearAlgebra
3// Autogenerated file, do not modify
5
6#pragma once
7
8static const char source_vxm[] = R"(
9
10
11__kernel void vxm_sparse_count(__global const uint* g_vi,
12 __global const TYPE* g_vx,
13 __global const uint* g_Ap,
14 __global const uint* g_Aj,
15 __global const TYPE* g_mask,
16 __global uint* g_size,
17 const uint n) {
18 const uint gid = get_global_id(0); // id of v entry to touch
19 const uint gstride = get_global_size(0);// step between v entries
20
21 for (int idx = gid; idx < n; idx += gstride) {
22 const uint vi = g_vi[idx];
23 const TYPE vx = g_vx[idx];
24
25 const uint start = g_Ap[vi];
26 const uint end = g_Ap[vi + 1];
27
28 uint count = 0;
29
30 for (uint i = start; i < end; i++) {
31 if (OP_SELECT(g_mask[g_Aj[i]])) count += 1;
32 }
33
34 atomic_add(g_size, count);
35 }
36}
37
38__kernel void vxm_sparse_collect(__global const uint* g_vi,
39 __global const TYPE* g_vx,
40 __global const uint* g_Ap,
41 __global const uint* g_Aj,
42 __global const TYPE* g_Ax,
43 __global const TYPE* g_mask,
44 __global uint* g_ri,
45 __global TYPE* g_rx,
46 __global uint* g_roffset,
47 const uint n) {
48 const uint gid = get_global_id(0); // id of v entry to touch
49 const uint gstride = get_global_size(0);// step between v entries
50
51 for (int idx = gid; idx < n; idx += gstride) {
52 const uint vi = g_vi[idx];
53 const TYPE vx = g_vx[idx];
54
55 const uint start = g_Ap[vi];
56 const uint end = g_Ap[vi + 1];
57
58 uint count = 0;
59
60 for (uint i = start; i < end; i++) {
61 if (OP_SELECT(g_mask[g_Aj[i]])) count += 1;
62 }
63
64 uint offset = atomic_add(g_roffset, count);
65
66 for (uint i = start; i < end; i++) {
67 const uint col_id = g_Aj[i];
68
69 if (OP_SELECT(g_mask[col_id])) {
70 g_ri[offset] = col_id;
71 g_rx[offset] = OP_BINARY1(vx, g_Ax[i]);
72 offset += 1;
73 }
74 }
75 }
76}
77)";