Discussion:
Templates?
(too old to reply)
Christopher Prosser
1999-05-24 17:48:26 UTC
Permalink
Hi All,
Am I mis-remembering, or did someone mention a couple of months ago they
were working on a template based audio processing framework?
Thanks,
Chris Prosser


dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Ross Bencina
1999-05-24 18:51:32 UTC
Permalink
Post by Christopher Prosser
Am I mis-remembering, or did someone mention a couple of months ago they
were working on a template based audio processing framework?
I don't remember anyone mentioning it here, but it's certainly a good idea.
I have read some interesting discussions of using templates to generate very
efficient vector/matrix processing code...

For example (assuming Signal is a 64 sample vector type):

Signal a,b,c,d;

d = (a + b)*c;

//using standard operator overloading the generated code might look like:
Signal a,b,c,d;

Signal temp;
for( int i=0; i<64; i++ )
temp[i] = a[i] + b[i];

for( int i=0; i<64; i++ )
d[i] = temp[i] * c[i];

//somehow it's possible to use templates to build and unroll a parse tree at
compile time
// to generate code that looks like this:

Signal a,b,c,d;

for( int i=0; i<64; i++ )
d[i] = (a[i] + b[i]) * c[i];


If anyone knows the details of how to achieve this I'd be really interested
in finding out about it.

Regards,

Ross
http://www.audiomulch.com/~rossb/





dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Thomas Hudson
1999-05-26 13:57:20 UTC
Permalink
Post by Ross Bencina
If anyone knows the details of how to achieve this I'd be really interested
in finding out about it.
Stroustrup discusse optimizations to minimize temporaries, multiple loops or the
same data, etc. through the use of auxiliary classes to represent binary operations
and deferring evaluation, i.e. closures, in Section 22.4.7, _The C++ Programming
Language_, Third Edition.

Signal a,b,c,d;

d = (a + b)*c;

// deferral of add operation
struct SigAdd {
const Signal& a;
const Signal& b;

SigMul(const Signal& aa, const Signal& bb) : a(aa), b(bb) {}

operator Signal(); //evaluate and return result
};

inline SigAdd operator*(const Signal& a, const Signal& b)
{
return SigAdd(a,b);
}

// deferral of add and multiply
struct SigAddSigMul {
const Signal& a;
const Signal& b;
const Signal& c;

SigAddSigMul(const SigAdd& sa, const Signal& cc)
: a(sa.a), b(sa.b), c(cc)
{}

operator Signal(); //evaluate and return
};

inline SigAddSigMul operator+(const SigAdd& sa, const Signal& c)
{
return SigAddSigMul(sa,c);
}

class Signal
{
float samples[64];

public:
Signal(const SigAddSigMul& sasm)
{
for (int i = 0; i < 64; ++i)
samples[i] = (sasm.a[i] + sasm.b[i]) * sasm.c[i];
}
Signal& operator=(const SigAddSigMul& sasm)
{
for (int i = 0; i < 64; ++i)
samples[i] = (sasm.a[i] + sasm.b[i]) * sasm.c[i];
}
// ...
};

Thomas

dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Dan Timis
1999-05-24 23:08:31 UTC
Permalink
Ross Bencina
1999-05-25 00:30:56 UTC
Permalink
Dan Timis wrote:
[snip]
valarray<double> fv(5);
for (i = 0; i < 5; i++)
fv[i] = (double) i;
<snip>
fv = sqrt(fv);
<snip>
fv = fv + fv;
<snip>
fv = fv - 10.0;
---
As you can see this does exactly what you want
not necessarily. My point was that it's possible to to design templates in
such a way that a composite expression (more than one operator) which would
usually create an unwanted temporary (because functions containing for loops
can't be inlined) dosn't, as in:

fv = (fv-10) * 500.

I will try to dig up the reference. Perhaps Herbert Schildt just didn't give
the example that would suggest this (which is not surprise).

Ross.




dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Michael Gogins
1999-05-25 01:06:35 UTC
Permalink
Check out the Blitz++ project. A web search should find it.

-----Original Message-----
From: Ross Bencina <***@audiomulch.com>
To: music-***@shoko.calarts.edu <music-***@shoko.calarts.edu>
Date: Monday, May 24, 1999 4:45 PM
Subject: Re: Templates?
Post by Ross Bencina
Post by Christopher Prosser
Am I mis-remembering, or did someone mention a couple of months ago they
were working on a template based audio processing framework?
I don't remember anyone mentioning it here, but it's certainly a good idea.
I have read some interesting discussions of using templates to generate
very
Post by Ross Bencina
efficient vector/matrix processing code...
Signal a,b,c,d;
d = (a + b)*c;
Signal a,b,c,d;
Signal temp;
for( int i=0; i<64; i++ )
temp[i] = a[i] + b[i];
for( int i=0; i<64; i++ )
d[i] = temp[i] * c[i];
//somehow it's possible to use templates to build and unroll a parse tree
at
Post by Ross Bencina
compile time
Signal a,b,c,d;
for( int i=0; i<64; i++ )
d[i] = (a[i] + b[i]) * c[i];
If anyone knows the details of how to achieve this I'd be really interested
in finding out about it.
Regards,
Ross
http://www.audiomulch.com/~rossb/
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Michael Gogins
1999-05-25 01:14:13 UTC
Permalink
The Blitz++ project is at http://monet.uwaterloo.ca/blitz/.

-----Original Message-----
From: Dan Timis <***@opcode.com>
To: music-***@shoko.calarts.edu <music-***@shoko.calarts.edu>
Date: Monday, May 24, 1999 7:30 PM
Subject: Re: Templates?
Dan Timis
1999-05-25 01:25:59 UTC
Permalink
Post by Ross Bencina
not necessarily. My point was that it's possible to to design templates in
such a way that a composite expression (more than one operator) which would
usually create an unwanted temporary (because functions containing for loops
fv = (fv-10) * 500.
One way to compute your expression may be:

temp = fv - 10;
fv = temp * 500;

another way may be:

fv = fv - 10;
fv = fv * 500;

In the second case there is no temp variable but there are two loops.
However, depending on the compiler and the CPU two loops may not be
significantly slower than one. If one can write a new set of templates
and achieve a 5-10% increase in efficiency, I personally wouldn't bother,
and use valarray instead.

But it is worth trying to implement a couple of operations and compare
the results with valarray. Somehow I suspect that you will not get a
very significant increase in performance.

Dan

dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Dan Timis
1999-05-25 05:24:14 UTC
Permalink
It may be worth looking into Blitz++. But here is a big potential
problems: I didn't see any mention of a Macintosh or Windows
implementation. And if there will be one someday who knows how fast it
is going to be ported or updated to new versions of the OS or new
compiler versions.

I use a Mac and I use Metrowerks CodeWarrior. I didn't have any time to
try it yet but I did check and CodeWarrior does have valarray templates.
I expect that any decent C++ compiler has them.

Dan
Post by Michael Gogins
The Blitz++ project is at http://monet.uwaterloo.ca/blitz/.
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Michael Gogins
1999-05-25 11:44:30 UTC
Permalink
The techniques in Blitz++ can be selectively applied using ordinary C or C++
code. For example in matrix math you can write dot product
Matrix A, B, C;
A = B * C;
which creates a temporary and copies it to A or
void Matrix::Matrix.dot(Matrix &A, Matrix &B, Matrix &C);
which creates no temporary and copies results into pre-allocated and waiting
A. Eliminating temporaries can always be done by careful use of function
closures such as this and template functions.

Similarly, by careful definition of closures and templates, it is possible
to get the compiler to inline and expand and unroll all elements of even
quite complex
expressions. This technique is called "expression templates." There was a
paper at the last ICMC (1998) on how to do this in signal processing code.

-----Original Message-----
From: Dan Timis <***@opcode.com>
To: music-***@shoko.calarts.edu <music-***@shoko.calarts.edu>
Date: Tuesday, May 25, 1999 1:37 AM
Subject: Re: Templates?
Post by Dan Timis
It may be worth looking into Blitz++. But here is a big potential
problems: I didn't see any mention of a Macintosh or Windows
implementation. And if there will be one someday who knows how fast it
is going to be ported or updated to new versions of the OS or new
compiler versions.
I use a Mac and I use Metrowerks CodeWarrior. I didn't have any time to
try it yet but I did check and CodeWarrior does have valarray templates.
I expect that any decent C++ compiler has them.
Dan
Post by Michael Gogins
The Blitz++ project is at http://monet.uwaterloo.ca/blitz/.
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Dan Timis
1999-05-25 20:28:50 UTC
Permalink
Post by Michael Gogins
This technique is called "expression templates." There was a
paper at the last ICMC (1998) on how to do this in signal processing code.
Do you know who the author is? Is this paper available from anywhere
besides the proceedings?

Thanks,

Dan

dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Michael Gogins
1999-05-25 22:31:31 UTC
Permalink
The paper was by Adrian Freed and is titled "Music Programming with the new
Features of Standard C++." One of the authors cited by Freed and to look for
on the Web or elsewhere in Veldhuizen, who wrote much of Blitz++. The EGCS
compiler (currently the state of the art compiler for GNU or Linux, as far
as I know) will compile Blitz++ and can be got from http://egcs.cygnus.com/.

-----Original Message-----
From: Dan Timis <***@opcode.com>
To: music-***@shoko.calarts.edu <music-***@shoko.calarts.edu>
Date: Tuesday, May 25, 1999 5:24 PM
Subject: Re: Templates?
Post by Dan Timis
Post by Michael Gogins
This technique is called "expression templates." There was a
paper at the last ICMC (1998) on how to do this in signal processing code.
Do you know who the author is? Is this paper available from anywhere
besides the proceedings?
Thanks,
Dan
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Chuck Caplan
1999-05-26 04:58:17 UTC
Permalink
Sorry I'm asking here, but this is the only forum i currently subscribe to, and
i am hoping one of you can help... My girlfriend has a Pentium 233 and a modem
internet connection. Whenever she logs on the internet, nothing from the
network will load unless she moves the mouse. For instance, it will say 0%
loaded until she moves the mouse pointer, and the page will load until she stops
moving it. Then it won't continue unless she moves the mouse. This is really
weird, at least I have never heard of it... Does anyone know how to fix this
problem, so the mouse doesn't have to move to make the network work? Thanks a
lot! By the way, this problem started when she made a new Dial Up Networking
Connection, but works for every connection (Her ISP, Juno, etc.) Thanks!

Chuck


dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Benjamin GOLINVAUX
1999-05-26 05:45:44 UTC
Permalink
Post by Chuck Caplan
weird, at least I have never heard of it... Does anyone know how to fix this
problem, so the mouse doesn't have to move to make the network work?
Thanks a
Post by Chuck Caplan
lot! By the way, this problem started when she made a new Dial Up Networking
Connection, but works for every connection (Her ISP, Juno, etc.) Thanks!
Try to use either COM1 or COM3 for the mouse and COM2 or COM4 for the modem.
Make sure they
do not use the same interrupt (you can check this in the Control Panel
applet, System tab)

If you have a PS/2 mouse, try to change the COM port of the modem.


Benjamin.




dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Chuck Caplan
1999-05-28 04:02:36 UTC
Permalink
you all were right, it was a conflict, thanks SO much for your help, all is
better now :)
chuck
Post by Chuck Caplan
Post by Chuck Caplan
weird, at least I have never heard of it... Does anyone know how to fix
this
Post by Chuck Caplan
problem, so the mouse doesn't have to move to make the network work?
Thanks a
Post by Chuck Caplan
lot! By the way, this problem started when she made a new Dial Up
Networking
Post by Chuck Caplan
Connection, but works for every connection (Her ISP, Juno, etc.) Thanks!
Try to use either COM1 or COM3 for the mouse and COM2 or COM4 for the modem.
Make sure they
do not use the same interrupt (you can check this in the Control Panel
applet, System tab)
If you have a PS/2 mouse, try to change the COM port of the modem.
Benjamin.
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Joshua Reich
1999-05-26 07:12:03 UTC
Permalink
is there an IRQ conflict between the network card and the mouse port ?
Post by Chuck Caplan
Sorry I'm asking here, but this is the only forum i currently subscribe to, and
i am hoping one of you can help... My girlfriend has a Pentium 233 and a modem
internet connection. Whenever she logs on the internet, nothing from the
network will load unless she moves the mouse. For instance, it will say 0%
loaded until she moves the mouse pointer, and the page will load until she stops
moving it. Then it won't continue unless she moves the mouse. This is really
weird, at least I have never heard of it... Does anyone know how to fix this
problem, so the mouse doesn't have to move to make the network work? Thanks a
lot! By the way, this problem started when she made a new Dial Up Networking
Connection, but works for every connection (Her ISP, Juno, etc.) Thanks!
Chuck
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Ross Bencina
1999-05-27 03:28:49 UTC
Permalink
Thanks Thomas,

that's a step up from my current understanding. The template examples I read
about (still havn't found the reference) defined recursive templates to
somehow implicitly built a parse tree at complie time, which was then
reduced by the optimiser, avoiding the explicit definition of every
composite case as in your example.
j***@maths.bath.ac.uk
1999-05-27 17:11:33 UTC
Permalink
Dan Timis
1999-05-27 07:01:40 UTC
Permalink
Post by Thomas Hudson
Stroustrup discusse optimizations to minimize temporaries, multiple loops
or the
same data, etc. through the use of auxiliary classes to represent binary
operations
and deferring evaluation, i.e. closures, in Section 22.4.7, _The C++
Programming
Language_, Third Edition.
Signal a,b,c,d;
d = (a + b)*c;
<snip>

I was having trouble understanding how this is supposed to work. Then I
saw a few typos.

1. SigMul(const Signal& aa, const Signal& bb) : a(aa), b(bb) {}

this is actually the constructor for SigAdd so it should be named SigAdd.

2. operator+ and operator* should be reversed.

3. sasm.a[i], sasm.b[i], and sasm.b[i] should actually be
sasm.a.samples[i], sasm.b.samples[i], and sasm.c.samples[i].

So the correct code should be:

-------------- start ---------------
// deferral of add operation
struct SigAdd {
const Signal& a;
const Signal& b;

SigAdd(const Signal& aa, const Signal& bb) : a(aa), b(bb) {}

operator Signal(); //evaluate and return result
};

inline SigAdd operator+(const Signal& a, const Signal& b)
{
return SigAdd(a,b);
}

// deferral of add and multiply
struct SigAddSigMul {
const Signal& a;
const Signal& b;
const Signal& c;

SigAddSigMul(const SigAdd& sa, const Signal& cc)
: a(sa.a), b(sa.b), c(cc)
{}

operator Signal(); //evaluate and return
};

inline SigAddSigMul operator*(const SigAdd& sa, const Signal& c)
{
return SigAddSigMul(sa,c);
}

class Signal
{
float samples[64];

public:
Signal() {}
Signal(const SigAddSigMul& sasm)
{
for (int i = 0; i < 64; ++i)
samples[i] = (sasm.a.samples[i] + sasm.b.samples[i]) *
sasm.c.samples[i];
}
Signal& operator=(const SigAddSigMul& sasm)
{
for (int i = 0; i < 64; ++i)
samples[i] = (sasm.a.samples[i] + sasm.b.samples[i]) *
sasm.c.samples[i];
}
// ...
};
-------------- end ---------------
Post by Thomas Hudson
Thanks Thomas,
that's a step up from my current understanding. The template examples I read
about (still havn't found the reference) defined recursive templates to
somehow implicitly built a parse tree at complie time, which was then
reduced by the optimiser, avoiding the explicit definition of every
composite case as in your example.
This is a very interesting intellectual exercise but like Ross says
you'll have to anticipate every single combination. If instead of "d =
(a + b) * c" you write "d = c * (a + b)" you'll have to provide yet
another SigAddSigMul constructor and another operator*.

There must be a better solution. I didn't want to consider Blitz++
because if I want to use it I might have to port it to the Mac myself.
But maybe I should look into it.

Dan

dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Thomas Hudson
1999-05-27 12:49:50 UTC
Permalink
Post by Dan Timis
I was having trouble understanding how this is supposed to work. Then I
saw a few typos.
Sorry, I should have warned everyone that I was in a hurry and typed it
in quickly.
Post by Dan Timis
This is a very interesting intellectual exercise but like Ross says
you'll have to anticipate every single combination. If instead of "d =
(a + b) * c" you write "d = c * (a + b)" you'll have to provide yet
another SigAddSigMul constructor and another operator*.
Yes, as Stroustrup points out in the previously mentioned section.
Post by Dan Timis
There must be a better solution. I didn't want to consider Blitz++
because if I want to use it I might have to port it to the Mac myself.
But maybe I should look into it.
I've thought about how to apply templates to the problem, but
every solution thus far simply pushes the complexity down into
the final evaluation. It does seem possible to use a set of
class templates to represent the deferred evaluation that would
be a stack of evaluations to apply. Then in

Signal& Signal::operator=(const DeferredEvauation<Signal>& de)
{
char c;
while ((c = de.getNextOperator())!=0)
{

for (int i = 0; i < 64; ++i)
{
switch (c)
{
case '+':
...

etc.

Then for DeferredEvaluation you only need define the four overloaded
operators twice,


template <class T>
class DeferredEvaluation
{
vector<T> operands;
vector<char> operators;
...
};
DeferredEvalutation& operator+(const T&, const T&);
DeferredEvalutation& operator+(const DeferredEvalution&, const T&);
...


I'll ask some of our compiler guys, they may know of the template
examples Ross referred to.

Thomas

dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Ross Bencina
1999-05-27 14:19:01 UTC
Permalink
OK, I finally found the article...

Todd Veldhuizen and Kumaraswamy Ponnambalam."Linear Algebra with C++
Template Metaprograms." Dr Dobbs Journal, August 1996. (The C/C++
programming issue, yellow cover).

I think these are the Blitz++ guys. The article compares these template
techniques with Rogue Wave's "Math.h++" library (some of which is "hand
coded" asm), and reports significant gains. My understanding is that
template metaprograms offer lots of opportunities for compiler optimisation
and inlining which aren't available using valarray et al.
Sarah Thompson
1999-05-30 02:18:56 UTC
Permalink
Post by Ross Bencina
I don't remember anyone mentioning it here, but it's certainly a good idea.
I have read some interesting discussions of using templates to generate
very
Post by Ross Bencina
efficient vector/matrix processing code...
Though not an answer to this question, we do have an in-house comms library
built using C++ templates. You essentially create a transport independent
protocol definition as a class, then instantiate the protocol as a client or
server by passing it in as a parameter to one of the comms classes. We've
built native Netbios, named pipes and TCP/IP so far, all of which have been
carefully tuned for performance. If you look at the code that comes out in a
disassembler, it looks just like someone had written comms code directly
calling the sockets/NetBios/whatever API directly. The classes were
difficult to get right - it was about a year's work split between two
people. However, it does mean that we can now put together very fast,
efficient and reliable comms code in literally minutes, which with no
modifications can be run across any common network transport.

My one disappointment with templates has been the STL - it makes writing
code really clean and simple, but it does some really stupid things,
especially in the vector<...> implementation. Inserting an element into the
middle of the array causes a cascade of constructor, destructor and copy
constructor invocations. A number of the other classes are a little mouldy
in terms of performance too. I am talking about the MS implementation of the
STL, which I believe is based on HP's original code. If there is a faster
implementation of the STL around, I'd love to see it! I do use the STL an
awful lot, but I am aware that it is making my code slower than it should be
a lot of the time.

Sarah


dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Christopher Prosser
1999-05-30 04:31:16 UTC
Permalink
Post by Sarah Thompson
in terms of performance too. I am talking about the MS implementation of the
STL, which I believe is based on HP's original code.
P.J. Plauger's company Dinkumare, the original author of Microsofts STL
implementation, continues to improve them. MS has not bothered to licence
any of his newer versions but he sells them at a reasonable price.
http://www.dinkumware.com/libcppvc.html (I don't work for him. But we just
just upgraded our product to the new libraries last week).
-Chris


dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Sarah Thompson
1999-05-30 22:58:29 UTC
Permalink
Post by Christopher Prosser
P.J. Plauger's company Dinkumare, the original author of Microsofts STL
implementation, continues to improve them. MS has not bothered to licence
any of his newer versions but he sells them at a reasonable price.
http://www.dinkumware.com/libcppvc.html (I don't work for him. But we just
just upgraded our product to the new libraries last week).
I just ordered a copy on line. The web site makes scary reading - it could
explain quite a few problems we've had over the last couple of years. We
have a product that is 350k lines of VC++ that heavily uses the stl in a
multithreaded environment. Reading that the stl as shipped by MS isn't
guaranteed to be thread safe is far from good news.

Thanks for the pointer - we will certainly follow this one up. By the way,
did you see any speedups or reliability changes after you went to the new
STL implementation?

Sarah

PS: This maybe should be an off-list message, but I thought that this
discussion may well impinge on quite a few people here, even if it isn't
exactly DSP related.


dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Michael Gogins
1999-06-01 05:08:30 UTC
Permalink
The Microsoft implementation of the STL is not as complete as some others.
It is known to have a variety of problems. I think that the Rogue Wave
implementation is better.

Question: Is there a GNU-licensed implementation of the STL that could be
compiled using Microsoft Visual C++? The Microsoft compiler is the one I
have and seems to be quite good.

-----Original Message-----
From: Sarah Thompson <***@telergy.com>
To: music-***@shoko.calarts.edu <music-***@shoko.calarts.edu>
Date: Saturday, May 29, 1999 10:38 PM
Subject: Re: Templates?
Post by Sarah Thompson
Post by Ross Bencina
I don't remember anyone mentioning it here, but it's certainly a good
idea.
Post by Sarah Thompson
Post by Ross Bencina
I have read some interesting discussions of using templates to generate
very
Post by Ross Bencina
efficient vector/matrix processing code...
Though not an answer to this question, we do have an in-house comms library
built using C++ templates. You essentially create a transport independent
protocol definition as a class, then instantiate the protocol as a client
or
Post by Sarah Thompson
server by passing it in as a parameter to one of the comms classes. We've
built native Netbios, named pipes and TCP/IP so far, all of which have been
carefully tuned for performance. If you look at the code that comes out in
a
Post by Sarah Thompson
disassembler, it looks just like someone had written comms code directly
calling the sockets/NetBios/whatever API directly. The classes were
difficult to get right - it was about a year's work split between two
people. However, it does mean that we can now put together very fast,
efficient and reliable comms code in literally minutes, which with no
modifications can be run across any common network transport.
My one disappointment with templates has been the STL - it makes writing
code really clean and simple, but it does some really stupid things,
especially in the vector<...> implementation. Inserting an element into the
middle of the array causes a cascade of constructor, destructor and copy
constructor invocations. A number of the other classes are a little mouldy
in terms of performance too. I am talking about the MS implementation of
the
Post by Sarah Thompson
STL, which I believe is based on HP's original code. If there is a faster
implementation of the STL around, I'd love to see it! I do use the STL an
awful lot, but I am aware that it is making my code slower than it should
be
Post by Sarah Thompson
a lot of the time.
Sarah
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
dupswapdrop: the music-dsp mailing list and website
http://shoko.calarts.edu/~glmrboy/musicdsp/music-dsp.html
Ross Bencina
1999-06-04 04:12:31 UTC
Permalink
Post by Dan Timis
There must be a better solution. I didn't want to consider Blitz++
because if I want to use it I might have to port it to the Mac myself.
But maybe I should look into it.
Dan Timis
1999-06-04 07:43:48 UTC
Permalink
Post by Dan Timis
There must be a better solution. I didn't want to consider Blitz++
because if I want to use it I might have to port it to the Mac myself.
But maybe I should look into it.
Continue reading on narkive:
Loading...