Generic Engine

Intro

This project attempts to implement a generic algorithm database, which can be used for a transparent storage of functions which can take a pice of data and mutate it to another form.

Each algorithm is split into three constructs: engine, context, and job. ENGINE is a factory of instances; it represents the algorithm. CONTEXT is an engine instance used for processing; it can execute an alg. operation. JOB is a process in which the algorithm is executein; can be async.

Example: Naming:
Each algorithm is named according to its type (ex: comp for compress), specific algorithm name, and implementation method. An example of an algorighm engine name is "comp-lzw-sw" which describes an engine which implements a compression LZW algorithm in software. It is possible to request any implementation by not speciing the last portion of a name; ex: if only one implementation of LZW was present then the same engine would be returned from get_engine_by_name when either "comp-lzw-sw" or "comp-lzw" were passed.
Why?
There are two main reasons. First, to reduce the duplication of code for operations. If there is an accepted interface for commonly use algorithms developers will be more enclined to use the existing code. Second, to allow for these operations to be done in a hardware accelerator for that algorithm - i.e. asynchronously.
How to use?

You may want to have a look at the test/test-*.c modules from the tarball (listed under download below). There you will see a bare-bones examples of how to use a real engine which has an implementation in the archive.

Below is a rundown of operation that are involved in a simle session...

  1. locate the engine in question:
        /* NOTE: engine must be returned using put_engine */
        engine = get_engine_by_name("comp-lzw-sw");
  2. generate an context:
        // defn is the algorithm specific context information
        create_context( engine, &defn, GFP_ATOMIC, &context );
      
  3. use context:
        create_job( context, GFP_ATOMIC, &job );
        job->data.in_ptr = (void*)...;   // buffer with data
        job->data.in_len = (int)...;             
        job->data.out_ptr = (void*)...;  // buffer for result
        job->data.out_len = (int)...;
        job->cb_fn = (int)(*)(void*)...; // async callback(job)
        job->opaque = (void*)...;        // anything
        execute_job( job );
  4. job finished...
        if( job->result ) ...;           // failure
        else ...;                        // success
        release_job( &job );
  5. done with context...
        release_context( &context );
  6. release the engine...
        put_engine( engine );
Download License:

Unless otherwise specified all source files in this package is released under the GPL. Some parts (implementations of various algorithms) may be protected by other licenses which are listed in those source files.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See http://www.fsf.org/copyleft/gpl.txt.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.



Bart Trojanowski
http://www.jukie.net/~bart
bart@jukie.net