NO

Author Topic: Storing 0 into a string  (Read 102 times)

Offline HellOfMice

  • Member
  • *
  • Posts: 80
  • Never be pleased, always improve
Storing 0 into a string
« on: Yesterday at 11:54:16 AM »
Just a proposition, I don't know if it is possible, so I need your advices


_mm256_xor_si256Compute the bitwise XOR of the 256-bit integer value of a and b.

char szString1[32] ;
_mm256_xor_si256(szString1,szString1) ;


That would fill a 32 bytes string with 0.
--------------------------------
Kenavo

Offline HellOfMice

  • Member
  • *
  • Posts: 80
  • Never be pleased, always improve
Re: Storing 0 into a string
« Reply #1 on: Yesterday at 12:38:51 PM »



                        __m256i a = _mm256_loadu_si256((__m256i*) _szTmp1);
                                 __m256i b = _mm256_loadu_si256((__m256i*) _szTmp1);


                        _mm256_xor_si256(a,b) ;

The compiler does not generate code for __mm_xor_si256 but it does for loading the two addresses
--------------------------------
Kenavo

Offline HellOfMice

  • Member
  • *
  • Posts: 80
  • Never be pleased, always improve
Re: Storing 0 into a string
« Reply #2 on: Yesterday at 12:48:02 PM »
The goo syntax for storing 32 Zeroes in a string is:


Code: [Select]

__m256i a = _mm256_loadu_si256((__m256i*) _szTmp1) ;
__m256i b = _mm256_loadu_si256((__m256i*) _szTmp1) ;


__m256i c = _mm256_xor_si256(a,b) ;
__mm256_storeu_si256((__m256i*) _szTmp1,c) ;


Verified under Pelle's C Compiler with pope
Code: [Select]

0x0000ED51  vmovdqu                         ymm0,ymmword ptr [rsp+188]  C5 FE 6F 84 24 88 01 00 00
0x0000ED5A  vmovdqu                         ymm1,ymmword ptr [rsp+188]  C5 FE 6F 8C 24 88 01 00 00
0x0000ED63  vpxor                              ymm0,ymm0,ymm1        C5 FD EF C1
0x0000ED67  vmovdqu                         ymmword ptr [rsp+188],ymm0  C5 FE 7F 84 24 88 01 00 00

Helped with this link: https://jcma.me/blog/2017/01/23/accelerate-c-code-with-avx2-instructions
« Last Edit: Yesterday at 12:54:03 PM by HellOfMice »
--------------------------------
Kenavo

Offline Vortex

  • Member
  • *
  • Posts: 857
    • http://www.vortex.masmcode.com
Re: Storing 0 into a string
« Reply #3 on: Yesterday at 07:43:37 PM »
/arch option (POCC) [9.00] :
 
Quote
Syntax:
/arch:{SSE2 | AVX | AVX2}

Quote
Description:
The /arch option selects the processor architecture (for X64).

Architecture Description Default
SSE2 Enable use of Streaming SIMD Extensions 2 instructions. Yes
AVX Enable use of Advanced Vector Extensions instructions. No
AVX2 Enable use of Advanced Vector Extensions 2 instructions. No
Code it... That's all...

Offline HellOfMice

  • Member
  • *
  • Posts: 80
  • Never be pleased, always improve
Re: Storing 0 into a string
« Reply #4 on: Yesterday at 07:47:35 PM »
Hi Vortex


In the project file I select the SSE2 for the code generation


Could it be possible to compute the mean of RGB values with these instruction; I am searching.
I think that first I must have A0R0G0B int this order for the number and after it is possible to add them.
It's an idea, maybe I dream


Thank you for your comments
--------------------------------
Kenavo