/ / मुझे कैसे पता चलेगा कि मेमोरी मैपिंग OpenCL - java, समानांतर-प्रसंस्करण, opencl, gpgpu में सफल है

मुझे कैसे पता चलेगा कि मेमोरी मैपिंग ओपनसीएल - जावा, समानांतर प्रसंस्करण, ओपनक्ल, gpgpu में सफल है

मैं ओपनसीएल के लिए नया हूं। वर्तमान में मैं एक बड़े एक आयाम सरणी पर काम कर रहा हूं। सरणी का आकार लगभग 8 मिलियन है। निम्नलिखित मेरे कोड का हिस्सा है:

//allocate opencl hosted memory for input
int[] Counts = new int[8000000];

//get device and create context....

CLBuffer<Integer> memIn1 = context.createIntBuffer(Usage.Input, 8000000);
Pointer<Integer> a = memIn1.map(queue, MapFlags.Write);
a.setInts(Counts);

//memory allocation for the second parameter memIn2

CLKernel kernel = program.createKernel("gpuScoring", memIn1, memIn2, 8000000, memOut);
kernel.enqueueNDRange(queue, new int[] {8000000}, null);

नीचे मेरा कर्नेल कोड है:

__kernel void gpuScoring(__global int *Counts, __global int *value, int width, int height, __global int *output){

int gid = get_global_id(0);
int x = gid % width;
int y = gid / width;
int count = Counts[y * width + x];
if(count != 0){
//need to do something here...
}
}

हालांकि, सवाल यह है कि मैंने पाया कि मैं कभी नहीं कर सकताअगर (गिनती! = 0) की सच्ची शाखा में जाओ। मुझे पूरा यकीन है कि मेरे जावा कोड में काउंट्स ऐरे में कुछ इंडेक्स वैल्यूज हैं जो 0. नहीं हैं। क्या ऐसा इसलिए है क्योंकि मैंने मेमोरी मैपिंग का गलत तरीके से इस्तेमाल किया है? कृपया मदद कीजिए। धन्यवाद।

उत्तर:

जवाब के लिए 0 № 1

बफर मैप करने के बाद, आपको अपना डेटा वहां लिखना होगा, फिर उसे अनमैप करना होगा। आप अधिक उपयोग कर रहे हैं जैसे कि मेजबान डेटा को कॉपी करने के साथ बफर बनाएं।