Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Custom DSP Code 2 (comunity project)

For general discussion related FlowStone

Re: Custom DSP Code 2 (comunity project)

Postby Father » Sun Nov 08, 2015 2:21 am

Hey KG
Could you correct this example code so i can see how its done?
Code: Select all
streamin in;
streamout left;
streamout right;
if (in<=0) {
left = 1;
right = in+1;}
else {
left = 1-in;
right = 1;}
Father
 
Posts: 177
Joined: Thu Jan 09, 2014 5:48 pm

Re: Custom DSP Code 2 (comunity project)

Postby KG_is_back » Sun Nov 08, 2015 3:45 pm

A bug in compiler. Bitwise true mask (int In1=-1;) was not initializing correctly. Now it should work... This is exactly why I need you guys to test it. I sometimes miss obvious bugs, because there is simply so much to test...
Attachments
DSPC3.2.fsm
(16.71 KiB) Downloaded 976 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Custom DSP Code 2 (comunity project)

Postby Father » Sun Nov 08, 2015 9:22 pm

I just copied the output and i think there might be a problem with "andnps" cuz the assembler turns gray on that.
Father
 
Posts: 177
Joined: Thu Jan 09, 2014 5:48 pm

Re: Custom DSP Code 2 (comunity project)

Postby KG_is_back » Sun Nov 08, 2015 9:37 pm

Oh, you must be using Flowstone 3.0.7 or eariler. The coloring bug of andnps was fixed in 3.0.8 and also some new opcodes were introduced. I remember that andnps must have the source operand as either a variable or register (can't remember which one) in those older versions. Please test these two codes in your version (the working should return -1#INF, broken should return zero) and PM me the result:

Code: Select all
streamout out;
int In1=-1;
pslld xmm0,32;
andnps xmm0,In1;
movaps out,xmm0;


Code: Select all
streamout out;
int In1=-1;
pslld xmm0,32;
movaps xmm1,In1;
andnps xmm0,xmm1;
movaps out,xmm0;


I will try to make DSPC3 version (or something like a "legacy mode") that is compatible with older versions of Flowstone. I should have pointed that out earier...
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Custom DSP Code 2 (comunity project)

Postby KG_is_back » Sun Nov 08, 2015 11:46 pm

OK this one should work with pre-308 versions of flowstone (haven't tested yet). Just open the properties of the module and click "legacyMode" on and it should produce pre-308 compatible code. Note that the syntax colouring bug will still be there (asm code after "andnps" will show black, but it will work).
Attachments
DSPC3.2.2.fsm
(17 KiB) Downloaded 949 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Custom DSP Code 2 (comunity project)

Postby Father » Mon Nov 09, 2015 12:12 am

Im not sure the output is correct. when doing it without if it works ok. Well im still on 3.0.5.
Code: Select all
streamin in;
streamout left;
streamout right;
right=((in<=0)&1)|((in>0)&(1-in));
left=((in>=0)&1)|((in<0)&(1+in));

Your compiler creates a faster assembler code for this. But using If/Else for same task creates more lines.
Father
 
Posts: 177
Joined: Thu Jan 09, 2014 5:48 pm

Re: Custom DSP Code 2 (comunity project)

Postby KG_is_back » Mon Nov 09, 2015 12:29 am

Yes. IF statements produce different code than traditional bitwise logic. IF statements are mainly meant to switch between completely different parts of CPU heavy code (they jump the code if condition is false, thus may save CPU). However, to produce SSE compatible IF statement, quite a few instructions have to be added. For your example code, IF statement is probably much less optimal.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Custom DSP Code 2 (comunity project)

Postby Spogg » Mon Nov 09, 2015 9:38 am

Simple question so sorry if it's too simple!

If I take a piece of working DSP code that I made before and run it through your compiler is it automatically optimised to the maximum possible?

Cheers

Spogg
User avatar
Spogg
 
Posts: 3323
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: Custom DSP Code 2 (comunity project)

Postby KG_is_back » Mon Nov 09, 2015 10:08 am

Spogg wrote:Simple question so sorry if it's too simple!

If I take a piece of working DSP code that I made before and run it through your compiler is it automatically optimised to the maximum possible?

Cheers

Spogg


Unfortunately not to the maximum. Although DSPC3 does better job at managing xmm registers and some expressions and it contains more optimal "blueprints" for the functions, it still is far from perfect. The compilation is happening in several stages and each offers room for optimization. I mainly wanted the core of it working first and optimization modules will be added over time.
If I will succeed to implement the few that are already in my head, then it will be pretty damn close to perfect.

However, be aware that DSPC3 is not fully compatible with stock DSP code. You may have to modify the code slightly to work. Few notable changes:
1.arrays expect the index in integer format (in stock module they expected float and converted it internally). You may have to add "to_i(x)"
2.array index is no longer being automatically limited to <0-(arraySize-1)> range. You have to do that manually now if it's necessary.
3.codeblocks ( like stage(2){your code here} )need to be terminated with ";" too. Otherwise compiler assumes the code continues.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Custom DSP Code 2 (comunity project)

Postby KG_is_back » Fri Nov 13, 2015 2:37 am

Hi guys... Have you found any further issues with the compiler? Please let me know, I'd like to put it on FS guru as a first release. Also any further suggestions are welcome.

What functions are you missing / would like to be added?
-perhaps some that operate on arrays, like max(array) or maybe even FFT.
Are you happy with the CPU performance?
-I can write a guide to help you optimize your code for DSPC3 and to avoid unnecessary CPU heavy code.
-I will also work on optimizer, which may solve some of the issues automatically.
Are you missing any features?
-code editor is a known and yet unsolved problem. The compiler already outputs an array of strings, each representing the text for desired color (with the characters that shouldn't be that color replaced by whitespace) and one complete text (for editing). If someone could help me with that it would definitely be cool...
-I'm working on a "credit" system. Basically, each function would carry the name of author in it, and names of all authors of functions you've used would appear on the top of each ASM code the compiler generates. I hope this may encourage people to make function packs, as it would be easier to check for original authors and give respective credit.
-As I mentioned, more user-friendly way to "include" new functions is being worked on too.
Any further questions, that you'd like to get clarified? (I'm doing a FAQ document...)
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 23 guests