我有一個自定義的C++模塊,用於顯示函數,其中一些使用TBB(tbb21_015oss)加速處理。在Python線程中調用TBB'parallel_for'
到目前爲止,在Win32環境下從Python(2.6.2)調用TBB加速函數時,我沒有任何問題。
但是現在,從Python線程(使用threading.Thread
類創建)調用此函數時遇到問題 - 在調用相同函數時,從主Python線程可以正常工作。
調用函數導致應用程序崩潰,並顯示以下消息:
First-chance exception at 0x03522e96 in python.exe:
0xC0000005: Access violation reading location 0x000000c8.
TBB.dll基地址爲0x03510000,並根據2005年MSVC調試器,墜毀代碼恰好從TBB的「parallel_for.h 」,顯然是在static void start_for::run( const Range& range, const Body& body, const Partitioner& partitioner)
執行時:
start_for& a = *new(task::allocate_root(context)) start_for(range,body,const_cast<Partitioner&>(partitioner));
似乎有被取消引用一個NULL指針。
// at 'global' scope
tbb::task_scheduler_init g_tbbinit(tbb::task_scheduler_init::deferred);
...
// in a function
g_tbbinit.initialize();
有沒有辦法來完成這項工作:
FWIW,TBB通過使用延遲初始化機制初始化?例如,TBB是否需要特定的初始化以允許從「自定義」線程調用它?
什麼是錯誤信息? – log0 2011-05-11 08:57:59
@Ugo - 更新的問題,以添加更多的信息 – rotoglup 2011-05-11 09:18:15