Skip to content

Instantly share code, notes, and snippets.

View sjperkins's full-sized avatar

Simon Perkins sjperkins

  • SARAO
  • Cape Town, South Africa
  • 10:38 (UTC +02:00)
View GitHub Profile
@sjperkins
sjperkins / aws.py
Last active March 29, 2023 15:24
PUT operation in S3 Rest API with AWS Signature Generation
import argparse
from configparser import ConfigParser
from collections import namedtuple
from datetime import datetime
from difflib import diff_bytes
import os
import os.path
from pprint import pprint
from urllib.parse import urlparse, quote
from hashlib import sha256
from ast import literal_eval
import dask
import dask.array as da
from distributed import Client
from distributed.diagnostics import SchedulerPlugin
def example():
# In Radio Astronomy we take many measurements along the row axis
# 1e12 and getting much much larger! But we also have a large channel axis
# 32,768 channels in the case of MeerKAT for e.g.
@sjperkins
sjperkins / linear_writes.py
Last active August 3, 2020 16:54
Implement extend and write with dask and pyrap.tables
import argparse
import contextlib
import gc
import os
import shutil
import tempfile
import dask
import dask.array as da
from dask.core import flatten
@sjperkins
sjperkins / dask-indexing.py
Last active June 3, 2020 09:15
Dask Indexing
import dask.array as da
import numpy as np
A = da.arange(128, chunks=32)
i = da.from_array([0, 98, 111, 127], chunks=1)
A[i].visualize("dask_idx.png")
A = np.arange(128)
A[tuple(i)].visualize("numpy_idx.png")

Keybase proof

I hereby claim:

  • I am sjperkins on github.
  • I am sjperkins (https://keybase.io/sjperkins) on keybase.
  • I have a public key whose fingerprint is 50DD AAFF F543 CF74 0C0A A2A8 A987 469C 3F60 7598

To claim this, I am signing this object:

def generate_kliko_task(task, image_name, *args, **kwargs):
class _task(KlikoTask):
@classmethod
def image_name(cls):
return image_name
def requires(self):
return _task(*args, **kwargs)
_task.__name__ = task
@sjperkins
sjperkins / test_register_host_mem.py
Last active November 8, 2021 06:06
Use of memory pinned with pycuda.driver.register_host_memory to asynchronously transfer data to GPU
import numpy as np
import pycuda.autoinit
import pycuda.driver as drv
import resource
from pycuda.compiler import SourceModule
# Create the kernel
mod = SourceModule("""
__global__ void test_kernel(int * data, int N)
@sjperkins
sjperkins / test_register_host_mem.cu
Created August 3, 2015 09:49
Use of memory pinned with cuCudaHostRegister to asynchronously transfer data to GPU
#include <cassert>
#include <cstdio>
#include <cuda.h>
#define CUDAPP_CALL_GUARDED(NAME, ARGLIST) \
{ \
CUresult cu_status_code; \
cu_status_code = NAME ARGLIST; \
if (cu_status_code != CUDA_SUCCESS) \