女人自慰AV免费观看内涵网,日韩国产剧情在线观看网址,神马电影网特片网,最新一级电影欧美,在线观看亚洲欧美日韩,黄色视频在线播放免费观看,ABO涨奶期羡澄,第一导航fulione,美女主播操b

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線(xiàn)課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

Arm架構(gòu)下的Synchronization概述和案例分析

安芯教育科技 ? 來(lái)源:安芯教育科技 ? 2023-05-11 14:45 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

本文選自極術(shù)專(zhuān)欄“Arm服務(wù)器”,文章將帶你了解Arm架構(gòu)下的Synchronization專(zhuān)業(yè)知識(shí)。

一、簡(jiǎn)介

隨著近年來(lái)Arm服務(wù)器的應(yīng)用越來(lái)越廣泛,越來(lái)越多的云廠商開(kāi)始提供基于Arm架構(gòu)的云實(shí)例,越來(lái)越多的開(kāi)發(fā)人員正在為Arm平臺(tái)編寫(xiě)軟件。

Synchronization是軟件遷移和優(yōu)化過(guò)程中的熱門(mén)話(huà)題。基于Arm架構(gòu)的服務(wù)器通常具有比其他架構(gòu)更多的CPU內(nèi)核,對(duì)Synchronization的深入理解顯得更為重要。

Arm和X86 CPU之間最顯著的區(qū)別之一是它們的內(nèi)存模型:Arm架構(gòu)具有與x86架構(gòu)的TSO(Total Store Order)模型不同的弱內(nèi)存模型。不同的內(nèi)存模型可能會(huì)導(dǎo)致程序在一種架構(gòu)上運(yùn)行良好,但在另一種架構(gòu)上會(huì)遇到性能問(wèn)題或錯(cuò)誤。Arm服務(wù)器更寬松的內(nèi)存模型允許更多的編譯器和硬件優(yōu)化以提高系統(tǒng)性能,但代價(jià)是它更難理解并且可能更容易編寫(xiě)錯(cuò)誤代碼。

我們創(chuàng)作此文檔是為了分享有關(guān)Arm架構(gòu)的Synchronization專(zhuān)業(yè)知識(shí),可以幫助其他架構(gòu)的開(kāi)發(fā)人員在Arm系統(tǒng)上進(jìn)行開(kāi)發(fā)。

二、Armv8-A架構(gòu)上的Synchronization方法

本文檔首先介紹了Armv8-A架構(gòu)上的Synchronization相關(guān)知識(shí),包括原子操作、Arm內(nèi)存順序和數(shù)據(jù)訪問(wèn)屏障指令。

2.1 原子操作

鎖的實(shí)現(xiàn)要求原子訪問(wèn),Arm架構(gòu)定義了兩種類(lèi)型的原子訪問(wèn):

Load exclusive and store exclusive

Atomic operation, which is introduced in armv8.1-a large system extension (LSE)

2.1.1 Exclusive load and store

LDREX/LDXR - The load exclusive instruction performs a load from an addressed memory location, the PE (e.g. the CPU) also marks the physical address being accessed as an exclusive access. The exclusive access mark is checked by store exclusive instructions.

STREX/STXR - The store exclusive instruction tries to a value from a register to memory if the PE (e.g. the CPU) has exclusive access to the memory address, and returns a status value of 0 if the store was successful, or of 1 if no store was performed.

2.1.2 LSE Atomic operation

LDXR/STXR使用了try and test機(jī)制,LSE不一樣,它直接強(qiáng)制原子訪問(wèn),主要有如下指令:

Compare and Swap instructions, CAS, and CASP. These instructions perform a read from memory and compare it against the value held in the first register. If the comparison is equal, the value in the second register is written to memory. If the write is performed, the read and write occur atomically such that no other modification of the memory location can take place between the read and write.

Atomic memory operation instructions, LD, and ST, whereis one of ADD, CLR, EOR, SET, SMAX, SMIN, UMAX, and UMIN. Each instruction atomically loads a value from memory, performs an operation on the values, and stores the result back to memory. The LDinstructions save the originally read value in the destination register of the instruction.

Swap instruction, SWP. This instruction atomically reads a location from memory into a register and writes back a different supplied value back to the same memory location.

2.2 Arm內(nèi)存順序

Arm架構(gòu)定義了一種弱內(nèi)存模型,內(nèi)存訪問(wèn)可能不會(huì)按照代碼順序:

f3f40e8c-efc5-11ed-90ce-dac502259ad0.png

2.3 Arm數(shù)據(jù)訪問(wèn)屏障指令

Arm架構(gòu)定義了屏障指令來(lái)保證內(nèi)存訪問(wèn)的順序。

DMB– Data Memory Barrier
Explicit memory accesses before the DMB are observed before any explicit access after the DMB

Does not guarantee when the operations happen, just guarantee the order

LDR X0, [X1] ;Must be seen by memory system before STR

DMB SY

ADD X2, #1 ; May be executed before or after memory system sees LDR

STR X3, [X4] ;Must be seen by memory system after LDR

DSB– Data Synchronization Barrier
A DSB is more restrictive than a DMB

Use a DSB when necessary, but do not overuse them

No instruction after a DSB will execute until:

All explicit memory accesses before the DSB in program order have completed

Any outstanding cache/TLB/branch predictor operations complete

DC ISW ; Operation must have completed before DSB can complete

STR X0, [X1] ; Access must have completed before DSB can complete

DSB SY

ADD X2, X2, #3 ;Cannot be executed until DSB completes

DMB和DSB是雙向柵欄,對(duì)兩個(gè)方向都限制,Armv8-a也設(shè)計(jì)了一種單向柵欄:load-acquire和store-release機(jī)制,只在一個(gè)方向上做限制。

Load-Acquire (LDAR)

All accesses after the LDAR are observed by memory system after the LDAR.

Accesses before the LDAR are not affected.

f412ad92-efc5-11ed-90ce-dac502259ad0.png

Store-Release (STLR)

All accesses before the STLR are observed by memory system before the STLR.

Accesses after the STLR are not affected.

f424103c-efc5-11ed-90ce-dac502259ad0.png

三、C++內(nèi)存模型

有了語(yǔ)言層面的內(nèi)存模型,對(duì)于大多數(shù)情況,開(kāi)發(fā)者不需要去寫(xiě)依賴(lài)于具體架構(gòu)的匯編代碼,而只需要借助于良好設(shè)計(jì)的語(yǔ)言層面的內(nèi)存模型來(lái)編寫(xiě)高質(zhì)量代碼,不必?fù)?dān)心架構(gòu)差異。


C++ memory model:
https://en.cppreference.com/w/cpp/header/atomic

f439ac08-efc5-11ed-90ce-dac502259ad0.png

我們做了一個(gè)C++內(nèi)存模型與Armv8-A實(shí)現(xiàn)之間的映射:

f4531328-efc5-11ed-90ce-dac502259ad0.png

四、總結(jié)

在白皮書(shū)中,為幫助讀者更好地理解,我們選取了三個(gè)典型案例進(jìn)行深入分析。由于與Synchronization相關(guān)的編程非常復(fù)雜,因此我們必須仔細(xì)權(quán)衡其正確性和性能。

我們建議首先使用較重的屏障指令保證邏輯的正確性,然后通過(guò)移除一些冗余屏障或在必要時(shí)切換到較輕的屏障來(lái)繼續(xù)提高性能。對(duì)Arm內(nèi)存模型和相關(guān)指令的深入理解,是對(duì)實(shí)現(xiàn)準(zhǔn)確和高性能的Synchronization編程非常有必要的。

在附錄部分,我們還介紹了內(nèi)存模型工具(The litmus test suite),它可以幫助理解內(nèi)存模型并在各種架構(gòu)上驗(yàn)證程序。

關(guān)于以上內(nèi)容更完整的講解,請(qǐng)參考“Arm架構(gòu)下的Synchronization概述和案例分析白皮書(shū)”。

審核編輯:湯梓紅

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • ARM
    ARM
    +關(guān)注

    關(guān)注

    134

    文章

    9350

    瀏覽量

    377408
  • 內(nèi)核
    +關(guān)注

    關(guān)注

    3

    文章

    1416

    瀏覽量

    41417
  • cpu
    cpu
    +關(guān)注

    關(guān)注

    68

    文章

    11076

    瀏覽量

    217015
  • 服務(wù)器
    +關(guān)注

    關(guān)注

    13

    文章

    9793

    瀏覽量

    87933
  • 編譯器
    +關(guān)注

    關(guān)注

    1

    文章

    1662

    瀏覽量

    50203

原文標(biāo)題:Arm架構(gòu)下的Synchronization概述和案例分析白皮書(shū)|附下載

文章出處:【微信號(hào):Ithingedu,微信公眾號(hào):安芯教育科技】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。

收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    ARM架構(gòu)是什么

    從單片機(jī)轉(zhuǎn)到ARM,主要需要學(xué)習(xí)ARM架構(gòu),ARM相比單片機(jī)多了一些外設(shè)和總線(xiàn)。在僅僅是裸奔的情況,如果熟悉了
    發(fā)表于 07-01 09:23

    ARM架構(gòu)

    ARM架構(gòu)ARM架構(gòu)如圖所示,ARM公司只提供內(nèi)核技術(shù),而其他外設(shè)則為芯片商設(shè)計(jì)并使用,ARM
    發(fā)表于 08-04 06:18

    介紹一ARM架構(gòu)

    微型計(jì)算機(jī)(PC計(jì)算機(jī))來(lái)說(shuō),就是降低中央處理器的頻率和規(guī)格,降低存儲(chǔ)器空間,這樣的改變,使之廣泛的運(yùn)用在各種儀器等電子產(chǎn)品中當(dāng)前,X86和ARM架構(gòu)是公認(rèn)的在商業(yè)化進(jìn)程中表現(xiàn)最優(yōu)秀的兩大架構(gòu)。之前
    發(fā)表于 11-25 08:51

    CMSIS軟件架構(gòu)概述?

    目錄CMSIS軟件架構(gòu)庫(kù)文件說(shuō)明CMSIS軟件架構(gòu)CMSIS概述? ? ?CMSIS軟件架構(gòu)由四層:用戶(hù)應(yīng)用層、操作系統(tǒng)及中間件接口層、CMSIS層和硬件層? ? ?由三部分構(gòu)成核內(nèi)外
    發(fā)表于 12-22 07:34

    介紹Armv8-A架構(gòu)上的Synchronization相關(guān)知識(shí)

    1、Arm架構(gòu)Synchronization概述和案例分析
    發(fā)表于 07-06 17:19

    ARM架構(gòu)同步概述及案例分析

    本白皮書(shū)的目的是分享有關(guān)ARM架構(gòu)的同步知識(shí)。 本文檔的目標(biāo)讀者是從事ARM?架構(gòu)同步工作的人員。 [警告]當(dāng)我們處理鎖定優(yōu)化時(shí),我們必須非常小心正確性。 同步導(dǎo)致的錯(cuò)誤通常很難找出根
    發(fā)表于 08-21 07:51

    Essential synchronization tech

    Essential synchronization technologies in PXI:Many test and measurement applications
    發(fā)表于 07-23 22:43 ?9次下載

    Converter Synchronization Prov

    A novel technique allows synchronization ofpower converters with internal timing capacitorsand supports features like programmable deadtime.
    發(fā)表于 06-28 14:12 ?13次下載

    ARM的發(fā)展史以及架構(gòu)解析

    本文從ARM的發(fā)展歷史著手,以S3C2440為例與51單片機(jī)進(jìn)行對(duì)比分析,詳細(xì)解析了ARM架構(gòu)
    發(fā)表于 04-22 11:00 ?1.6w次閱讀

    什么叫arm架構(gòu)_X86架構(gòu)ARM架構(gòu)有什么區(qū)別

    本文首先介紹了arm架構(gòu)的概念,其次介紹了ARM架構(gòu)圖與ARM的技術(shù)實(shí)現(xiàn),最后介紹了X86架構(gòu)
    發(fā)表于 04-24 08:45 ?8.7w次閱讀
    什么叫<b class='flag-5'>arm</b><b class='flag-5'>架構(gòu)</b>_X86<b class='flag-5'>架構(gòu)</b>與<b class='flag-5'>ARM</b><b class='flag-5'>架構(gòu)</b>有什么區(qū)別

    ARM架構(gòu)的應(yīng)用領(lǐng)域的發(fā)展分析

    ARM架構(gòu)是一個(gè)32位精簡(jiǎn)指令集(RISC)處理器架構(gòu),其廣泛地使用在許多嵌入式系統(tǒng)設(shè)計(jì)。由于節(jié)能的特點(diǎn),ARM處理器非常適用于移動(dòng)通訊領(lǐng)域,
    的頭像 發(fā)表于 05-22 06:04 ?5604次閱讀

    ARM7TDMI 調(diào)試架構(gòu)分析

    設(shè)計(jì)中,微處理器內(nèi)核不能直接從芯片外圍訪問(wèn),這增加了調(diào)試系統(tǒng)的問(wèn)題。本應(yīng)用筆記描述了 ARM7TDMI 調(diào)試架構(gòu)如何克服這個(gè)問(wèn)題以及使用這種方法的優(yōu)勢(shì)。 ARM 調(diào)試架構(gòu)——
    的頭像 發(fā)表于 06-18 16:42 ?2875次閱讀
    <b class='flag-5'>ARM</b>7TDMI 調(diào)試<b class='flag-5'>架構(gòu)</b><b class='flag-5'>分析</b>

    Arm架構(gòu)Synchronization概述和案例分析

    DMB和DSB是雙向柵欄,對(duì)兩個(gè)方向都限制,Armv8-a也設(shè)計(jì)了一種單向柵欄:load-acquire和store-release機(jī)制,只在一個(gè)方向上做限制。
    發(fā)表于 07-07 09:19 ?1272次閱讀

    Arm架構(gòu)科普解讀 Arm架構(gòu)的底層邏輯和Arm架構(gòu)的頂層設(shè)計(jì)

    本文主要探討了 Arm 架構(gòu)的底層邏輯,介紹了Arm 架構(gòu)的頂層設(shè)計(jì);以處理器核心架構(gòu)為基礎(chǔ),以系統(tǒng)架構(gòu)
    的頭像 發(fā)表于 02-06 05:33 ?7151次閱讀
    <b class='flag-5'>Arm</b><b class='flag-5'>架構(gòu)</b>科普解讀  <b class='flag-5'>Arm</b><b class='flag-5'>架構(gòu)</b>的底層邏輯和<b class='flag-5'>Arm</b><b class='flag-5'>架構(gòu)</b>的頂層設(shè)計(jì)

    arm架構(gòu)和x86架構(gòu)區(qū)別 linux是x86還是arm

    ARM架構(gòu)和x86架構(gòu)概述 1.1 ARM架構(gòu) ARM
    的頭像 發(fā)表于 01-30 13:46 ?2.3w次閱讀