在OpenCL内核的全局内存中读/写(Read/write in Global Memory of an OpenCL Kernel)

编程入门 行业动态 更新时间:2024-10-18 22:35:24
在OpenCL内核的全局内存中读/写(Read/write in Global Memory of an OpenCL Kernel)

我一直关注这个页面,我认为它是一般编程问题的最佳页面之一。

好吧,通常我总是尝试找到解决问题的方法,但现在我认为我需要一些社区的帮助,因为我不知道如何解决我的问题。

我遇到的问题是OpenCL API。 我需要编写一个在“全局内存”中添加一些值的内核。 该问题的简要描述是:

我有一个大小为N的“索引”数组。 我有一个大小为N的“值”数组。 我有一个'添加'大小M的数组。 索引数组包含数组'adds'的索引。 例如,如果索引数组的第一个值是3,那么'values'数组的第一个值将添加到'adds'数组的索引3中。

问题是我有N个线程(每个索引/值一个)在gobal内存中同时读/写并且它们可以在同一位置读/写,然后最终值不一致

我添加了一张图片以图形方式查看问题: https : //drive.google.com/file/d/0BzQ4sqg5hAdnMXZlZlIzUFB4QkhQOXZXVjcyS1ZKdXZYTS1j/view?usp=docslist_api

你知道吗?

感谢你并致以真诚的问候。

I followed this page for many time, I consider that it is one of the best pages for questions ofprograming in general.

Well, normally I alway try to find a solution for my problems but now I think that I need some help of the comunity because I don't know how to resolve my problem.

The problem that I have is with the OpenCL API. I need to program a Kernel that adds some values in 'global memory'. A brief description of the problem is:

I have an array of 'index' the size N. I have an array of 'values 'the size N. I have an array of 'adds' the size M. The array of index contains the index of the array 'adds'. For example, if the first value of the array of index is 3, then the first value of the array of 'values' is add to the index 3 of the array of 'adds'.

The problem is that I have N threads (one for each index/value) that read/write in gobal memory simultanious and they can read/write in the same location, then the final value is inconsistent

I added an image to see the problem graphically: https://drive.google.com/file/d/0BzQ4sqg5hAdnMXZlZlIzUFB4QkhQOXZXVjcyS1ZKdXZYTS1j/view?usp=docslist_api

You have any idea?

Thank you and best regards.

最满意答案

另外,查看OpenCL原子函数: https : //www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/atomicFunctions.html

Also, check out OpenCL atomic functions: https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/atomicFunctions.html

更多推荐

本文发布于:2023-08-04 01:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405939.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:全局   内核   内存   OpenCL   Read

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!