The MASM Forum

Toddler's Corner => Romper Room => Topic started by: TimoVJL on October 09, 2019, 01:58:45 AM

Title: Intel SPMD Program Compiler
Post by: TimoVJL on October 09, 2019, 01:58:45 AM
Intel SPMD Program Compiler (https://ispc.github.io/index.html)
Title: Re: Intel SPMD Program Compiler
Post by: hutch-- on October 09, 2019, 03:19:04 PM
Great link Timo, looks like good stuff.
Title: Re: Intel SPMD Program Compiler
Post by: LiaoMi on October 09, 2019, 10:57:03 PM
Two years ago, I tried unsuccessfully to compile this project, contacted the author, he could not help. According to the description on the github, people periodically have problems with compilation. I could not start the binary file that can be downloaded on the site, the program closed with an exception. Here is the author - https://github.com/dbabokin/ This code is similar to Proof of Concept, step left step right and nothing works.
Title: Re: Intel SPMD Program Compiler
Post by: HSE on October 10, 2019, 06:52:40 AM
Hi Liaomi!

Binary (v1.12.0-windows) apparently is working in x86. I can build mandelbrot example as an object, and then to generate masm code with objconv (because ispc emit intel or ATT asm).
Title: Re: Intel SPMD Program Compiler
Post by: Raistlin on October 10, 2019, 04:09:26 PM
Why are you guys posting all the COOL stuff in the Romper Room ?  :undecided:
Makes it hard for mere mortals like me to find it - or - is this the new secret lair slash bat-cave ....
Title: Re: Intel SPMD Program Compiler
Post by: TimoVJL on October 10, 2019, 05:55:01 PM
Code: [Select]
x86
[mandelbrot ispc]:              [141.179] million cycles
Wrote image file mandelbrot-ispc.ppm
[mandelbrot serial]:            [965.913] million cycles
Wrote image file mandelbrot-serial.ppm
                                (6.84x speedup from ISPC)
x64
[mandelbrot ispc]:              [134.526] million cycles
Wrote image file mandelbrot-ispc.ppm
[mandelbrot serial]:            [373.930] million cycles
Wrote image file mandelbrot-serial.ppm
                                (2.78x speedup from ISPC)
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 10, 2019, 11:16:18 PM
Intel compiler, including in attachment .exes and modified files.
Code: [Select]
x86 C++ compiler: Intel, Version 1900 Build Date: 20190417
@time of ISPC run:                      [41.831] million cycles
@time of ISPC run:                      [39.380] million cycles
@time of ISPC run:                      [40.292] million cycles
[mandelbrot ispc]:              [39.380] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [276.504] million cycles
@time of serial run:                    [283.851] million cycles
@time of serial run:                    [309.351] million cycles
[mandelbrot serial]:            [276.504] million cycles
Wrote image file mandelbrot-serial.ppm
                                (7.02x speedup from ISPC)

x64 C++ compiler: Intel, Version 1900 Build Date: 20190417
@time of ISPC run:                      [41.312] million cycles
@time of ISPC run:                      [41.491] million cycles
@time of ISPC run:                      [40.101] million cycles
[mandelbrot ispc]:              [40.101] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [285.268] million cycles
@time of serial run:                    [299.299] million cycles
@time of serial run:                    [324.834] million cycles
[mandelbrot serial]:            [285.268] million cycles
Wrote image file mandelbrot-serial.ppm
                                (7.11x speedup from ISPC)
Title: Re: Intel SPMD Program Compiler
Post by: TimoVJL on October 10, 2019, 11:41:30 PM
Those examples need an AVX support ?
Could we have an examples using SSE2 ?

An old AMD
Code: [Select]
C++ compiler: Intel, Version 1900 Build Date: 20190417
@time of ISPC run:                      [178.016] million cycles
@time of ISPC run:                      [153.057] million cycles
@time of ISPC run:                      [194.262] million cycles
[mandelbrot ispc]:              [153.057] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [310.135] million cycles
@time of serial run:                    [317.251] million cycles
@time of serial run:                    [303.225] million cycles
[mandelbrot serial]:            [303.225] million cycles
Wrote image file mandelbrot-serial.ppm
                                (1.98x speedup from ISPC)

C++ compiler: Intel, Version 1900 Build Date: 20190417
@time of ISPC run:                      [158.360] million cycles
@time of ISPC run:                      [148.705] million cycles
@time of ISPC run:                      [150.118] million cycles
[mandelbrot ispc]:              [148.705] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [358.490] million cycles
@time of serial run:                    [349.711] million cycles
@time of serial run:                    [343.810] million cycles
[mandelbrot serial]:            [343.810] million cycles
Wrote image file mandelbrot-serial.ppm
                                (2.31x speedup from ISPC)
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 10, 2019, 11:57:55 PM
Those examples need an AVX support ?
Could we have an examples using SSE2 ?
I have done this way

x64
ispc -O2 "%(Filename).ispc" -o "$(IntDir)%(Filename).obj" -h "$(ProjectDir)%(Filename)_ispc.h"  --target=sse4,avx2 --opt=fast-math

x86
ispc -O2 --arch=x86 "%(Filename).ispc" -o "$(IntDir)%(Filename).obj" -h "$(ProjectDir)%(Filename)_ispc.h" --target=sse4,avx2 --opt=fast-math



For x64, with:
ispc -O2 "%(Filename).ispc" -o "$(IntDir)%(Filename).obj" -h "$(ProjectDir)%(Filename)_ispc.h"  --target=sse2 --opt=fast-math

C++ compiler: Intel, Version 1900 Build Date: 20190417
@time of ISPC run:                      [91.228] million cycles
@time of ISPC run:                      [87.654] million cycles
@time of ISPC run:                      [87.918] million cycles
[mandelbrot ispc]:              [87.654] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [294.670] million cycles
@time of serial run:                    [286.823] million cycles
@time of serial run:                    [286.338] million cycles
[mandelbrot serial]:            [286.338] million cycles
Wrote image file mandelbrot-serial.ppm
                                (3.27x speedup from ISPC)

For x86, same performance.
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 11, 2019, 01:22:08 AM
VS 2017 .exe are much smaller than for Intel, spmd performance roughly the same.

x64
C++ compiler: Microsoft Visual C/C++ Version: 1916 Toolset: 191627031
@time of ISPC run:                      [41.134] million cycles
@time of ISPC run:                      [40.187] million cycles
@time of ISPC run:                      [40.242] million cycles
[mandelbrot ispc]:              [40.187] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [296.413] million cycles
@time of serial run:                    [333.210] million cycles
@time of serial run:                    [308.974] million cycles
[mandelbrot serial]:            [296.413] million cycles
Wrote image file mandelbrot-serial.ppm
                                (7.38x speedup from ISPC)

x86
C++ compiler: Microsoft Visual C/C++ Version: 1916 Toolset: 191627031
@time of ISPC run:                      [44.781] million cycles
@time of ISPC run:                      [39.926] million cycles
@time of ISPC run:                      [39.294] million cycles
[mandelbrot ispc]:              [39.294] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [298.390] million cycles
@time of serial run:                    [302.402] million cycles
@time of serial run:                    [311.517] million cycles
[mandelbrot serial]:            [298.390] million cycles
Wrote image file mandelbrot-serial.ppm
                                (7.59x speedup from ISPC)

Title: Re: Intel SPMD Program Compiler
Post by: daydreamer on October 11, 2019, 02:59:19 AM
if you use vector library and use vectors instead of array on a standard compiler,there suppose to be a setting that unrolls loop using vectors to use SIMD,but havent tried it yet
but it would be nice to see if it also works speeding up  more than 3x ?
Title: Re: Intel SPMD Program Compiler
Post by: caballero on October 11, 2019, 03:14:26 AM
Mandelbrot in 5kb, with tinyc and just gdi.
Title: Re: Intel SPMD Program Compiler
Post by: caballero on October 11, 2019, 04:11:33 AM
mandelbrot with tinyc+gdi in 5.50kb, much faster and better than previous, but a bit bigger
Title: Re: Intel SPMD Program Compiler
Post by: TimoVJL on October 11, 2019, 05:18:39 AM
Code: [Select]
[mandelbrot ispc]:              [141.766] million cycles SSE2
[mandelbrot serial]:            [1016.228] million cycles PellesC 8
[mandelbrot serial]:            [1372.807] million cycles tcc x86

tcc: 9.67x speedup from ISPC
but how to link with tcc ? objconv -felf32 -nu
Code: [Select]
@time of ISPC run:                      [143.013] million cycles
@time of ISPC run:                      [141.965] million cycles
@time of ISPC run:                      [141.684] million cycles
[mandelbrot ispc]:              [141.684] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [1292.054] million cycles
@time of serial run:                    [17592186041617.738] million cycles
@time of serial run:                    [1287.692] million cycles
[mandelbrot serial]:            [1287.692] million cycles
Wrote image file mandelbrot-serial.ppm
                                (9.09x speedup from ISPC)

EDIT:
Benchmarking-NET-Core-SIMD-performance-vs-Intel-IS (https://www.codeproject.com/Articles/1223361/Benchmarking-NET-Core-SIMD-performance-vs-Intel-IS)
PellesC AVX2
Code: [Select]
@time of ISPC run:                      [147.803] million cycles
@time of ISPC run:                      [149.325] million cycles
@time of ISPC run:                      [137.857] million cycles
[mandelbrot ispc]:              [137.857] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [274.158] million cycles
@time of serial run:                    [283.609] million cycles
@time of serial run:                    [276.143] million cycles
[mandelbrot serial]:            [274.158] million cycles
Wrote image file mandelbrot-serial.ppm
                                (1.99x speedup from ISPC)
Can someone give an intel CPU or AMD Ryzen results ?
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 11, 2019, 10:25:03 PM
Quote
Can someone give an intel CPU or AMD Ryzen results ?

For mandelbrot_ispc_tcc:

@time of ISPC run:                      [17592186040405.824] million cycles
@time of ISPC run:                      [84.668] million cycles
@time of ISPC run:                      [84.757] million cycles
[mandelbrot ispc]:              [84.668] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [656.562] million cycles
@time of serial run:                    [656.442] million cycles
@time of serial run:                    [656.480] million cycles
[mandelbrot serial]:            [656.442] million cycles
Wrote image file mandelbrot-serial.ppm
                                (7.75x speedup from ISPC)

The mandelbrot64v9_AVX2 fails.
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 12, 2019, 03:02:48 AM
This is an example of using ISPC (Intel SPMD Program Compiler ) with MASM.
This is the straightforward method, there are other ways, namely the ISPC compiler can produce ASM, but requires a cleanup before being ready for assembly.

I selected the Simple sample from the distribution (the simplest of them all) and am building for SSE2 so everybody will be able to run it.
Output:

Code: [Select]
0: simple(0.000000) = 0.000000
1: simple(1.000000) = 1.000000
2: simple(2.000000) = 4.000000
3: simple(3.000000) = 1.732051
4: simple(4.000000) = 2.000000
5: simple(5.000000) = 2.236068
6: simple(6.000000) = 2.449490
7: simple(7.000000) = 2.645751
8: simple(8.000000) = 2.828427
9: simple(9.000000) = 3.000000
10: simple(10.000000) = 3.162278
11: simple(11.000000) = 3.316625
12: simple(12.000000) = 3.464102
13: simple(13.000000) = 3.605551
14: simple(14.000000) = 3.741657
15: simple(15.000000) = 3.872983

PS: To build, you will need to download ipsc.exe from the Intel link above.

Title: Re: Intel SPMD Program Compiler
Post by: TimoVJL on October 12, 2019, 06:15:27 AM
As ispc create a switcher for different instruction sets, it's an easy way to have them in same program.
In x64 speed gain is only 2 - 3 times faster.

Sadly some IDE's don't even give an opportunity select them for different functions.

In poide it's possible to change options for object file by editing build macro.
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 12, 2019, 07:09:00 AM
In x64 speed gain is only 2 - 3 times faster.

These targets on the mandelbrot sample.
--target=avx2-i32x16    > 12x
--target=avx1-i32x16    almost 10x
--target=sse2-i32x8           5 to 6 x

Not sure if your AMD supports AVX1 but at leats you can use --target=sse2-i32x8
Title: Re: Intel SPMD Program Compiler
Post by: TimoVJL on October 12, 2019, 06:45:18 PM
OK. Having a bad AMD CPU :sad:

How AMD Razor perform ?
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 12, 2019, 07:28:49 PM
 :biggrin:

In VS 2019 x64, Release Mode

Using the Custom Build Tool for the ispc file:
Command Line:
ispc -O2 "%(Filename).ispc" -o "$(ProjectDir)%(Filename).obj" -h "$(ProjectDir)%(Filename)_ispc.h" --target=sse2-i32x8 --opt=fast-math --target-os=windows
Output: $(ProjectDir)%(Filename).obj

So, for SSE2 (double-pumped) we get:

Code: [Select]
C++ compiler: Microsoft Visual C/C++ Version: 1923 Toolset: 192328106
@time of ISPC run:                      [57.462] million cycles
@time of ISPC run:                      [55.335] million cycles
@time of ISPC run:                      [58.917] million cycles
[mandelbrot ispc]:              [55.335] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [297.770] million cycles
@time of serial run:                    [297.318] million cycles
@time of serial run:                    [297.424] million cycles
[mandelbrot serial]:            [297.318] million cycles
Wrote image file mandelbrot-serial.ppm
                                (5.37x speedup from ISPC)

If for the Custom Build Tool:
Command Line:
ispc -O2 "%(Filename).ispc" -o "$(ProjectDir)%(Filename).obj" -h "$(ProjectDir)%(Filename)_ispc.h" --target=sse2-i32x8,avx1-i32x16,avx2-i32x16 --opt=fast-math --target-os=windows
Output: $(ProjectDir)%(Filename).obj;$(ProjectDir)%(Filename)_sse2.obj;$(ProjectDir)%(Filename)_avx.obj;$(ProjectDir)%(Filename)_avx2.obj

It will try to figure out the best for the running computer, for me it finds AVX2 (double-pumped), so:

Code: [Select]
C++ compiler: Microsoft Visual C/C++ Version: 1923 Toolset: 192328106
@time of ISPC run:                      [29.066] million cycles
@time of ISPC run:                      [25.350] million cycles
@time of ISPC run:                      [25.265] million cycles
[mandelbrot ispc]:              [25.265] million cycles
Wrote image file mandelbrot-ispc.ppm
@time of serial run:                    [296.230] million cycles
@time of serial run:                    [296.588] million cycles
@time of serial run:                    [299.479] million cycles
[mandelbrot serial]:            [296.230] million cycles
Wrote image file mandelbrot-serial.ppm
                                (11.72x speedup from ISPC)
Title: Re: Intel SPMD Program Compiler
Post by: TimoVJL on October 13, 2019, 01:07:30 AM
Can't continue with this kind of things, as i don't have access to proper hardware, but maybe a bit later.
A small test with Visual Studio 2017 was a nightmare, why it is so slow and difficult, made for masochist ?
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 13, 2019, 01:36:00 AM
A small test with Visual Studio 2017 was a nightmare, why it is so slow and difficult, made for masochist ?
You need 32 GB RAM and a little faster CPU then it takes 1 second to load.

 :biggrin:

(https://www.dropbox.com/s/cj3gj3ds6qe1jy3/vs2007.gif?dl=1)
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 18, 2019, 01:56:06 AM
Poor man's Mandelbrot  :sad:

Code: [Select]
..............................................................................
......................................................#.......................
..................................................########....................
.................................................##########...................
....................................##.#....##################.###............
....................................####################################......
................................########################################......
...............................############################################...
.............###.#####.#.......###########################################....
.........#.#################..############################################....
.....#.#..################################################################....
######################################################################........
.....#.#..################################################################....
.........#.#################..############################################....
.............###.#####.#.......###########################################....
...............................############################################...
................................########################################......
....................................####################################......
....................................##.#....##################.###............
.................................................##########...................
..................................................########....................
......................................................#.......................

Code (MSVC, original here (http://www.fractalforums.com/programming/mandelbrot-with-only-18-lines-of-cplusplus-code!/)):

Code: [Select]
#include <complex.h>
#include <stdio.h>

int main() {
int max_row = 22, max_column = 78, max_iteration = 20;
for (int row = 0; row < max_row; ++row) {
for (int column = 0; column < max_column; ++column) {
_Fcomplex z = {};
_Fcomplex  c = { (float)column * 2 / max_column - 1.5f , (float)row * 2 / max_row - 1.0f };
int iteration = 0;
while ((cabsf(z) < 2) && (++iteration < max_iteration))
{
z = cpowf(z, { 2.0f, 0 });
z = { real(z) + real(c) , imag(z) + imag(c) };
}
printf("%c", iteration == max_iteration ? '#' : '.');
}
printf("\n");
}
}

Title: Re: Intel SPMD Program Compiler
Post by: TimoVJL on October 18, 2019, 02:55:33 AM
converted to C99
Code: [Select]
#include <complex.h>
#include <stdio.h>

int main(void) {
int max_row = 22, max_column = 78, max_iteration = 20;
for (int row = 0; row < max_row; ++row) {
for (int column = 0; column < max_column; ++column) {
//_Fcomplex z = {};
float _Complex z = 0 + 0 * I;
//_Fcomplex  c = { (float)column * 2 / max_column - 1.5f , (float)row * 2 / max_row - 1.0f };
float _Complex c = ((float)column * 2 / max_column - 1.5f) + ((float)row * 2 / max_row - 1.0f) * I;
int iteration = 0;
while ((cabsf(z) < 2) && (++iteration < max_iteration))
{
//z = cpowf(z, { 2.0f, 0 });
z = cpowf(z, 2.0f + 0 * I);
//z = { real(z) + real(c) , imag(z) + imag(c) };
z = (crealf(z) + crealf(c)) + (cimagf(z) + cimagf(c)) * I;
}
printf("%c", iteration == max_iteration ? '#' : '.');
}
printf("\n");
}
}
and bit more
Code: [Select]
#include <complex.h>
#include <stdio.h>

int main(void) {
int max_row = 22, max_column = 78, max_iteration = 20;
for (int row = 0; row < max_row; ++row) {
for (int column = 0; column < max_column; ++column) {
float _Complex z = 0;
float _Complex c = ((float)column * 2 / max_column - 1.5f) + ((float)row * 2 / max_row - 1.0f) * I;
int iteration = 0;
while ((cabsf(z) < 2) && (++iteration < max_iteration))
z = z * z + c;
printf("%c", iteration == max_iteration ? '#' : '.');
}
printf("\n");
}
}
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 18, 2019, 07:41:26 AM
Smaller?

Code: [Select]
#include <complex.h>
#include <stdio.h>

int main(void)
{
float _Complex z, c; int iteration, max_row = 22, max_column = 78, max_iteration = 20;
for (int row = 0; row < max_row; ++row) {
for (int column = 0; column < max_column; ++column) {
for (iteration = 0 , z=0, c = ((float)column * 2 / max_column - 1.5f) + ((float)row * 2 / max_row - 1.0f) * I; (cabsf(z) < 2) && (++iteration < max_iteration) ;)
z = z * z + c;
printf("%c", iteration == max_iteration ? '#' : '.');
}
printf("\n");
}
}
Builds to 23 KB (Intel compiler)

Microsoft way (same number of source lines):

Code: [Select]
#include <complex.h>
#include <stdio.h>

int main() {
_Fcomplex z, c; int iteration, max_row = 22, max_column = 78, max_iteration = 20;
for (int row = 0; row < max_row; ++row) {
for (int column = 0; column < max_column; ++column) {
for (iteration = 0, z = {}, c = { (float)column * 2 / max_column - 1.5f , (float)row * 2 / max_row - 1.0f }; (cabsf(z) < 2) && (++iteration < max_iteration);)
z = { z._Val[0] * z._Val[0] - z._Val[1] * z._Val[1] + c._Val[0], z._Val[0] * z._Val[1] + z._Val[1] * z._Val[0] + c._Val[1] };
printf("%c", iteration == max_iteration ? '#' : '.');
}
printf("\n");
}
}
Builds to 9 KB (VS 2019)
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 18, 2019, 06:09:11 PM
New attempt. Microsoft 12 lines  :eusa_clap:, C99 13 lines  :eusa_pray:.

C99 (32-bit: Pelles builds to 36 KB, 64-bit: Pelles builds to 42 KB):
Code: [Select]
#include <complex.h>
#include <stdio.h>

int main(void) {
float _Complex z, c;
for (int row = 0, max_row = 22, max_iteration = 20; row < max_row; ++row) {
for (int column = 0, iteration, max_column = 78; column < max_column; ++column) {
for (z = 0, c = ((float)column * 2 / max_column - 1.5f) + ((float)row * 2 / max_row - 1.0f) * I, iteration = 0; (cabsf(z) < 2) && (++iteration < max_iteration); z = z * z + c);
printf("%c", iteration == max_iteration ? '#' : '.');
}
printf("\n");
}
}

MSVC (32-bit: VS 2019 builds to 9 KB, 64-bit: VS 2019 build to 11 KB):
Code: [Select]
#include <complex.h>
#include <stdio.h>

int main() {
for (int row = 0, max_row = 22, max_iteration = 20; row < max_row; ++row) {
for (int column = 0, iteration=0, max_column = 78; column < max_column; ++column, iteration = 0) {
for (_Fcomplex z = { 0,0 }, c = { (float)column * 2 / max_column - 1.5f , (float)row * 2 / max_row - 1.0f }; (cabsf(z) < 2) && (++iteration < max_iteration); z = { z._Val[0] * z._Val[0] - z._Val[1] * z._Val[1] + c._Val[0], z._Val[0] * z._Val[1] + z._Val[1] * z._Val[0] + c._Val[1] });
printf("%c", iteration == max_iteration ? '#' : '.');
}
printf("\n");
}
}
Title: Re: Intel SPMD Program Compiler
Post by: TimoVJL on October 18, 2019, 07:22:47 PM
If i try to compile a that example as C
Code: [Select]
>cl -GS- -MD PoorManFractalMS_AW.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.23.28106.4 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

PoorManFractalMS_AW.c
PoorManFractalMS_AW.c(7): error C2059: syntax error: '{'
so it was compiled as .cpp ?
Code: [Select]
>clang-cl -GS- -MD PoorManFractalMS_AW.c
PoorManFractalMS_AW.c(7,166): error: expected expression
  ..., (float)row * 2 / max_row - 1.0f }; (cabsf(z) < 2) && (++iteration < max_iteration); z = { z._Val[0] * z._Val[0...

                                                                                               ^
PoorManFractalMS_AW.c(7,166): error: expected ')'
PoorManFractalMS_AW.c(7,8): note: to match this '('
                        for (_Fcomplex z = { 0,0 }, c = { (float)column * 2 / max_column - 1.5f , (float)row * ...
                            ^
PoorManFractalMS_AW.c(7,287): warning: for loop has empty body [-Wempty-body]
  ...* z._Val[0] - z._Val[1] * z._Val[1] + c._Val[0], z._Val[0] * z._Val[1] + z._Val[1] * z._Val[0] + c._Val[1] });
                                                                                                                  ^
PoorManFractalMS_AW.c(7,287): note: put the semicolon on a separate line to silence this warning
1 warning and 2 errors generated.
and if size matters, Pelles C 9 5/6 kb
EDIT:
C11 made the <complex.h> header optional. (http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0063r3.html)
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 18, 2019, 08:27:39 PM
Quote
so it was compiled as .cpp ?

This 12 lines shall build as "C" with MSVC:  :thumbsup:

#include <complex.h>
#include <stdio.h>

int main() {
   for (int row = 0, max_row = 22, max_iteration = 20; row < max_row; ++row) {
      for (int column = 0, iteration=0, max_column = 78; column < max_column; ++column, iteration = 0) {
         for (_Fcomplex z = { 0,0 }, x = { 0,0 }, c = { (float)column * 2 / max_column - 1.5f , (float)row * 2 / max_row - 1.0f }; (cabsf(z) < 2) && (++iteration < max_iteration); x._Val[0] = z._Val[0] * z._Val[0] - z._Val[1] * z._Val[1] + c._Val[0], x._Val[1] = z._Val[0] * z._Val[1] + z._Val[1] * z._Val[0] + c._Val[1], z._Val[0]=x._Val[0], z._Val[1] = x._Val[1]);
         printf("%c", iteration == max_iteration ? '#' : '.');
      }
      printf("\n");
   }
}


Quote
clang-cl -GS- -MD PoorManFractalMS_AW.c

clang-cl uses msvc include files, right?

Quote
and if size matters, Pelles C 9 5/6 kb

I am talking without tricks.
Without tricks it will go to 36KB/42KB.  :sad:

Edit: Fixed small bug, it requires an intermediate complex variable because z was overwritten here:
z._Val[0] = z._Val[0] * z._Val[0] - z._Val[1] * z._Val[1] + c._Val[0], z._Val[1] = z._Val[0] * z._Val[1] + z._Val[1] * z._Val[0] + c._Val[1]
.

Title: Re: Intel SPMD Program Compiler
Post by: AW on October 18, 2019, 09:51:00 PM
In MSVC, built with tricks (size 2560 bytes).  :biggrin:
Same code built with Clang-Cl hosted in VS (size 2048) in attachment 2.

Edit: Updated files to fix bug:
Edit: Fixed small bug, it requires an intermediate complex variable because z was overwritten here:
z._Val[0] = z._Val[0] * z._Val[0] - z._Val[1] * z._Val[1] + c._Val[0], z._Val[1] = z._Val[0] * z._Val[1] + z._Val[1] * z._Val[0] + c._Val[1]
.


Title: Re: Intel SPMD Program Compiler
Post by: TimoVJL on October 18, 2019, 11:03:20 PM
without headers and with ucrtbase.lib
Code: [Select]
cl -GS- -O2 -Zl PMF_AW1.c -FePMF_AW1_ms.exe -link -nocoffgrpinfo -fixedmsvc 2019: 1 536 bytes / 2 560 bytes
Code: [Select]
#pragma comment(lib, "ucrtbase.lib")

typedef struct _C_float_complex {
float _Val[2];
} _C_float_complex;
typedef _C_float_complex _Fcomplex;

__declspec(dllimport) int __cdecl putchar(int c);
__declspec(dllimport) float __cdecl cabsf(_Fcomplex z);

void __cdecl mainCRTStartup(void)
{
__declspec(dllimport) void __cdecl exit(int status);
int __cdecl main(void);
exit(main());
}

int _fltused;

int main(void) {
for (int row = 0, max_row = 22, max_iteration = 20; row < max_row; ++row) {
for (int column = 0, iteration=0, max_column = 78; column < max_column; ++column, iteration = 0) {
//for (_Fcomplex z = { 0,0 }, c = { (float)column * 2 / max_column - 1.5f , (float)row * 2 / max_row - 1.0f }; (cabsf(z) < 2) && (++iteration < max_iteration); z._Val[0] = z._Val[0] * z._Val[0] - z._Val[1] * z._Val[1] + c._Val[0], z._Val[1] = z._Val[0] * z._Val[1] + z._Val[1] * z._Val[0] + c._Val[1]);
for (_Fcomplex z = { 0,0 }, x = { 0,0 }, c = { (float)column * 2 / max_column - 1.5f , (float)row * 2 / max_row - 1.0f }; (cabsf(z) < 2) && (++iteration < max_iteration); x._Val[0] = z._Val[0] * z._Val[0] - z._Val[1] * z._Val[1] + c._Val[0], x._Val[1] = z._Val[0] * z._Val[1] + z._Val[1] * z._Val[0] + c._Val[1], z._Val[0]=x._Val[0], z._Val[1] = x._Val[1]);
putchar(iteration == max_iteration ? '#' : '.');
}
putchar('\n');
}
}
clang 9 1 536 bytes / 2 560 bytes
Code: [Select]
bin\Clang-cl -GS- -O2 -Zl PMF_AW1.c -FePMF_AW1_cl.exe -link -nocoffgrpinfo -dynamicbase:no -fixed -mapwithout M$ headers or libs.
Title: Re: Intel SPMD Program Compiler
Post by: AW on October 19, 2019, 12:01:36 AM
This produces 1536 bytes:
cl -GS- -O1 -Zl mandelbrottest.c -mandelbrottest.exe -link /entry:"main" -fixed

Code: [Select]
#include <complex.h>
#include <stdio.h>
#pragma comment(lib, "ucrt.lib")
#pragma comment(linker,"/merge:.data=.text")

float _fltused = 0.0;
int main() {
for (int row = 0, max_row = 22, max_iteration = 20; row < max_row; ++row) {
for (int column = 0, iteration=0, max_column = 78; column < max_column; ++column, iteration = 0) {
for (_Fcomplex z = { 0,0 }, x = { 0,0 }, c = { (float)column * 2 / max_column - 1.5f , (float)row * 2 / max_row - 1.0f }; (cabsf(z) < 2) && (++iteration < max_iteration); x._Val[0] = z._Val[0] * z._Val[0] - z._Val[1] * z._Val[1] + c._Val[0], x._Val[1] = z._Val[0] * z._Val[1] + z._Val[1] * z._Val[0] + c._Val[1], z._Val[0]=x._Val[0], z._Val[1] = x._Val[1]);
printf("%c", iteration == max_iteration ? '#' : '.');
}
printf("\n");
}
}
Title: Re: Intel SPMD Program Compiler
Post by: Luciad71 on February 13, 2020, 05:32:18 AM
Two years ago, I tried unsuccessfully to compile this project, contacted the author, he could not help. According to the description on the github, people periodically have problems with compilation. I could not start the binary file that can be downloaded on the site, the program closed with an exception meilleures mutuelles senior (https://www.comparateur-mutuelle-assurance-sante.com/la-meilleure-mutuelle-sante-senior). Here is the author - https://github.com/dbabokin/ This code is similar to Proof of Concept, step left step right and nothing works.
Ma come qualsiasi applicazione o macchina, questa può correggere errori in qualsiasi momento, ma si ripristinerà rapidamente.

Translated Italian
But like any application or machine, it can correct errors at any time, but it will recover quickly.