我正在使用的NVIDIA卡2.1計算能力上推力蒙特卡羅模擬。如果我嘗試一次對整個device_vector進行transform_reduce,會出現以下錯誤。它不需要在設備上使用內存,因爲矢量很大(〜1-10mb)。我知道我的代碼是正確的,因爲如果我使用openmp進行編譯並僅在主機上運行,它就可以工作。什麼可能導致這個問題?推力::系統:: SYSTEM_ERROR在transform_reduce
在0x776e15de未處理異常mccva.exe:微軟C++異常:推力::系統:: SYSTEM_ERROR內存位置0x0014cb28。
但是,如果我做transform_reduce在大塊它,直到我在擴展模擬它然後給出了同樣的錯誤時步的數量正常工作。
//run the Monte Carlo simulation
zpath * norm_ptr = thrust::raw_pointer_cast(&z[0]);
cout << "initialized raw pointer" << endl;
thrust::device_vector<ctrparty> devctrp = ctrp;
assert(devctrp.size()==ctrp.size());
cout << "Initialized device vector" << endl;
cout << "copied host vec to device vec" << endl;
float cva = 0;
for(unsigned int i=0; i<5; i++)
{
if(i<4)
cva += (1-R) * thrust::transform_reduce(devctrp.begin()+i*2000, devctrp.begin() + (i+1)*2000 - 1, calc(norm_ptr, dt, r, sims, N), 0.0f, sum());
else
cva += (1-R) * thrust::transform_reduce(devctrp.begin()+i*2000, devctrp.begin() + (i+1)*2000, calc(norm_ptr, dt, r, sims, N), 0.0f, sum());
}
我得到的錯誤,當我試試這個:
float cva = 0.0f;
try
{
cva = thrust::transform_reduce(devctrp.begin(), devctrp.end(), calc(norm_ptr, dt, r, sims, N), 0.0f, sum()); //get the simulated CVA
}
catch(thrust::system_error e)
{
printf(e.what());
}
我使用VS2010,當它打破的錯誤它指向的dbgheap.c文件以下。
__finally {
/* unlock the heap
*/
_munlock(_HEAP_LOCK);
}
什麼是'計算的()'和'總和()'的定義是什麼?其中之一可能是問題。你可以試着用'calc'和'sum'()''''thrust'reduce'來做一個'thrust :: transform',看看你能否縮小錯誤的根源。例如,'norm_ptr'指向設備數組'z'。我不知道'calc'是如何精確使用它的,但是如果它以某種方式通過'z'索引,那麼也許當你增加變換的長度時,你會在那裏遇到麻煩。這只是推測,但它有助於看到更完整的描述你在變換中做什麼 – 2013-03-08 08:01:14
你是在構建項目的調試還是發佈版本? – 2013-03-08 08:03:31
我已經檢查過calc和sum函數在函數中使用printf是否正常工作。我看到一次transform_reducing整個向量時使用printf的時候,是它看起來像其分成塊本身我看到的「計算」,其次是「和」,其次是更多的「鈣」和「總和」,但它擲骰子一路走來。我正在使用調試版本,我確實已關閉了-g和-G標誌。 – postelrich 2013-03-08 16:09:28