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
-- binary literals | |
1 + 0b101 | |
-- Attributes | |
#[unsafe] x + 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
static inline int smin32(int x, int y) | |
{ | |
return x < y ? x : y; | |
} | |
static inline int sdiv_up32(int x, int y) | |
{ | |
return (x + y - 1) / 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
#define CL_TARGET_OPENCL_VERSION 120 | |
#include <CL/cl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
static void* slurp_file(const char *filename) { | |
unsigned char *s; | |
FILE *f = fopen(filename, "rb"); // To avoid Windows messing with linebreaks. | |
if (f == NULL) return NULL; |
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 xs_mem = alloc ... | |
let ys_mem = alloc ... | |
... | |
let xs@xs_mem = ... | |
... | |
... last use of xs ... | |
... | |
let ys@ys_mem = ... | |
... | |
in ys -- or whatever |
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
from contact_map import contact_map | |
import numpy as np | |
import time | |
import jax.numpy as jnp | |
fut = contact_map() | |
@profile | |
def futhark(shape): | |
arr = np.float32(np.random.normal(0,2,shape[0]*shape[1])) |
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 dotprod xs ys = f32.sum (map2 (*) xs ys) | |
let all_pairs_norm [n][k] (A: [n][k]f32) (B: [n][k]f32) : [n][n]f32 = | |
let sqrA = map (map (**2)) A |> map f32.sum |> replicate n | |
let sqrB = map (map (**2)) B |> map f32.sum |> map (replicate n) | |
let diff = map (\a -> map (dotprod a) B) A | |
in map2 (map2 (+)) sqrA sqrB | |
|> map2 (map2 (\diff' x -> x-2*diff')) diff | |
|> map (map f32.sqrt) |
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 prut x = x + 1 |
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
# This default.nix builds a tarball containing a statically linked | |
# Futhark binary and some manpages. Likely to only work on linux. | |
# | |
# Just run 'nix-build' and fish the tarball out of 'result/'. | |
let | |
# Fetch the latest haskell.nix and import its default.nix | |
haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}; | |
# haskell.nix provides access to the nixpkgs pins which are used by our CI, hence |
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
nix-build '<nixpkgs>' --arg overlays '[ (import /home/mzd885/nixos-rocm/pkgs/all-packages.nix) ]' -A rocm-opencl-runtime | cachix push athas |
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
module Main(main) where | |
import Control.Concurrent (threadDelay) | |
import System.IO | |
import System.IO.Error | |
import System.Environment (getArgs) | |
followDelayMicroseconds :: Int | |
followDelayMicroseconds = 1000000 `div` 60 |