<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>Re: [clean-list] (no subject)</title></head><body>
<div><br></div>
<div>Timothy Hochberg wrote:</div>
<blockquote type="cite" cite>I've been playing with Clean for a few
weeks now and I have a few questions and observations, more about
infrastructure of Clean than the language itself:<br>
</blockquote>
<blockquote type="cite" cite>* The profiler overflows for me: I tend
to get negative time value, which makes it difficult to interpret the
results. It's possible that this is related to running the code on a
dual core processor since I didn't encounter this when I ran similar
code on a single core machine. I'm not certain though, since it wasn't
exactly the same code. Is this a known issue? I can provide examples
if you like.</blockquote>
<div><br></div>
<div>The time profiler uses the time stamp counter (TSC) of the
processor. It is possible that different cores have different values
for the TSC. This</div>
<div>could cause negative time values when profiling, if a thread is
executed</div>
<div>by more than one core.</div>
<div><br></div>
<div>Could you try adding the following 2 functions:</div>
<div><br></div>
<div>GetCurrentThread :: Int;<br>
GetCurrentThread = code {<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>ccall
GetCurrentThread@0 &quot;P:I&quot;<br>
}<br>
<br>
SetThreadAffinityMask :: !Int !Int -&gt; Int;<br>
SetThreadAffinityMask thread_h thread_afinity_mask = code {</div>
<div><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>ccall
SetThreadAffinityMask@8 &quot;PII:I&quot;<br>
}<br>
</div>
<div>And call the functions at the beginning of the program:</div>
<div><br></div>
<div>Start</div>
<div><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>|
SetThreadAffinityMask GetCurrentThread 1&lt;&gt;0<br>
</div>
<div>To be able to link the program, add an extra line with:</div>
<div>SetThreadAffinityMask@8</div>
<div>at the end of the kernel_library file in the directory</div>
<div>Libraries\StdEnv\Clean System Files</div>
<div>using the CleanIDE or another text editor.</div>
<div><br></div>
<div>This should cause the program to be executed by one core only,
and</div>
<div>hopefully solve the problem with the profiler. If it doesn't,
could</div>
<div>you send us an example ?</div>
<div><br></div>
<div>For very small functions, that are not recursive, negative time
values</div>
<div>are sometimes reported by the profiler, because it tries to
subtract the</div>
<div>overhead caused by profiling from the measured execution time,
and sometimes</div>
<div>the computed overhead is a bit too large.</div>
<div><br></div>
<blockquote type="cite" cite>* While I'm on the subject, is there some
documentation on how to interpret the mangled names that show up in
the profiler? &quot;g_cl;100;54;82&quot; for example?</blockquote>
<div><br></div>
<div>I couldn't find g_cl, maybe you mean g_c1 ?</div>
<div><br></div>
<blockquote type="cite" cite>I'm guessing that this is some anonymous
function defined on line 100? Is that correct?</blockquote>
<div><br>
Yes.<br>
</div>
<blockquote type="cite" cite>And is there more information that can be
deduced from the name?</blockquote>
<div><br></div>
<div>If it is g_c1 or g_c2, then it is generated for a
comprehension.</div>
<div><br></div>
<blockquote type="cite" cite>* The first time some text is drawn in
the window, it seems to go to the wrong place. In particular the
example in section 5.4.3 of the ObjectIO tutorial:<br>
&nbsp;&nbsp;&nbsp; example = drawAt zero &quot;Pop&quot;</blockquote>
<blockquote type="cite" cite>puts the text in the wrong place until
the window is resized. If the window is minimized and then restored,
the text is once again in the wrong place.</blockquote>
<div><br></div>
<div>I haven't tried this yet.</div>
<div><br></div>
<blockquote type="cite" cite>* The non ObjectIO games have a horrible,
seizure inducing flicker on my machine. Otherwise they're pretty
cool.</blockquote>
<div><br></div>
<div>This doesn't happen on my computer.</div>
<div><br></div>
<blockquote type="cite" cite>* Some of the examples run way too fast.
Bounce, for example, needed some delay inserted before I could see
what was going on.</blockquote>
<div><br></div>
<div>Yes, some examples were written on much slower computers.</div>
<div><br></div>
<blockquote type="cite" cite>* Having the IDE written in Clean is good
marketing! However, the IDE seems needlessly crippled by having only a
single level of undo. Is there some way of activating multi level undo
that I am missing?</blockquote>
<div><br></div>
<div>No, as far as I know.</div>
<div><br></div>
<blockquote type="cite" cite>&nbsp;It would also be nice to be able to
bind block comment (AKA &quot;Add Prefix&quot;) to a key, but it
doesn't look like that is possible.</blockquote>
<div><br></div>
<div>Or use /* and */ instead (nested comments are allowed in
Clean).</div>
<div><br></div>
<blockquote type="cite" cite>* I'm interested in calling into clean
from another language (Python to be specific). I found some
documentation on how to call into Clean as long as I use Ints[1]. A
little bit more digging[2] revealed that there is some experimental
code to allow Reals and Strings and maybe someday {#Int} and {#Real}.
For the stuff I'd like to try those last two would be critical, so let
this be a vote for getting those implemented.<br>
<br>
[1] <a
href="http://www.xs4all.nl/~keslr/functional/clean/howto/cleandll.html"
>http://www.xs4all.nl/~keslr/functional/clean/howto/cleandll.html</a
></blockquote>
<blockquote type="cite" cite>[2] <a
href="http://article.gmane.org/gmane.comp.lang.clean/883"
>http://article.gmane.org/gmane.comp.lang.clean/883</a></blockquote>
<div><br></div>
<div>I have implemented foreign export of {#Int} and {#Real}, and
updated:</div>
<div><br></div>
<div
>http://clean.cs.ru.nl/download/Clean22/windows/Clean_2.2_extended_fo<span
></span>reign_export.zip</div>
<div><br></div>
<div>To use this compiler:</div>
<div>- copy the .exe and .dll files in the zip file into the
Tools/Clean System directory of Clean 2.2.</div>
<div>- copy the .o files in the zip file into the
Libraries/StdEnv/Clean System Files directory of Clean 2.2</div>
<div>(in both cases overwriting the old files with the new
version).</div>
<div><br></div>
<div>The file Tools/htoclean/Clean.h contains some macros for
accessing the arrays.</div>
<div><br></div>
<div>If an array is passed from Clean to c, the c function is passed a
pointer to</div>
<div>an array inside Clean's heap. This pointer should not be used any
more after</div>
<div>the c function returns, because the garbage collector may move or
deallocate</div>
<div>the array.</div>
<div><br></div>
<div>To pass an array from c to Clean, the int (4 bytes) at (byte)
offset -8,</div>
<div>should contain the number of elements of the array. A copy of
this array is</div>
<div>made in the Clean heap when the c function returns, and this copy
is used.</div>
<div><br></div>
<div>The c programmer is responsible for releasing any memory
allocated</div>
<div>for these arrays in c, because the foreign export interface does
not call</div>
<div>functions that free memory, like free or LocalFree.<br>
</div>
<blockquote type="cite" cite>That's about it for now. Thanks for the
interesting tool. And kudos on the Clean book, which is one of the
best intro functional programming texts that I've seen.</blockquote>
<div><br></div>
<div>Thank you.<br>
</div>
<blockquote type="cite" cite>All of this is running with Clean 2.2
under Window XP on a Core Duo processor.</blockquote>
<div><br></div>
<div>Kind regards,</div>
<div><br></div>
<div>John van Groningen</div>
</body>
</html>