~ubuntu-branches/ubuntu/wily/numexpr/wily-proposed

« back to all changes in this revision

Viewing changes to numexpr/module.hpp

  • Committer: Package Import Robot
  • Author(s): Antonio Valentino
  • Date: 2013-09-28 09:03:27 UTC
  • mfrom: (7.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130928090327-s69mvg0n2xnz6cn8
New upstream release (fixes a build failure on s390)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef NUMEXPR_MODULE_HPP
 
2
#define NUMEXPR_MODULE_HPP
 
3
 
 
4
// Deal with the clunky numpy import mechanism
 
5
// by inverting the logic of the NO_IMPORT_ARRAY symbol.
 
6
#define PY_ARRAY_UNIQUE_SYMBOL numexpr_ARRAY_API
 
7
#ifndef DO_NUMPY_IMPORT_ARRAY
 
8
#  define NO_IMPORT_ARRAY
 
9
#endif
 
10
 
 
11
#include <Python.h>
 
12
#include <numpy/ndarrayobject.h>
 
13
#include <numpy/arrayscalars.h>
 
14
 
 
15
#include "numexpr_config.hpp"
 
16
 
 
17
struct global_state {
 
18
    /* Global variables for threads */
 
19
    int nthreads;                    /* number of desired threads in pool */
 
20
    int init_threads_done;           /* pool of threads initialized? */
 
21
    int end_threads;                 /* should exisiting threads end? */
 
22
    pthread_t threads[MAX_THREADS];  /* opaque structure for threads */
 
23
    int tids[MAX_THREADS];           /* ID per each thread */
 
24
    npy_intp gindex;                 /* global index for all threads */
 
25
    int init_sentinels_done;         /* sentinels initialized? */
 
26
    int giveup;                      /* should parallel code giveup? */
 
27
    int force_serial;                /* force serial code instead of parallel? */
 
28
    int pid;                         /* the PID for this process */
 
29
 
 
30
    /* Syncronization variables */
 
31
    pthread_mutex_t count_mutex;
 
32
    int count_threads;
 
33
    pthread_mutex_t count_threads_mutex;
 
34
    pthread_cond_t count_threads_cv;
 
35
 
 
36
    global_state() {
 
37
        nthreads = 1;
 
38
        init_threads_done = 0;
 
39
        end_threads = 0;
 
40
        pid = 0;
 
41
    }
 
42
};
 
43
 
 
44
extern global_state gs;
 
45
 
 
46
int numexpr_set_nthreads(int nthreads_new);
 
47
 
 
48
#endif // NUMEXPR_MODULE_HPP