Skip to content

Instantly share code, notes, and snippets.

@jar
jar / randf.S
Last active March 21, 2017 20:17
A 32-bit floating pont random number generator [0,1) for the Adapteva Epiphany
/*
* A 32-bit floating pont random number generator [0,1) for the Adapteva Epiphany
* Based on http://simul.iro.umontreal.ca/rng/lfsr113.c
* A shortcut was taken for conversion of unsigned int to floating point so that
* half of the results are off by the least significant bit. This probably shouldn't
* be used for Monte Carlo simulation, but should still have a normal distribution
* and the underlying state remains the same.
* C Prototype: float randf(void);
*/
.section .text
@jar
jar / dot_product.S
Created July 26, 2016 19:35
An optimized single precision dot product routine for the Epiphany architecture
/* // Optimized Dot Product routine follows this protoype
float dot_product(const float* a, const float* b, int nd8m1) {
int i;
float c = 0.0f;
int n = (nd8m1+1)*8;
for (i=0; i<n; i++) {
c += a[i] * b[i];
}
return c;
} */
@jar
jar / ctimer.c
Last active July 26, 2016 04:03
Clock timer code for Adapteva Epiphany processor
/*
unsigned int t0, t1;
ctimer_start();
t0 = ctimer_get();
// place timed code here
t1 = ctimer_get();
unsigned int dt = t0 – t1; // elapsed time in clock cycles
*/
static void ctimer_start(void)