At ICFP/FHPNC, Hans-Wolfgang Loidl suggested a joint "challenge" for the various projects and efforts within the FP/performance/parallelism intersection. The purpose is on one hand to demonstrate that there are actually some pretty solid projects going on, and on the other hand to investigate differences in approaches. Essentially something very similar to the old SICSA MultiCore Challenge.
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 safescatter 't [m] [n] (dest: *[m]t) (is: [n]i32) (vs: [n]t): *[m]t = | |
let dest' = scatter dest is vs | |
let in_bounds = scatter (replicate 1 true) | |
(map (\i -> if i >= 0 && i < m then -1 else 0) is) | |
(replicate n false) | |
in assert in_bounds[0] dest' | |
-- == | |
-- entry: test_scatter test_safescatter | |
-- random input { 100 [1000000]i32 } auto output |
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
type Agent = { strategy_sum: []f32 | |
, regret_sum: []f32 | |
} | |
type Setting = {num_fields: i32, | |
num_soldiers: i32 | |
} | |
let compare (x: i32) (y: i32) = | |
i32.sgn (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
module FwdAD(T: real): { | |
type r = T.t | |
type t = (r, r) | |
val inject: r -> t | |
val set_deriv: t -> r -> t | |
val get_deriv: t -> r | |
val make_dual: r -> r -> t | |
include from_prim with t = (r,r) | |
include numeric with t = (r,r) |
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
-- == | |
-- entry: direct im2col winograd mec | |
-- random input { [1024][1024]f32 [3][3]f32 } | |
-- random input { [512][512]f32 [3][3]f32 } | |
import "direct" | |
import "im2col" | |
import "mec" | |
import "winograd" |
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 interpretData [rows][cols] | |
(data: [rows][cols]f32): [][9]f32 = | |
let res = | |
unsafe | |
map (\flat -> | |
unsafe | |
let i = 1+flat / (cols-2) | |
let j = 1+flat % (cols-2) | |
in [data[i-1,j-1], data[i-1, j], data[i-1, j+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
""" Neural Network. | |
A 2-Hidden Layers Fully Connected Neural Network (a.k.a Multilayer Perceptron) | |
implementation with TensorFlow. This example is using the MNIST database | |
of handwritten digits (http://yann.lecun.com/exdb/mnist/). | |
Links: | |
[MNIST Dataset](http://yann.lecun.com/exdb/mnist/). | |
Author: Aymeric Damien |
This file has been truncated, but you can view the full file.
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <math.h> | |
#include <stdint.h> | |
#undef NDEBUG | |
#include <assert.h> | |
// Start of panic.h. | |
#include <stdarg.h> |
This file has been truncated, but you can view the full file.
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
#ifdef cl_clang_storage_class_specifiers | |
#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable | |
#endif | |
#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable | |
#pragma OPENCL EXTENSION cl_khr_fp64 : enable | |
__kernel void dummy_kernel(__global unsigned char *dummy, int n) | |
{ | |
const int thread_gid = get_global_id(0); | |
if (thread_gid >= 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
let hood 'a (xs: []a) : [](a,a,a) = | |
zip3 (rotate (-1) xs) xs (rotate 1 xs) | |
let hood_2d 'a (xss: [][]a) : [][]((a,a,a), | |
(a,a,a), | |
(a,a,a)) = | |
map hood xss -- [][](a, a, a) | |
|> hood -- []([](a, a, a), [](a, a, a), [](a, a, a)) | |
|> map (\(a,b,c) -> zip3 a b c) |