Skip to content

Instantly share code, notes, and snippets.

View ra1u's full-sized avatar
💻
Focusing

Luka Rahne ra1u

💻
Focusing
View GitHub Profile
import 'dart:io';
int PORT = 5555;
void testconnect(){
print("testconnect");
Socket.connect("localhost", PORT).then((Socket sock){
sock.add("hello".codeUnits);
});
}
@ra1u
ra1u / trans.c
Created May 14, 2015 19:35
transactonal memory dining philosopers
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef struct { int food; } philosoper_type;
static inline int eat(philosoper_type *philo, int *lfork, int *rfork) {
int r = 0;
while (!r) {
@ra1u
ra1u / timeTest.cpp
Created May 25, 2015 17:02
gcc tight loop measure
#include <iostream>
#include <chrono>
#include <thread>
#include <atomic>
using namespace std::literals;
// compile command
// g++ -lpthread -std=c++14 -march=native -O3 timeTest.cpp -o timeTest
#include <iostream>
#include <chrono>
#include <thread>
#include <atomic>
using namespace std::literals;
// compile command
// g++ -lpthread -std=c++14 -march=native -O3 timeTest.cpp -o timeTest
@ra1u
ra1u / timeThread.java
Created May 27, 2015 20:12
thread safe loop performance test
import java.lang.Runnable;
import java.lang.Thread;
import java.lang.InterruptedException;
import java.util.concurrent.atomic.AtomicLong;
class timeThread {
private
static AtomicLong running_ms =
new AtomicLong(0); // atomic is thread safe variable
private
$ cabal --with-gcc=arm-linux-gnueabi-gcc-5 --with-ghc=arm-unknown-linux-gnueabi-ghc --with-ghc-pkg=arm-unknown-linux-gnueabi-ghc-pkg --with-ld=arm-linux-gnueabi-ld --with-strip=arm-linux-gnueabi-strip --reinstall -v3 install pipes
/usr/bin/alex --version
/home/ralu/.cabal/bin/c2hs --numeric-version
/usr/bin/arm-linux-gnueabi-gcc-5 -dumpversion
/usr/bin/happy --version
/usr/bin/hpc version
looking for tool hsc2hs near compiler in /usr/local/bin
/usr/bin/hsc2hs --version
/usr/local/bin/arm-unknown-linux-gnueabi-ghc -c /tmp/13362.c -o /tmp/13362.o
/usr/bin/arm-linux-gnueabi-ld -x -r /tmp/13362.o -o /tmp/13363.o
./hw +RTS -M100k -Dg -v -RTS
created capset 0 of type 2
created capset 1 of type 3
cap 0: initialised
assigned cap 0 to capset 0
assigned cap 0 to capset 1
hw: maximum heap size (-M) is smaller than minimum alloc area size (-A)
allocated 1 megablock(s) at 0xb6b00000
----------------------------------------------------------
Gen Max Mut-list Blocks Large Live Slop
arm-unknown-linux-gnueabi-ghc hw.hs -rtsopts -debug -v
Glasgow Haskell Compiler, Version 7.10.1, stage 1 booted by GHC version 7.8.4
Using binary package database: /usr/local/lib/arm-unknown-linux-gnueabi-ghc-7.10.1/package.conf.d/package.cache
Using binary package database: /home/ralu/.ghc/arm-linux-7.10.1/package.conf.d/package.cache
wired-in package ghc-prim mapped to ghc-prim-0.4.0.0-361e8e2c9cf389d2a3e7a0e22f6c7443
wired-in package integer-simple mapped to integer-simple-0.1.1.0-9bd007614b43388e2bb7b2146145b894
wired-in package base mapped to base-4.8.0.0-8d0e6769a75e6a598cebc9657285312b
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.10.0.0-5e6c60df81db6fb5f949b92c4196d6c2
wired-in package ghc not found.
{-# LANGUAGE TemplateHaskell #-}
module Cordic where
import CLaSH.Prelude as C
-- one step cordic for first quadrant 1 and 4
cordicQ14 :: (NumSFixedC 2 s, NumSFixedC 2 r)
=> SFixed 2 s-- fixing angle (constant)
-> Int -- shift size
-> (SFixed 2 r,SFixed 2 r) -- (x,y) or cos,sin
@ra1u
ra1u / pid.hs
Created February 8, 2016 15:15
module Pid where
import CLaSH.Prelude as C
{-# ANN topEntity
(defTop
{ t_name = "pid"
, t_inputs = ["initI","initD","kP","kI","kD","setvalue"]
, t_outputs = ["pidsignal"]
, t_extraIn = [ ("CLOCK", 1)]
, t_clocks = [ clockWizard "clkwiz50" "CLOCK[0]" "~ KEY[0]" ]