There was a bug in the F# compiler that made it emit code that wouldn't get bound checking removed on loops. I'm not sure if this was fixed in Beta 1 or not. (The bounds checking is removed by the JIT, if the IL matches a certain pattern.)

If you need random access without bounds checking, you might check out the NativeInterop module. You'll be able to get pointers and directly write to memory as you please. I don't know what IL is emitted and how this gets JIT'd, so it may or may not be faster -- but it's an option to consider.

By on 8/27/2009 10:44 PM ()

My advice is

(a) consider using a professional profiling tool to uncover potential bottlenecks.

(b) share your code if possible - this sort of thing can make a great case study.

(c) look for algorithmic improvements

(d) where necessary, consider using C++ math implementation code via P/Invokes and/or other native interop. This is especially true for existing, polished C++ or Fortran components.

Kind regards

don

By on 9/8/2009 3:42 PM ()

Thanks for the advice. I ended up using a trial version of JetBrains and it turns out there was a lot of time spent pinning an array at each iteration before calling the Sobol routine (if you're curious this was fortran code, called via dllimport ffi).

For some reason I ended up implementing a class in C++/CLI which avoided having to pin an array each time (but still required a copy from unmanaged array into a managed array). The same thing should work in F# directly.

I've attached the code, unfortunately it's part of a larger codebase, so may not be very useful. In the unlikely event that I get enough free time, it would be great to clean it all up and release it somewhere.

Thanks,

David

By on 9/8/2009 4:20 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper