Raw numerical data physical memory addresses aligning

2 ビュー (過去 30 日間)
Igor Varfolomeev
Igor Varfolomeev 2015 年 10 月 10 日
編集済み: Jan 2015 年 10 月 18 日
I'm currently writing c++ mex function. I'd like to utilize some SIMD instructions.
  1. Is it safe to assume, that the pointer to the raw numeric data (the result on mxGetData() ) is aligned ?
  2. Is it 16-byte (SSE-like) or 32-byte (AVX-like) alignment?
  3. Does it depend on the CPU capabilities, Matlab version or anything else?
  4. Is there any document about this subject?
Matlab makes some use of SSE as well, so, most probably, each array must be aligned. And my initial experiments do confirm, that all raw-data pointers are 32-byte aligned... But it would be nice to have an "official confirmation" and/or notices about the possible caveats.

回答 (1 件)

Jan
Jan 2015 年 10 月 10 日
編集済み: Jan 2015 年 10 月 18 日
Since at least R2008b I've never observed an array, which is not aligned at 16 bytes. My Mex functions stop with an error otherwise and no user reported such an error yet. This concerns 32 and 64 bit versions of Matlab and Windows.
I agree that an official statement is required.
[EDITED] "Aligned at 32 bits" -> "Aligned at 16 bytes"
I've used SSE statements only, so I did not check for 32 byte alignment.
  1 件のコメント
Igor Varfolomeev
Igor Varfolomeev 2015 年 10 月 11 日
Thanks for the answer! It greatly increases my belief, that everything should be OK.
Though, you probably mean "aligned at 32 bytes", don't you ? :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by