SSE/MMX
Posted: Mon Aug 08, 2005 12:51 am
				
				This code uses SSE/MMX. 
(add 2 buffers of floating points, multiply them by v_gain, and move the result into a third buffer of 16bit integers)
It works all the time in a process with 1 thread.
In a multithreaded process however, It works sometimes and sometimes not.
(when this code is called from an Asio_CallBack)
Sometimes, just by minimizing the main application window and restoring it, the code works again. (no I am not drunk! this is really happening, i can reproduce it many times....)
It is difficult to figure out what exactly goes wrong, since it's impossible to debug the real time thread without a crash.
Should I do something extra?
			(add 2 buffers of floating points, multiply them by v_gain, and move the result into a third buffer of 16bit integers)
It works all the time in a process with 1 thread.
In a multithreaded process however, It works sometimes and sometimes not.
(when this code is called from an Asio_CallBack)
Sometimes, just by minimizing the main application window and restoring it, the code works again. (no I am not drunk! this is really happening, i can reproduce it many times....)
It is difficult to figure out what exactly goes wrong, since it's impossible to debug the real time thread without a crash.
Should I do something extra?
Code: Select all
  !movss xmm2,[v_Gain]
  !unpcklps xmm2,xmm2
  !movlhps xmm2,xmm2
  
  !MOV edi, [v_L0]
  !MOV esi, [v_L1]
  !MOV ebp, [v_LD]
  !MOV ecx, 256
  !.While1:
    !movups xmm0,[edi]
    !movups xmm1,[esi]
    !addps xmm0,xmm1
    !mulps xmm0, xmm2
    !cvtps2pi mm0,xmm0
    !movhlps xmm0,xmm0
    !cvtps2pi mm1,xmm0  
    !packssdw mm0,mm1
    !movq [ebp],mm0
    !ADD esi,16
    !ADD edi,16
    !ADD ebp,8
  !LOOP .While1
  !EMMS