← Back to team overview

instant team mailing list archive

Re: Timing of in-memory cache

 

On Fri, Sep 05, 2008 at 10:50:37AM +0200, Martin Sandve Alnæs wrote:
> I've added a test that times the cache mechanism, using
> a signature object that sleeps for a second in sig.signature()
> and half a second in sig.__hash__().
> It's called test18.py. Seems to me that the cache works fine.

I can't get it to work, but maybe I'm using it wrong.

I'm running the bench/fem/jit/ test script in DOLFIN with the current
version of FFC (just pushed) and I always get the following:

--- Calling FFC JIT compiler ---
1. Module returned by import_module:  None
2. Calling FFC just-in-time (JIT) compiler, this may take some time... done
3. Creating Python extension (compiling and linking), this may take some time... done
Assembling matrix over cells (finished).

In step (1), Instant always returns None when calling import_module().
I assume this means that the module was not found, neither in the
in-memory cache nor disk cache.

Since it returns None, FFC generates code in step (2). This takes a
second or two.

Then in step (3), FFC sends the generated code to build_module(). This
goes surprisingly fast, so it seem Instant must return something from
cache.

So, something strange is going on, both in step (1) and (3). Here's
the code for FFC's jit() which is now very short:

    # Check options
    options = check_options(input_form, options)

    # Wrap input
    jit_object = wrap(input_form, options)

    # Check cache
    module = instant.import_module(jit_object)
    print "Module returned by import_module: ", module

    # Compile form
    debug("Calling FFC just-in-time (JIT) compiler, this may take some  time...", -1)
    signature = jit_object.signature()
    compile(input_form, signature, options)
    debug("done", -1)

    # Wrap code into a Python module using Instant
    debug("Creating Python extension (compiling and linking), this may take some time...", -1)
    filename = signature + ".h"
    (cppargs, path, ufc_include) = extract_instant_flags(options)
    module = instant.build_module(wrap_headers=[filename],
                                  additional_declarations=ufc_include,
                                  include_dirs=path,
                                  cppargs=cppargs,
                                  signature=signature)
    debug("done", -1)

    # Extract form
    exec("compiled_form = module.%s()" % signature)

Can you spot something wrong?

-- 
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References