News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

different compares clock cycle test ???

Started by daydreamer, February 11, 2025, 04:23:36 AM

Previous topic - Next topic

sinsi

Quote from: daydreamer on February 13, 2025, 07:43:34 AMWhat's happened to this forum ?,nobody wants to test run code anymore ? :(
I have a comparison that might not been tested yet :
A loop with many scalar compares with conditional jumps vs packed compares ???

The skeleton code I wrote earlier is all you need, just add the code you want to test.

zedd151

Quote from: daydreamer on February 13, 2025, 07:43:34 AMWhat's happened to this forum ?,nobody wants to test run code anymore ? :(
It's usually the OP that supplies the testing method. This will ensure that all testers will use the same testbed (I.e., testing methods), for better comparison between processors where the test is being conducted, and even to test for any differences between OS's etc. that are testing the same function or algorithm.
¯\_(ツ)_/¯

NoCforMe

We look forward to your test results, hopefully soon.
Assembly language programming should be fun. That's why I do it.

daydreamer

Scalar vs packed SSE compare

// primesx.cpp

#include "pch.h"
#include <iostream>
using namespace std;
float zero = 0.0;
int pflag = 0;
alignas(16) float flut[]{ 2.0,3.0,5.0,7.0,11.0,13.0,17.0,19.0,0.0,0.0,0.0 };
alignas(16) float arr[]{ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 };
char lut[]{ 0, 0, 2, 3, 0, 5, 0, 7, 0, 0,0,11,0,13,0,0,0,0,0,0 };
int main()
{
int i, j=3;
float f = 3.0;
float fresult = 0;
    cout << "Primesx\n";
for (i = 0; i < 14; i++) {
cout << i << " ";
if (lut[i] != 0) cout << "prime " << (int)lut[i] << " ";
cout << f << " ";
//f = f + 1.0;
}
cout << f << " ";
cout << "\n\n\n\n";
for (j = 1; j < 14; j=j+1) {
f = (float)j; //test all floats
_asm {
push ebx

mov ecx, 14
mov ebx, 1
; lea ebx, [ebx * 4]
lea ebx, [flut + ebx * 4]
; lea ebx, flut
L2 :
movss xmm0, f
movss xmm1, [ebx]
; subss xmm0, xmm1
ucomiss xmm0, xmm1
jne L1; found prime
ja L4s;ja jump if above,jb jump if below
mov eax, 1
mov pflag, eax
movss xmm0, [ebx]
movss fresult, xmm0
jmp l3;have found prime, jump out of loop
L4s:
mov eax,0ffffffffh
jmp L3
L1 :
xorps xmm0, xmm0
mov eax,0
mov pflag,eax
; movss fresult, xmm0
add ebx, 4
dec ecx
jne L2
L3:
pop ebx


}
fresult = fresult * pflag;
cout << fresult << " ";
}//j
cout << "\n";
for (j = 2; j < 20; j++) {
f = (float)j;

_asm {
push ebx
lea ebx, flut
movss xmm0, f
shufps xmm0, xmm0, 0
movups xmm1, [ebx]
movaps xmm3, xmm1
CMPEQPS xmm1, xmm0
pand xmm1, xmm3
movaps xmm7, xmm1
add ebx, 16
movups xmm1, [ebx]
movaps xmm3, xmm1
CMPEQPS xmm1, xmm0
pand xmm1, xmm3
por xmm1, xmm7
movups arr, xmm1
haddps xmm1, xmm1
haddps xmm1, xmm1
movss fresult, xmm1


pop ebx
}
cout << "xmm reg float 0,float 1,float 2,float 3 : "<< arr[0] << " " << arr[1] << " " << arr[2] << " " << arr[3] << "\n";
cout << fresult << " zero = non prime\n";

}//second time j


}


my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

jack


NoCforMe

Assembly language programming should be fun. That's why I do it.

TimoVJL

Quote from: NoCforMe on February 17, 2025, 06:16:19 AMI don't see any results, only C code.
C++ code with part of assembler block.
C and C++ aren't same thing.

I don't use C++, as i don't need it, and as it isn't universal at all, as it can't share object files nor libraries.
May the source be with you