2012-03-12 10 views
7

सी ++ एएमपी में, कर्नेल फ़ंक्शन या लैम्ब्डा को प्रतिबंधित (amp) के साथ चिह्नित किया जाता है, जो सी ++ (listed here) के अनुमत सबसेट पर गंभीर प्रतिबंध लगाता है। क्या सीयूडीए कर्नेल कार्यों में सी या सी ++ के उप-समूह पर और अधिक स्वतंत्रता की अनुमति देता है?सीयूडीए कर्नेल कोड से अधिक प्रतिबंधित है (amp)?

+1

निम्नलिखित प्रश्न से संबंधित हो सकता है। http://stackoverflow.com/questions/4899425/what-are-the-real-c-language-constructs-supported-by-cuda-device-code –

+0

अच्छा सवाल है, हालांकि मुझे डर है कि यह वास्तव में तुलनीय नहीं है (शायद प्रोग्रामर.एसई में माइग्रेट करें?): एनवीसीसी अभी तक सी ++ 11 का समर्थन नहीं करता है, इसलिए जब लैम्बडास के बारे में बात करते हैं तो आप स्पष्ट रूप से बहुत दूर नहीं जाते हैं! दूसरी ओर, एएमपी के पास माइक्रोसॉफ्ट के साथ शुरू होने से पूरी तरह से अलग प्रतिबंध हैं; कि (या, शायद अधिक सही ढंग से, एक गैर-डायरेक्टएक्स-कार्यान्वयन की वर्तमान कमी) इसे कई उदाहरणों के लिए पूरी तरह से अनुपयोगी बनाती है। वैज्ञानिक अनुप्रयोगों। लेकिन मुझे लगता है कि आप केवल _language_ प्रतिबंधों का मतलब है? – leftaroundabout

+0

@ बाएंअराउंडबाउट: हाँ, मैं केवल _language_ प्रतिबंधों के बारे में बात कर रहा हूं, और मैं सी ++ 03 में रहने के लिए ठीक हूं। मैंने केवल लैम्बडा का उल्लेख किया है क्योंकि यह सी ++ एएमपी के साथ कर्नेल कोड लॉन्च करने के लिए निर्धारित तंत्र है। – Eugene

उत्तर

18

विजुअल स्टूडियो 11 और CUDA 4.1, restrict(amp) फ़ंक्शन CUDA के समान __device__ फ़ंक्शंस की तुलना में अधिक प्रतिबंधित हैं। सबसे महत्वपूर्ण बात यह है कि एएमपी पॉइंटर्स का उपयोग कैसे किया जा सकता है इसके बारे में अधिक प्रतिबंधक है। यह एएमपी के डायरेक्टएक्स 11 कम्प्यूटेशनल सब्सट्रेट का एक प्राकृतिक परिणाम है, जो HLSL (ग्राफिक्स शेडर) कोड में पॉइंटर्स को अस्वीकार करता है। कॉन्सस्ट्रा द्वारा, सीयूडीए के निचले स्तर के आईआर PTX है, जो एचएलएसएल की तुलना में अधिक सामान्य उद्देश्य है।

| VS 11 AMP restrict(amp) functions  | CUDA 4.1 sm_2x __device__ functions | 
|------------------------------------------------------------------------------| 
|* can only call functions that have |* can only call functions that have | 
| the restrict(amp) clause    | the __device__ decoration   | 
|* The function must be inlinable  |* need not be inlined     | 
|* The function can declare only  |* Class types are allowed    | 
| POD variables      |          | 
|* Lambda functions cannot    |* Lambdas are not supported, but  | 
| capture by reference and    | user functors can hold pointers  | 
| cannot capture pointers    |          | 
|* References and single-indirection |* References and multiple-indirection | 
| pointers are supported only as  | pointers are supported    | 
| local variables and function   |          | 
|* No recursion       |* Recursion OK      | 
|* No volatile variables    |* Volatile variables OK    | 
|* No virtual functions     |* Virtual functions OK    | 
|* No pointers to functions    |* Pointers to functions OK   | 
|* No pointers to member functions  |* Pointers to member functions OK  | 
|* No pointers in structures   |* Pointers in structures OK   | 
|* No pointers to pointers    |* Pointers to pointers OK    | 
|* No goto statements     |* goto statements OK     | 
|* No labeled statements    |* Labeled statements OK    | 
|* No try, catch, or throw statements |* No try, catch, or throw statements | 
|* No global variables     |* Global __device__ variables OK  | 
|* Static variables through tile_static |* Static variables through __shared__ | 
|* No dynamic_cast      |* No dynamic_cast      | 
|* No typeid operator     |* No typeid operator     | 
|* No asm declarations     |* asm declarations (inline PTX) OK | 
|* No varargs       |* No varargs       | 

आप restrict(amp) के प्रतिबंध here के बारे में अधिक पढ़ सकते हैं:

यहाँ लाइन तुलना द्वारा एक लाइन है। आप CUDA C Programming Guide के परिशिष्ट डी में CUDA __device__ फ़ंक्शंस में C++ समर्थन के बारे में पढ़ सकते हैं।

+0

आईआईआरसी यहां सुविधाओं के बारे में एक चर्चा है कि सी ++ एएमपी सक्षम हो सकता है लेकिन कभी-कभी समानांतर कंप्यूटिंग में अच्छे प्रथाओं को प्रोत्साहित करने के लिए स्पष्ट विकल्पों पर आधारित नहीं होता है: http://channel9.msdn.com/Shows/Going+Deep/C- एएमपी-विकास-टीम-तकनीकी-गोलमेज सम्मेलन –

संबंधित मुद्दे