Computer Chess Club Archives


Search

Terms

Messages

Subject: C++ class design question

Author: Gerd Isenberg

Date: 14:05:41 10/09/03


Hi all,
especially low level C++ experts,

I introduced this SSE2-intrinsic wrapper class with sizeof(2*8):

http://www.talkchess.com/forums/1/message.html?320110

It encapsulates the intrinsic data type __m128i.

Now i like to write a compatible class with standard C++ 64-bit types,
two bitboards.

Both classes have the same public interface, the same size,
the same memory image, but disjoint register representation.

Due to all constructors and operators are forced to be inlined,
a abstract, pure virtual base class makes no sense. And late binding
at runtime is no issue here.

The issue is portability and the possibility to mix SSE2 (or other 128-bit
register files on other processors) and gp-algorithms with independent
instruction chains. Performance tuning by changing some datatype of connected
(register) variables (but probably not the type of incarnations in memory,
e.g. members of some source and target structs).

What is the best way to implement that,
with respect to the different register files?

1. Two none related classes with coincidentally have
   the same operators, size and memory image.

2. One "protected" base class with a union of both types, but no operators,
   and two derived classes with inlined operators and constructors?

  union
  {
    __m128i dbl;
    BitBoard sgl[2];
  }

3. A portable full implemented base class and a derived class with
   overloaded operators and constructors implemented with
   intrinsic functions and data type.

One problem is assignment from one type to the other and casting.
Memory-memory/register or vice versa is fine, but register-register
is rather inperformant and should be avoided.

Thanks in advance,
Gerd



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.