NetDEM v1.0
Loading...
Searching...
No Matches
webgpu_prefix_sum.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <webgpu/webgpu.hpp>
5
6namespace netdem {
7namespace webgpu {
8
9class PrefixSum {
10public:
11 PrefixSum(wgpu::Device &device);
12
13 void Init(wgpu::Device &device);
14
15 void Solve(wgpu::Buffer buffer_src, wgpu::Buffer buffer_dst,
16 size_t array_size);
17
18private:
19 wgpu::Device &device;
20 wgpu::BindGroupLayout bg_layout;
21 wgpu::ComputePipeline cmp_pl_prefix_sum_sub;
22 wgpu::ComputePipeline cmp_pl_add_block_sums;
23
24 void Init();
25
26 void InitBindGroupLayout();
27 wgpu::BindGroup GetBindGroup(wgpu::Buffer buffer_data_src,
28 wgpu::Buffer buffer_presum_src,
29 wgpu::Buffer buffer_dst, size_t offset_data_src,
30 size_t offset_presum_src, size_t offset_dst,
31 size_t array_size_src, size_t array_size_dst);
32 void InitPipeline();
33
34 void PrefixSumSub(wgpu::Buffer buffer_data_src,
35 wgpu::Buffer buffer_presum_src, wgpu::Buffer buffer_dst,
36 size_t offset_data_src, size_t offset_presum_src,
37 size_t offset_dst, size_t array_size_src,
38 size_t array_size_dst, wgpu::ComputePassEncoder cmp_pass);
39
40 void AddBlockSums(wgpu::Buffer buffer_data_src,
41 wgpu::Buffer buffer_presum_src, wgpu::Buffer buffer_dst,
42 size_t offset_data_src, size_t offset_presum_src,
43 size_t offset_dst, size_t array_size_src,
44 size_t array_size_dst, wgpu::ComputePassEncoder cmp_pass);
45
46 const size_t workgroup_size = 256;
47 const size_t ele_size = sizeof(u_int32_t);
48 const size_t align_size = 256 / ele_size;
49};
50
51} // namespace webgpu
52} // namespace netdem
Definition webgpu_prefix_sum.hpp:9
void Init(wgpu::Device &device)
void Solve(wgpu::Buffer buffer_src, wgpu::Buffer buffer_dst, size_t array_size)
Definition webgpu_prefix_sum.cpp:17
PrefixSum(wgpu::Device &device)
Definition webgpu_prefix_sum.cpp:10
Definition bond_entry.hpp:7