This repository was archived by the owner on Nov 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathhost_bsp_private.h
More file actions
171 lines (139 loc) · 4.6 KB
/
Copy pathhost_bsp_private.h
File metadata and controls
171 lines (139 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
This file is part of the Epiphany BSP library.
Copyright (C) 2014-2015 Buurlage Wits
Support e-mail: <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License (LGPL)
as published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
and the GNU Lesser General Public License along with this program,
see the files COPYING and COPYING.LESSER. If not, see
<http://www.gnu.org/licenses/>.
*/
#pragma once
#include "host_bsp.h"
#include "ebsp_common.h"
#define __USE_XOPEN2K
#define __USE_POSIX199309 1
#include <time.h>
#define MAX_N_STREAMS 1000
#ifdef DEBUG
typedef struct {
int index;
unsigned int value; // must be unsigned, addresses use the last bit
size_t size;
int type; // STT_FUNC, STT_OBJECT, etc
int bind; // STB_GLOBAL, STB_LOCAL
int section; // SHN_ABS, SHN_COMMON, SHN_UNDEF, or section index
char name[64];
} Symbol;
#endif
/*
* Global BSP state
*/
typedef struct {
// The number of processors available
int nprocs;
// The directory of the program and e-program
// including a trailing slash
char e_directory[1024];
// The name of the e-program
char e_fullpath[1024];
// Number of rows or columns in use
int rows;
int cols;
// Number of processors in use
int nprocs_used;
// Epiphany structure to describe external memory mmap info
e_mem_t emem;
// memory-mapped pointers to external memory
// They are the host-side version of E_XXX_ADDR in common.h
void* host_combuf_addr;
void* host_dynmem_addr;
// Local copy of ebsp_combuf to copy from and copy into.
ebsp_combuf combuf;
// For reading out the final queue after spmd
int message_index;
void (*sync_callback)(void);
void (*end_callback)(void);
int num_vars_registered;
// Epiphany specific variables
e_platform_t platform;
e_epiphany_t dev;
// Timer storage
struct timespec ts_start, ts_end;
// Buffer. First is deprecated, second is new version
ebsp_stream_descriptor buffered_streams[NPROCS][MAX_N_STREAMS];
ebsp_stream_descriptor shared_streams[MAX_N_STREAMS];
#ifdef DEBUG
Symbol* e_symbols;
int num_symbols;
#endif
} bsp_state_t;
extern bsp_state_t state;
/*
* host_bsp
*/
int bsp_init(const char* _e_name, int argc, char** argv);
int bsp_begin(int nprocs);
int ebsp_spmd();
int bsp_end();
int bsp_nprocs();
/*
* host_bsp_memory
*/
void ebsp_malloc_init();
void* ebsp_ext_malloc(unsigned int nbytes);
void ebsp_free(void* ptr);
int ebsp_write(int pid, void* src, off_t dst, int size);
int ebsp_read(int pid, off_t src, void* dst, int size);
int _write_core_syncstate(int pid, int syncstate);
int _write_extmem(void* src, off_t offset, int size);
/*
* host_bsp_buffer
*/
void ebsp_send_buffered(void* src, int dst_core_id, int nbytes,
int max_chunksize);
void ebsp_send_buffered_raw(void* src, int dst_core_id, int nbytes,
int max_chunksize);
void* ebsp_get_buffered(int src_core_id, int nbytes, int max_chunksize);
void _ebsp_add_stream(int dst_core_id, void* extmem_in_buffer, int nbytes,
int max_chunksize, int is_instream);
void ebsp_create_down_stream_raw(const void* src, int dst_core_id, int nbytes,
int max_chunksize);
/*
* host_bsp_mp
*/
void ebsp_set_tagsize(int* tag_bytes);
void ebsp_send_down(int pid, const void* tag, const void* payload, int nbytes);
int ebsp_get_tagsize();
void ebsp_qsize(int* packets, int* accum_bytes);
ebsp_message_header* _next_queue_message();
void _pop_queue_message();
void ebsp_get_tag(int* status, void* tag);
void ebsp_move(void* payload, int buffer_size);
int ebsp_hpmove(void** tag_ptr_buf, void** payload_ptr_buf);
/*
* host_bsp_utility
*/
void ebsp_set_sync_callback(void (*cb)());
void ebsp_set_end_callback(void (*cb)());
void* _arm_to_e_pointer(void* ptr);
void* _e_to_arm_pointer(void* ptr);
void _update_remote_timer();
void _microsleep(int microseconds);
void _get_p_coords(int pid, int* row, int* col);
void init_application_path();
/*
* host_bsp_debug
*/
#ifdef DEBUG
void _read_elf(const char* filename);
Symbol* _get_symbol_by_addr(void* addr);
Symbol* _get_symbol_by_name(const char* symbol);
#endif