当前位置:网站首页>[openvx] VX for basic use of objects_ distribution
[openvx] VX for basic use of objects_ distribution
2022-07-28 03:39:00 【zhy29563】
1. Program source code
#include <iostream>
#include <VX/vx.h>
void print_distribution(vx_distribution distribution, const char *message)
{
std::cout << "===============================" << std::endl;
std::cout << message << std::endl;
vx_size dimensions;
vxQueryDistribution(distribution, (vx_enum)VX_DISTRIBUTION_DIMENSIONS, &dimensions, sizeof(dimensions));
vx_int32 offset;
vxQueryDistribution(distribution, (vx_enum)VX_DISTRIBUTION_OFFSET, &offset, sizeof(offset));
vx_uint32 range; // Need to be for bins Multiple
vxQueryDistribution(distribution, (vx_enum)VX_DISTRIBUTION_RANGE, &range, sizeof(range));
vx_size bins; // BIN The number of
vxQueryDistribution(distribution, (vx_enum)VX_DISTRIBUTION_BINS, &bins, sizeof(bins));
vx_uint32 window; // BIN Width window=RANGE/BINS
vxQueryDistribution(distribution, (vx_enum)VX_DISTRIBUTION_WINDOW, &window, sizeof(window));
vx_size size; // Total bytes
vxQueryDistribution(distribution, (vx_enum)VX_DISTRIBUTION_SIZE, &size, sizeof(size));
std::cout << "dimensions : " << dimensions << std::endl;
std::cout << "offset : " << offset << std::endl;
std::cout << "range : " << range << std::endl;
std::cout << "bins : " << bins << std::endl;
std::cout << "window : " << window << std::endl;
std::cout << "size : " << size << std::endl;
vx_map_id map_id;
void* ptr;
// The output address is vx_uint32 Array of , The number of VX_DISTRIBUTION_BINS The return value of
std::cout << "item : " << std::endl;
vxMapDistribution(distribution, &map_id, &ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST, 0);
for (int i = 0; i < bins; ++i) {
std::cout << "\t" << "index: " << i << ", value: " << ((vx_uint32*)ptr)[i] << std::endl;
}
vxUnmapDistribution(distribution, map_id);
}
int main(int argc, char *argv[])
{
(void) argc;
(void) argv;
vx_status status;
vx_context context = vxCreateContext();
vx_size bins = 64;
vx_uint32 offset = 0U;
vx_uint32 range = 256U;
vx_distribution distribution = vxCreateDistribution(context, bins, offset, range);
print_distribution(distribution, "create");
vx_uint32* array = new vx_uint32 [bins];
for (int i = 0; i < bins; ++i) {
array[i] = i;
}
vxCopyDistribution(distribution, array, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
print_distribution(distribution, "update");
delete[] array;
vxReleaseDistribution(&distribution);
vxReleaseContext(&context);
return EXIT_SUCCESS;
}
2. Running results
===============================
create
dimensions : 1
offset : 0
range : 256
bins : 64
window : 4
size : 256
item :
index: 0, value: 0
index: 1, value: 0
index: 2, value: 0
index: 3, value: 0
index: 4, value: 0
index: 5, value: 0
index: 6, value: 0
index: 7, value: 0
index: 8, value: 0
index: 9, value: 0
index: 10, value: 0
index: 11, value: 0
index: 12, value: 0
index: 13, value: 0
index: 14, value: 0
index: 15, value: 0
index: 16, value: 0
index: 17, value: 0
index: 18, value: 0
index: 19, value: 0
index: 20, value: 0
index: 21, value: 0
index: 22, value: 0
index: 23, value: 0
index: 24, value: 0
index: 25, value: 0
index: 26, value: 0
index: 27, value: 0
index: 28, value: 0
index: 29, value: 0
index: 30, value: 0
index: 31, value: 0
index: 32, value: 0
index: 33, value: 0
index: 34, value: 0
index: 35, value: 0
index: 36, value: 0
index: 37, value: 0
index: 38, value: 0
index: 39, value: 0
index: 40, value: 0
index: 41, value: 0
index: 42, value: 0
index: 43, value: 0
index: 44, value: 0
index: 45, value: 0
index: 46, value: 0
index: 47, value: 0
index: 48, value: 0
index: 49, value: 0
index: 50, value: 0
index: 51, value: 0
index: 52, value: 0
index: 53, value: 0
index: 54, value: 0
index: 55, value: 0
index: 56, value: 0
index: 57, value: 0
index: 58, value: 0
index: 59, value: 0
index: 60, value: 0
index: 61, value: 0
index: 62, value: 0
index: 63, value: 0
===============================
update
dimensions : 1
offset : 0
range : 256
bins : 64
window : 4
size : 256
item :
index: 0, value: 0
index: 1, value: 1
index: 2, value: 2
index: 3, value: 3
index: 4, value: 4
index: 5, value: 5
index: 6, value: 6
index: 7, value: 7
index: 8, value: 8
index: 9, value: 9
index: 10, value: 10
index: 11, value: 11
index: 12, value: 12
index: 13, value: 13
index: 14, value: 14
index: 15, value: 15
index: 16, value: 16
index: 17, value: 17
index: 18, value: 18
index: 19, value: 19
index: 20, value: 20
index: 21, value: 21
index: 22, value: 22
index: 23, value: 23
index: 24, value: 24
index: 25, value: 25
index: 26, value: 26
index: 27, value: 27
index: 28, value: 28
index: 29, value: 29
index: 30, value: 30
index: 31, value: 31
index: 32, value: 32
index: 33, value: 33
index: 34, value: 34
index: 35, value: 35
index: 36, value: 36
index: 37, value: 37
index: 38, value: 38
index: 39, value: 39
index: 40, value: 40
index: 41, value: 41
index: 42, value: 42
index: 43, value: 43
index: 44, value: 44
index: 45, value: 45
index: 46, value: 46
index: 47, value: 47
index: 48, value: 48
index: 49, value: 49
index: 50, value: 50
index: 51, value: 51
index: 52, value: 52
index: 53, value: 53
index: 54, value: 54
index: 55, value: 55
index: 56, value: 56
index: 57, value: 57
index: 58, value: 58
index: 59, value: 59
index: 60, value: 60
index: 61, value: 61
index: 62, value: 62
index: 63, value: 63
边栏推荐
- Assembly method of golang Gorm query arbitrary fields
- LabVIEW loads and uses custom symbols in tree control projects
- ES6 from entry to mastery 07: Deconstruction assignment
- 【论文笔记】基于深度学习的移动机器人自主导航实验平台
- 4-day excel practical training camp, 0.01 yuan special offer for only three days, 200 sets of learning kits
- What is tor? What is the use of tor browser update?
- 【P4】 查看库文件两个历史版本的区别
- CF question making record from July 25th to July 31st
- ES6 from getting started to mastering 09: symbol type
- Leetcode 29th day
猜你喜欢
![2022-07-27: Xiao Hong got an array arr with a length of N. she is going to modify it only once. She can modify any number arr[i] in the array to a positive number not greater than P (the modified numb](/img/24/fbf63272f83b932e0ee953f8d4db75.png)
2022-07-27: Xiao Hong got an array arr with a length of N. she is going to modify it only once. She can modify any number arr[i] in the array to a positive number not greater than P (the modified numb

8000字讲透OBSA原理与应用实践

MySQL Basics (create, manage, add, delete, and modify tables)

Integrate SSM to realize search of addition, deletion, modification and query

动态规划——509. 斐波那契数

C语言实现动态版本的通讯录

AI chief architect 12 AICA Baidu OCR vertical large-scale landing practice

How to solve the problem of win11 black desktop background?

C language to achieve a dynamic version of the address book

Leetcode brush question: dynamic planning 09 (weight of the last stone II)
随机推荐
In December, the PMP Exam adopted the new syllabus for the first time. How to learn?
An article grasps the calculation and processing of date data in PostgreSQL
After reading MySQL database advanced practice (SQL xiaoxuzhu)
Leetcode skimming: dynamic programming 08 (segmentation and subsets)
Shell: resource monitoring script and high load alarm
Version compatibility issues
8000字讲透OBSA原理与应用实践
Redis source code analysis (who says C language can't analyze it?)
【P4】解决本地文件修改与库文件间的冲突问题
pip-script.py‘ is not present Verifying transaction: failed
Shell: one click deployment PXE
Billions of asset addresses are blacklisted? How to use the tether address freezing function?
Asemi rectifier bridge gbpc5010, gbpc5010 parameters, gbpc5010 size
[5g NR] RRC reject analysis
Responsive high-end website template source code Gallery material resource download platform source code
服务器内存故障预测居然可以这样做!
Leetcode 29th day
贪心——53. 最大子数组和
【OPENVX】对象基本使用之vx_distribution
玩一玩WolframAlpha计算知识引擎