|
Post by Pjot on Jan 5, 2020 16:48:38 GMT 1
All, It may have seemed a bit quiet lately, but behind the scenes I have been busy optimizing BaCon further. This has resulted into a new compile scheme for BaCon, which, as with 2.0 and 3.0, will bump the version number to 4.0. The new scheme will lookup the required functions using an M4-based tokenizer. Advantages are: - BaCon doesn't need to link to an external library 'libbacon.a' or 'libbacon++.a' which sometimes caused trouble
- The resulting binary is 10%-30% smaller than before
- No complicated fiddling with optional external libraries for regular expressions, optional TLS, and so on
- Performance improvement up to 40%
There's a downside too: all compile procedures now depend on the presence of the m4. However, checking several platforms, it seems m4 is widely available, even in Android. If you feel adventurous, please try the latest beta and let me know any issues popping up on your platform. BR Peter
|
|
|
Post by vovchik on Jan 5, 2020 19:10:29 GMT 1
Dear Peter,
Everything compiled nicely on Mint 19.2 (64 bit) and on my new Pi4 running Debian Buster. I am still running a few post-compile tests...bit so far everything is working.
Thanks.
With kind regards, vovchik
|
|
|
Post by Pjot on Jan 5, 2020 19:23:03 GMT 1
Thanks vovchik, I ran into a problem with the 'MI' program, but this is fixed. Curiously, the good old benchmark program now runs 40% faster. Program: PRAGMA OPTIONS -fopenmp PRAGMA LDFLAGS -lgomp
FOR i = 1 TO 200000 a$ = CONCAT$(a$, "@") NEXT
PRINT LEN(a$) PRINT "Serial processing time: ", TIMER, " msecs."
tt = TIMER
PRAGMA omp parallel sections private(i) :' Start parallel processing for the next body of code. Variable "i" is local to each thread. DO PRAGMA omp section :' Section wich concatenates 50,000 times one character FOR i = 1 TO 50000 PRAGMA omp critical :' Strings in BaCon are not thread safe, therefore mark concatenation as critical b1$ = b1$ & "@" NEXT
PRAGMA omp section :' Another section wich concatenates 50,000 times one character FOR i = 1 TO 50000 PRAGMA omp critical b2$ = b2$ & "@" NEXT
PRAGMA omp section :' Another section wich concatenates 50,000 times one character FOR i = 1 TO 50000 PRAGMA omp critical b3$ = b3$ & "@" NEXT
PRAGMA omp section :' Another section wich concatenates 50,000 times one character FOR i = 1 TO 50000 PRAGMA omp critical b4$ = b4$ & "@" NEXT DONE
PRINT LEN(b1$ & b2$ & b3$ & b4$) :' Check; show total length
PRINT "Parallel processing time: ", TIMER-tt, " msecs."
Results with BaCon 3.9.3 version: Results with new beta 4.0 version: A significant difference BR Peter
|
|
|
Post by rikky on Jan 7, 2020 8:30:33 GMT 1
Working on Rpi Raspbian-Stretch BaCon version 3.9.4 on Linux armv7l - (c) Peter van Eerten - MIT License.
200000 Serial processing time: 16920 msecs. 200000 Parallel processing time: 4758 msecs.
BaCon version 4.0 on Linux armv7l - (c) Peter van Eerten - MIT License.
200000 Serial processing time: 9885 msecs. 200000 Parallel processing time: 2562 msecs. Nearly twice as fast. Which is very welcome for a slow Rpi. Rik.
|
|
|
Post by vovchik on Jan 7, 2020 9:19:58 GMT 1
Dear Rik, I just got a new RP4B, installed Raspbian Buster and ran the benchmark program. Compared to my old Pi3B, it is more than 3x faster, which is very pleasant. 200000 Serial processing time: 3023 msecs. 200000 Parallel processing time: 798 msecs. Script completed hit RETURN to close window. With kind regards, vovchik
|
|
|
Post by rikky on Jan 7, 2020 18:28:16 GMT 1
Wow, that's a huge difference. But I still have 2 unused RPi 3 's waiting to be putted somewhere. So I'll wait for the Rpi5 :°) Thanks for the info. Rik.
|
|
|
Post by Pjot on Jan 7, 2020 18:38:46 GMT 1
Thanks guys, That looks really great! This is good news. Interestingly, my binaries now are smaller too. For example, the Gopher client compiled with BaCon 3.9.3, after stripping: # ls -l gopher -rwxrwxr-x 1 peter peter 72320 jan 7 18:32 gopher
And in the BaCon 4.0 version, stripped: # ls -l gopher -rwxrwxr-x 1 peter peter 64144 jan 7 18:32 gopher
This is more than 10% smaller, and in some other programs I even reach up to 30% smaller sizes BR Peter
|
|
|
Post by vovchik on Jan 8, 2020 14:01:49 GMT 1
Dear Peter and Rik, The performance gains are impressive - and smaller binaries are always welcome. I managed to improve my Pi4 benchmark results by overclocking - I added two lines to boot/config.txt and my Pi4, which has a tiny and silent fan, now runs safely at 2000 and not 1500. My results now are: 200000 Serial processing time: 2207 msecs. 200000 Parallel processing time: 590 msecs. I am not displeased. With kind regards, vovchik
|
|
|
Post by agrellum on Jan 8, 2020 16:17:21 GMT 1
Nice work. M4 and no lib. OpenBSD 6.6 Installed in home directory to test.
|
|
pebau
Junior Member
Posts: 81
|
Post by pebau on Jan 10, 2020 19:17:07 GMT 1
Latest Bacon works good with gcc. I have seen runtime segfault error with the tcc compiler and simple HUG examples. Im using Ubuntu 18.04 on x86.
@:~/src_bacon$ bacon -v
BaCon version 4.0 on Linux x86_64 - (c) Peter van Eerten - MIT License.
peter@brix:~/src_bacon$ bacon -c tcc button1.bac Converting 'button1.bac'... done, 2979 lines were processed in 0.314 seconds. Analyzing dependencies... chop concat dec delimengine error hash instring left malloc memcheck mid minmax os right str utf8 version Compiling 'button1.bac'... tcc -c button1.bac.c tcc -o button1 button1.bac.o -ldl -lm Done, program 'button1' ready. peter@brix:~/src_bacon$ ./button1 ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause. peter@brix:~/src_bacon$
Strace output: prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0 statfs("/sys/fs/selinux", 0x7ffeb84bb250) = -1 ENOENT (No such file or directory) statfs("/selinux", 0x7ffeb84bb250) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/proc/filesystems", O_RDONLY|O_CLOEXEC) = 3 fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0 read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tr"..., 1024) = 454 read(3, "", 1024) = 0 close(3) = 0 access("/etc/selinux/config", F_OK) = -1 ENOENT (No such file or directory) --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x18} --- write(2, "ERROR: signal for SEGMENTATION F"..., 149ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause. ) = 149 exit_group(11) = ? +++ exited with 11 +++
|
|
|
Post by Pjot on Jan 10, 2020 19:29:21 GMT 1
Hi Peter, Thanks for letting know. Compiling HUG programs with TCC does not work with previous versions of BaCon either. As a test, I tried 3.9.2 and 3.9 but none of these work. So this is not different in the new 4.0 release Having said that, I will try to see what the reason might be. Best regards Peter
|
|
pebau
Junior Member
Posts: 81
|
Post by pebau on Jan 12, 2020 20:38:17 GMT 1
Using TRACE ON in BaCon 4.0 gives me undefined reference to `__b2c__getch' Should this work ?
TRACE ON PRINT "hello world"
peter@brix:~/src_bacon$ bacon hellow2.bac Converting 'hellow2.bac'... done, 3 lines were processed in 0.001 seconds. Analyzing dependencies... error malloc memcheck minmax utf8 Compiling 'hellow2.bac'... cc -c hellow2.bac.c cc -o hellow2 hellow2.bac.o -lm Makefile.bacon:4: recipe for target 'hellow2' failed
collect2: error: ld returned 1 exit status
INFO: see full error report (y/[n])? y hellow2.bac.o: In function `main': hellow2.bac.c:(.text+0x28cc): undefined reference to `__b2c__getch' collect2: error: ld returned 1 exit status make: *** [hellow2] Error 1
|
|
|
Post by Pjot on Jan 13, 2020 7:47:45 GMT 1
Thanks pebau, Well spotted! Indeed the TRACE statement should add a dependent function. It is fixed in the latest beta. BR Peter
|
|
pebau
Junior Member
Posts: 81
|
Post by pebau on Jan 14, 2020 19:34:16 GMT 1
Hello, Should OPTION DELIM "e" work in BaCon 4.0 ? When I use the FOR string$ IN strings$ it looks like OPTION DELIM is not used, instead the default delimiter " " is used. Where could I see which Options are really used during compilation? Somewhere in the *.h header files ?
BR, pebau
|
|
|
Post by Pjot on Jan 15, 2020 7:31:41 GMT 1
Hi pebau,
In case of FOR/NEXT it is the optional STEP part which defines the delimiter in case of strings.
If the STEP is not specified then STEP uses the default " ", thereby overwriting the setting from OPTION DELIM.
Indeed the documentation is not clear about this, but also, it is a little bit confusing. I will change this behavior so STEP takes the OPTION DELIM setting instead.
Thanks, Peter
PS: the fix is available in the latest beta.
|
|