Skip to content

Instantly share code, notes, and snippets.

@mppf
mppf / chapel.rb
Created February 2, 2022 14:20
draft homebrew formula for Python 3.10 and Chapel 1.25.1
class Chapel < Formula
desc "Programming language for productive parallel computing at scale"
homepage "https://chapel-lang.org/"
url "https://github.com/chapel-lang/chapel/releases/download/1.25.1/chapel-1.25.1.tar.gz"
sha256 "0c13d7da5892d0b6642267af605d808eb7dd5d4970766f262f38b94fa2405113"
license "Apache-2.0"
revision 1
bottle do
sha256 arm64_monterey: "e11d484b8dbeb19649b46ebadb1ff063e79a3fa7c3e1befc258c6fd28a4712a2"
@mppf
mppf / libevent-timing-demo.c
Created September 29, 2021 17:17
libevent timeout across multiple event_add
/*
Program to demonstrate managing total timeout across many
event_add calls.
It accepts input on stdin for 2 seconds and demonstrates running
for 2 seconds whether there is input or not.
*/
#include <errno.h>
@mppf
mppf / gist:bc354d8c6277e999c27bbbca0c2a034f
Last active December 21, 2022 03:55
setting up git for access token on Ubuntu 20.04
# Install gpg helper tools
sudo apt-get install gnupg-agent pinentry-curses
# Fix permission on the included git-credential-netrc
sudo chmod a+x /usr/share/doc/git/contrib/credential/netrc/git-credential-netrc
# create a GitHub access token for this
# Go to Settings -> Developer Settings -> Personal access tokens -> Generate new token
# We will save the token in an encrypted .netrc file below
# create a gpg key (if you do not have one already on the machine)
@mppf
mppf / dp-m2.chpl
Created May 17, 2020 11:34
variants on dp question
// shows program modified to avoid array views in inner loops
class AbstractKernel {
// assumes x[xfirst, ..] and y[yfirst, ..] have shape 1..p
proc kernel(x, xfirst: int, y: [?D] ?T, yfirst: int, p: int): T
{
return x[xfirst, 0]; // out of bounds (intentionally?)
}
}
@mppf
mppf / spec.rst
Created September 23, 2019 19:31

©2019 Cray Inc.

Scope

[Scope]

Chapel is a new parallel programming language that is under development at Cray Inc. in the context of the DARPA High Productivity Computing Systems initiative.

module OtherMSBRadix {
use Shell;
use Time;
/* Sorting criterion has a method:
(key:uint,done:bool) = criterion.keyBits(record, startbit)
(cmp=-1,0,1,nsamebits) = criterion.prefixCompare(recordA, recordB)
cmp=-1,0,1 = criterion.compare(recordA, recordB)
@mppf
mppf / jt.chpl
Created August 10, 2017 14:52
Example of reading JSON with a Chapel class
class Fighter {
var subclass:string;
var level:int;
}
var mem = openmem();
var writer = mem.writer().write('{"subclass":"ninja", "level":3}');
var reader = mem.reader();
// This works
proc testOnBegin() {
sync {
on Locales[numLocales-1] do begin {
writeln("HERE");
}
}
}
testOnBegin();
@mppf
mppf / Bug.chpl
Last active July 21, 2017 17:18
showing bug with implicit module and same name inner module
proc bar() {
writeln("in bar");
}
module Bug {
proc foo() {
writeln("in foo");
}
}
#include <stdio.h>
void setit(int* ptr) {
*ptr = 200;
}
void f(int x) {
printf("%i\n", x);
}