我一直关注这个页面,我认为它是一般编程问题的最佳页面之一。
好吧,通常我总是尝试找到解决问题的方法,但现在我认为我需要一些社区的帮助,因为我不知道如何解决我的问题。
我遇到的问题是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
更多推荐
发布评论