Author Topic: The integer Mandelbrot bench  (Read 13846 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
Re: The integer Mandelbrot bench
« Reply #15 on: April 20, 2014, 02:54:30 AM »
Mike
this is just a proof how stupid is work with SB .
First what kind of interpreter is this DOS... ;D
and why i must always use stupid command prompt to run any example
this is more than stupid and John constantly crap how is work with script basic
easy ...
and with all this years he is not capable to create interpreter which resopnd on
drag & drop.
another what kind of install ...there is no instal only ziped file... ::)
all in all this sucks from the ground.

Mike Lobanovsky

  • Guest
Re: The integer Mandelbrot bench
« Reply #16 on: April 20, 2014, 03:35:41 AM »
If somebody would help John, perhaps he could have a nice Windows installer that performs .sb script file association with the main binary, installation of dynamic libraries into system directories, copying of package directory structure onto the hard disk, and registration of environment variables automatically? It can also perform automatic uninstallation of the entire package if needed... ::)

As for drag-and-drop, since his binary can read script file names from its command line, it supports Linux and Windows GUI's drag-and-drop out of the box. That's a built-in feature on both platforms and no extra programming effort is necessary. The only requirement is that there should be no extra options needed to launch the scripts for execution. Otherwise drag-and-drop won't be possible at all; however the scripts will be launchable with a double click on the script file if the .sb MIME type is associated correctly with the ScriptBASIC binary by the package installer together with any extra options the binary may need.

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #17 on: April 20, 2014, 06:54:42 AM »
@Aurel - PLEASE remove all traces of Script BASIC from your system. You are not qualified to use the language.

One must at least have the basic understanding what a Windows console is, what the DIR command does and and how to change directories with the CD command. You have refused to try any effort I have given to help you resolve your issues. You are the only person on the face of the earth that has been unable to get Script BASIC to run. Congratulations!
« Last Edit: April 20, 2014, 07:54:15 AM by John »

Peter

  • Guest
Re: The integer Mandelbrot bench
« Reply #18 on: April 20, 2014, 07:58:02 AM »
Quote
@Aurel - PLEASE remove all traces of Script BASIC from your system. You are not qualified to use the language.

Lol

+1  ;D

Aurel

  • Guest
Re: The integer Mandelbrot bench
« Reply #19 on: April 20, 2014, 09:12:01 AM »
LOL  +++1

Whit a :

Code: [Select]
Declare Function GetCommandLine Lib "kernel32.dll" Alias "GetCommandLineA" () as String
Is to hard to implement this api call into sciribaw ?

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #20 on: April 20, 2014, 09:25:35 AM »
Aurel,

If you want a IUP / SDL based GUI SB script to run from Windows explorer then make a standalone version by binding scriba to the script.

scribaw -Eo mypgm.exe mypgm.sb

If you don't have scriba.conf setup then all dependencies must be in the same directory as the script executable. This is why putting scriba.exe in the search path and setting up a minimal scriba.conf (SCRIBA.INI) to point to the SB include and modules directory is an important first step.


JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #21 on: May 06, 2014, 02:13:46 PM »
Ed,

Can you add this C BASIC 64 bit version of your benchmark to your list?

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

MAIN
BEGIN_FUNCTION
  DIM AS int left_edge, right_edge, top_edge, bottom_edge, max_iter,
             x_step, y_step, y0, x0, x, y, i, x_x, y_y, temp,
             the_char, accum, count;
  accum = 0;
  count = 0;
  DEF_WHILE (count < 1545)
  BEGIN_WHILE
    left_edge = -420;
    right_edge = 300;
    top_edge = 300;
    bottom_edge = -300;
    x_step = 7;
    y_step = 15;
    max_iter =  200;
    y0 = top_edge;
    DEF_WHILE (y0 > bottom_edge)
    BEGIN_WHILE
      x0 = left_edge;
      DEF_WHILE (x0 < right_edge)
      BEGIN_WHILE
        y = 0;
        x = 0;
        the_char = 32;
        x_x = 0;
        y_y = 0;
        i = 0;
        DEF_WHILE (i < max_iter AND x_x + y_y <= 800)
        BEGIN_WHILE
          x_x = (x * x) / 200;
          y_y = (y * y) / 200;
          IF (x_x + y_y > 800 ) THEN
            the_char = 48 + i;
            IF  (i > 9) THEN
              the_char = 64;
            END_IF
          ELSE
            temp = x_x - y_y + x0;
            IF ((x < 0 AND y > 0) OR (x > 0 AND y < 0)) THEN
              y = (-1 * ((-1 * (x * y)) / 100)) + y0;
            ELSE
              y = x * y / 100 + y0;
            END_IF
            x = temp;
          END_IF
          i = i + 1;
        WEND
        accum = accum + the_char;
        x0 = x0 + x_step;
      WEND
      y0 = y0 - y_step;
    WEND
    IF (count MOD 300 EQ 0) THEN_DO PRINT ("%d\n", accum);
    count = count + 1;
  WEND
  PRINT ("%d\n", accum);
  RETURN_FUNCTION(0);
END_FUNCTION

jrs@laptop:~/C_BASIC/xlate$ gcc -O3 edbench.c -o edbench
jrs@laptop:~/C_BASIC/xlate$ time ./edbench
200574
60372774
120544974
180717174
240889374
301061574
309886830

real   0m2.028s
user   0m2.024s
sys   0m0.000s
jrs@laptop:~/C_BASIC/xlate$


.
« Last Edit: May 06, 2014, 06:59:01 PM by John »

Mike Lobanovsky

  • Guest
Re: The integer Mandelbrot bench
« Reply #22 on: May 06, 2014, 05:04:52 PM »
Hello John,

1. Your code contains two cheats (or typos, if you prefer): :)
-- DEF_WHILE() that's third from the top reads && instead of AND; and
-- bottommost IF reads % instead of MOD.

2. Why bother about GCC -O3 if you can get this for free: :D

.

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #23 on: May 06, 2014, 05:18:27 PM »
Good catch. (above code corrected) Dropping the -O3 added more than a second to the time.

jrs@laptop:~/C_BASIC/xlate$ gcc edbench.c -o edbench
jrs@laptop:~/C_BASIC/xlate$ time ./edbench
200574
60372774
120544974
180717174
240889374
301061574
309886830

real   0m3.576s
user   0m3.572s
sys   0m0.000s
jrs@laptop:~/C_BASIC/xlate$

Mike Lobanovsky

  • Guest
Re: The integer Mandelbrot bench
« Reply #24 on: May 06, 2014, 05:31:25 PM »
Dropping the -O3 added more than a second to the time.

Oh John, if only my DynC were doing in its fraction of a millisecond what GCC does in a second, I would be richer than Linus Torvalds and would be living somewhere at Les Champs-Élysées in Paris.  ;D

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #25 on: May 06, 2014, 07:04:52 PM »
I'm impressed. Embedded C BASIC:D

Mike Lobanovsky

  • Guest
Re: The integer Mandelbrot bench
« Reply #26 on: May 06, 2014, 07:31:40 PM »
I'm impressed. Embedded C BASIC:D

Exactly. You can add yet another slogan to CBASIC's virtues: fully embeddable as-is. :D

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #27 on: May 06, 2014, 10:04:00 PM »
Here is C BASIC embedded as an extension module.

Code: [Select]
DECLARE SUB Mandel ALIAS "Int_Mandle_Bench" LIB "imb"

Mandel

Here is the Script BASIC imb.so extension module code.

Code: [Select]
/* The integer Mandelbrot bench

UXLIBS:
DWLIBS:

*/

#include <stdio.h>
#include "../../basext.h"

/**************************
 Extension Module Functions
**************************/

besVERSION_NEGOTIATE
  RETURN_FUNCTION((int)INTERFACE_VERSION);
besEND

besSUB_START
  DIM AS long *p;
  besMODULEPOINTER = besALLOC(sizeof(long));
  IF (besMODULEPOINTER EQ NULL) THEN_DO RETURN_FUNCTION(0);
  p = (long*)besMODULEPOINTER;
  RETURN_FUNCTION(0);
besEND

besSUB_FINISH
  DIM AS long *p;
  p = (long*)besMODULEPOINTER;
  IF (p EQ NULL) THEN_DO RETURN_FUNCTION(0);
  RETURN_FUNCTION(0);
besEND

besFUNCTION(Int_Mandle_Bench)
  DIM AS int left_edge, right_edge, top_edge, bottom_edge, max_iter,
             x_step, y_step, y0, x0, x, y, i, x_x, y_y, temp,
             the_char, accum, count;
  accum = 0;
  count = 0;
  DEF_WHILE (count < 1545)
  BEGIN_WHILE
    left_edge = -420;
    right_edge = 300;
    top_edge = 300;
    bottom_edge = -300;
    x_step = 7;
    y_step = 15;
    max_iter =  200;
    y0 = top_edge;
    DEF_WHILE (y0 > bottom_edge)
    BEGIN_WHILE
      x0 = left_edge;
      DEF_WHILE (x0 < right_edge)
      BEGIN_WHILE
        y = 0;
        x = 0;
        the_char = 32;
        x_x = 0;
        y_y = 0;
        i = 0;
        DEF_WHILE (i < max_iter AND x_x + y_y <= 800)
        BEGIN_WHILE
          x_x = (x * x) / 200;
          y_y = (y * y) / 200;
          IF (x_x + y_y > 800 ) THEN
            the_char = 48 + i;
            IF  (i > 9) THEN
              the_char = 64;
            END_IF
          ELSE
            temp = x_x - y_y + x0;
            IF ((x < 0 AND y > 0) OR (x > 0 AND y < 0)) THEN
              y = (-1 * ((-1 * (x * y)) / 100)) + y0;
            ELSE
              y = x * y / 100 + y0;
            END_IF
            x = temp;
          END_IF
          i = i + 1;
        WEND
        accum = accum + the_char;
        x0 = x0 + x_step;
      WEND
      y0 = y0 - y_step;
    WEND
    IF (count MOD 300 EQ 0) THEN_DO PRINT ("%d\n", accum);
    count = count + 1;
  WEND
  PRINT ("%d\n", accum);
  RETURN_FUNCTION(0);
besEND

Results

jrs@laptop:~/sb/sb22/test$ time scriba mandel.sb
200574
60372774
120544974
180717174
240889374
301061574
309886830

real    0m2.036s
user    0m2.020s
sys     0m0.004s
jrs@laptop:~/sb/sb22/test$

@Ed - Can you update the time for Script BASIC. (scriba)   ;D

JRS

  • Guest
Re: The integer Mandelbrot bench
« Reply #28 on: May 06, 2014, 11:57:16 PM »
This time I'm embedding the Script BASIC API in C BASIC which is running the same script above which calls the C BASIC extension module that contains the Integer Mandel Benchmark.

sbembed.c
Code: [Select]
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include "scriba.h"
#include "cbasic.h"

MAIN
BEGIN_FUNCTION
  DIM AS pSbProgram pProgram;
  pProgram = scriba_new(malloc,free);
  scriba_LoadConfiguration(pProgram, "/home/jrs/sb/sb22/bin/basic.conf");
  scriba_SetFileName(pProgram, argv[1]);
  scriba_LoadSourceProgram(pProgram);
  scriba_Run(pProgram, argv[2]);
  scriba_destroy(pProgram);
  RETURN_FUNCTION(0);
END_FUNCTION


jrs@laptop:~/sb/sb22/test$ time ./sbembed mandel.sb
200574
60372774
120544974
180717174
240889374
301061574
309886830

real    0m2.033s
user    0m2.024s
sys     0m0.000s
jrs@laptop:~/sb/sb22/test$

« Last Edit: May 07, 2014, 07:43:19 AM by John »

Mike Lobanovsky

  • Guest
Re: The integer Mandelbrot bench
« Reply #29 on: May 07, 2014, 03:56:37 AM »
LOL John,

I'm lazying today but if I weren't, I would:

1. Write and execute an FBSL script that would:
-- load the Mandel script and C BASIC header files separately;
-- open a sender socket;
-- spawn another FBSL process that would open a receiver socket;
-- send to the other FBSL process over the sockets the Mandel script, C BASIC header, 1545 as the Mandel iteration limit, and yet another script that would force that other process ...

2. ... to perform the following:
-- concatenate the Mandel script with the C BASIC header;
-- load Fbsl.dll and pass to it the merged script, 1545 as the Mandel iteration limit, and yet another script that would force Fbsl.dll ...

3. ... to perform the following:
-- accept the merged script and wrap it into a DynC function;
-- pass 1545 as the DynC function argument;
-- run the Mandel benchmark to its upper limit of 1545 iterations in the DynC function in its own Dynamic C layer;
-- stopwatch the execution time and display the benchmark results.

All that without using any extra modules whatsoever.

Obviously, scripts and/or executables written in any other suitable language might be used at stages 1 and 2.