From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2003-11-17 19:07:15


Hurd, Matthew wrote:

[...]

> That link seems to suggest it is good for Windows Server 2003 only...
> Is that the case?
>
> InterlockedIncrement suggests it supports
> ___________
>
> Client: Included in Windows XP, Windows 2000 Professional, Windows
> NT
> Workstation, Windows Me, Windows 98, and Windows 95.
> Server: Included in Windows Server 2003, Windows 2000 Server, and
> Windows NT Server.
> ___________

Actually InterlockedIncrementAcquire works only on Windows 2003 Server but
InterlockedIncrement works on every Windows platform:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
e/interlockedincrement.asp

> For win32 the fastest approach I've found is to turn on the using
> intrinsics optimization for win32... though your mileage may vary.
> Also
> be warned I've found a roughly 3 to 1 difference between AMD and Intel
> P4s on this because of the processor differences.

Interesting... Intel is usually faster for those memory-access operations.

[...]

> Then perhaps something long the lines of this:
>
> class atomic_op
> {
> public:
> template< typename word_size_type>
> static word_size_type inc(word_size_type& v)
> {
> assert(sizeof(word_size_type) == sizeof(LONG));
> return InterlockedIncrement (reinterpret_cast< LONG volatile
> *>( &v ) );
> }
>
> et cetera...
>
>
> At the end of the day you only get tens of millions of increments a
> second for multithreaded code versus some billions per second for
> single
> thread increments using ++ ;-)

The interesting part is to speed up existing code with minimal dependencies,
knowing it cannot be faster. I am looking forward for eventual benchmarks
against Hans-Boehm's garbage collectors ;) To be honest with you, working
on this full-time... I would implement my "real-time" collector to get rid
instantaneously of cyclic references and add atomic reference count
operations immediately.

Regards.

Philippe