spla
Loading...
Searching...
No Matches
auto_count.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_count[] = R"(
9
10
11__kernel void count_nz(__global const TYPE* g_vec,
12 __global uint* g_count,
13 const uint n) {
14 const uint gid = get_global_id(0);
15 const uint gsize = get_global_size(0);
16 uint count = 0;
17
18 for (uint i = gid; i < n; i += gsize) {
19 if (g_vec[i] != 0) {
20 count += 1;
21 }
22 }
23
24 atomic_add(g_count, count);
25}
26
27__kernel void count_mf(__global const TYPE* g_vec,
28 __global uint* g_count,
29 const uint n,
30 const TYPE ref) {
31 const uint gid = get_global_id(0);
32 const uint gsize = get_global_size(0);
33 uint count = 0;
34
35 for (uint i = gid; i < n; i += gsize) {
36 if (g_vec[i] != ref) {
37 count += 1;
38 }
39 }
40
41 atomic_add(g_count, count);
42}
43)";