当前位置:网站首页>CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1
CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1
2022-07-05 04:31:00 【Stanford rabbit】
problem : Atomic manipulation atomicAdd() Report errors err:MSB3721, Return code 1.
Problem description : Today, I am writing and using cuda Accelerate the calculation of normal direction related code after 3D point cloud reconstruction , One step is to calculate the average point distance after counting the point cloud distance . This requires multiple threads to add the distance between different points and adjacent points , Then divide by the number of points .
But without atomic operation atomicAdd() Words , The addition result will inevitably make mistakes . Be similar to OpenMP In parallel for The principle of loop locking the addition variable to ensure the correct addition of variables .
But because of Dot distance is double type , Ignorant I use it directly atomicAdd() Adding dots causes compilation errors err:MSB3721, Return code 1, After searching the official documents, I learned , For double precision double Type of atomic operation atomicAdd(), Only in The computing power is greater than 6.0 On the machine that supports , For my computing power, only 3.5 Old age machine GT720, Unable to compile successfully . So far, the final reason has been found . Look at the Yellow characters .
Direct cause : Double precision double The atomic operation of is done only when the computing power is 6.0 The above devices support , But my equipment is too LOW.
Solution : But the government also gave us this kind of old GPU The way to live , Using the code in the figure, the computing power can be less than 6.0 The device performs double precision double Atomic manipulation .
【 Be careful : Copy the following code , Don't use the official website code directly , Otherwise, the redefinition operator will report an error 】
#if define (__CUDA_ARCH__)||__CUDA_ARCH__ < 600
__device__ double atomicAdd(double* address, double val)
{
unsigned long long int* address_as_ull =
(unsigned long long int*)address;
unsigned long long int old = *address_as_ull, assumed;
do {
assumed = old;
old = atomicCAS(address_as_ull, assumed,
__double_as_longlong(val +
__longlong_as_double(assumed)));
// Note: uses integer comparison to avoid hang in case of NaN (since NaN != NaN)
} while (assumed != old);
return __longlong_as_double(old);
}
#endif
If this method can be used , Please pay attention to a favorite collection !
边栏推荐
- Threejs Internet of things, 3D visualization of farm (III) model display, track controller setting, model moving along the route, model adding frame, custom style display label, click the model to obt
- Function (error prone)
- 如何优雅的获取每个分组的前几条数据
- 函数(基本:参数,返回值)
- Sequelize. JS and hasmany - belongsto vs hasmany in serialize js
- Fuel consumption calculator
- American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
- 美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
- WeNet:面向工业落地的E2E语音识别工具
- Common features of ES6
猜你喜欢
Common features of ES6
Web开发人员应该养成的10个编程习惯
可观测|时序数据降采样在Prometheus实践复盘
Advanced length of redis -- deletion strategy, master-slave replication, sentinel mode
【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
Construction d'un Cluster redis sous Windows
Hypothesis testing -- learning notes of Chapter 8 of probability theory and mathematical statistics
How can CIOs use business analysis to build business value?
随机推荐
Looking back on 2021, looking forward to 2022 | a year between CSDN and me
The remainder operation is a hash function
[Chongqing Guangdong education] 2408t Chinese contemporary literature reference test in autumn 2018 of the National Open University
Fuel consumption calculator
揭秘技术 Leader 必备的七大清奇脑回路
web资源部署后navigator获取不到mediaDevices实例的解决方案(navigator.mediaDevices为undefined)
直播預告 | 容器服務 ACK 彈性預測最佳實踐
Aperçu en direct | Services de conteneurs ACK flexible Prediction Best Practices
【UNIAPP】系统热更新实现思路
Introduction to RT thread kernel (4) -- clock management
level17
Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
Web开发人员应该养成的10个编程习惯
解密函数计算异步任务能力之「任务的状态及生命周期管理」
A application wakes up B should be a fast method
Ctfshow 2022 Spring Festival welcome (detailed commentary)
Pointer function (basic)
概率论与数理统计考试重点复习路线
About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture
Leetcode hot topic Hot 100 day 33: "subset"