Could we finally ditch C++ for VSTs?

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

syntonica wrote: Fri Jun 30, 2023 6:52 am
mystran wrote: Fri Jun 30, 2023 6:40 am
syntonica wrote: Thu Jun 29, 2023 11:24 pm Isn't this why we have -Os now? It does peephole optimizations and similar, but I think it doesn't unroll loops. I find it does about the same as O3 but not quite Ofast. That is, when my code object is tiny to begin with, there's no point in making it tinier.
-Os optimizes for size. If it can make the code 1 byte smaller by making it 10 times slower, it'll do that.
Isn't that -Oz? I've never tried that one. I've only experimented with Os and it really is quite good, but -Ofast always beats it, but not by that much. If I was doing embedded, I'd be quite happy with -Os.
Oh.. you might be right. It used to be that -Os was ridiculous, but I guess they split the truly ridiculous stuff into -Oz instead.

edit:

Ok, so basically it looks like in GCC -Os is basically -O2 that turns off a few things like loop alignments and such. In general the stuff that can aggressively increases code size (eg. most of the loop restructing and unrolling and whatever) is all in -O3 for GCC and probably for clang as well.

-Ofast is the same as -O3 + -ffast-math and comparing it with the others is kinda apples and oranges, because -ffast-math allows floating point to be optimized pretending that they are real numbers and you can specify -ffast-math with any of the other optimization levels too.

Returning to the previous example of "(foo+foo)/2" if "foo" is float/double, then without -ffast-math I believe we can rewrite "(foo+foo)*.5" because the reciprocal happens to be exact, but that's it. With -ffast-math (1) we can assume that foo is neither inf or nan, (2) we can assume that (foo+foo) is not inf and (3) we are allowed to neglect the fact that (foo+foo) loses one bit of precision in the mantissa, so we can optimize to "foo" which is too accurate for strict IEEE rules. Without -ffast-math we can't use fused-multiply-adds on architectures where those are available either for the same reason: too accurate.

-ffast-math is also essential for things like vectorization. Suppose you have a loop that's computing the sum of floating point values over an array. This is easy to vectorize, just compute partial sums in parallel then do a horizontal sum at the very end... except without -ffast-math we can't do this, because we can't change the order of additions, because it changes rounding.

If you don't want to use -Ofast because -O3 blows up the code size (or compile time) too much, really just add -ffast-math to whatever other optimization level you want and you'll get a better idea what the real differences are.

Post

[edit] nevermind, brainfart...
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

Here we are:

-O3 is based on -O2
opt adds: -callsite-splitting -argpromotion

-Ofast is based on -O3, valid in clang but not in opt
clang adds: -fno-signed-zeros -freciprocal-math -ffp-contract=fast -menable-unsafe-fp-math -menable-no-nans -menable-no-infs -mreassociate -fno-trapping-math -ffast-math -ffinite-math-only

-Os is similar to -O2
opt drops: -libcalls-shrinkwrap and -pgo-memopt-opt

-Oz is based on -Os
opt drops: -slp-vectorizer
Looks like my understanding was wrong. I thought that -Os worked more intelligently by only accepting those found optimizations that resulted in smaller code size, but it appears that code size change is always a known for each option. Thus, -Oz dropping vectorization.

Something I should mention: Xcode always has fast math as a selectable option, so it's always set to true, regardless of the optimization level I've set. It must be why my -Os is so acceptable. I'd only be concerned it I was doing rocket science.
I started on Logic 5 with a PowerBook G4 550Mhz. I now have a MacBook Air M1 and it's ~165x faster! So, why is my music not proportionally better? :(

Post

Super Piano Hater 64 wrote: Wed Jun 28, 2023 4:46 pm
umd wrote: Wed Jun 28, 2023 12:38 pm What's not to like?
Undefined behavior.
I think that planned obsolescence is a bigger concern.
Free MIDI plugins and other stuff:
https://jstuff.wordpress.com
"MIDI 2.0 is an extension of MIDI 1.0. It does not replace MIDI 1.0(...)"

Post

umd wrote: Thu Jul 06, 2023 3:01 pm
Super Piano Hater 64 wrote: Wed Jun 28, 2023 4:46 pm
umd wrote: Wed Jun 28, 2023 12:38 pm What's not to like?
Undefined behavior.
I think that planned obsolescence is a bigger concern.
I'm familiar with the use of this term to describe consumer hardware made unnecessarily short-lived by deliberate design flaws, but I don't see how it applies to programming languages. Can you elaborate?
I hate signatures too.

Post

Super Piano Hater 64 wrote: Thu Jul 06, 2023 6:33 pm
umd wrote: Thu Jul 06, 2023 3:01 pm
Super Piano Hater 64 wrote: Wed Jun 28, 2023 4:46 pm
umd wrote: Wed Jun 28, 2023 12:38 pm What's not to like?
Undefined behavior.
I think that planned obsolescence is a bigger concern.
I'm familiar with the use of this term to describe consumer hardware made unnecessarily short-lived by deliberate design flaws, but I don't see how it applies to programming languages. Can you elaborate?
I think he's speaking about software designers. If you create a program that runs forever, you either have to make a better or different program to make more sales, or design it to fail at some point so that you can sell customers a replacement. It's a very fundamental flaw of capitalism.
I started on Logic 5 with a PowerBook G4 550Mhz. I now have a MacBook Air M1 and it's ~165x faster! So, why is my music not proportionally better? :(

Post

syntonica wrote: Thu Jul 06, 2023 6:50 pm
Super Piano Hater 64 wrote: Thu Jul 06, 2023 6:33 pm
umd wrote: Thu Jul 06, 2023 3:01 pm I think that planned obsolescence is a bigger concern.
I'm familiar with the use of this term to describe consumer hardware made unnecessarily short-lived by deliberate design flaws, but I don't see how it applies to programming languages. Can you elaborate?
I think he's speaking about software designers. If you create a program that runs forever, you either have to make a better or different program to make more sales, or design it to fail at some point so that you can sell customers a replacement. It's a very fundamental flaw of capitalism.
I mean, I agree with that, and I could also make guesses at what exactly he meant, but I still can't seem to figure out how it's related to undefined behavior, so I've invited him to explain.
I hate signatures too.

Post

Super Piano Hater 64 wrote: Thu Jul 06, 2023 6:54 pm I mean, I agree with that, and I could also make guesses at what exactly he meant, but I still can't seem to figure out how it's related to undefined behavior, so I've invited him to explain.
Maybe the OP's behavior is undefined. :hihi:
I started on Logic 5 with a PowerBook G4 550Mhz. I now have a MacBook Air M1 and it's ~165x faster! So, why is my music not proportionally better? :(

Post

What I am saying is that (in my opinion) we will always have a problem with "undefined behaviors"...

I understand that sometimes a change is necessary, but I'd rather deal with an undefined behaviour from a programming language than an undefined behaviour from some management team. :hihi:
Free MIDI plugins and other stuff:
https://jstuff.wordpress.com
"MIDI 2.0 is an extension of MIDI 1.0. It does not replace MIDI 1.0(...)"

Post

umd wrote: Thu Jul 06, 2023 7:34 pm What I am saying is that (in my opinion) we will always have a problem with "undefined behaviors"...

I understand that sometimes a change is necessary, but I'd rather deal with an undefined behaviour from a programming language than an undefined behaviour from some management team. :hihi:
Great. All right then. I'll leave you to it.

I'm so tired.
I hate signatures too.

Post

You're tired? I've still got boxes and boxes of cards to feed my 704, but any real audio DSP guru knows everything sounds better if it's written in FORTRAN, and thousands of warm glowing valves are involved.

Next: hand-milling every part required to run Tassman on an Analytical Engine!

:P
Music can no longer soothe the worried thoughts of monarchs; it can only tell you when it's time to buy margarine or copulate. -xoxos
Discontinue use if rash or irritation develops.

Post Reply

Return to “DSP and Plugin Development”