It is currently Fri Dec 06, 2019 1:49 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: memory tips for ultra low jitter
PostPosted: Wed Nov 26, 2014 1:53 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2004 11:40 pm
Posts: 760
Location: Okazaki, JAPAN
This tips from my high quality sound player.

The slight jitter not even allowed software, the following Tips will help.

  • Don't use MOVQ
  • Use MOVNTQ, MOVNTDQ, then don't use CPU cache memory
  • Use MMX register

Code:
Procedure InitializeMemory(*memory, mem_size.i)
  Protected s.i
 
  If *memory
    If mem_size%8>0
      s = mem_size + (8 - mem_size%8)
    Else
      s = mem_size
    EndIf
    If s < 1
      ProcedureReturn
    EndIf

    !PXOR mm1, mm1
    !MOV Eax, [p.v_s]
    !MOV Ecx, [p.p_memory]
    !InitializeMemory:
    !movntq [Ecx], mm1
    !ADD  Ecx, 8
    !SUB  Eax, 8
    !JNZ InitializeMemory
    !emms
  Else
    ; error
    End
  EndIf
EndProcedure

*buffer = AllocateMemory(4096, #PB_Memory_NoClear)
InitializeMemory(*buffer, 4096)


ReWriteMemory
viewtopic.php?f=12&t=60968

  • This code use for After decode process or After sound process or For Asio buffer.
  • Bit holding voltage rise in the memory circuit of the memory chip for ultra low jitter.
  • Ranking of quality : 1st MMX(movntq), 2nd AVX (vmovntdq) 3rd SSE(movntdq)

Code:
Procedure ReWriteMemory(*memory, mem_size.i)
  Protected s.i
 
  If mem_size%16>0
    s = mem_size + (16 - mem_size%16)
  Else
    s = mem_size
  EndIf
 
  !PXOR xmm0, xmm0
  !MOV Eax, [p.v_s]
  !MOV Ecx, [p.p_memory]
  !ReWrite:
  !PXOR xmm0, xmm0
  !movdqa xmm0, [Ecx]
  !movntdq [Ecx], xmm0
  !ADD  Ecx, 16
  !SUB  Eax, 16
  !JNZ ReWrite
EndProcedure


CopyMemory for ultra low jitter

  • Don't use MOVQ
  • Use MOVNTQ, MOVNTDQ, then don't use CPU cache memory
  • Use MMX register

Code:
Procedure CopyMemoryMMX(*memory_in, *memory_out, mem_size.i)
  Protected s.i ; integer
 
  If mem_size%8>0 ; adjust align
    s = mem_size + (8 - mem_size%8)
  Else
    s = mem_size
  EndIf
 
  If s < 1
    ProcedureReturn
  EndIf
 
  CompilerSelect #PB_Compiler_Processor
    CompilerCase #PB_Processor_x86
      !PXOR mm1, mm1
      !MOV Eax, [p.v_s]
      !MOV Ecx, [p.p_memory_in]
      !MOV Edx, [p.p_memory_out]
      !CopyMemoryMMX:
      !PXOR mm1, mm1
      !movq mm1, [Ecx]
      !movntq [Edx], mm1
      !ADD  Ecx, 8
      !ADD  Edx, 8
      !SUB  Eax, 8
      !JNZ CopyMemoryMMX
      !emms
      ProcedureReturn
    CompilerCase #PB_Processor_x64
      !PXOR mm1, mm1
      !MOV Rax, [p.v_s]
      !MOV Rcx, [p.p_memory_in]
      !MOV Rdx, [p.p_memory_out]
      !CopyMemoryMMX:
      !PXOR mm1, mm1
      !movq mm1, [Rcx]
      !movntq [Rdx], mm1
      !ADD  Rcx, 8
      !ADD  Rdx, 8
      !SUB  Rax, 8
      !JNZ CopyMemoryMMX
      !emms
      ProcedureReturn
  CompilerEndSelect
 
EndProcedure


That is, jitter is caused by CPU cache use.

_________________
My general site & Bug head technology - Ultimate high quality sound player by BASS
My facebook page.


Top
 Profile  
Reply with quote  
 Post subject: Re: memory tips for ultra low jitter
PostPosted: Wed Dec 03, 2014 7:53 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 5:05 pm
Posts: 1769
Location: Norway
A comment/response to this is found under off-topic at viewtopic.php?f=17&t=61134


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye