2013-07-22 78 views
0

我試圖運行在http://docs.thrust.googlecode.com/hg/group__modifying.html上描述的推力for_each示例,但在編譯和運行時出現錯誤。推力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) 
+2

可能值得指出的是,推銷谷歌代碼回購已被棄用,並在兩年前轉移到github。這些示例實際上已被放棄,並且github回購庫中的錯誤修復程序肯定沒有反映在Google代碼中。 – talonmies

+0

在[public github文檔]中也出現錯誤(http://thrust.github.io/doc/group__modifying.html#gacef91d7036641ffd9a9a483ff760de05)。確實,github回購中的doxygen資源可能存在問題,但尚未公開表示。 –

回答

6

也許你的意思這在你的代碼:

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

的這個代替:

printf("%d\n"); 

當我對代碼進行更改時,它會爲我編譯和運行成功。

我承認文檔中的錯誤,並會在thrust googlegroup thrust-users上報告。

+0

謝謝。你是對的。 –

+1

截止到今天(2014年4月5日),這種印刷錯誤似乎沒有被修復,請參閱[Group Modifying](http://thrust.github.io/doc/group__modifying.html)。 – JackOLantern

相關問題