Skip to content

Instantly share code, notes, and snippets.

View ibaned's full-sized avatar

Dan Ibanez ibaned

  • Sandia National Laboratories
  • Albuquerque, NM
View GitHub Profile
static void dumpPythonStack() {
PyFrameObject* frame = PyEval_GetFrame();
if (!frame) {
fprintf(stderr, "Got NULL frame...\n");
return;
}
while (frame) {
int lineno = PyFrame_GetLineNumber(frame);
PyCodeObject* code = frame->f_code;
PyObject* filename = code->co_filename;
@ibaned
ibaned / dansync.c
Last active January 8, 2017 23:09
/* Copyright 2017 Sandia Corporation
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
#!/home/dibanez/install/ParaView-5.1.0-Qt4-OpenGL2-MPI-Linux-64bit/bin/pvpython
import sys
from paraview import simple
reader = simple.OpenDataFile(sys.argv[1])
writer = simple.CreateWriter("copied.vtu", reader)
writer.DataMode = "Ascii"
writer.UpdatePipeline()
#include <apf.h>
#include <gmi_null.h>
#include <apfMDS.h>
#include <apfMesh2.h>
#include <PCU.h>
#include <apfNumbering.h>
#include <apfShape.h>
#include <iostream>
#include <stdbool.h>
@ibaned
ibaned / first.sh
Last active August 28, 2015 15:06
two-script solution to getting a 1B element case going
#!/bin/sh
#SBATCH --job-name=make1B
#SBATCH -t 02:00:00
## are we in fact able to do this with 16 ranks per node ?
#SBATCH -N 64
#SBATCH -n 1024
#SBATCH --partition small
#SBATCH -D /gpfs/u/scratch/PGES/PGESzhnl/Test/10x10/mesh
set +xe
EXE_DIR=/gpfs/u/home/PGES/PGESgnzw/scratch/core/build/test
@ibaned
ibaned / orientation.cc
Last active August 29, 2015 14:05
parallel element-to-element orientation arrays
#include <apfMesh.h>
#include <apfNumbering.h>
#include <PCU.h>
static int getOrientationCode(
int side_i,
long* verts,
int other_side_i,
long* other_verts)
{
@ibaned
ibaned / 2048.c
Created May 13, 2014 22:11
a simple C version of the popular 2048 game
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <termios.h>
#include <unistd.h>
#define SIZE 4
struct game {
int tiles[SIZE][SIZE];
@ibaned
ibaned / deadlock.c
Last active December 30, 2015 03:59
hybrid MPI/thread program that deadlocks on Blue Gene/Q
/* This program should be run on a single Blue Gene/Q node
using 5 or more parallel processes and 8 threads per process
(threads per process is the only argument to the program)
mpirun -np 5 ./deadlock 8
It has a high probability of going into a deadlocked state
(or at least timing out at 5~10 minutes).
The probability increases as LOOPS is increased */
#include <mpi.h>
#include <pthread.h>
@ibaned
ibaned / quine.c
Created August 15, 2012 13:06
My solution to the quine problem: a program that prints itself
#include<stdio.h>
#include<string.h>
void p(const char*c,int d)
{
for(;d;++c,--d)
putchar(*c);
}
void q(const char*c,int d)
{
for(;d;++c,--d)
@ibaned
ibaned / fits.c
Created May 22, 2012 20:10
FITS file processor
#include <stdio.h>
#include <fitsio.h>
#include <dirent.h>
#include <string.h>
#include <mpi.h>
/*If status != 0, report the error and return 1.*/
#define FITS_ERROR_CHECK if(status){fits_report_error(stdout, status); return 1;}
int countNumFits(int limit, char * dir);