SpiNNFrontEndCommon  7.4.0
Common support code for user-facing front end systems.
profiler.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 The University of Manchester
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
23 
24 #ifndef PROFILER_H
25 #define PROFILER_H
26 
28 #define PROFILER_N_HEADER_WORDS 1
29 
30 //---------------------------------------
31 // Declared functions
32 //---------------------------------------
33 
38 void profiler_init(uint32_t* data_region);
39 
44 void profiler_finalise(void);
45 
49  uint32_t count;
55  uint32_t samples[];
56 };
57 
61  uint32_t *count;
65  uint32_t *output;
66 };
67 
68 #ifdef PROFILER_ENABLED
69 
70 #include <stdint.h>
71 #include <spin1_api.h>
72 
73 //---------------------------------------
74 // Macros
75 //---------------------------------------
76 
79  PROFILER_ENTER = 1 << 31,
80  PROFILER_EXIT = 0
81 };
82 
83 //---------------------------------------
84 // Externals
85 //---------------------------------------
86 
88 extern struct profiler_state profiler_state;
89 
90 //---------------------------------------
91 // Inline functions
92 //---------------------------------------
93 
99 static inline void profiler_write_entry(uint32_t tag) {
101  *profiler_state.output++ = tc[T2_COUNT];
102  *profiler_state.output++ = tag;
104  }
105 }
106 
111 static inline void profiler_write_entry_disable_irq_fiq(uint32_t tag) {
112  uint sr = spin1_irq_disable();
113  spin1_fiq_disable();
115  spin1_mode_restore(sr);
116 }
117 
122 static inline void profiler_write_entry_disable_fiq(uint32_t tag) {
123  uint sr = spin1_fiq_disable();
125  spin1_mode_restore(sr);
126 }
127 #else // PROFILER_ENABLED
128 
129 static inline void __profiler_skip(void) { return; }
130 
131 #define profiler_write_entry(tag) __profiler_skip()
132 #define profiler_write_entry_disable_irq_fiq(tag) __profiler_skip()
133 #define profiler_write_entry_disable_fiq(tag) __profiler_skip()
134 
135 #endif // PROFILER_ENABLED
136 
137 #endif // PROFILER_H
void profiler_init(uint32_t *data_region)
Initialise the profiler from a SDRAM region.
Definition: profiler.c:34
static void profiler_write_entry_disable_fiq(uint32_t tag)
Write an entry with just fast interrupts disabled.
Definition: profiler.h:122
void profiler_finalise(void)
Finalises profiling.
Definition: profiler.c:51
profiler_event
Types of profiler event.
Definition: profiler.h:78
uint32_t samples[]
The samples.
Definition: profiler.h:55
static void profiler_write_entry_disable_irq_fiq(uint32_t tag)
Write an entry with all interrupts disabled.
Definition: profiler.h:111
static void profiler_write_entry(uint32_t tag)
Write a profiler entry.
Definition: profiler.h:99
uint32_t count
The number of samples taken.
Definition: profiler.h:49
uint32_t samples_remaining
How many samples can be written before space is exhausted.
Definition: profiler.h:63
uint32_t * output
Points to where the next sample will be written.
Definition: profiler.h:65
uint32_t * count
Points to where the profiling data starts being stored.
Definition: profiler.h:61
The layout of the profiler's DSG region.
Definition: profiler.h:47
The internal state of the profiler.
Definition: profiler.h:59