Subversion Repositories PlanixRsrch.SVN

Rev

Rev 45 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 45 Rev 289
1
#ifndef UNIT_H_
1
#ifndef UNIT_H_
2
#define UNIT_H_
2
#define UNIT_H_
3
 
3
 
4
#include <cstdlib>
4
#include <cstdlib>
5
#include <mutex>
5
#include <mutex>
6
 
6
 
7
 
7
 
8
#include "dq.h"
8
#include "dq.h"
9
 
9
 
10
//#include "qube.h"
10
//#include "qube.h"
11
 
11
 
12
 
12
 
13
class unit
13
class unit
14
{
14
{
15
public:
15
public:
16
    weight_t syns[SYNS_PER_UNIT];
16
    weight_t syns[SYNS_PER_UNIT];
17
    volatile float sum;
17
    volatile float sum;
18
    std::mutex mtx;
18
    std::mutex mtx;
19
    unit() {
19
    unit() {
20
        sum=0.0;
20
        sum=0.0;
21
        for (int i=0; i<SYNS_PER_UNIT; i++) {
21
        for (int i=0; i<SYNS_PER_UNIT; i++) {
22
            weight_t r = static_cast <weight_t> (rand()) / static_cast <weight_t> (RAND_MAX);
22
            weight_t r = static_cast <weight_t> (rand()) / static_cast <weight_t> (RAND_MAX);
23
            syns[i]=r;
23
            syns[i]=r;
24
        }
24
        }
25
 
25
 
26
    }
26
    }
27
 
27
 
28
 
28
 
29
    void receive(int from,float val);
29
    void receive(int from,float val);
30
 
30
 
31
    int run(class qube * qube, int me);
31
    int run(class qube * qube, int me);
32
 
32
 
33
 
33
 
34
    void adjust(int from);
34
    void adjust(int from);
35
 
35
 
36
 
36
 
37
    inline void dump() {
37
    inline void dump() {
38
        for (int i=0; i<SYNS_PER_UNIT; i++) {
38
        for (int i=0; i<SYNS_PER_UNIT; i++) {
39
            printf("[%0.6f]",syns[i]);
39
            printf("[%0.6f]",syns[i]);
40
        }
40
        }
41
    }
41
    }
42
 
42
 
43
 
43
 
44
 
44
 
45
    void fire(qube * q,int me, float val);
45
    void fire(qube * q,int me, float val);
46
 
46
 
47
 
47
 
48
 
48
 
49
 
49
 
50
};
50
};
51
 
51
 
52
#endif
52
#endif
53
 
53