This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET "LIBHDR" | |
LET START() BE | |
$( | |
WRITES("Hello, world!*N") | |
$) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.actors.Actor | |
object Calculator extends Actor { | |
var v: Int = 0 | |
this.start() | |
override def act(): Unit = { | |
loop { | |
react { | |
case Inc(i) => v += i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Calculator.{Get, Dec, Inc} | |
import scala.actors.Actor | |
object Client extends Actor { | |
override def act(): Unit = { | |
Calculator ! Inc(4) | |
Calculator ! Inc(2) | |
Calculator ! Dec(1) | |
Calculator ! Get() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def !!!(msg: String, e: Throwable) = throw new Exception(msg, e) | |
implicit class ExceptionEnricher[A](thingToDo: => A) { | |
def !!!!(msg: String): A = { | |
try { | |
thingToDo | |
} catch { | |
case e: Throwable => | |
!!!(msg, e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait |[+A, +B] extends Dynamic { | |
type Union[T] = T =|= (A | B) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rk4 h f (x, y) = | |
let k1 = h * f(x, y) | |
let k2 = h * f(x + 0.5*h, y + 0.5*k1) | |
let k3 = h * f(x + 0.5*h, y + 0.5*k2) | |
let k4 = h * f(x + h, y + k3) | |
x + h, y + k1 / 6.0 + k2 / 3.0 + k3 / 3.0 + k4 / 6.0 | |
// A single step | |
rk4 1.0 (fun (x, y) -> y) (0.0, 1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let solve n r f = | |
let dx = 1.0 / float(n-1) | |
let dt = r * dx * dx | |
let g u0 u1 u2 = r*u0 + (1.0 - 2.0 * r)*u1 + r*u2 | |
( 0.0, | |
[|for i in 0..n-1 -> | |
f(float i / float(n-1))|] ) | |
|> Seq.unfold (fun (t, us) -> | |
Some( (t, us), | |
(t + dt, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cached[-I, +O](f: I => O) extends (I => O) { | |
private[this] val cache = scala.collection.concurrent.TrieMap.empty[I, O] | |
def apply(x: I): O = { | |
if (cache.contains(x)) { | |
cache(x) | |
} else { | |
val y = f(x) | |
cache += (x -> y) | |
y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<ReflectedDefinition>] | |
let MatrixTrans(a: float32[], wi: WorkItemInfo) = | |
let aT = Array.zeroCreate<float32> a.Length | |
let aLocal = local(Array.zeroCreate<float32> (BLOCK_SIZE * BLOCK_SIZE)) | |
for i = 0 to MULT do | |
for j = 0 to MULT do | |
let baseIdxA = (wi.GroupID(0) * NR_GROUPS + i) * BLOCK_SIZE + (wi.GroupID(1) + j * NR_GROUPS) * A_BLOCK_STRIDE | |
let globalIdxA = baseIdxA + wi.LocalID(0) + aWidth * wi.LocalID(1) | |
wi.Barrier(CLK_LOCAL_MEM_FENCE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"strconv" | |
"time" | |
) |
OlderNewer