Re: NXC: Matrix algebra library
Posted: 14 Jul 2011, 21:40
[OT]
what is this BranchTest and this BranchComp for? Just for testing? Can it be dropped just to run the code?
(Already ArrayIndex and ArrayReplace I don't quite understand.)
I'll gladly test where I can, but I need to know what exactly I shall be testing. I must admit that I slowly don't quite understand anymore what's happening to my original code.
I want to add 3 aspects (not offending, and not nitpicking, for heaven's sake!) which is important for an "average" NXC user and even for those who understand and try a little more (like maybe me myself) without being an expert or a professional:
1st, any code should still remain "readable" C code,
2nd, of course it's marvellous to have a code that works twice as fast as before; but
3rd, it must not end up in writing pure NBC code to get quite optimized byte code.
To be honest, the fact that nested loops (for (i=...) for (j=....) ...) and array operations (A*=x) and array index operations (A[j]=B[n][m)] are widly unefficient and should be completely replaced by NBC code is not very reassuring.
From the point of view of my current project (stochastic filters) I don't know how important it is to have "maximum speed code" for matrices although it's good to know to have them: I will maybe have to do 3 or 5 or maybe even 10 matrix operations (and for a future particle filter maybe 20 random number generations) every 20msec - the rest are Wait states.
But for a C library it's better to have everything in pure C code (with a little speed disadvantage) than asm code (with a little speed advantage). Too much asm code and tons of #defines will deter NXC users if they don't understand it (e.g., me, in case it's not my own library).
High level code optimization 3+ is good if one knows what it's doing, but e.g., for / while loops or array look ups should be optimized anyway (already by level 0). I personally am suspicious of a code optimization if I don't know what's exactly happening, that's why I'm using code optimization level 1 (only unneeded functions and variables should be erased). The result of any higher optimization level should be accessible by writing pure C code (not asm) without any compiler optimazition, too.
Of course I'm glad that the matrix library leads to this discussion and to the related enhancements of both code and compiler.
Thanks to all for contributing!
[/OT]
what is this BranchTest and this BranchComp for? Just for testing? Can it be dropped just to run the code?
(Already ArrayIndex and ArrayReplace I don't quite understand.)
I'll gladly test where I can, but I need to know what exactly I shall be testing. I must admit that I slowly don't quite understand anymore what's happening to my original code.
I want to add 3 aspects (not offending, and not nitpicking, for heaven's sake!) which is important for an "average" NXC user and even for those who understand and try a little more (like maybe me myself) without being an expert or a professional:
1st, any code should still remain "readable" C code,
2nd, of course it's marvellous to have a code that works twice as fast as before; but
3rd, it must not end up in writing pure NBC code to get quite optimized byte code.
To be honest, the fact that nested loops (for (i=...) for (j=....) ...) and array operations (A*=x) and array index operations (A[j]=B[n][m)] are widly unefficient and should be completely replaced by NBC code is not very reassuring.
From the point of view of my current project (stochastic filters) I don't know how important it is to have "maximum speed code" for matrices although it's good to know to have them: I will maybe have to do 3 or 5 or maybe even 10 matrix operations (and for a future particle filter maybe 20 random number generations) every 20msec - the rest are Wait states.
But for a C library it's better to have everything in pure C code (with a little speed disadvantage) than asm code (with a little speed advantage). Too much asm code and tons of #defines will deter NXC users if they don't understand it (e.g., me, in case it's not my own library).
High level code optimization 3+ is good if one knows what it's doing, but e.g., for / while loops or array look ups should be optimized anyway (already by level 0). I personally am suspicious of a code optimization if I don't know what's exactly happening, that's why I'm using code optimization level 1 (only unneeded functions and variables should be erased). The result of any higher optimization level should be accessible by writing pure C code (not asm) without any compiler optimazition, too.
Of course I'm glad that the matrix library leads to this discussion and to the related enhancements of both code and compiler.
Thanks to all for contributing!
[/OT]