/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk

« back to all changes in this revision

Viewing changes to dict_hw/src/hw_sched.h

  • Committer: Suren A. Chilingaryan
  • Date: 2010-04-25 04:39:54 UTC
  • Revision ID: csa@dside.dyndns.org-20100425043954-v7xm2bzohickyl9z
Multi-GPU support

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _HW_SCHED_H
 
2
#define _HW_SCHED_H
 
3
 
 
4
typedef struct HWSchedT *HWSched;
 
5
 
 
6
#include "dict_hw.h"
 
7
#include "hw_thread.h"
 
8
 
 
9
enum HWSchedModeT {
 
10
    HW_SCHED_MODE_PREALLOCATED = 0,
 
11
    HW_SCHED_MODE_SEQUENTIAL
 
12
};
 
13
typedef enum HWSchedModeT HWSchedMode;
 
14
 
 
15
 
 
16
#define HW_SINGLE_MODE
 
17
//#define HW_DETECT_CPU_CORES
 
18
#define HW_MAX_THREADS MAX_DEVICES
 
19
//#define HW_MAX_THREADS 128
 
20
 
 
21
#ifdef HW_SINGLE_MODE
 
22
    typedef HWRunFunction HWEntry;
 
23
#else /* HW_SINGLE_MODE */
 
24
    typedef int HWEntry;
 
25
#endif /* HW_SINGLE_MODE */
 
26
 
 
27
 
 
28
#ifndef HW_HIDE_DETAILS
 
29
#include <glib.h>
 
30
struct HWSchedT {
 
31
    int status;
 
32
    int started;
 
33
    
 
34
    int n_threads;
 
35
    HWThread thread[HW_MAX_THREADS];
 
36
    
 
37
    GCond *job_cond, *compl_cond;
 
38
    GMutex *job_cond_mutex, *compl_cond_mutex, *data_mutex;
 
39
    
 
40
    HWSchedMode mode;
 
41
    int *n_blocks;
 
42
    int *cur_block;
 
43
 
 
44
    HWEntry entry;
 
45
    void *ctx;
 
46
};
 
47
typedef struct HWSchedT HWSchedS;
 
48
#endif /* HW_HIDE_DETAILS */
 
49
 
 
50
# ifdef __cplusplus
 
51
extern "C" {
 
52
# endif
 
53
 
 
54
HWSched hw_sched_create(int ppu_count);
 
55
void hw_sched_destroy(HWSched ctx);
 
56
int hw_sched_set_sequential_mode(HWSched ctx, int *n_blocks, int *cur_block);
 
57
int hw_sched_get_chunk(HWSched ctx, int thread_id);
 
58
int hw_sched_schedule_task(HWSched ctx, void *appctx, HWEntry entry);
 
59
int hw_sched_wait_task(HWSched ctx);
 
60
 
 
61
#define hw_sched_lock(ctx, type) g_mutex_lock(ctx->type##_mutex)
 
62
#define hw_sched_unlock(ctx, type) g_mutex_unlock(ctx->type##_mutex)
 
63
#define hw_sched_broadcast(ctx, type) g_cond_broadcast(ctx->type##_cond)
 
64
#define hw_sched_signal(ctx, type) g_cond_signal(ctx->type##_cond)
 
65
#define hw_sched_wait(ctx, type) g_cond_wait(ctx->type##_cond, ctx->type##_cond_mutex)
 
66
 
 
67
# ifdef __cplusplus
 
68
}
 
69
# endif
 
70
 
 
71
#endif /* _HW_SCHED_H */
 
72