Intel MKLを試していますが、独自のメモリ管理(Cスタイル)があるようです。
彼らは、ベクトルと行列にMKL_malloc / MKL_freeのペアを使用することを提案していますが、それを処理するための良い方法がわかりません。その理由の1つは、メモリアライメントが少なくとも16バイトであることが推奨されており、これらのルーチンでは明示的に指定されていることです。
私は以前、auto_ptrとboost :: smart_ptrに依存して、メモリのクリーンアップを忘れていました。
MKLメモリ管理を使用して例外セーフプログラムを作成するにはどうすればよいですか、または通常のauto_ptrを使用するだけで、わざわざ使用する必要はありませんか?
前もって感謝します。
http://software.intel.com/sites/products/documentation/hpc/mkl/win/index.htmを編集します
このリンクは私が質問を提起した理由を説明するかもしれません
アップデート
アロケータには以下の回答のアイデアを使用しました。これは私が今持っているものです:
template <typename T, size_t TALIGN=16, size_t TBLOCK=4>
class aligned_allocator : public std::allocator<T>
{
public:
pointer allocate(size_type n, const void *hint)
{
pointer p = NULL;
size_t count = sizeof(T) * n;
size_t count_left = count % TBLOCK;
if( count_left != 0 ) count += TBLOCK - count_left;
if ( !hint ) p = reinterpret_cast<pointer>(MKL_malloc (count,TALIGN));
else p = reinterpret_cast<pointer>(MKL_realloc((void*)hint,count,TALIGN));
return p;
}
void deallocate(pointer p, size_type n){ MKL_free(p); }
};
誰か提案があれば、遠慮なく改善してください。