Rodent 0.12

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Rodent 0.12

Post by PK »

hi,

thanks for Your input.

as for sleeping, it is used for weakening the engine. this feature is not activated yet, because it needs much more tuning than I can afford right now.

do You have access to code that wasets specific number of nanoseconds under Linux?
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Rodent 0.12

Post by lucasart »

PK wrote: do You have access to code that wasets specific number of nanoseconds under Linux?
Yes, the link I sent you. There is also usleep (if you want microseconds).

In fact it's probably easier to use usleep, unless you really need nanosecond precision and to not be polluted by signals.

Using usleep couldn't be easier:

Code: Select all

#include <unistd.h>

int usleep&#40;useconds_t usec&#41;;
(usec is expressed in microseconds)
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Rodent 0.12

Post by lucasart »

also for the sake of portability (as well as simplicity), you could use the ISO C function clock() instead of all this

Code: Select all

int sTimer&#58;&#58;GetMS&#40;void&#41;
&#123;
#if defined&#40;_WIN32&#41; || defined&#40;_WIN64&#41;
  return GetTickCount&#40;);
#else
  struct timeval tv;

  gettimeofday&#40;&tv, NULL&#41;;
  return tv.tv_sec * 1000 + tv.tv_usec / 1000;
#endif
&#125;
while linux gives you nanosecond precision, I don't think windows' GetTickCount has a better resolution than a millisecond (or maybe even 10 ms...), so there's no point in all this complication.

Much easier and fully portable:

Code: Select all

#include <time.h>

clock_t start = clock&#40;);
...
clock_t stop = clock&#40;);

unsigned duration_milliseconds = &#40;stop - start&#41; * 1000 / CLOCKS_PER_SEC;
Anyway, I fixed your code and compiled it. I'll test it in my Open Source Bullet rating list. As usual results tomorrow in the tournament forum :D
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Rodent 0.12

Post by Michel »

In fact it's probably easier to use usleep, unless you really need nanosecond precision and to not be polluted by signals.
Well usleep is deprecated....

Code: Select all

POSIX.1-2001  declares  this  function  obsolete;  use  nanosleep&#40;2&#41;  instead.
       POSIX.1-2008 removes the specification of usleep&#40;).
PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Rodent 0.12

Post by PK »

64-bit compiles by Denis Mendoza and Dann Corbit are uploaded
developement snapshot with compatibility fixes will come after the weekend

busy regards,

pawel
User avatar
Jim Ablett
Posts: 1383
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: Rodent 0.12

Post by Jim Ablett »

Here's my Rodent 0.12 GCC builds (Win32 & Linux 32/64) plus src+makefile which compiles cleanly.
I didn't include a Mingw64 compile because it runs slower than the Msvc/Intel ones from Dann & Dennis which
surprised me as the Mingw32 compile is faster.

http://dl.dropbox.com/u/5047625/rodent-012-gcc-ja.zip

Jim.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Rodent 0.12

Post by lucasart »

lucasart wrote: while linux gives you nanosecond precision, I don't think windows' GetTickCount has a better resolution than a millisecond (or maybe even 10 ms...)
Actually, according to Micro$oft, GetTickCount and GetTickCount64 have a resolution between 10 and 16 ms :shock:

I couldn't find a proper timer that uses the CPU clock in the Windows API. And it seems that MSVC implements clock() by calling GetTickCount anyway.

As always, Windows sucks ;)
mar
Posts: 2555
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Rodent 0.12

Post by mar »

lucasart wrote: Actually, according to Micro$oft, GetTickCount and GetTickCount64 have a resolution between 10 and 16 ms :shock:

I couldn't find a proper timer that uses the CPU clock in the Windows API. And it seems that MSVC implements clock() by calling GetTickCount anyway.

As always, Windows sucks ;)
You can try QueryPerformanceCounter/QueryPerformanceFrequency instead if you need really precise timing.
ZirconiumX
Posts: 1334
Joined: Sun Jul 17, 2011 11:14 am

Re: Rodent 0.12

Post by ZirconiumX »

Jim,

Your source is non-compileable (if there is such a word).

Code: Select all

g++ -c -g attacks.c  -Wall -O3 -Wno-write-strings 
attacks.c&#58;33&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;33&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;35&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;35&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;37&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;37&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;37&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;37&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;49&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;49&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;50&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;50&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;58&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;58&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;59&#58; error&#58; integer constant is too large for 'long' type
attacks.c&#58;59&#58; error&#58; integer constant is too large for 'long' type
make&#58; *** &#91;attacks.o&#93; Error 1
Yes, I know - my GCC is _ancient_ (4.0.1) - and I'll try to build myself a copy of clang(++).

Matthew:out
Some believe in the almighty dollar.

I believe in the almighty printf statement.
User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: Rodent 0.12

Post by rvida »

lucasart wrote:
lucasart wrote: while linux gives you nanosecond precision, I don't think windows' GetTickCount has a better resolution than a millisecond (or maybe even 10 ms...)
Actually, according to Micro$oft, GetTickCount and GetTickCount64 have a resolution between 10 and 16 ms :shock:

I couldn't find a proper timer that uses the CPU clock in the Windows API. And it seems that MSVC implements clock() by calling GetTickCount anyway.

As always, Windows sucks ;)
You can get 1ms precision using timeBeginPeriod, timeEndPeriod and timeGetTime functions.

http://msdn.microsoft.com/en-us/library ... 85%29.aspx
The default precision of the timeGetTime function can be five milliseconds or more, depending on the machine. You can use the timeBeginPeriod and timeEndPeriod functions to increase the precision of timeGetTime.