Discussion:
problems installing/running SWI-Prolog on Mac OS X
Anamaria Stoica
2007-03-31 12:01:47 UTC
Permalink
Hi,

I can't run SWI-Prolog on Mac OS X, hope you can help.

I've downloaded first :

SWI-Prolog/XPCE for MacOS X 10.4 (tiger) on ppc,

and installed it on my computer, then realized that i
need the (tiger) on intel version.

So, i deleted the whole "opt" folder (as it didn't
exist before), and installed the version for intel :

SWI-Prolog/XPCE 5.6.32 for MacOS X 10.4 (tiger) on
intel

The process went well and said that it was installed
successfully.

But I don't know how to run it. It says "System is
installed in /opt/local/bin/swipl", I have the
opt/local/bin and many others in opt directory, but no
swipl anywhere.

It also said "Needs X11 installed", which I previously
did.

Thank you in advance,

Anamaria Stoica




____________________________________________________________________________________
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail
Samer Abdallah
2007-03-31 13:54:11 UTC
Permalink
You need to:
1. start the X11 application
2. open a Terminal
3. Type:
env DISPLAY=:0 /opt/local/bin/swipl

That should start SWI. You can check if the X11
part is working by typing 'help.' at the Prolog prompt

?- help.
This should bring up a new window with the help
browser.

If the all of the above works, you can save yourself
some typing by editing (or creating) a file called
.profile in your home directory: add the following lines

export PATH=$PATH:/opt/local/bin:/opt/local/sbin
export MANPATH=$MANPATH:/opt/local/man:/opt/local/share/man
export INFOPATH=$MANPATH:/opt/local/share/info

Then you should be able to type just swipl instead of /opt/local/bin/
swipl,
and also you will be able to read the man pages for any software
installed
under /opt/local, by typing at the terminal prompt, eg
$ man swipl
Finally, you might want to set the DISPLAY environment variable
to :0 but there several ways to do this under MacOSX, none of them
entirely
satisfactory. One option is to create a file in a directory
called .MacOSX
under your home directory:
~/.MacOSX/environment.plist
containing the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DISPLAY</key>
<string>:0</string>
</dict>
</plist>


Samer
Post by Anamaria Stoica
Hi,
I can't run SWI-Prolog on Mac OS X, hope you can help.
SWI-Prolog/XPCE for MacOS X 10.4 (tiger) on ppc,
and installed it on my computer, then realized that i
need the (tiger) on intel version.
So, i deleted the whole "opt" folder (as it didn't
SWI-Prolog/XPCE 5.6.32 for MacOS X 10.4 (tiger) on
intel
The process went well and said that it was installed
successfully.
But I don't know how to run it. It says "System is
installed in /opt/local/bin/swipl", I have the
opt/local/bin and many others in opt directory, but no
swipl anywhere.
It also said "Needs X11 installed", which I previously
did.
Thank you in advance,
Anamaria Stoica
______________________________________________________________________
______________
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail
------------
For further info, please visit http://www.swi-prolog.org/
To unsubscribe, send a plaintext mail with "unsubscribe prolog <e-
mail>"
ok
2007-04-02 02:44:35 UTC
Permalink
Post by Samer Abdallah
1. start the X11 application
2. open a Terminal
env DISPLAY=:0 /opt/local/bin/swipl
Why set DISPLAY to :0?

The usual setting for $DISPLAY in a shell running under X11 on a Unix
box with just one display is ":0.0" (not ":0"), and on my MacOS 10.4.7
box, "open -a X11" give me a terminal where $DISPLAY already has the
right :0.0 value. And starting X11 gives me an xterm, which is just
what
I want, not a Terminal, which isn't.
Anamaria Stoica
2007-04-02 10:49:23 UTC
Permalink
hi,
I don't have swipl in my /opt/local/bin/ ? Does this
mean that the installation didn't go as it should ?

I retried 3 times, and there was still no swipl,
though it said that the installation completed
successfully.
thanks,
Anamaria
Post by Samer Abdallah
1. start the X11 application
2. open a Terminal
env DISPLAY=:0 /opt/local/bin/swipl
That should start SWI. You can check if the X11
part is working by typing 'help.' at the Prolog
prompt
?- help.
This should bring up a new window with the help
browser.
If the all of the above works, you can save yourself
some typing by editing (or creating) a file called
.profile in your home directory: add the following
lines
export PATH=$PATH:/opt/local/bin:/opt/local/sbin
export
MANPATH=$MANPATH:/opt/local/man:/opt/local/share/man
export INFOPATH=$MANPATH:/opt/local/share/info
Then you should be able to type just swipl instead
of /opt/local/bin/
swipl,
and also you will be able to read the man pages for
any software
installed
under /opt/local, by typing at the terminal prompt,
eg
$ man swipl
Finally, you might want to set the DISPLAY
environment variable
to :0 but there several ways to do this under
MacOSX, none of them
entirely
satisfactory. One option is to create a file in a
directory
called .MacOSX
~/.MacOSX/environment.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST
1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DISPLAY</key>
<string>:0</string>
</dict>
</plist>
Samer
Post by Anamaria Stoica
Hi,
I can't run SWI-Prolog on Mac OS X, hope you can
help.
Post by Anamaria Stoica
SWI-Prolog/XPCE for MacOS X 10.4 (tiger) on ppc,
and installed it on my computer, then realized
that i
Post by Anamaria Stoica
need the (tiger) on intel version.
So, i deleted the whole "opt" folder (as it didn't
exist before), and installed the version for intel
SWI-Prolog/XPCE 5.6.32 for MacOS X 10.4 (tiger) on
intel
The process went well and said that it was
installed
Post by Anamaria Stoica
successfully.
But I don't know how to run it. It says "System is
installed in /opt/local/bin/swipl", I have the
opt/local/bin and many others in opt directory,
but no
Post by Anamaria Stoica
swipl anywhere.
It also said "Needs X11 installed", which I
previously
Post by Anamaria Stoica
did.
Thank you in advance,
Anamaria Stoica
______________________________________________________________________
Post by Samer Abdallah
Post by Anamaria Stoica
______________
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail
------------
For further info, please visit
http://www.swi-prolog.org/
Post by Anamaria Stoica
To unsubscribe, send a plaintext mail with
"unsubscribe prolog <e-
Post by Anamaria Stoica
mail>"
------------
For further info, please visit
http://www.swi-prolog.org/
To unsubscribe, send a plaintext mail with
"unsubscribe prolog <e-mail>"
____________________________________________________________________________________
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367
Alan Baljeu
2007-04-02 13:53:47 UTC
Permalink
I currently have C# code which calls C which calls Prolog which calls C which calls C#.
Does anyone know a better way?
Darren Bane
2007-04-02 16:13:02 UTC
Permalink
Post by Alan Baljeu
I currently have C# code which calls C which calls Prolog which calls C which calls C#.
Does anyone know a better way?
Make up a network protocol using UBF(A)?

http://www.sics.se/~joe/ubf/site/home.html

Use of a network protocol, rather than an API, is defended in Chapter 9,
"APIs and Protocols" in Joe Armstrong's Ph.D. thesis:

http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf
--
Darren Bane
Alan Baljeu
2007-04-02 17:56:49 UTC
Permalink
Post by Alan Baljeu
Post by Alan Baljeu
I currently have C# code which calls C which calls Prolog
which calls C which calls C#.
Post by Alan Baljeu
Does anyone know a better way?
Make up a network protocol using UBF(A)?
http://www.sics.se/~joe/ubf/site/home.html
Use of a network protocol, rather than an API, is defended in
http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf
--
Darren Bane
Thanks for the response. That looks like a very interesting an instructive thesis.

But I guess I should have defined "better". I meant "more directly" and "faster". Perhaps
I could set up an inprocess communication pipeline to transmit data across environments. I
know extremely little about how that is done. If someone believes that may be better
(according to the above definition), and has a suggestion on how to achieve that, I'm all
eyes.

alan
Darren Bane
2007-04-02 23:19:09 UTC
Permalink
Alan Baljeu <***@cornerstonemold.com> wrote:

!snip!
Post by Alan Baljeu
Thanks for the response. That looks like a very interesting an instructive thesis.
But I guess I should have defined "better". I meant "more directly" and "faster". Perhaps
I could set up an inprocess communication pipeline to transmit data across environments. I
know extremely little about how that is done. If someone believes that may be better
(according to the above definition), and has a suggestion on how to achieve that, I'm all
eyes.
I can't argue what that criterion. However, unless you're generating
all your glue code from something like SWIG, writing the FFI code will
take time too. Such code is usually simple to write, but an absolute
bitch to debug because the symptoms of getting the GC interaction wrong
won't surface until many seconds after the mistake was made.

Just contrast writing that boring FFI code in C with 300-400 lines of
a network server in Prolog (I presume it would take about the same as
Erlang, since both languages are about as powerful as each other).
--
Darren Bane
Jan Wielemaker
2007-04-03 07:53:36 UTC
Permalink
Post by Darren Bane
!snip!
Post by Alan Baljeu
Thanks for the response. That looks like a very interesting an instructive thesis.
But I guess I should have defined "better". I meant "more directly" and
"faster". Perhaps I could set up an inprocess communication pipeline to
transmit data across environments. I know extremely little about how
that is done. If someone believes that may be better (according to the
above definition), and has a suggestion on how to achieve that, I'm all
eyes.
I can't argue what that criterion. However, unless you're generating
all your glue code from something like SWIG, writing the FFI code will
take time too. Such code is usually simple to write, but an absolute
bitch to debug because the symptoms of getting the GC interaction wrong
won't surface until many seconds after the mistake was made.
Just contrast writing that boring FFI code in C with 300-400 lines of
a network server in Prolog (I presume it would take about the same as
Erlang, since both languages are about as powerful as each other).
I'm more and more convinced that merging Prolog with orther complex
environments doing GC, etc. in one process is not a good idea. Most of
the cases you are much better of keeping some distance between Prolog
and the rest of the code using the network. The result is often much
easier to debug. Both finding weird interaction problems and in simple
Prolog debugging as the network solution allows you to keep access to
the toplevel (running the services from a Prolog thread).

Cheers --- Jan
Jan Wielemaker
2007-04-03 18:50:18 UTC
Permalink
Post by Darren Bane
Post by Darren Bane
Just contrast writing that boring FFI code in C with
300-400 lines of
Post by Darren Bane
a network server in Prolog (I presume it would take about
the same as
Post by Darren Bane
Erlang, since both languages are about as powerful as each other).
I'm more and more convinced that merging Prolog with orther
complex environments doing GC, etc. in one process is not a
good idea. Most of the cases you are much better of keeping
some distance between Prolog and the rest of the code using
the network. The result is often much easier to debug. Both
finding weird interaction problems and in simple Prolog
debugging as the network solution allows you to keep access
to the toplevel (running the services from a Prolog thread).
I'm currently operating a single-process solution, no webserver, no
network. Since copying is obviously necessary in any conceivable solution,
maybe it wouldn't hurt performance to have a separate process. (Or maybe
it would. I don't know.) But I require education here. What is the (best)
way to set up communications?
Depends very much on the language and libraries you want to use, how
complicated the datatypes are, whether you want to stay language
independent, etc. You can find a binary exchange system for C++ in the
package cppproxy (download the source). This never came to completion,
but there is a good start there. You can also use HTTP and use the
HTTP server libraries. This is not particulary fast, but it is very
flexible with wide support in many languages.

--- Jan
Jan Wielemaker
2007-04-03 19:21:04 UTC
Permalink
Post by Jan Wielemaker
here. What is the (best) way to set up communications?
Depends very much on the language and libraries you want to
use, how complicated the datatypes are, whether you want to
stay language independent, etc. You can find a binary
exchange system for C++ in the package cppproxy (download the
source). This never came to completion, but there is a good
start there. You can also use HTTP and use the HTTP server
libraries. This is not particulary fast, but it is very
flexible with wide support in many languages.
--- Jan
I just need an efficient and simple way to retrieve data from C# objects.
The environment is Windows XP.
I don't like how the current system converts data from C# into C++, then
converts from C++ to PlTerms. It might not be a huge issue, but I thought
maybe there was a better way.
Efficiency-wise this isn't too bad in general.

--- Jan
Alan Baljeu
2007-04-03 19:07:52 UTC
Permalink
Post by Jan Wielemaker
here. What is the (best) way to set up communications?
Depends very much on the language and libraries you want to
use, how complicated the datatypes are, whether you want to
stay language independent, etc. You can find a binary
exchange system for C++ in the package cppproxy (download the
source). This never came to completion, but there is a good
start there. You can also use HTTP and use the HTTP server
libraries. This is not particulary fast, but it is very
flexible with wide support in many languages.
--- Jan
I just need an efficient and simple way to retrieve data from C# objects. The environment
is Windows XP.

I don't like how the current system converts data from C# into C++, then converts from C++
to PlTerms. It might not be a huge issue, but I thought maybe there was a better way.
Carlo Capelli
2007-04-03 07:46:30 UTC
Permalink
Post by Alan Baljeu
I currently have C# code which calls C which calls Prolog which calls C
which calls C#.
Post by Alan Baljeu
Does anyone know a better way?
P#, being Prolog compiled to C#, has a shorter path, but i can't see any
utility in swi-pl.
Anyway, being the foreign swi-pl interface in C, the path can't be shorter.
But you could avoid the last C to C# (re)writing directly the C# applicative
part in managed C++ (maybe could be done automatically, but i'm not shure)
embedded in the foreign interface. I bet the efficiency gain will be very
small....

Bye Carlo
Martin Sondergaard
2007-04-03 13:12:49 UTC
Permalink
I'm using SWI Prolog 5.6.12 with Windows XP.

I needed to speed up some of my code,
so I ran some speed tests on it.
I was hoping to compare the speed of new code
with the speed of old code.

This led to some baffling behaviour.
I couldn't understand why one rule ran faster
than another one.

It turned out that if I compiled two identical
copies of the program, one copy runs faster
than the other!

If I start up 4 or 5 identical copies of the program,
some of them run faster than others.

Does anyone know why this is so?
Can I control this in some way?


Here are some comparisons of the results
of running some speed tests on one bit of code.

Program copy number 1. Speed test 1.
Duration was 0.453 seconds.
Duration was 0.422 seconds.
Duration was 0.437 seconds.

Program copy number 2. Speed test 1.
Duration was 0.391 seconds.
Duration was 0.375 seconds.
Duration was 0.375 seconds.


When I timed a different bit of code, the differences in speed
are even greater. Look at these speed tests.

Program copy number 1. Speed test 2.
Duration was 0.062 seconds.
Duration was 0.0780001 seconds.
Duration was 0.063 seconds.
Duration was 0.0780001 seconds.
Duration was 0.063 seconds.

Program copy number 2. Speed test 2.
Duration was 0.016 seconds.
Duration was 0.0159998 seconds.
Duration was 0.0159998 seconds.
Duration was 0.016 seconds.


This inconsistent behaviour makes it hard to
test the speed of a bit of code.
Is there a way to control this problem?

(In the tests above, I have not shown the *first* time
the code is run. This is normally much slower than later times.
I think this is due to SWI Prolog spending some time indexing
some Prolog facts, the first time those facts are used.)
--
Martin Sondergaard,
London, UK.





































.
ok
2007-04-04 01:54:27 UTC
Permalink
Post by Martin Sondergaard
Here are some comparisons of the results
of running some speed tests on one bit of code.
Program copy number 1. Speed test 1.
Duration was 0.453 seconds.
Duration was 0.422 seconds.
Duration was 0.437 seconds.
Program copy number 2. Speed test 1.
Duration was 0.391 seconds.
Duration was 0.375 seconds.
Duration was 0.375 seconds.
This tells us practically nothing. The variation within the tests is
typical timing noise; any benchmark that runs for less than 10 seconds
is pretty useless. The variation between the tests is interesting, but
without knowing what you mean by "copy".
Post by Martin Sondergaard
(In the tests above, I have not shown the *first* time
the code is run. This is normally much slower than later times.
I think this is due to SWI Prolog spending some time indexing
some Prolog facts, the first time those facts are used.)
Probably not. It's well known in the micro-benchmarking field that you
have to "burn in" a test. It has to do with the memory hierarchy.
For example, I recently ran some system benchmarks on two machines,
an UltraSPARC and a PowerPC:
Fetch from main
L1 cache L2 cache memory
SPARC 2 cycles 10 cycles 100 cycles
PowerPC 3 cycles 10 cycles 95 cycles

On the basis of that, I've just done a test that found counting
occurrences
of a wide character in 4 million wide characters is 1.28 times faster
if I
do it on utf8-compressed text, decompressing as I go, rather than the
simple
obvious wchar_t-at-a-time loop you would think to write.

These days, we have lots of main memory, but it is MUCH slower than we
think it is, and which bits are in cache can have a very large effect on
our benchmarks.

Loading...