Ah of course that explains it.
On Fri, 4 Aug 2017, 11:22 Dave Cheney, wrote:
> Gcc on OS X is an alias for clang as Apple does not ship any GPLv3
> software with their os.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
Gcc on OS X is an alias for clang as Apple does not ship any GPLv3 software
with their os.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
I seem to have a disguised gcc/clang thing...
gcc --version
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
even at -O3 gcc wouldn't do it, probably because pow is implemented in
another compilation unit.
On Fri, Aug 4, 2017 at 6:49 PM, Sebastien Binet wrote:
>
>
> On Fri, Aug 4, 2017 at 10:47 AM, Dave Cheney wrote:
>>
>> I'm disappointed that both compilers didn't
On Fri, Aug 4, 2017 at 10:47 AM, Dave Cheney wrote:
> I'm disappointed that both compilers didn't compile both original samples
> to a noop.
>
clang did it, though.
-s
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To
I'm disappointed that both compilers didn't compile both original samples to a
noop.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
And the guess how it's arriving at that optimization:
Step 0: base code
x := 2.5
res := 0.0
for n := 0; n < NMAX; n++ {
for i := 0; i < 4; i++ {
res += math.Pow(x, float(i))
}
}
Step 1: unroll inner-loop
x := 2.5
res := 0.0
for n := 0; n < NMAX; n++ {
res += math.Pow(x, float(0))
res +=
Use the Assembly Luke.
https://godbolt.org/g/nGFMbf
It looks like clang manages to compute a table of powers of x. Which, is
very very impressive.
Which is roughly https://play.golang.org/p/CZkiJKfe7s -- except clang, also
does inner loop unrolling.
+ Egon
On Friday, 4 August 2017 11:16:10
I've put these files and a bash script for convenience
here: https://gist.github.com/cpmech/b13b6e17789c0bdfa469b2f1b6b71587
Thanks again.
On Friday, August 4, 2017 at 6:16:10 PM UTC+10, Dorival Pedroso wrote:
>
> wait, what?!
>
> the same code:
>
> #include "stdio.h"
> #include "math.h"
> int
wait, what?!
the same code:
#include "stdio.h"
#include "math.h"
int main() {
double res = 0.0;
double x = 2.5;
int Nmax = 1000;
for (int N=0; N
On Fri, Aug 4, 2017 at 9:51 AM, Henrik Johansson
wrote:
> Actually I get the same as the original program on my mac.
>
> time ./ccode
> sum=606329794183272.375000
> ./ccode 0.17s user 0.00s system 98% cpu 0.170 total
>
> The Go version -O2 -Wall
> time ./pow
>
Sebastien is right! Thanks a lot! I forgot that the optimizer does
eliminate some code at times. (and forgot
this https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go)
This is the C code now (compiled with gcc -O2 run_std_pow.c -o run_std_pow
-lm):
#include "stdio.h"
#include
Actually I get the same as the original program on my mac.
time ./ccode
sum=606329794183272.375000
./ccode 0.17s user 0.00s system 98% cpu 0.170 total
The Go version -O2 -Wall
time ./pow
sum=6.063297941832724e+14./pow 5.47s user 0.01s system 99% cpu 5.490 total
fre 4 aug. 2017 kl 09:38
Dorival,
On Fri, Aug 4, 2017 at 8:20 AM, Dorival Pedroso
wrote:
> I've noticed that this C code:
>
> #include "math.h"
> int main() {
> double x = 2.5;
> int Nmax = 1000;
> for (int N=0; N for (int i=0; i<20;
I've noticed that this C code:
#include "math.h"
int main() {
double x = 2.5;
int Nmax = 1000;
for (int N=0; N
15 matches
Mail list logo