0

http://docs.thrust.googlecode.com/hg/group__modifying.htmlで説明されている推力 for_each の例を実行しようとしていますが、コンパイルして実行するとエラーが発生します。

次のファイルを使用します: fe.cu:

#include <thrust/for_each.h>
#include <thrust/device_vector.h>
#include <stdio.h>

struct printf_functor{
    __host__ __device__
    void operator()(int x){
        printf("%d\n");
    }
};

int main(){
    thrust::device_vector<int> d_vec(3);
    d_vec[0] = 0; d_vec[1] = 1; d_vec[2] = 2;
    thrust::for_each(d_vec.begin(), d_vec.end(), printf_functor());
}

でコンパイルしnvcc -arch=sm_20 fe.cuます。

./a.out を使用して実行すると、次の出力が得られます。

terminate called after throwing an instance of 'thrust::system::system_error'
  what():  unspecified launch failure
Aborted

以下は、コードの実行に使用される GPU に関する情報です。

   --- General Information for device 0 ---
Name:  Tesla C2075
Compute capability:  2.0
Clock rate:  1147000
Device copy overlap:  Enabled
Kernel execution timeout :  Disabled
   --- Memory Information for device 0 ---
Total global mem:  5636554752
Total constant Mem:  65536
Max mem pitch:  2147483647
Texture Alignment:  512
   --- MP Information for device 0 ---
Multiprocessor count:  14
Shared mem per mp:  49152
Registers per mp:  32768
Threads in warp:  32
Max threads per block:  1024
Max thread dimensions:  (1024, 1024, 64)
Max grid dimensions:  (65535, 65535, 65535)
4

1 に答える 1

6

おそらく、コードでこれを意味しました:

    printf("%d\n", x);

これの代わりに:

    printf("%d\n");

コードにその変更を加えると、コンパイルして正常に実行されます。

ドキュメントのエラーを認め、推力 googlegroup 推力ユーザーで報告します。

于 2013-07-22T19:02:56.993 に答える