DDA: avoid looking up the movebuffer array.

As we have mb_tail_dda now, that's no longer necessary. Using
something like movebuffer[mb_tail] is more expensive than
dereferencing mb_tail_dda directly.

This is the first time we see a stepping performance improvement
since introducing mb_tail_dda. 13 clock cycles faster on the
slowest step, which is 9 cycles faster than before that
introduction.

Binary size also a nice 94 bytes down.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19270 bytes      135%       63%       31%       15%
     Data:   2179 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 218 clock cycles.
  LED on time maximum: 395 clock cycles.
  LED on time average: 249.051 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 438 clock cycles.
  LED on time average: 272.216 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 395 clock cycles.
  LED on time average: 262.572 clock cycles.
This commit is contained in:
Markus Hitter 2016-11-27 20:54:28 +01:00
parent eec0e00f85
commit d5eb8cd916
4 changed files with 17 additions and 17 deletions

10
clock.c
View File

@ -116,11 +116,11 @@ static void clock_250ms(void) {
// target position
sersendf_P(PSTR("Dst: %lq,%lq,%lq,%lq,%lu\n"),
movebuffer[mb_tail].endpoint.axis[X],
movebuffer[mb_tail].endpoint.axis[Y],
movebuffer[mb_tail].endpoint.axis[Z],
movebuffer[mb_tail].endpoint.axis[E],
movebuffer[mb_tail].endpoint.F);
mb_tail_dda->endpoint.axis[X],
mb_tail_dda->endpoint.axis[Y],
mb_tail_dda->endpoint.axis[Z],
mb_tail_dda->endpoint.axis[E],
mb_tail_dda->endpoint.F);
// Queue
print_queue();

4
dda.c
View File

@ -940,7 +940,7 @@ void dda_clock() {
/// update global current_position struct
void update_current_position() {
DDA *dda = &movebuffer[mb_tail];
DDA *dda = mb_tail_dda;
enum axis_e i;
static const axes_uint32_t PROGMEM steps_per_m_P = {
@ -950,7 +950,7 @@ void update_current_position() {
STEPS_PER_M_E
};
if (dda->live) {
if (dda != NULL) {
uint32_t axis_steps, axis_um;
for (i = X; i < AXIS_COUNT; i++) {

View File

@ -58,8 +58,8 @@ uint8_t queue_full() {
/// Take a step or go to the next move.
void queue_step() {
if (movebuffer[mb_tail].live) {
dda_step(&movebuffer[mb_tail]);
if (mb_tail_dda != NULL) {
dda_step(mb_tail_dda);
}
/**
@ -67,7 +67,7 @@ void queue_step() {
This needs no atomic protection, because we're in an interrupt already.
*/
if ( ! movebuffer[mb_tail].live) {
if ( ! mb_tail_dda->live) {
if (mb_tail != mb_head) {
mb_tail = MB_NEXT(mb_tail);
mb_tail_dda = &(movebuffer[mb_tail]);

View File

@ -611,15 +611,15 @@ void process_gcode_command() {
if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) {
sersendf_P(PSTR("Endpoint: X:%ld,Y:%ld,Z:%ld,E:%ld,F:%lu,c:%lu}\n"),
movebuffer[mb_tail].endpoint.axis[X],
movebuffer[mb_tail].endpoint.axis[Y],
movebuffer[mb_tail].endpoint.axis[Z],
movebuffer[mb_tail].endpoint.axis[E],
movebuffer[mb_tail].endpoint.F,
mb_tail_dda->endpoint.axis[X],
mb_tail_dda->endpoint.axis[Y],
mb_tail_dda->endpoint.axis[Z],
mb_tail_dda->endpoint.axis[E],
mb_tail_dda->endpoint.F,
#ifdef ACCELERATION_REPRAP
movebuffer[mb_tail].end_c
mb_tail_dda->end_c
#else
movebuffer[mb_tail].c
mb_tail_dda->c
#endif
);
print_queue();