source: soft/giet_vm/applications/rosenfeld/include/mca.h @ 822

Last change on this file since 822 was 822, checked in by meunier, 8 years ago

In rosenfeld:

  • Updated nrio0, nrio1, nrio2, nrio1f, nrio2f, nrio1x, nrbool1, nrbool2 and nralloc1 in the nrc2 lib in order to use macro-typed functions
  • Updated the simulation script to include performance evaluation with random images, and a script to generate graphs
  • Updated the clock.h to use 64-bit integers, which potentially breaks the printing on the giet
File size: 3.2 KB
Line 
1/* ------------- */
2/* --- MCA.h --- */
3/* ------------- */
4
5/*
6 * Copyright (c) 2016 Lionel Lacassagne, LIP6, UPMC, CNRS
7 * Init  : 2016/03/03
8 */
9
10// Multi/Many Cores Connected Component Computation en Analysis
11// extension of pixel-based and run-based algorithm to manycores with distributed memory
12
13#ifndef __MCA_H__
14#define __MCA_H__
15
16#include "ecc_features.h"
17
18#include "nrc_os_config.h"
19
20#if TARGET_OS == GIETVM
21    #include <user_lock.h>
22    #include <user_barrier.h>
23#elif TARGET_OS == LINUX
24    #include <pthread.h>
25#endif
26
27
28// QM : using mutex lock instead of spinlock,
29// because apparently spinlocks cause a bug in valgrind
30// (solved but the installed version is not recent enough)
31// cf. https://bugs.kde.org/show_bug.cgi?id=336435
32pthread_mutex_t print_lock;
33
34
35
36
37#if MCA_VERBOSE_LEVEL >= 1
38    #define MCA_VERBOSE1(X) ({             \
39        pthread_mutex_lock(&print_lock);   \
40        X;                                 \
41        pthread_mutex_unlock(&print_lock); \
42        })
43#else
44    #define MCA_VERBOSE1(X)
45#endif
46
47#if MCA_VERBOSE_LEVEL >= 2
48    #define MCA_VERBOSE2(X) ({             \
49        pthread_mutex_lock(&print_lock);   \
50        X;                                 \
51        pthread_mutex_unlock(&print_lock); \
52        })
53#else
54    #define MCA_VERBOSE2(X)
55#endif
56
57#if MCA_VERBOSE_LEVEL >= 3
58    #define MCA_VERBOSE3(X) ({             \
59        pthread_mutex_lock(&print_lock);   \
60        X;                                 \
61        pthread_mutex_unlock(&print_lock); \
62        })
63#else
64    #define MCA_VERBOSE3(X)
65#endif
66
67
68typedef struct sMCA {
69    int p, np;         // numero du processeur et nb total de processeurs
70   
71    uint8  ** X; // image source
72    uint32 ** E; // image d'etiquette 32 bits
73   
74    int width;
75    int height;
76   
77    int i0, i1;
78    int j0, j1;
79   
80    uint32 e0, e1; // indice pour chaque bande
81    uint32 ne;     // indice max d'etiquettes utilise par bande
82
83    int alpha;     // puissance de 2 >= a la taille d'un bloc
84    uint32  * T;   // table d'quivalence table (Rosenfeld) ou d'indices (Warp)
85    uint32 ** D;   // distributed table (instanciee dans chaque worker)
86   
87    RegionStats * stats;
88    RegionStats ** F;
89   
90    struct sMCA * mca;   // pointeur vers le maitre (pour les esclaves)
91    struct sMCA ** mcas; // tableau de pointeurs vers les workers
92
93    // For pyramidal barriers
94    int nb_level;
95    pthread_barrier_t * barriers;
96} MCA;
97 
98void MCA_Error(char * msg);
99
100MCA * MCA_pConstructor_Empty(void);
101MCA * MCA_pDestructor(MCA * mca);
102
103void MCA_Set_ImageX(MCA * mca, uint8  ** X);
104void MCA_Set_ImageL(MCA * mca, uint32 ** E);
105
106void MCA_Set_Size(MCA * mca, int width, int height);
107void MCA_Set_NP(MCA * mca, int np);
108
109uint32 MCA_CalcMaxLabels(int connection, uint32 height, uint32 width);
110
111void MCA_Display_Parameters(MCA *mca);
112
113void MCA_Initialize(MCA * mca);
114void MCA_Finalize  (MCA * mca);
115
116
117// master to workers
118void MCA_Scatter_ImageX(MCA * mca);
119
120// workers to master
121void MCA_Gather_ImageL(MCA * mca);
122
123// CC run
124void MCA_Rosenfeld(MCA * mca);
125void MCA_MPar(MCA * mca);
126void MCA_Warp(MCA * mca);
127
128
129#endif // __MCA_H__
130
Note: See TracBrowser for help on using the repository browser.