Author: Gerd Isenberg
Date: 02:21:13 10/10/03
Go up one level in this thread
On October 09, 2003 at 19:02:44, Patrick N wrote:
>On October 09, 2003 at 18:46:14, Gerd Isenberg wrote:
>
>>On October 09, 2003 at 18:08:41, Patrick N wrote:
>>
>>>I'd say it depends on what exactly you are trying to do. Are you trying to have
>>>a common class with different implementations depending on what hardware is
>>>available or different implementations which you use at the same time?
>>>If you want a common class, you could have one header but different
>>>implementations (using different source files and/or preprocessor).
>>
>>Hi Patrick,
>>
>>I understand, i want to use them simultaniously in one routine to gain more
>>parallel performance with different register files.
>>
>>>One example
>>>I use like this is a thread class. This way I can have a common interface for
>>>both posix threads and windows threads. I use the same header file, but
>>>different implementations depending on the platform.
>>>If you are trying to use two different approaches to storing data in the same
>>>algorithm, I recommend two different classes, but have operators that can
>>>convert easily between them.
>>
>>I tend to favor this solution too.
>>
>>One possible pro for a common base: Member incarnations with instanciable base,
>>register incarnation with two derivates. Assignment, copy constructurs only from
>>base to derivates, but not between derivates (different register files). Kind of
>>OO-perversion ;-)
>
>I'm not sure why you want to have a common base class here. Although the two
>different datatypes have the same operations, I don't think there is any benefit
>to a common base because all the operations are inline anyway. The base class
>would only be there to make it "look" more OO.
>If you need to hide the implementation and pass generic classes around, then the
>common base class starts to make more sense
>-Patrick
I'm not sure, too. A sample:
A - the instanciable base determines the sizeof
/ \
/ C - intrinsic wrapper
B - C++ wrapper
class CTarget
{
A x;
A y;
...
};
class CNode
{
A a;
A aa;
...
inline void foo (CTarget* pTarget) const;
};
// a time critical function with two independent calculation chains
void CNode::foo (CTarget* pTarget) const
{
register B b1(a);
register B b2(aa);
register B br = (b1 ^ (b2<<8)) >> 8;
register B q1(a);
register B q2(aa);
register B qr = (q1 ^ (q2>>8)) << 8;
...
br.store (pTarget->x);
qr.store (pTarget->y);
}
// a time critical function with two independent calculation chains
// changed to use different register files,
// like general purpose and XMM-registers
// only by changing type B to C in one chain
void CNode::foo (CTarget* pTarget) const
{
register B b1(a);
register B b2(aa);
register B br = (b1 ^ (b2<<8)) >> 8;
register C q1(a);
register C q2(aa);
register C qr = (q1 ^ (q2>>8)) << 8;
...
q1 = b1; // should probably not allowed due to different register file
br.store (pTarget->x);
qr.store (pTarget->y);
}
Gerd
<snip>
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.