Skip to content

Commit 768b3f4

Browse files
committed
Initial Code
1 parent d76863f commit 768b3f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+16171
-0
lines changed

.gitignore

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# This file is used to ignore files which are generated
2+
# ----------------------------------------------------------------------------
3+
4+
*~
5+
*.autosave
6+
*.a
7+
*.core
8+
*.moc
9+
*.o
10+
*.obj
11+
*.orig
12+
*.rej
13+
*.so
14+
*.so.*
15+
*_pch.h.cpp
16+
*_resource.rc
17+
*.qm
18+
.#*
19+
*.*#
20+
core
21+
!core/
22+
tags
23+
.DS_Store
24+
.directory
25+
*.debug
26+
*.prl
27+
*.app
28+
moc_*.cpp
29+
ui_*.h
30+
qrc_*.cpp
31+
Thumbs.db
32+
*.res
33+
*.rc
34+
/.qmake.cache
35+
/.qmake.stash
36+
37+
# qtcreator generated files
38+
*.pro.user*
39+
40+
# xemacs temporary files
41+
*.flc
42+
43+
# Vim temporary files
44+
.*.swp
45+
46+
# Visual Studio generated files
47+
*.ib_pdb_index
48+
*.idb
49+
*.ilk
50+
*.pdb
51+
*.sln
52+
*.suo
53+
*.vcproj
54+
*vcproj.*.*.user
55+
*.ncb
56+
*.sdf
57+
*.opensdf
58+
*.vcxproj
59+
*vcxproj.*
60+
61+
# MinGW generated files
62+
*.Debug
63+
*.Release
64+
65+
# Python byte code
66+
*.pyc
67+
68+
# Binaries
69+
# --------
70+
*.dll
71+
*.exe
72+
73+
*.txt
74+
*.bat
75+
*.json
76+
gmon.out
77+
callgrind.out.*
78+
79+
.idea/
80+
*.csv
81+
results/
82+
build/
83+
*.sh
84+
results*/
85+
*.py
86+
running/

STSchedule.pro

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
TEMPLATE = app
2+
CONFIG += console c++11
3+
CONFIG -= app_bundle
4+
CONFIG -= qt
5+
6+
7+
QMAKE_CXXFLAGS_RELEASE -= -O2
8+
QMAKE_CXXFLAGS_RELEASE += -O3 -Wall
9+
10+
QMAKE_LFLAGS += -Wl,--stack,64000000 -Wall
11+
12+
HEADERS += \
13+
include/bitset.h \
14+
include/bufferusage.h \
15+
include/cluster.h \
16+
include/core.h \
17+
include/coremapping.h \
18+
include/datalayout.h \
19+
include/json/json.h \
20+
include/json/json_autolink.h \
21+
include/json/json_batchallocator.h \
22+
include/json/json_config.h \
23+
include/json/json_features.h \
24+
include/json/json_forwards.h \
25+
include/json/json_internalarray.inl \
26+
include/json/json_internalmap.inl \
27+
include/json/json_reader.h \
28+
include/json/json_value.h \
29+
include/json/json_valueiterator.inl \
30+
include/json/json_writer.h \
31+
include/layer.h \
32+
include/layerengine.h \
33+
include/ltreenode.h \
34+
include/network.h \
35+
include/nns/nns.h \
36+
include/noc.h \
37+
include/partition.h \
38+
include/placement.h \
39+
include/schnode.h \
40+
include/util.h
41+
42+
SOURCES += \
43+
src/bitset.cpp \
44+
src/bufferusage.cpp \
45+
src/cluster.cpp \
46+
src/core.cpp \
47+
src/coremapping.cpp \
48+
src/datalayout.cpp \
49+
src/json/json_reader.cpp \
50+
src/json/json_value.cpp \
51+
src/json/json_writer.cpp \
52+
src/layer.cpp \
53+
src/layerengine.cpp \
54+
src/ltreenode.cpp \
55+
src/main.cpp \
56+
src/network.cpp \
57+
src/nns/alexnet.cpp \
58+
src/nns/darknet19.cpp \
59+
src/nns/densenet.cpp \
60+
src/nns/gnmt.cpp \
61+
src/nns/googlenet.cpp \
62+
src/nns/incep_resnet.cpp \
63+
src/nns/pnasnet.cpp \
64+
src/nns/resnet.cpp \
65+
src/nns/transformer.cpp \
66+
src/nns/vgg.cpp \
67+
src/nns/zfnet.cpp \
68+
src/noc.cpp \
69+
src/partition.cpp \
70+
src/placement.cpp \
71+
src/schnode.cpp \
72+
src/util.cpp
73+
74+
INCLUDEPATH += include/

include/bitset.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#ifndef BITSET_H
2+
#define BITSET_H
3+
4+
#include <bitset>
5+
#include <cstdint>
6+
#include <initializer_list>
7+
#include <iostream>
8+
#include <vector>
9+
10+
#define FOR_BITSET(var, set) for(Bitset::bitlen_t var = set.first(); var != set.max_size(); var = set.next(var))
11+
12+
#define MAX_BITS_IN_BS 640
13+
14+
class Bitset: private std::bitset<MAX_BITS_IN_BS>{
15+
public:
16+
typedef std::uint16_t bitlen_t;
17+
private:
18+
typedef std::bitset<MAX_BITS_IN_BS> std_bs;
19+
// std::int64_t bits[4];
20+
Bitset(std_bs&& base);
21+
public:
22+
Bitset()=default;
23+
explicit Bitset(bitlen_t bit);
24+
Bitset(std::initializer_list<bitlen_t> bits);
25+
Bitset(std::vector<bitlen_t> list);
26+
bitlen_t count() const;
27+
// Undefined behaviour if bitset is empty.
28+
bitlen_t first() const;
29+
// Returns 0 if there is no next.
30+
bitlen_t next(bitlen_t bit) const;
31+
bool contains(bitlen_t bit) const;
32+
void set(bitlen_t bit);
33+
void reset(bitlen_t bit);
34+
void clear();
35+
bitlen_t max_size() const;
36+
Bitset& operator|=(const Bitset& other);
37+
bool operator==(const Bitset& other) const;
38+
//Bitset& operator|=(bitlen_t other);
39+
friend std::ostream& operator<<(std::ostream& os, const Bitset& set);
40+
friend Bitset operator|(const Bitset& lhs, const Bitset& rhs);
41+
};
42+
43+
#undef MAX_BITS_IN_BS
44+
45+
#endif // BITSET_H

include/bufferusage.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifndef BUFFERUSAGE_H
2+
#define BUFFERUSAGE_H
3+
4+
#include <unordered_map>
5+
#include "util.h"
6+
7+
class BufferUsage{
8+
struct pos_hash {
9+
std::size_t operator()(const pos_t& pos) const {
10+
return std::hash<pos_t::pos_hash_t>{}(*reinterpret_cast<const pos_t::pos_hash_t*>(&pos));
11+
}
12+
};
13+
std::unordered_map<pos_t, vol_t, pos_hash> usage;
14+
vol_t factor, max_vol;
15+
bool valid;
16+
public:
17+
BufferUsage();
18+
BufferUsage(vol_t _max_vol);
19+
bool add(pos_t chip, vol_t size);
20+
bool all_add(vol_t size);
21+
operator bool() const;
22+
BufferUsage& operator+=(const BufferUsage& other);
23+
BufferUsage operator+(const BufferUsage& other) const;
24+
void max(const BufferUsage& other);
25+
vol_t max() const;
26+
double avg() const;
27+
bool multiple(vol_t n);
28+
vol_t get_max_vol() const;
29+
30+
friend std::ostream& operator<<(std::ostream& os, const BufferUsage& usage);
31+
};
32+
33+
#endif // BUFFERUSAGE_H

include/cluster.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#ifndef CLUSTER_H
2+
#define CLUSTER_H
3+
4+
#include <memory>
5+
//#include <vector>
6+
#include "util.h"
7+
8+
class Cluster{
9+
public:
10+
/*
11+
struct core{
12+
pos_t pos;
13+
vol_t UBUF_vol;
14+
};
15+
*/
16+
typedef vol_t hop_t;
17+
typedef cidx_t xyid_t;
18+
typedef std::unique_ptr<cidx_t[]> allocRes_t;
19+
static mlen_t xlen,ylen,stride;
20+
static double min_util;
21+
private:
22+
//const core* cores;
23+
struct{
24+
cidx_t first, last;
25+
}range;
26+
27+
// TODO: use core_list in the future,
28+
// when cores are not allocated in rectangular fashion.
29+
//bool use_range;
30+
//std::vector<pos_t> core_list;
31+
32+
public:
33+
Cluster(cidx_t _first, cidx_t _last);
34+
bool operator==(const Cluster& other) const;
35+
bool operator!=(const Cluster& other) const;
36+
cidx_t num_cores() const;
37+
allocRes_t try_alloc(utime_t* ops, cidx_t childNum, utime_t totOps=0) const;
38+
Cluster sub_cluster(cidx_t childIdx, const allocRes_t& allocRes) const;
39+
Cluster sub_cluster(cidx_t from, cidx_t num) const;
40+
/*
41+
static hop_t unicast(pos_t src, pos_t dst);
42+
// TODO: dst needs to be in inc. order.
43+
static hop_t multicast(pos_t src, pos_t* dst, cidx_t len);
44+
// DRAM is at (-1,x) and (n,x)
45+
static hop_t unicast_dram(pos_t dst, vol_t size);
46+
static hop_t unicast_to_dram(pos_t dst, vol_t size);
47+
static hop_t multicast_dram(pos_t* dst, cidx_t len, vol_t size);
48+
*/
49+
static pos_t get_pos(cidx_t core_idx);
50+
static xyid_t get_xyid(pos_t& chip);
51+
// bool first_chip(pos_t& chip) const;
52+
// bool next_chip(pos_t& chip) const;
53+
pos_t operator[](cidx_t num_chip) const;
54+
memidx_t nearest_dram() const;
55+
};
56+
57+
58+
#endif // CLUSTER_H

include/core.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#ifndef CORE_H
2+
#define CORE_H
3+
4+
#include <cstdint>
5+
#include "util.h"
6+
7+
class Core{
8+
public:
9+
typedef std::uint16_t numMac_t;
10+
const numMac_t mac_num, LR_mac_num;
11+
const energy_t LR_mac_cost;
12+
13+
struct Buffer{
14+
vol_t Size;
15+
energy_t RCost, WCost;
16+
bw_t RBW, WBW;
17+
Buffer(vol_t _size = 0, energy_t _rCost = 0, bw_t _rBW = 256, energy_t _wCost = 0, bw_t _wBW = 0);
18+
};
19+
Core(numMac_t _mac_num, numMac_t _LR_mac_num, energy_t _LR_mac_cost);
20+
virtual const Buffer& ubuf() const = 0;
21+
};
22+
23+
class PolarCore : public Core{
24+
public:
25+
typedef std::uint8_t vmac_t;
26+
struct PESetting{
27+
vmac_t vecSize, laneNum;
28+
energy_t MACCost;
29+
PESetting(vmac_t _vecSize, vmac_t _laneNum, energy_t _macCost);
30+
};
31+
typedef std::uint8_t numpe_t;
32+
struct Bus{
33+
numpe_t aLen,oLen,totNum; // x for act. y for wgt.
34+
energy_t hopCost;
35+
bw_t busBW;
36+
Bus(numpe_t _aLen, numpe_t _oLen, energy_t _hopCost,bw_t _busBW);
37+
};
38+
struct Buffers{
39+
// Notice: there are 8 wl1 in each Polar Core.
40+
const Buffer al1, wl1, ol1, al2, wl2, ol2, ul3;
41+
};
42+
const PESetting pes;
43+
const Bus bus;
44+
const Buffer al1, wl1, ol1, al2, wl2, ol2, ul3;
45+
public:
46+
PolarCore(const PESetting& _pes, const Bus& _noc,
47+
const Buffer& _al1,
48+
const Buffer& _wl1, const Buffer& _ol1,
49+
const Buffer& _al2, const Buffer& _wl2,
50+
const Buffer& _ol2, const Buffer& _ul3,
51+
numMac_t _LR_mac_num, energy_t _LR_mac_cost);
52+
virtual const Core::Buffer& ubuf() const;
53+
};
54+
class EyerissCore : public Core {
55+
public:
56+
typedef std::uint8_t vmac_t;
57+
struct PESetting {
58+
vmac_t Xarray, Yarray;
59+
energy_t MacCost;
60+
PESetting(vmac_t _Xarray, vmac_t _Yarray, energy_t _MacCost);
61+
};
62+
struct Bus {
63+
energy_t BusCost;//global bus
64+
bw_t BusBW;
65+
Bus(energy_t _BusCost, bw_t _BusBW);
66+
};
67+
const PESetting pes;
68+
const Bus ibus, wbus, pbus;
69+
const Buffer al1, wl1, pl1, ul2;
70+
public:
71+
EyerissCore(const PESetting& _pes, const Bus& _ibus, const Bus& _wbus, const Bus& _pbus,
72+
const Buffer& _al1, const Buffer& _wl1,
73+
const Buffer& _ol1, const Buffer& _ul2,
74+
numMac_t _LR_mac_num, energy_t _LR_mac_cost
75+
);
76+
virtual const Core::Buffer& ubuf() const;
77+
};
78+
#endif // CORE_H

0 commit comments

Comments
 (0)