ejolson
Posts: 2899
Joined: Tue Mar 18, 2014 11:47 am

Re: Is ARM doomed?

Thu Mar 28, 2019 4:46 am

Heater wrote:
Thu Mar 28, 2019 3:22 am
Of course I know what REP MOVSB and memcpy() do. Used them since the IBM PC was born.
I heard a rumor that REP MOVSB is now one of the slower ways to copy memory.

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 6:20 am

It's impossible to tell. How you move/copy data depends on:

Element size, 8, 16, 32, etc bits.
Number of elements.
Alignment.
Cache friendlyness.
Processor generation/type/manufacturer.
Phase of the moon

https://software.intel.com/sites/defaul ... manual.pdf

AMD optimization guides here: https://developer.amd.com/resources/dev ... s-manuals/

jahboater
Posts: 4198
Joined: Wed Feb 04, 2015 6:38 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 7:28 am

Heater, Ejolson,

Sorry, I was addressing Tim Rowledge re not knowing how simple REP MOSB and general 8086 insns are.
I know you two are experts.

As for REP MOVSB (and REP STOSB) speed.

Take a look at the ERMSB feature (Enhanced Rep Movs/Stos Byte) since IvyBridge.
On Linux, there is a flag in /proc/cpuinfo to say if your CPU supports it.

Code: Select all

grep erms /proc/cpuinfo
Intel did a lot of work speeding up this instruction around 2012, and importantly, are updating it as new CPU models appear with wider internal data paths.

GCC uses MOVS now instead of loops.
For some "easy" copies (at least 16 byte alignment and the length a multiple of 64) it is very fast indeed (much faster than MOVSD according to Intel, presumably faster than MOVSQ)
Not sure how it compares to using the wide SIMD registers though, apparently:
"implementing memcpy using ERMSB might not reach the same level of throughput as using 256-bit or 128-bit AVX alternatives, depending on length and alignment factors."

I like it because it is one simple two byte instruction that gives competitive performance most of the time.

Also see all the "stringop-strategy" options in the GCC man page.

ejolson
Posts: 2899
Joined: Tue Mar 18, 2014 11:47 am

Re: Is ARM doomed?

Thu Mar 28, 2019 3:00 pm

jahboater wrote:
Thu Mar 28, 2019 7:28 am
Sorry, I was addressing Tim Rowledge re not knowing how simple REP MOSB and general 8086 insns are.
I know you two are experts.
I suspect he is more an expert than me. A 20-fold performance improve in the speed of complicated softwares like Scratch and Smalltalk doesn't happen by accident.

I wonder has anyone thought to try a proper comparison between the Amazon ARM cloud and existing Raspberry Pi computers. This would help determine whether ARM is doomed as well as how much to charge my brother per hour if he wants to use my Pi.

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 5:21 pm

Yes, there are "experts" and then there are experts.

To my mind the real experts get things done orders of magnitude faster with better algorithms. Think Cooley and & Tukey and the Fast Fourier Transform.

Or they find the existing algorithms that fit the use case in question better.

Meanwhile, the low level assembler experts are dinking around wondering if REP MOSB is a bit faster than a hand made loop or not.

Both have their place of course. But thank God for the former.

jahboater
Posts: 4198
Joined: Wed Feb 04, 2015 6:38 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 6:03 pm

Heater,
You are stating the obvious ...
We all know that choosing the best algorithm is far more effective than micro-optimization.

The two expertise types do require different mind sets. If you have been programming for decades, the best algorithms and data structures are (often) readily apparent. Micro optimization on the other hand, although mostly done for fun or academic interest, usually requires more research.

The best programmers are capable of both - where appropriate.

Finally, successful optimizations are usually indicative of poor code to start with.

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 6:27 pm

jahboater,
You are stating the obvious ...
We all know that choosing the best algorithm is far more effective than any micro-optimization.
I like to think so.

However from listening to lots of conversations here and elsewhere about how "I can hand optimize assembler better than a compiler" I start to realize it is not so obvious to many.
If you have been programming for decades, the best algorithms and data structures are often readily apparent.
That is not so clear to me.

One could be programming forever, squeezing the last ounce of performance out of what ever machine one is programming.

All the while never inventing the Fast Fourier Transform, for example, which renders all of your hard work silly.

Or do you mean that programmers should be aware of things far outside of their programming box? Like mathematics and algorithms?

In which case, I agree.

jahboater
Posts: 4198
Joined: Wed Feb 04, 2015 6:38 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 6:46 pm

Heater wrote:
Thu Mar 28, 2019 6:27 pm
One could be programming forever, squeezing the last ounce of performance out of what ever machine one is programming.
Who gets to do that?
Never at any programming job I have ever had.
Perhaps game developers :)
Heater wrote:
Thu Mar 28, 2019 6:27 pm
Or do you mean that programmers should be aware of things far outside of their programming box? Like mathematics and algorithms?
Certainly as broad a knowledge base as possible. That's what a CS course at uni should be doing.

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 6:47 pm

jahboater,
Finally, successful optimizations are usually indicative of poor code to start with.
Wait a minute...

My Fibonacci challenge, to calculate the first Finonacci number with 1 million digits, might have taken forever if I was using the schoolboy fibo algorithm, and the school boy multiplication. No matter how brilliant my code was. No matter if it was Python or C or hand crafted assembler. Code good, result terrible.

As it happens I used some funky new algorithms that I had never seen before. Result: An answer in a minute and a half. Amazing.

OK, the rest of the speed up was low level tweaking.

jahboater
Posts: 4198
Joined: Wed Feb 04, 2015 6:38 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 7:00 pm

Heater wrote:
Thu Mar 28, 2019 6:47 pm
My Fibonacci challenge, to calculate the first Fibonacci number with 1 million digits, might have taken forever if I was using the schoolboy fibo algorithm, and the school boy multiplication. No matter how brilliant my code was. No matter if it was Python or C or hand crafted assembler. Code good, result terrible.
Good clean code maybe, but if the result is terrible, and unacceptably slow, then the algorithm (or something) is unsuitable.
You did the research and found a better algorithm, now the program is fit for purpose.

Had an optimal algorithm been chosen in the first place, your amazing speedup would not have been possible.

That's all I meant by that remark.
In my experience a large speedup usually means something was wrong in the first place. Of course some things will naturally take forever, but the fact that a speedup actually was achieved ...
Last edited by jahboater on Thu Mar 28, 2019 7:09 pm, edited 1 time in total.

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 7:07 pm

Yeah, I think we agree then. There is a lot more to programming than just programming. If you see what I mean.

jahboater
Posts: 4198
Joined: Wed Feb 04, 2015 6:38 pm

Re: Is ARM doomed?

Thu Mar 28, 2019 7:09 pm

Heater wrote:
Thu Mar 28, 2019 7:07 pm
There is a lot more to programming than just programming. If you see what I mean.
Yes yes!

timrowledge
Posts: 1259
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Is ARM doomed?

Thu Mar 28, 2019 8:11 pm

jahboater wrote:
Thu Mar 28, 2019 7:28 am
Heater, Ejolson,

Sorry, I was addressing Tim Rowledge re not knowing how simple REP MOSB and general 8086 insns are.
I know you two are experts.
You’ll have to forgive me - after all I’ve only been doing this stuff professionally for 40-some years.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

ejolson
Posts: 2899
Joined: Tue Mar 18, 2014 11:47 am

Re: Is ARM doomed?

Fri Mar 29, 2019 1:01 am

timrowledge wrote:
Thu Mar 28, 2019 8:11 pm
jahboater wrote:
Thu Mar 28, 2019 7:28 am
Heater, Ejolson,

Sorry, I was addressing Tim Rowledge re not knowing how simple REP MOSB and general 8086 insns are.
I know you two are experts.
You’ll have to forgive me - after all I’ve only been doing this stuff professionally for 40-some years.
It does seem a strange dichotomy that the Raspberry Pi is for school children but the Raspberry Pi Forum is for the over-50 crowd.

One might imagine people hired to code well-known algorithms in a way that is nearly optimal for a particular computing architecture would include programmers working on

IBM Engineering and Scientific Library

AMD EPYC CPU Libraries

NVIDIA GPU-accelerated Libraries for Computing

NCAR Weather Forecasting and Research Model

Intel Math Kernel Library

Linus and others working on the Linux Kernel

Tim with NuScratch for the Raspberry Pi

While there are many other kinds of programming jobs, especially ones which involve web sites and mouse interfaces, there are plenty where best performance possible is the main objective.
Linus Torvalds wrote:Sometimes "pi = 3.14" is (a) infinitely faster than the "correct" answer and (b) the difference between the "correct" and the "wrong" answer is meaningless. And this is why I get upset when somebody dismisses performance issues based on "correctness". The thing is, some specious value of "correctness" is often irrelevant because it doesn't matter. While performance almost always matters. And I absolutely detest the fact that people so often dismiss performance concerns so readily.

--Git mailing list, Fri, 8 Aug 2008

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Fri Mar 29, 2019 5:05 am

jamesh,
Compilers.

Compilers mean you really don't need to worry about the instruction set at all. So for Intel, ARM, RISC-V, the majority of people who use them don't give a flying whotsit about the ISA.
Therein lies a paradox. In some ideal world high level languages, compilers, interpreters make the instruction set irrelevant. However in the real world the vast majority of desktop system and servers are x86 based, whilst the vast majority of mobile devices are ARM based. Looks like the instruction set is the critical difference between these ecosystems.

Even in Pi world we are stuck in a 32 instruction set when a perfectly good 64 bit one exists.

jahboater
Posts: 4198
Joined: Wed Feb 04, 2015 6:38 pm

Re: Is ARM doomed?

Fri Mar 29, 2019 8:40 am

Ejolson,

I see in your links AMD's and Intel's math libraries. AMD claims to be faster and more accurate than the standard one that comes with the C compiler, Intel claims to be the most used math library on x86. Not too sure about either claim, but interesting.

About correctness.
I like the quote from Linus.

Long long ago I was impressed by the Microsoft C compiler that emitted hardware instructions (FSIN/FCOS etc) for the trig functions. The UNIX compiler stubbornly insisted on using its large and slow math library functions.

Much later when I had MPFR (the floating point extension to GMP) to compare results with, I tested the FSIN instruction, the C library double sin() function, and a 128-bit library function. It turned out that the FSIN instruction was less accurate for small argument values and hopelessly wrong for large ones. (Its range reduction uses an 18 digit value of Pi, the C libray function used a 512 digit value of Pi).

The standard C math library function sin() (with the least precision of the three) performed faultlessly.

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Fri Mar 29, 2019 10:06 am

I suspect that the vast majority of programmers are not employed to code well known algorithms or work terribly hard to optimize anything.

I also suspect it is not necessary. Once a reasonable implementation of something is available in a program, library or built into a language feature by somebody then everybody else can use it. This is an efficient use of man power, hence money. Also it would be unreasonable to expect all programmers be highly proficient in the maths required or the intimate details of the horrendously complex systems they are using. Perhaps it's better they dedicate their time to understanding their problem domain.

Of course it can only be a competitive advantage for a programmer to be aware of such algorithms, have some experience of implementing them and know when to use them to good effect.

Part of all that is knowing when to use PI = 3 :)

ejolson
Posts: 2899
Joined: Tue Mar 18, 2014 11:47 am

Re: Is ARM doomed?

Fri Mar 29, 2019 5:24 pm

Heater wrote:
Fri Mar 29, 2019 10:06 am
I also suspect it is not necessary. Once a reasonable implementation of something is available in a program, library or built into a language feature by somebody then everybody else can use it.
In my opinion, the free (but not open source) NVIDIA GPU libraries and the associated CUDA programming language are the main reasons NVIDIA dominates high-performance computing. For example, the current fastest supercomputer Summit obtains much of it's performance from NVIDIA V100 GPU accelerators.

While it is true that once the libraries have been written and optimised for a particular hardware others can use them in applications, it is also true that if the libraries haven't been written then they can't be used. From a practical point of view, someone needs to write the libraries.

From an educational point of view, it is not clear who has such abilities and interests until the opportunity to try is made widely available. Moreover, to train the teachers that teach the few who will do the work, far more need to possess the knowledge and understanding. As a result, I believe discussing the interaction between algorithmic and hardware performance characteristics is of value as soon as possible. However, before studying such things a curriculum needs to advance students beyond Python and Scratch.

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Sat Mar 30, 2019 4:01 am

I think we agree.

Whilst I was saying that only a minority of programmers are involved in developing high performance, highly optimized libraries and such I did not mean to imply that this should be missing from a programmers education.

We teach kids maths in school, some may find it interesting, some will find it useful in life, a very few will become mathematicians. Like wise we teach literacy but don't expect everyone to be come authors.
...a curriculum needs to advance students beyond Python and Scratch.
Sounds like my college CS course had that down. There we were introduced to programming my means of BASIC, but a lot of the course was numerical methods and statistics along with some discussion of computer architecture, were had to get to grips with assembler.

I can see Python replacing BASIC in that situation. I don't know where Scratch fits in. Seems like Scratch is to programming what finger painting is to geometry.

ejolson
Posts: 2899
Joined: Tue Mar 18, 2014 11:47 am

Re: Is ARM doomed?

Sat Mar 30, 2019 3:07 pm

Heater wrote:
Sat Mar 30, 2019 4:01 am
Scratch is to programming what finger painting is to geometry.
I wonder if the above statement should replace the current slogan
Scratch website wrote:Scratch - Imagine, Program, Share
Create stories, games, and animations
Share with others around the world
on the official MIT page. Maybe we are all doomed, not just ARM. To be certain, it would be necessary to know how well Scratch runs on RISC-V.
Last edited by ejolson on Sat Mar 30, 2019 5:26 pm, edited 1 time in total.

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Sat Mar 30, 2019 5:10 pm

Seems the gave up on the programming part. Now it just reads:

"Create stories, games, and animations
Share with others around the world"

ejolson
Posts: 2899
Joined: Tue Mar 18, 2014 11:47 am

Re: Is ARM doomed?

Sat Mar 30, 2019 5:22 pm

Heater wrote:
Sat Mar 30, 2019 5:10 pm
Seems the gave up on the programming part.
The part which reads

Scratch - Imagine, Program, Share

is the title of the webpage. That title may not display depending on what browser you use and whether on mobile or desktop. I suspect you are right, though, that the slogan itself doesn't mention programming or even finger painting.

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Sat Mar 30, 2019 6:32 pm

Ah so it is. I normally have so many tabs open there is no space for the titles.

I tried having a quick scratch. Gave up after five minutes trying to figure out how to cut and paste the blocks I had from my cat to my robot. This is kind of like Logo but harder to use.

Guess I'll just have to continue writing my stories in text and sharing with git.

timrowledge
Posts: 1259
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Is ARM doomed?

Sat Mar 30, 2019 7:31 pm

Scratch is an environment for introducing people with no prior experience to the concept of programming a computer. Instead of dumping newcomers into a nightmare of stupid text editors and command line with ridiculous incantations that have to be properly spelled (sic) in order to do anything at all, it provides an experience more like sticking together LEGO blocks. They get to learn a bit about making things happen, algorithms, control structures etc without suffering the delights of writing a splodge of gibberish and getting nothing but absurd error messages in return. I consider this a somewhat more beginner friendly approach than dumping a vat of plastics precursors on a bench and telling kids to work out how to make their own blocks before they can play.
Most people do not need to be any sort of expert at programming but everyone ought to have little exposure to the power it offers to affect your life. Some will find themselves entranced, others turned off. Some that would be turned off by the appalling state of programming tools might perhaps find Scratch a better experience and develop into experienced developers later.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

Heater
Posts: 12209
Joined: Tue Jul 17, 2012 3:02 pm

Re: Is ARM doomed?

Sat Mar 30, 2019 7:53 pm

Despite my jibes I do appreciate the idea behind Scratch, Tim.

Having spent most of today fighting Scala, InteliJ, SBT and Quartus I particularly feel the point about stupid IDEs, text editors, build systems and so on.

Still, I recall young teenagers in the early 1989's building robots with their Sinclair Spectrums, so I find it amazing we need all the complexity something like Scratch to achieve the same ends, perhaps less, today.

If somebody could fix the the appalling state of programming tools for us experienced adults that would be great. We muddle through of course but it must be billions of professional programmer man hours wasted on that stuff.

Return to “Off topic discussion”