Recent

Author Topic: FPC for high-performance computing  (Read 9018 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: FPC for high-performance computing
« Reply #45 on: June 02, 2025, 10:19:55 pm »
He is a troll, he won't believe your repeatable results anyway, so yes, maybe a bike ride will be the better option.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Lenny33

  • New Member
  • *
  • Posts: 49
Re: FPC for high-performance computing
« Reply #46 on: June 02, 2025, 11:11:51 pm »
He is a troll, he won't believe your repeatable results anyway, so yes, maybe a bike ride will be the better option.
You can think of me as anything you want. But it won't speed up the final code generated by FPC  :(
And nobody in their right mind except Pascal fanatics and enthusiasts of manual optimization or direct assembler will use it for high-performance calculations.

Seenkao

  • Hero Member
  • *****
  • Posts: 718
    • New ZenGL.
Re: FPC for high-performance computing
« Reply #47 on: June 03, 2025, 01:36:21 pm »
You can think of me as anything you want.
Мы не думаем так, вы себя показываете таким.

Все ваши ответы показывают, что головой думать вы не хотите, вы надеетесь на компилятор и пытаетесь высмеять другие компиляторы, в данном случае компилятор FPC. Все давно знают, что он не лучшей. Но не важно, лучший он или нет. Он выполняет свои функции.
А вы продолжаете троллить. Продолжайте в том же духе и с вами просто перестанут общаться.


Google translate:
We don't think so, you show yourself that way.

All your answers show that you don't want to think with your head, you rely on the compiler and try to ridicule other compilers, in this case the FPC compiler. Everyone has known for a long time that he is not the best. But it doesn't matter whether it is the best or not. It does its job.
And you continue to troll. Continue in the same spirit and people will simply stop communicating with you.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

440bx

  • Hero Member
  • *****
  • Posts: 6022
Re: FPC for high-performance computing
« Reply #48 on: June 03, 2025, 02:13:59 pm »
FPC does a few optimizations but, FPC is nowhere near what an optimizing compiler is. 

For instance, constant folding is an easy optimization.  So easy that sometimes it is the parser that does it, not even the code generator and, FPC can easily be tripped there.

Refer to the attachment.  That program was compiled with -O4 and _all_ individual optimizations (-OoXXX) enabled, yet FPC could not consolidate all the constants being added to Value into a single constant.

That's just one example and, there are a large number of similarly simple optimizations that FPC cannot do.  It is NOT the programmer's job to add constants.  The compiler (or any other piece of software for that matter), works for the programmer, the programmer isn't supposed to work for the compiler.

In case someone wants to play with it, also attached is the program that produced that output.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

ccrause

  • Hero Member
  • *****
  • Posts: 1086
Re: FPC for high-performance computing
« Reply #49 on: June 03, 2025, 03:10:27 pm »
For instance, constant folding is an easy optimization.  So easy that sometimes it is the parser that does it, not even the code generator and, FPC can easily be tripped there.
Should be fixed (not tested!) by this commit.  This means of course the fix is currently only available in the development branch.

Lenny33

  • New Member
  • *
  • Posts: 49
Re: FPC for high-performance computing
« Reply #50 on: June 03, 2025, 03:12:43 pm »
Continue in the same spirit and people will simply stop communicating with you.
Pragmatically minded people are more likely to stop listening to obvious dreamers like you  ;)
I didn't start this thread. And before my posts, there were already reasonable answers that the code generated by FPC is far from the fastest in comparison with modern C++ compilers.
Do you have nothing better to do than manual optimization? I'm glad for you that you have so much time to waste when modern C++ compilers do it even better for a seconds ;)
Personally you have already done manual optimization in another thread, which VC++ did in a couple of seconds, and still VC++ code worked twice as fast because FPC cannot inline large procedures and even with the variability of inlined code.

Most people choose an instrument according to its purpose and capabilities. If you need high-performance computing, you don't go to FPC. That's not what FPC is for. At least for its current version.
« Last Edit: June 03, 2025, 03:26:18 pm by Lenny33 »

440bx

  • Hero Member
  • *****
  • Posts: 6022
Re: FPC for high-performance computing
« Reply #51 on: June 03, 2025, 03:25:33 pm »
For instance, constant folding is an easy optimization.  So easy that sometimes it is the parser that does it, not even the code generator and, FPC can easily be tripped there.
Should be fixed (not tested!) by this commit.  This means of course the fix is currently only available in the development branch.
Thank you for pointing that out.

I'm not happy to write what follows but, it really pushes the limits of what is acceptable to have such a simple deficiency take over 3 years to eliminate and it is still not part of the stable release.   That itself is a problem.

One thing I believe would help FPC would be to have it as a policy to have a bug-fixes-only release every year.  That way, there would be a continuously available stable release with important bugs and/or deficiencies fixed.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: FPC for high-performance computing
« Reply #52 on: June 03, 2025, 03:36:05 pm »
I agree with that, but basically it is not rocket science to compile fixes (which is stable too)
Problem is again not enough hands to prepare a full distribution for all platforms. And that is maybe inconvenient, but how it works in practice.
Otherwise platforms beyond Windows, Linux and MacOS get out of sync...
The latter three are less of a problem, but the rest is....
I fully understand the core team. They do not want to drop platforms for a release.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Seenkao

  • Hero Member
  • *****
  • Posts: 718
    • New ZenGL.
Re: FPC for high-performance computing
« Reply #53 on: June 03, 2025, 03:38:55 pm »
Refer to the attachment.  That program was compiled with -O4 and _all_ individual optimizations (-OoXXX) enabled, yet FPC could not consolidate all the constants being added to Value into a single constant.
И на самом деле это правильное поведение компилятора! Он выполнил задание программиста, а программист задал несколько переменных. При изменении переменных в программе, она будет корректно выполняться.
Лично меня, устраивает подобное поведение компилятора!

А что меня не устраивает, это то, что когда всем переменным передаётся значение "A", то значение "A" не записывается в регистр и в последующем не передаётся другие переменные просто считывая данные из регистра, а постоянно обращается к памяти считывая значение "A", для того чтоб записать значение в новую переменную (это не постоянное поведение компилятора, но очень частое).

-----------------------------------
Google translate:
And in fact, this is the correct behavior of the compiler! It has completed the programmer's task, and the programmer has set several variables. When changing variables in the program, it will be executed correctly.
Personally, I am satisfied with this behavior of the compiler!

But what I am not satisfied with is that when all variables are passed the value "A", the value "A" is not written to the register and subsequently other variables are not passed simply by reading data from the register, but constantly accesses memory reading the value "A" in order to write the value to a new variable (this is not constant behavior of the compiler, but very common).


Do you have nothing better to do than manual optimization?
Поздравляю! Вы в очередной раз подтвердили что вы несёте чушь! )))

Google translate:
Congratulations! You have once again confirmed that you are talking nonsense! )))
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Lenny33

  • New Member
  • *
  • Posts: 49
Re: FPC for high-performance computing
« Reply #54 on: June 03, 2025, 04:07:20 pm »
Personally, I am satisfied with this behavior of the compiler!
We all here have to put up with the compiler's shortcomings in exchange for cross-platform freebies.
But “some dreamers” use it for some reason obviously not for its intended purpose  ;)

Congratulations! You have once again confirmed that you are talking nonsense! )))
Do you need to be reminded again of your miserable efforts on manual optimization which resulted in vc++ code running twice as fast anyway?  ;)
The programming world is so huge for different tasks, but you personally are stuck on Pascal for everithing and say pathetic excuses and inappropriate insults.
« Last Edit: June 03, 2025, 04:15:00 pm by Lenny33 »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12593
  • FPC developer.
Re: FPC for high-performance computing
« Reply #55 on: June 03, 2025, 04:38:14 pm »
And nobody in their right mind except Pascal fanatics and enthusiasts of manual optimization or direct assembler will use it for high-performance calculations.

Ok. Now please go to the Python forums, and explain there why Python has no place in data analytics, AI etc as it is not a high performance calculation language, since itis worse than FPC by orders of magnitude.

Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: FPC for high-performance computing
« Reply #56 on: June 03, 2025, 04:42:04 pm »
Yes, Python is - regarding performance - merely a user interface to C compiled libraries.
( Or, cheekely, FPC compiled libraries.. :D )
It defers difficult performant code to others.
Anyway, stop this troll and kill the thread.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Lenny33

  • New Member
  • *
  • Posts: 49
Re: FPC for high-performance computing
« Reply #57 on: June 03, 2025, 05:01:21 pm »
Ok. Now please go to the Python forums, and explain there why Python has no place in data analytics, AI etc as it is not a high performance calculation language, since itis worse than FPC by orders of magnitude.
It has already been answered that it is just glue for C libraries.
In our project we use Lazarus only as glue for C++ libraries and certainly for cross-platform desktop, but not for computational tasks (it's all in C++ libraries).

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12593
  • FPC developer.
Re: FPC for high-performance computing
« Reply #58 on: June 03, 2025, 07:59:57 pm »
In our project we use Lazarus only as glue for C++ libraries and certainly for cross-platform desktop, but not for computational tasks (it's all in C++ libraries).

I do machine vision for nearly 19 years now. All computationally heavy, but a few assembler routines here and there, and some manual tuning is enough.

Maybe I would need less manual tuning if I did large parts in C++, but for me, the tuning is less than the trouble of a multi language project. Yes, I already have C++ wrapper DLL, but those are static, while otherwise both codebases would be live.

LV

  • Sr. Member
  • ****
  • Posts: 389
Re: FPC for high-performance computing
« Reply #59 on: June 03, 2025, 09:39:38 pm »
Fiddled a bit with Pascal code (no assembly inserts).

The model Cauchy problem for the transport equation. Simulation time 0.1.

Code: Text  [Select][+][-]
  1. Enter number of threads: 20
  2. Total steps: 111112
  3. Execution time: 24.36 seconds
  4.  

Additionally, I added a suggestion from @gues1 (thanks).
Code: Pascal  [Select][+][-]
  1.     SetProcessAffinityMask(getcurrentProcess, $FFFF);
  2.  

Code: Text  [Select][+][-]
  1. Enter number of threads: 20
  2. Total steps: 111112
  3. Execution time: 20.23 seconds
  4.  

To be on the safe side, I reran the C++ code in Visual Studio 2022 with the OpenMP library connected and the settings /O2 /Ob2 /Oi /Ot /GL /openmp

Code: Text  [Select][+][-]
  1. Total steps: 111112
  2. Execution time: 40.269 seconds
  3. Press Enter to exit...
  4.  

 

TinyPortal © 2005-2018