Skip to content

Commit

Permalink
Merge aff435b into f34c9dd
Browse files Browse the repository at this point in the history
  • Loading branch information
dkfellows authored Jan 30, 2020
2 parents f34c9dd + aff435b commit d6badda
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
37 changes: 32 additions & 5 deletions c_common/front_end_common_lib/include/recording.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,53 @@ typedef struct {
uint8_t sequence;
} host_data_read_ack_packet_header;

//! \brief records some data into a specific recording channel, calling a
//! callback function once complete. DO NOT CALL THIS DIRECTLY. Use
//! recording_record() or recording_record_and_notify().
//! \param[in] channel the channel to store the data into.
//! \param[in] data the data to store into the channel.
//! \param[in] size_bytes the number of bytes that this data will take up.
//! \param[in] callback callback to call when the recording has completed
//! \return boolean which is True if the data has been stored in the channel,
//! False otherwise.
bool recording_do_record_and_notify(
uint8_t channel, void *data, uint32_t size_bytes,
recording_complete_callback_t callback);

//! \brief records some data into a specific recording channel.
//! \param[in] channel the channel to store the data into.
//! \param[in] data the data to store into the channel.
//! \param[in] size_bytes the number of bytes that this data will take up.
//! This may be any number of bytes, not just whole words.
//! \return boolean which is True if the data has been stored in the channel,
//! False otherwise.
bool recording_record(
uint8_t channel, void *data, uint32_t size_bytes);
static inline bool recording_record(
uint8_t channel, void *data, uint32_t size_bytes) {
// Because callback is NULL, spin1_memcpy will be used
// and that means that non-word transfers are supported.
return recording_do_record_and_notify(channel, data, size_bytes, NULL);
}

//! \brief records some data into a specific recording channel, calling a
//! callback function once complete
//! \param[in] channel the channel to store the data into.
//! \param[in] data the data to store into the channel.
//! \param[in] size_bytes the number of bytes that this data will take up.
//! \param[in] callback callback to call when the recording has completed
//! This must be in whole words if the callback is supplied due to
//! limitations in the DMA engine.
//! \param[in] callback callback to call when the recording has completed, or
//! NULL to use direct, immediate copying.
//! \return boolean which is True if the data has been stored in the channel,
//! False otherwise.
bool recording_record_and_notify(
static inline bool recording_record_and_notify(
uint8_t channel, void *data, uint32_t size_bytes,
recording_complete_callback_t callback);
recording_complete_callback_t callback) {
if ((size_bytes & 3 || ((uint32_t) data) & 3) && callback != NULL) {
io_printf(IO_BUF, "ERROR: DMA transfer of non-word data quantity!");
rt_error(RTE_SWERR);
}
return recording_do_record_and_notify(channel, data, size_bytes, callback);
}

//! \brief Finishes recording - should only be called if recording_flags is
//! not 0
Expand Down
11 changes: 1 addition & 10 deletions c_common/front_end_common_lib/src/recording.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <recording.h>
#include <simulation.h>
#include <buffered_eieio_defs.h>
#include <simulation.h>
#include <sark.h>
#include <circular_buffer.h>
#include <spin1_api_params.h>
Expand Down Expand Up @@ -421,7 +420,7 @@ static void buffering_in_handler(uint mailbox, uint port) {
log_debug("Done freeing message");
}

bool recording_record_and_notify(
bool recording_do_record_and_notify(
uint8_t channel, void *data, uint32_t size_bytes,
recording_complete_callback_t callback) {
if (has_been_initialised(channel)) {
Expand All @@ -448,14 +447,6 @@ bool recording_record_and_notify(
return false;
}

bool recording_record(uint8_t channel, void *data, uint32_t size_bytes) {
// Because callback is NULL, spin1_memcpy will be used
if (!recording_record_and_notify(channel, data, size_bytes, NULL)) {
return false;
}
return true;
}

//! \brief this writes the state data to the regions
static void recording_buffer_state_data_write(void) {
for (uint32_t recording_region_id = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from spinnman.messages.sdp import SDPHeader, SDPMessage, SDPFlag
from spinnman.messages.eieio import EIEIOType, create_eieio_command
from spinnman.messages.eieio.data_messages import EIEIODataMessage
from data_specification.constants import BYTES_PER_WORD
from spinn_front_end_common.utilities.constants import (
SDP_PORTS, BUFFERING_OPERATIONS)
from spinn_front_end_common.utilities.exceptions import (
Expand Down Expand Up @@ -210,6 +211,13 @@ def _request_data(self, transceiver, placement_x, placement_y, address,
return transceiver.read_memory(
placement_x, placement_y, address, length)

# Round to word boundaries
initial = address % BYTES_PER_WORD
address -= initial
length += initial
final = (BYTES_PER_WORD - (length % BYTES_PER_WORD)) % BYTES_PER_WORD
length += final

sender = self._extra_monitor_cores_by_chip[placement_x, placement_y]
receiver = locate_extra_monitor_mc_receiver(
self._machine, placement_x, placement_y,
Expand All @@ -221,7 +229,16 @@ def _request_data(self, transceiver, placement_x, placement_y, address,
txrx_data = transceiver.read_memory(
placement_x, placement_y, address, length)
self._verify_data(extra_mon_data, txrx_data)
return extra_mon_data

# If we rounded to word boundaries, strip the padding junk
if initial and final:
return extra_mon_data[initial:-final]
elif initial:
return extra_mon_data[initial:]
elif final:
return extra_mon_data[:-final]
else:
return extra_mon_data

def _verify_data(self, extra_mon_data, txrx_data):
for index, (extra_mon_element, txrx_element) in enumerate(
Expand Down

0 comments on commit d6badda

Please sign in to comment.