Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 01 16:39
    CI run 3593958467 passed
  • Dec 01 15:19

    feeley on master

    Add cpu cycle count to |time| s… (compare)

  • Dec 01 11:57
    feeley commented on 53f03e4
  • Dec 01 07:16
    CI run 3589906839 passed
  • Dec 01 05:53

    gambiteer on master

    Add new macro giving minimum bi… (compare)

  • Dec 01 05:35
    gambiteer commented on 53f03e4
  • Dec 01 05:01
    feeley commented on 53f03e4
  • Dec 01 04:06
    CI run 3588958459 passed
  • Dec 01 03:34
    gambiteer commented on 6071372
  • Dec 01 02:42

    gambiteer on master

    Fix exact-integer division (compare)

  • Dec 01 00:47
    CI run 3587930130 passed
  • Nov 30 23:25
    gambiteer commented on 6071372
  • Nov 30 23:24

    gambiteer on master

    Fix for division on universal b… (compare)

  • Nov 30 02:38
    CI run 3579423372 passed
  • Nov 30 01:15

    feeley on master

    Add ##cpu-cycle-count primitive (compare)

  • Nov 29 11:07
    feeley commented #800
  • Nov 28 20:09
    amirouche commented #800
  • Nov 28 20:08
    amirouche commented #800
  • Nov 28 13:10
    feeley commented #800
  • Nov 28 12:01
    feeley edited #800
Marc Feeley
@feeley
Here’s a slightly longer example showing off the SIX FFI:
$ cat sixffi.scm
(include "~~lib/_six/js#.scm") ;; get six.infix macro
(define Date \Date)
(define now (Date))
(define el \document.createElement("div"))
\(`el).innerHTML=`now
\document.body.appendChild(`el)
$ gsc -target js -exe -o sixffi.html sixffi.scm
$ open sixffi.html
Marc Feeley
@feeley
And here is how you can get a minimal REPL which supports the SIX FFI:
$ cat jsrepl.scm
(include "~~lib/_six/six-expand.scm")
(##namespace (""))
(eval '(##define-syntax six.infix _six/six-expand#six.infix-js-expand))
(##repl-debug-main)
$ gsc/gsc -:= -target js -exe -o jsrepl.html jsrepl.scm
$ open jsrepl.html
Guillaume Cartier
@gcartier
@feeley Wonderful. Thanks Marc
Guillaume Cartier
@gcartier
Does the --enable-single-host option have any impact on the JavaScript backend?
Guillaume Cartier
@gcartier
I am reading old posts about the JS backend and I saw this option you use Marc: --enable-default-compile-options="(compactness 9)”. Is there a way to ask gsc to use compactness 9? (so I can use the same Gambit to build the JavaScript for human readability I’ll use in development or for production compactness)
Marc Feeley
@feeley
You can specify the compactness when you call gsc. However the library also needs to be compiled with the same compactness… so you’ll have to build the library for each compactness level you will use (the default is 9).
Marc-André Bélanger
@belmarca
@gcartier I build with --enable-default-compile-options="(compactness 0)"
Mark Friedman
@mark-friedman
Similar to the sixff1.scm example above, should I expect that the following will work to set the click handler of a HTML button to a gambit procedure? I tried the pure sixff1.scm example in the try.gambitscheme.org repl and it works, but my button version below doesn't. It displays the button just fine, but the click handler doesn't appear to be working
(include "~~lib/_six/js#.scm") ;; get six.infix macro
(define Date \Date)
(define now (Date))
(define div1 \document.createElement("div"))
\(`div1).innerHTML=`now
\document.body.appendChild(`div1)
(define btn1 \document.createElement("button"))
\(`btn1).innerHTML="Click me!"
\document.body.appendChild(`btn1)
\(`btn1).addEventListener('click', `(lambda () (set! now (Date))))
2 replies
I test it by evaluating now before and after clicking the button and see no difference. Is there some other way to use Scheme procedures as JavaScript functions or did I just not quite get the syntax right?
Guillaume Cartier
@gcartier
I’m trying to get a ballpark figure of how large jazz would be compiled to the javascript backend. gsi.exe compressed is roughly 2M and the gambit runtime compiled to js compressed is 640K. does the js runtime contain everything gsi.exe contains? If yes is that a good rule of thumb having a ratio of compressed js beeing 3x smaller than compressed binary code?
FredericHamel
@FredericHamel
I was looking at the unit tests and found out a test that does not seem to do anything. What is tests/unit-tests/03-number/issue_455.scm is testing?
Bradley Lucier
@gambiteer
It is testing something, it's testing whether number->string works.
There was a problem in bignum division that was triggered when converting that large number to a string.
FredericHamel
@FredericHamel
This test would not detect whether or not the result is valid.
Bradley Lucier
@gambiteer
It crashed.
FredericHamel
@FredericHamel
What 13-modules/prim_misc.scm is really testing? This test seems to just test whether or not some procedures work without exception. Should this test output data to the standard output? It doesn't use any of the check macros defined in #.scm.
Bradley Lucier
@gambiteer
I think it's checking whether the ##car procedure does the same thing as car. You may be able to figure it out by looking at #.scm in this subdirectory.
All the ## procedures versus the standard procedures. (Sorry.)
FredericHamel
@FredericHamel
I figure out what is the purpose of these test. I didn't notice the call to the macro check-same-behaviour. Thanks @gambiteer .
FredericHamel
@FredericHamel
Is it possible to capture the output of the procedure (apropos) to a string? This procedure writes to the repl-output-port, which is not affected by changing the current-output-port parameter object. The procedure repl-output-port fetch the output port use by the current thread.
Marc-André Bélanger
@belmarca
I just tried this:
(define (apropos-to-string sym)
  (let ((s (open-output-string)))
    (##apropos sym s)
    (close-output-port s)
    (get-output-string s)))

;; > (apropos-to-string 'void)
;; "\"##\" namespace:\n  thread-void-action!, void, void-constant?\nempty namespace:\n  void\n"
FredericHamel
@FredericHamel
I don't want to change the call to apropos, which is (apropos). The goal is to validate that apropos does the same thing as ##apropos. This is possible to change the repl-output-port but this requires change the repl-ports of the current-thread.
Amirouche Amazigh BOUBEKKI
@amirouche
On Ubuntu 22.04, using git bisect starting with the following commit d057cbc8e71d2080c0c50a824eadb0f7f8d51bfe I can't compile :arrow_heading_down:
3 replies
Bradley Lucier
@gambiteer

@amirouche Try this script:

heine:~/programs/gambit/gambit> cat `which update-gambit-git`
make clean\
&& rm -rf boot gsc-boot\
&& git pull\
&& make -j8 core\
&& make -j8 modules\
&& make doc\
&& make check

It appears you may be having a bootstrap problem.

Amirouche Amazigh BOUBEKKI
@amirouche
It is missing a call to configure?
# make clean
make: *** No rule to make target 'clean'.  Stop.
# rm -rf boot gsc-boot
# git pull
Already up to date.
# make -j8 core
make: *** No rule to make target 'core'.  Stop.
#
cs7
@cs7:matrix.org
[m]
Yes you are
Jaime Fournier
@ober
Are system threads usable yet?
Marc Feeley
@feeley
SMP is getting closer, but there are still some bugs that need to be understood and fixed. @Negdayen has been a great help to move SMP forward.
@amirouche The script that @gambiteer gave you is to “update” gambit after it has been built previously (which implies having done a ./configure … and a make before the script is run)
Jaime Fournier
@ober
@feely and that's just adding ./configure --enable-smp --enable-multiple-threaded-vms --enable-thread-system=pthread?
Marc Feeley
@feeley
@ober yes but the --enable-thread-system=… is not needed because it is autodetected and on linux there is no other option
however you need to do a full bootstrap with make;make bootstrap;make bootclean;make in order to enable the SMP thread scheduler
Jaime Fournier
@ober
ty
Marc Feeley
@feeley
the gambitscheme.org server will be down until saturday for a scheduled power outage, in case you wonder why it is not reachable
Drew Crampsie
@drewc
"Sorry Clients, cannot get any work done because of The World Cup^H^H^H a scheduled power outage" <--- I've been searching hard for an excuse! :D
pslh
@pslh7_twitter
Website goes back up today? :)
Marc Feeley
@feeley
the power is back on but unfortunately nobody is at work to reboot the machine… reboot on monday
Marc Feeley
@feeley
gambitscheme.org is back online
Bradley Lucier
@gambiteer

Marc: I'm writing some code to go into the library, so I have a file division.scm that starts with

(##include "header.scm")

and when I use define-prim I can compile it as gsc division.scm and then run it as gsi division just fine, but if I try gsi division.scm I get the message:

heine:~/programs/gambit/gambit/lib> gsi division.scm
*** ERROR IN #:case0, "_gambit#.scm"@100.17 -- Unbound variable: c#target.prim-info

Can I work around this? (Other than defining my-define which I can set to expand either to define or define-prim depending on whether I want to run it interpreted or not.)

Marc Feeley
@feeley
@gambiteer A hack but you could do:
$ gsi -e '(define (c#target.prim-info name) #f)' division.scm
Bradley Lucier
@gambiteer
remind me, how do I build _gambit.js and gsi-js with no code compression? I'm trying to run down a bug that results in a segfault in the C target, but gives me a halfway intelligible error in the JS target.
Marc Feeley
@feeley
$ ./configure --enable-single-host --enable-default-compile-options="(compactness 0)"
$ make clean
$ make -j8 core
$ make _gambit.js
$ gsc/gsc -:= -target js -exe -o gsi-js -prelude "(##include\"../lib/header.scm\")" gsi/_gsi.scm
$ ./gsi-js
Gambit v4.9.4

> (println "hello brad!")
hello brad!
> ,q
$ wc gsi-js
 1208721 3000757 24627058 gsi-js
Bradley Lucier
@gambiteer
Thanks!
Bradley Lucier
@gambiteer

I'm working on the following puzzle for a couple hours now:

[MacBook-Pro:~/programs/gambit] lucier% ./gsi-js
Gambit v4.9.4

> (define ##min-bignum (+ ##max-fixnum 1))
> ##min-bignum
536870912
> (remainder ##min-bignum ##min-fixnum)
0
> ##min-bignum 
0

Good times.

Marc Feeley
@feeley

Here are a few clues:

> (define y (+ ##max-fixnum 1))
> (host-eval "console.log(@1@)" (scheme y))
_Scheme { scmobj: _Bignum { digits: [ 0, 0, 2 ] } }
> (define x ##min-fixnum)
> x
-536870912
> y
536870912
> (##fx< 1 (##bignum.adigit-length y))
#t
> (##exact-int.div x y)
0
-536870912
> (##bignum.mdigit-length y)
3
> (##bignum.adigit-length y)
3

I think the error is on line 11477 of _num.scm… When adigits are not big enough to contain a fixnum value (as is the case in the JS backend) it is not true that (##fx< 1 (##bignum.adigit-length y)) implies that (abs y) > (abs x) .

With the C backend the correct result is computed:
> (define y (+ ##max-fixnum 1))
> (define x ##min-fixnum)
> (##exact-int.div x y)
-1
0
Marc Feeley
@feeley
On x86 Gambit now supports the procedures ##cpu-cycle-count-start and ##cpu-cycle-count-end that access the cpu cycle counter (with the rdtsc x86 instruction). This is useful for measuring very small execution times. The time special form also reports the number of cpu cycles (if it is supported by the processor). Here’s a test program that measures the execution time of length on a 1000 element list:
(declare
  (extended-bindings)
  (standard-bindings)
  (not safe)
  (inlining-limit 0)
)

(define repeat 1000000)

(define (cpu-cycles-overhead)
  (let loop ((n repeat) (min-cycles 999999999))
    (if (fx> n 0)
        (let* ((start (##cpu-cycle-count-start))
               (cycles (fx- (##cpu-cycle-count-end) start)))
          (loop (fx- n 1) (fxmin min-cycles cycles)))
        min-cycles)))

(define lst (iota 1000))

(define (cpu-cycles)
  (let loop ((n repeat) (min-cycles 999999999))
    (if (fx> n 0)
        (let* ((start (##cpu-cycle-count-start))
               (_ (length lst)) ;; operation to measure
               (cycles (fx- (##cpu-cycle-count-end) start)))
          (loop (fx- n 1) (##first-argument (fxmin min-cycles cycles) _)))
        min-cycles)))

(define overhead (cpu-cycles-overhead))

(println "cpu cycles for operation " (fx- (cpu-cycles) overhead))
Guillaume Cartier
@gcartier
Wow that is really nice
Bradley Lucier
@gambiteer
The timing seems to be very consistent:
heine:~/programs/gambit/gambit> gsi timing
cpu cycles for operation 3663
cpu cycles overhead 24
heine:~/programs/gambit/gambit> gsi timing
cpu cycles for operation 3663
cpu cycles overhead 24
heine:~/programs/gambit/gambit> gsi timing
cpu cycles for operation 3663
cpu cycles overhead 24