November 27, 2020, 06:13:45 AM

Author Topic: Is int128 the same as C long long?  (Read 160 times)

Offline Scaremonger

  • Jr. Member
  • **
  • Posts: 95
    • ITSpeedway - Ramblings of a geek!
Is int128 the same as C long long?
« on: November 09, 2020, 05:10:22 PM »
Hi,
Is the data type "long long" equivalent to BlitzMaxNG Int128 datatype or is it a ULong?

I have finally got around to updating Fungicide after it stuttered it's way into second place in the Nov-Jan 2018 "Retro" game competition. I already know that the main issue is with my game loop, but I have been digging around for other issues too. One of the first things I looked at was timing. I had chosen to use a modified form of ImaginaryHumans MilliSecsLong() function and I've found it is very slow compared to the standard MilliSecs() function. A million iterations gave me:

MilliSecs(): 89ms
MilliSecsLong(): 226ms

The reason I went for the MilliSecsLong() function was because of Integer rollover, so it got me looking at the MinGW C Library and I threw together this function:

milli.c
Code: [Select]
#include "time.h"
#include <sys/time.h>
long long Milli(void) {
struct timeval tv;
gettimeofday( &tv, NULL );
return (( (long long)tv.tv_sec )*1000 )+( tv.tv_usec/1000 );
}

Blitzmax:
Code: [Select]
Import  "milli.c"
Extern
Function Milli:Int128()
End Extern

local time:int128 = Milli()

A million iterations now gave me:
MilliSecs(): 92ms
MilliSecsLong(): 236ms
Milli(): 89ms

So back to my initial question... Is int128 the correct datatype?

Fungicide: https://www.syntaxbomb.com/index.php/topic,3984.0.html
Competition: https://www.syntaxbomb.com/index.php/topic,3997.0.html
MilliSecsLong(): https://www.syntaxbomb.com/index.php?topic=2349.0

Regards,
Si...
Follow me at ITSpeedway.net.

Offline Henri

  • Sr. Member
  • ****
  • Posts: 265
Re: Is int128 the same as C long long?
« Reply #1 on: November 09, 2020, 07:35:39 PM »
Hi,

nope. Bmax Ng equivalent of a C long long (64 bit signed integer) is just plain long :-) Int128 is a special SIMD datatype which I'm not that familiar with.

See here https://blitzmax.org/docs/en/language/data_types/

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Offline Scaremonger

  • Jr. Member
  • **
  • Posts: 95
    • ITSpeedway - Ramblings of a geek!
Re: Is int128 the same as C long long?
« Reply #2 on: November 09, 2020, 09:55:22 PM »
Thanks @Henri

So the blitzmax part of the code should be:

Code: [Select]
Import  "milli.c"
Extern
Function Milli:Long()
End Extern

local time:Long = Milli()
print time
Follow me at ITSpeedway.net.

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: Is int128 the same as C long long?
« Reply #3 on: November 09, 2020, 10:28:01 PM »
While this is a good "speedup" ... how often are you calling Millisecs() a second? :D


Bye
Ron aka "A MillisecsLong() user"

Offline Matty

  • Hero Member
  • *****
  • Posts: 1253
    • MattiesGames
Re: Is int128 the same as C long long?
« Reply #4 on: November 10, 2020, 05:17:03 AM »
Hardly the point of slowdown in any game - a call to a system timer.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal