Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_gambit.php code generation problem #173

Open
gambiteer opened this issue Jan 21, 2016 · 6 comments
Open

_gambit.php code generation problem #173

gambiteer opened this issue Jan 21, 2016 · 6 comments

Comments

@gambiteer
Copy link
Collaborator

With the current gsc:

    44  12:09   pu lib
    45  12:09   make _gambit.php
    46  12:10   cd ..
    49  13:02   gsc -:=. -target php -link chud2.scm
    50  13:02   cat chud2.php chud2_.php lib/_gambit.php > ! crap.php
    51  13:02   php crap.php

Result:

heine:~/programs/gambit/gambit> php crap.php
PHP Fatal error: Cannot redeclare g_bb1__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_() (previously declared in /home/lucier/programs/gambit/gambit/crap.php:479628) in /home/lucier/programs/gambit/gambit/crap.php on line 479684

It seems to be real:

function g_bb1__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_() {static $id = 0, $parent = NULL, $nfree = -1, $name = "##os-device-tty-history-max-length-set!", $ctrlpts = array("g_bb1__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_"), $info = false; // entry-point (+rest) <============== line 479628
global $g_null_obj, $g_r1, $g_nargs, $g_cst1799___gambit, $g_pollcount;
if ($g_nargs == 0) {
$g_r1 = $g_null_obj;
} else {
if (!g_build_rest(0)) {
return g_wrong_nargs(g_bb1__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_);
}
}
$g_r1 = $g_cst1799___gambit;
if (--$g_pollcount == 0) {
return g_poll(g_bb2__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_);
} else {
$g_nargs = 1;
if (--$g_pollcount == 0) {
return g_poll(g_bb1_error);
} else {
return g_bb1_error;
}
}
}

and

$g_peps["##os-device-tty-history-max-length-set!"] = g_bb1__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_;

function g_bb1__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_() {static $id = 0, $parent = NULL, $nfree = -1, $name = "##os-device-tty-history-max-length-set!", $ctrlpts = array("g_bb1__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_"), $info = false; // entry-point (+rest)
global $g_null_obj, $g_r1, $g_nargs, $g_cst1800___gambit, $g_pollcount;
if ($g_nargs == 0) {
$g_r1 = $g_null_obj;
} else {
if (!g_build_rest(0)) {
return g_wrong_nargs(g_bb1__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_);
}
}
$g_r1 = $g_cst1800___gambit;
if (--$g_pollcount == 0) {
return g_poll(g_bb2__23__23_os_2d_device_2d_tty_2d_history_2d_max_2d_length_2d_set_21_);
} else {
$g_nargs = 1;
if (--$g_pollcount == 0) {
return g_poll(g_bb1_error);
} else {
return g_bb1_error;
}
}
} <============================== line 479684

@gambiteer
Copy link
Collaborator Author

It seems there are two repeated definitions in _univlib.scm, so I commented them out as so:

'(define-prim (##os-device-tty-history-max-length-set! . rest)
(error "##os-device-tty-history-max-length-set! not implemented yet"))

'(define-prim (##os-device-tty-history-set! . rest)
(error "##os-device-tty-history-set! not implemented yet"))

Then I ran it but got thousands of "notices", e.g.,

heine:~/programs/gambit/gambit> php crap.php
PHP Notice: Use of undefined constant g_bb1__20_chud2 - assumed 'g_bb1__20_chud2' in /home/lucier/programs/gambit/gambit/crap.php on line 784
PHP Notice: Use of undefined constant g_bb1__20_chud2 - assumed 'g_bb1__20_chud2' in /home/lucier/programs/gambit/gambit/crap.php on line 785
PHP Notice: Use of undefined constant g_bb1_cpu_2d_time - assumed 'g_bb1_cpu_2d_time' in /home/lucier/programs/gambit/gambit/crap.php on line 914
PHP Notice: Use of undefined constant g_bb1_ch_2d_split - assumed 'g_bb1_ch_2d_split' in /home/lucier/programs/gambit/gambit/crap.php on line 8507
PHP Notice: Use of undefined constant g_bb1_pi - assumed 'g_bb1_pi' in /home/lucier/programs/gambit/gambit/crap.php on line 11229
PHP Warning: array_key_exists() expects parameter 2 to be array, null given in /home/lucier/programs/gambit/gambit/crap.php on line 11719
PHP Notice: Undefined variable: g_null_obj in /home/lucier/programs/gambit/gambit/crap.php on line 11235
PHP Notice: Use of undefined constant g_bb1__20_chud2 - assumed 'g_bb1__20_chud2' in /home/lucier/programs/gambit/gambit/crap.php on line 11291
etc.

No clue what's going on.

heine:~/programs/gambit/gambit> php -v
PHP 5.6.11-1ubuntu3.1 (cli)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

@feeley
Copy link
Member

feeley commented Jan 21, 2016

Try adding this at the top of crap.php:

error_reporting(E_ALL ^ E_NOTICE);

Did you add the link file in front of crap.php ?

@gambiteer
Copy link
Collaborator Author

On 01/21/2016 02:26 PM, Marc Feeley wrote:

Try adding this at the top of crap.php:

error_reporting(E_ALL ^ E_NOTICE);

Wow, when I add that as the second line, so the top of crap.php looks like

php crap.php Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 10, CPU time: .0019999999999999983. Last 5 digits 26535. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 100, CPU time: .009000000000000001. Last 5 digits 70679. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 1000, CPU time: .249. Last 5 digits 1989. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 10000, CPU time: 24.024. Last 5 digits 75678. Man is php slow! Here it is in javascript: heine:~/programs/gambit/gambit> nodejs crap.js Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 10, CPU time: .009999999999999995. Last 5 digits 26535. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 100, CPU time: .006000000000000005. Last 5 digits 70679. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 1000, CPU time: .031. Last 5 digits 1989. Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 10000, CPU time: .902. Last 5 digits 75678. > Did you add the link file in front of crap.php ? This is what I did: heine:~/programs/gambit/gambit> !gsc gsc -:=. -warnings -target php -link chud2.scm heine:~/programs/gambit/gambit> !cat cat chud2_.php chud2.php lib/_gambit.php > ! crap.php heine:~/programs/gambit/gambit> php crap.php |& head PHP Notice: Use of undefined constant g_bb1_real_2d_time_2d_milliseconds - assumed 'g_bb1_real_2d_time_2d_milliseconds' in /home/lucier/programs/gambit/gambit/crap.php on line 421 PHP Notice: Use of undefined constant g_bb1_println - assumed 'g_bb1_println' in /home/lucier/programs/gambit/gambit/crap.php on line 869 PHP Notice: Use of undefined constant g_bb1__20_chud2 - assumed 'g_bb1__20_chud2' in /home/lucier/programs/gambit/gambit/crap.php on line 1723 PHP Notice: Use of undefined constant g_bb1__20_chud2 - assumed 'g_bb1__20_chud2' in /home/lucier/programs/gambit/gambit/crap.php on line 1724 PHP Notice: Use of undefined constant g_bb1_cpu_2d_time - assumed 'g_bb1_cpu_2d_time' in /home/lucier/programs/gambit/gambit/crap.php on line 1853 PHP Notice: Use of undefined constant g_bb1_ch_2d_split - assumed 'g_bb1_ch_2d_split' in /home/lucier/programs/gambit/gambit/crap.php on line 9446 PHP Notice: Use of undefined constant g_bb1_pi - assumed 'g_bb1_pi' in /home/lucier/programs/gambit/gambit/crap.php on line 12168 PHP Notice: Use of undefined constant g_bb1__20_chud2 - assumed 'g_bb1__20_chud2' in /home/lucier/programs/gambit/gambit/crap.php on line 12230 PHP Notice: Use of undefined constant g_bb1__20___gambit - assumed 'g_bb1__20___gambit' in /home/lucier/programs/gambit/gambit/crap.php on line 14440 PHP Notice: Use of undefined constant g_bb1__20___gambit - assumed 'g_bb1__20___gambit' in /home/lucier/programs/gambit/gambit/crap.php on line 14441

@feeley
Copy link
Member

feeley commented Jan 21, 2016

Ha! Yes PHP is slower than JS by roughly an order of magnitude. Of course PHP wasn't exactly conceived as a language for number crunching. How long will it take for a million digits? Sounds like it will be around one hour. That will certainly put you in the record books!

@gambiteer
Copy link
Collaborator Author

I don't know, there's a gmp module for php, search for gmp here:

http://us3.php.net/manual/en/indexes.functions.php

Brad

@gambiteer
Copy link
Collaborator Author

Here are times for chud2.scm computing various numbers of digits of pi in php. Very ugly.

firefly:~/programs/gambit/gambit> php crap.php
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 10, CPU time: .0019999999999999983.
Last 5 digits 26535.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 100, CPU time: .010000000000000002.
Last 5 digits 70679.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 1000, CPU time: .22900000000000004.
Last 5 digits 1989.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 10000, CPU time: 12.721.
Last 5 digits 75678.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 100000, CPU time: 308.26.
Last 5 digits 24646.
Chudnovsky's algorithm using binary splitting in Gambit Scheme: digits 1000000, CPU time: 4736.768.
Last 5 digits 58151.

This is on my i7 at home using the "fast" algorithms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants