Is there any standardized function in GCC or glibc to allocate memory block at aligned pointer? Like _align_malloc() in MSVC?
まずは確保したいバッファサイズ(size)より15バイト多く確保してそのアドレスをp1とします。 p1のアドレスがどうなるかは環境に依存するらしいので16バイトの境界にあっているとは限りません。なのでこのままでは高速なSSE命令が使えないので二行目の計算を行って16バイトの境界に合わせます。
posix_memalign() が良い理由 本ブログでは今まで _mm_malloc() を使用してメモリアライメントを揃えていましたが,posix_memalign() を使用したほうが良いぽいです.理由は _mm_malloc() が Intel CPU 環境でのみ動作するのに対し,posix_memalign() は標準化されているためメインストリームな環境であれば概ね動作するためです.また,posix_memalign() で確保したメモリは free() で解放することができ,_mm_free() が混在しなくなるためコードの保守性の向上が考えられます. posix_memalign の使用方法 簡単な使用方法のみ掲載します. ・インクルードするファイル #include <stdlib.h> ・posix_memalign() の使用方法 int posix_memalign
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く