Wednesday, 4 August 2010

Technical Interlude I

Before carrying on with the economic model, a brief technical  post for which feedback would be appreciated - apologies to those of a less technical disposition!

When implementing this model, there are going to be lots of things to update in each click of our virtual clock.  In order to do this efficiently on modern processors with their many cores, whilst allowing the program to scale to improved hardware without rewriting the entire base, I've decided to adopt a task-based approach to threading using Intel's Thread Building Blocks.  Exactly how will depend a bit on the final simulation structure, but this will become clearer after a few more posts, at which point I shall write Technical Interlude II.

The problem is that I committed myself to customisability, which involves user-defined scripting.  For this purpose, I suggested Lua as an ideal option.  The problem is that I don't believe I can use Lua's virtual machine (the bit that interprets the script) from multiple bits of the program operating simultaneously.  I would therefore have to either implement locks/mutexes around access to the virtual machine (costly for performance) or give each parallel thread its own VM (costly in terms of memory and some speed).

The alternatives are:

  1. No customisation:  not a chance that this is going to be a viable option!
  2. Customisation via compiled C/C++ plugins:  sets the technical barrier a little high for novices and presents me with some significant challenges in allowing access
  3. Find a scripting language that can cope with the threading model I've chosen
  4. Write my own scripting language or get other folks working on a similar one that can work from multiple threads
It is tempting to go mad and say I'll write my own, but that could be a whole separate project on its own.   I'd prefer alternative 3 followed by 2.

This is where I really need some assistance - including from non-techies who might want to customise this software - how would you like to write scripts?

5 comments:

  1. Afraid I can't help you on this one...

    ReplyDelete
  2. I might actually have come up with a suitable workaround to keep using Lua, which is preferable because it's relatively easy to learn. I won't know if it will work without coding it - I might knock together a test case over the next few days.
    In other news, to the two of you watching (!), I plan to put up a post a day this week (starting tomorrow, probably, rather than today) in order to get the entire economic model in place. I have it all written down, but have been curiously lax in typing it up

    ReplyDelete
  3. Not everyone watching your blog is a 'follower' ;).

    ReplyDelete