Skip to content

Instantly share code, notes, and snippets.

@aprell
aprell / rcceinstall
Created November 8, 2011 17:52
Script to install/update RCCE
#!/bin/bash
# Script to install/update RCCE
usage="rcceinstall [ emulator | SCC_LINUX | SCC_BAREMETAL ]"
RCCE_src_root=$HOME/RCCE_src
RCCE_root=$HOME/RCCE
RCCE_repo=http://marcbug.scc-dc.com/svn/repository/trunk/rcce
#RCCE_repo=http://marcbug.scc-dc.com/svn/repository/tags/RCCE_v1.1.0/
@aprell
aprell / findstring
Created November 10, 2011 09:42
Searches for a string in all files of a directory. Useful wrapper for grep.
#!/bin/bash
usage="Usage: findstring <string> [directory]"
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo $usage
exit 0
fi
if [ $# -eq 1 ]; then
@aprell
aprell / duff.c
Created November 11, 2011 17:46
Jumping like Duff
#include <stdio.h>
#include <stdlib.h>
// Found in the slow clone of Cilk procedures
// An application of Duff's device to jump directly into the middle of code
// See Cilk 5.4.6 Reference Manual
//
// The same technique can be used to implement stack-based coroutines
// See Simon Tatham's Coroutines in C
@aprell
aprell / Makefile
Created November 20, 2011 17:54
Simple unit testing for C
CC = gcc
CPPFLAGS += -D_GNU_SOURCE
CFLAGS += -O0 -g -Wall -Wextra
SRCS = driver.c module.c
OBJS = $(SRCS:.c=.o)
all: utest
utest: $(OBJS)
@aprell
aprell / shuffle.c
Created November 21, 2011 17:22
Fisher-Yates array shuffle
#include <stdio.h>
#include <stdlib.h>
#define N 10
static int A[N];
static unsigned int seed;
static void swap(int *a, int *b)
@aprell
aprell / hello_mpi.c
Created December 2, 2011 16:05
Hello MPI
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#define WORKER(id) if (ID == (id))
#define MASTER WORKER(0)
int main(int argc, char *argv[])
{
int numprocs, ID;
@aprell
aprell / mpi_send_recv.c
Created December 2, 2011 16:12
Blocking send and receive
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#define WORKER(id) if (ID == (id))
#define MASTER WORKER(0)
int main(int argc, char *argv[])
{
int numprocs, ID;
@aprell
aprell / mpi_isend_irecv.c
Created December 2, 2011 16:17
Nonblocking send and receive
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#define WORKER(id) if (ID == (id))
#define MASTER WORKER(0)
int main(int argc, char *argv[])
{
int numprocs, ID;
@aprell
aprell / mpi_put.c
Created December 6, 2011 10:19
One-sided communication
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#define WORKER(id) if (ID == (id))
#define MASTER WORKER(0)
int main(int argc, char *argv[])
{
int numprocs, ID;
@aprell
aprell / mpi_put_2.c
Created December 6, 2011 10:22
One-sided communication 2
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#define WORKER(id) if (ID == (id))
#define MASTER WORKER(0)
int main(int argc, char *argv[])
{
int numprocs, ID;