- 并行編程方法與優(yōu)化實踐
- 劉文志
- 339字
- 2019-01-01 01:08:29
1.1.4 加載和存儲
SSE內(nèi)置函數(shù)支持的加載和存儲操作及其數(shù)據(jù)類型如表1-4所示。不但支持正向設置、逆向設置、清零、全部設置為某值,還支持不經(jīng)過緩存的加載和存儲,以及對應的存儲和加載。
表1-4 SSE加載和存儲
其中extract操作單精度浮點數(shù)據(jù)的定義如下:
int _mm_extract_ps(__m128 a, const int id); r = a[id];
在SSE指令中,extract是非常耗時的操作,故不建議使用。
insert按照掩碼的對應比特值決定對應位量元素乘積是否相加,并將結果寫入掩碼指定位置,如下所示:
__m128 _mm_insert_ps(__m128 a, __m128 b, const int id); int bid = value of bit 6-7 for id int bv = b[bid]; bid = value of bit 4-5 for id r[0] = (bid == 0) ? bv : a[0]; r[1] = (bid == 1) ? bv : a[1]; r[2] = (bid == 2) ? bv : a[2]; r[3] = (bid == 3) ? bv : a[3]; r[0] = (0x1 & id == 1) ? 0.0 : r[0]; r[1] = (0x2 & id == 1) ? 0.0 : r[1]; r[2] = (0x4 & id == 1) ? 0.0 : r[2]; r[3] = (0x8 & id == 1) ? 0.0 : r[3];
掩碼的第6、7位決定了取b的哪個元素取代a中元素,而第4、5位決定了a的哪個元素被取代。
推薦閱讀
- Python快樂編程:人工智能深度學習基礎
- MongoDB for Java Developers
- Scala Design Patterns
- Easy Web Development with WaveMaker
- Learning ELK Stack
- Getting Started with Greenplum for Big Data Analytics
- Unity 2D Game Development Cookbook
- WildFly Cookbook
- 超簡單:用Python讓Excel飛起來(實戰(zhàn)150例)
- SQL Server on Linux
- Clojure Web Development Essentials
- Mastering Clojure
- SOA Patterns with BizTalk Server 2013 and Microsoft Azure(Second Edition)
- MySQL數(shù)據(jù)庫應用技術及實戰(zhàn)
- jBPM6 Developer Guide