Re: turn off let floating
On Thu, Apr 15, 2004 at 01:52:38PM +1000, Bernard James POPE wrote: However, if you have any suggestions about how to make a FAST global counter I would be very glad to hear it. From profiling it seems like this code is a little expensive (also it is called quite frequently). Well, I'm not Simon, but I would suggest to change the line with writeIORef to: writeIORef count $! newCount Best regards, Tom -- .signature: Too many levels of symbolic links ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: turn off let floating
So I have code like: {-# NOINLINE count #-} count :: IORef Int count = unsafePerformIO $ newIORef 0 {-# NOINLINE getCount #-} getCount :: (Int - a) - a getCount f = let nextCount = (unsafePerformIO $ do oldCount - readIORef count let newCount = oldCount + 1 writeIORef count newCount return oldCount) in seq nextCount (f nextCount) It seems to work okay. However, if you have any suggestions about how to make a FAST global counter I would be very glad to hear it. From profiling it seems like this code is a little expensive (also it is called quite frequently). You could try the FastMutInt module from GHC (ghc/compiler/utils/FastMutInt.hs) to speed things up. Unfortunately unsafePerformIO has some unavoidable overhead: it can't be inlined because we don't want the compiler to see its definition. Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [wxhaskell-users] RE: [Haskell] Dynamically loading wxhaskell?
On Wed, 14 Apr 2004 09:37:02 +0100, Simon Marlow [EMAIL PROTECTED] wrote: What error messages do you get, specifically? Here it is: --- Loading package data ... linking ... done. Loading package wxcore ... ghc-6.2.1: can't load .so/.DLL for: wxc-gtk2.4.2-0.7 (/usr/local/stow/wxhaskell//lib/libwxc-gtk2.4.2-0.7.so: undefined symbol: _ZN10wxGLCanvasC1EP8wxWindowiRK7wxPointRK6wxSizelRK8wxStringPi RK9wxPalette) -- I suspect it's something funny with Debian's setup, and quite possibly a bug somewhere else in Debian. That symbol looks suspiciously like it comes from the separate OpenGL parts of WX, which reside in a separate library That is probably the problem. I did not see all messages of this thread, but one should indeed use --with-opengl on wxHaskell configure if wxWidgets was build with --with-opengl. Unfortunately, due to wxWidgets changes, I can not automatically detect the need for this flag, but I promise to discuss it with the wxWidgets devs. fyi. it seems ghci can not handle stripped dynamic libraries on windows, but that may be due to the use of both a *.dll and an import library *.a. Funnily enough, ghc can handle link with those. (I haven't tested extensively though, and it might be related with the use of the upx packer). All the best, Daan. (/usr/lib/libwx_gtk_gl-2.4.so here). On my system, libwxc has an explicit dependency on libwx_gtk_gl, because it was linked against it. Did you configure wxHaskell with --with-opengl? Cheers, Simon --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70alloc_id638opÌk ___ wxhaskell-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/wxhaskell-users ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Inlining question
On Tuesday 13 Apr 2004 10:10 am, Adrian Hey wrote: Hello, Does inlining work with any function definitions (including those defined locally following a where.. say), or only with top level function definitions? Well, as far as I can tell from my experiments, it does only work for for top level definitions (or to be more precise, it seems not to work with local definitions). I assume it does work with top level definitions, so to get (what would otherwise be) local definitions inlined I have to lambda lift them manually to the top level? The remark in the manual about inline pragmas occuring anywhere where a type signature could occur would seem to confirm this (for Haskell 98 at least). I'd be grateful if somebody who knows could confirm this (or not perhaps). I don't want to uglify my code if it's not necessary :-( Thanks -- Adrian Hey ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: turn off let floating
However, if you have any suggestions about how to make a FAST global counter I would be very glad to hear it. From profiling it seems like this code is a little expensive (also it is called quite frequently). You could try the FastMutInt module from GHC (ghc/compiler/utils/FastMutInt.hs) to speed things up. Unfortunately unsafePerformIO has some unavoidable overhead: it can't be inlined because we don't want the compiler to see its definition. What happens if you use the FFI to call a C function like int getCount() { static int x; return x++; } and mark the function pure (outside the IO monad) and noinline? (Probably all the calls get commoned up and it only gets called once; but it might be worth a try). You mentioned that you're trying to get a new counter value for every function application; maybe something like an FFI call to int getCount(void *f, void *a) { static int x; return x++; } where you have getCount :: (a - b) - a - Int; then you pass the function and its argument to getCount. This should prevent any unwanted common subexpression elimination. Carl Witty ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users