2012-03-12 9 views
7

C++ AMPでは、カーネル関数またはラムダにはrestrict(amp)とマークされています。これは、C++の許可されたサブセット(listed here)に厳しい制限を課します。 CUDAは、カーネル関数のCまたはC++のサブセットで自由を許しますか?CUDAカーネルコードよりもrestrict(amp)の方が制限がありますか?

+1

次の質問に関連していてもよいです。 http://stackoverflow.com/questions/4899425/what-are-the-real-c-language-constructs-supported-by-cuda-device-code –

+0

良い質問ですが、恐らくそれは本当に匹敵しません(おそらくプログラマーに移行してください.SE?):nvccはC++ 11をまだサポートしていませんので、ラムダについて話すときには、はるかに遠くにはありません。一方、AMPはマイクロソフトから始めて全く異なる制限があります。 DirectXを実装していないという欠点があります。科学的なアプリケーション。しかし、あなたは_language_制限だけを意味すると思いますか? – leftaroundabout

+0

@leftaroundabout:はい、私は_language_制限について話していますが、C++ 03のままにしても問題ありません。ラムダはC++ AMPでカーネルコードを起動するための規定されたメカニズムであるため、ラムダについて言及しました。 http://channel9.msdn.com/Shows/Going+Deep/C-: – Eugene

答えて

18

Visual Studio 11およびCUDA 4.1以降では、restrict(amp)関数はCUDAの類似の__device__関数よりも制限的です。最も顕著なことに、AMPはポインタの使用方法をより制限しています。これは、HLSL(グラフィックシェーダ)コードのポインタを許可しないAMPのDirectX11計算基板の自然な結果です。制約によって、CUDAの低レベルIRはPTXであり、これはHLSLより一般的な目的です。ここで

は、ライン比較によるラインです:

| 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の付録DのCUDA __device__の関数でC++のサポートについて読むことができます。

+0

はIIRC C++ AMPが有効でなかったが、時々、並列コンピューティングに優れた慣行を奨励するために、明示的な選択に基づいている可能性の特徴について、ここでの議論がありますAMP-開発チーム - テクニカルラウンドテーブル –

関連する問題