gtc 2010 py_cula_better

1
PyCU LA Transparent Python Bindings for CULA http://www.math.temple.edu/research/ geometry/PyCULA/ Features Complete CULA support Complete PyCUDA support Mix Kernel and Runtime code Interpreter Friendly! Combine the power of Python Modules Interfaces directly with Numpy Integration with PyCUDA Memory Management Super Simple Syntax: Why GPU Compute in Python? Integrate SQL databases for your scientific Data Use Scipy to read and write to MATLAB files Simple parsing code Easily execute multiple instances via subprocess Prototype or compute within the interpreter; No need to manually compile! Write a single program to code optimized programs on the fly Easily compress and extract data with gzip and zlib modules Take advantage of automatic memory management; Helps write leak free code! Simple, short, clean code helps Built In Coherent Documentation: Confused about how to use gpu_syev? From Python, just type help(gpu_syev) Research Application In order to sort through the enormous database of hypothetical structures we are implementing spectral analysis. Specifically we are performing log(Det()) of an energy function weighted adjacency matrix. Having PyCULA to integrate sparse expansion kernels, GPU accelerated LAPACK, and add a Pythonic interface is a priceless utility. References: Atlas of Prospective Zeolite Structures http://www.hypotheticalzeolites.net/ Many thanks to the NSF for funding our research into the computational physics of zeolites. Garrett Wright and Dr. Louis Theran >>> from PyCULA.cula import * # Load PyCULA >>> a = numpy.array([[1.,1.],[0.,1.]]) # Create Data >>> culaInitialize() # Initialize Device >>> print gpu_svd(a) # Perform SVD [ 1.61803399 0.61803399] # Printed Results >>> culaShutdown() # Shutdown Device from PyCULA.cula import * from PyCULA.my_init import * import numpy as np import atexit import kernel_modules #import custom kernel module code pycuda_init_once() culaInitialize() atexit.register(cula.culaShutdown) # This is an adjacency list, a *condensed* form of a larger sparse adjacency matrix. E=np.array([[1 , 2 ],[ 1 , 16 ], [3 , 4 ],[ 4 , 5 ], [ 6 , 7 ],[ 7 , 8 ],[ 8 , 9 ],[ 8 , 5 ],[ 9 , 10 ], [ 9 , 4 ],[ 19 , 16 ],[ 20 , 1 ]], dtype=np.float32) # expand reduced form into full matrix using GPGPU kernel M_ = kernel_modules.gpu_expand_kernel(E) eigvals = gpu_devsyev(M_) # run CULA syev on GPU array M_ This is a hypothetical zeolite structure. We currently have a database of over 2 million such structures, yet only a few have been discovered in nature Help on function gpu_syev in module PyCULA.cula: gpu_syev(A, vectors=False, uplo='U') Takes symmetric matrix as np.array and returns eigenvalues (optionally eigenvectors) as np.array. Keyword arguments: A -- input matrix as np.array, symmetric vectors -- default == False; use 'True' to compute vectors. uplo -- Defines whether input array has data in Upper or Lower half using 'U' or 'L' respectively default=='U' Note: When vectors==False, gpu_syev returns only the eigenvalues. When vectors==True, gpu_syev returns tuple (eigenvalues,eigenvectors) (END)

Upload: igor-rivin

Post on 03-Dec-2014

470 views

Category:

Technology


1 download

DESCRIPTION

Describes a wrapper for CULA (a linear algebra library using NVDIA's CUDA technology), developed by Garrett Wright and Louis Theran (under my benign guidance :)) This is a mid-2010 poster.

TRANSCRIPT

Page 1: Gtc 2010 py_cula_better

PyCULA Transparent Python Bindings for CULA

http://www.math.temple.edu/research/geometry/PyCULA/

Features

Complete CULA supportComplete PyCUDA supportMix Kernel and Runtime codeInterpreter Friendly!Combine the power of Python ModulesInterfaces directly with Numpy Integration with PyCUDAMemory ManagementSuper Simple Syntax:

Why GPU Compute in Python?

Integrate SQL databases for your scientific DataUse Scipy to read and write to MATLAB filesSimple parsing codeEasily execute multiple instances via subprocessPrototype or compute within the interpreter; No need to manually compile!Write a single program to code optimized programs on the flyEasily compress and extract data with gzip and zlib modulesTake advantage of automatic memory management; Helps write leak free code!Simple, short, clean code helps prevent bugs!

Built In Coherent Documentation:

Confused about how to use gpu_syev?From Python, just type help(gpu_syev)

Research Application

In order to sort through the enormous database of hypothetical structures we are implementing spectral analysis. Specifically we are performing log(Det()) of an energy function weighted adjacency matrix.

Having PyCULA to integrate sparse expansion kernels, GPU accelerated LAPACK, and add a Pythonic interface is a priceless utility.

References:

Atlas of Prospective Zeolite Structureshttp://www.hypotheticalzeolites.net/

Many thanks to the NSF for funding our research into the computational physics of zeolites.

Garrett Wright and Dr. Louis Theran

>>> from PyCULA.cula import * # Load PyCULA>>> a = numpy.array([[1.,1.],[0.,1.]]) # Create Data>>> culaInitialize() # Initialize Device>>> print gpu_svd(a) # Perform SVD[ 1.61803399 0.61803399] # Printed Results>>> culaShutdown() # Shutdown Device

from PyCULA.cula import *from PyCULA.my_init import *import numpy as npimport atexitimport kernel_modules #import custom kernel module code

pycuda_init_once()culaInitialize()atexit.register(cula.culaShutdown)

# This is an adjacency list, a *condensed* form of a larger sparse adjacency matrix.

E=np.array([[1 , 2 ],[ 1 , 16 ], [3 , 4 ],[ 4 , 5 ],[ 6 , 7 ],[ 7 , 8 ],[ 8 , 9 ],[ 8 , 5 ],[ 9 , 10 ],[ 9 , 4 ],[ 19 , 16 ],[ 20 , 1 ]], dtype=np.float32)

# expand reduced form into full matrix using GPGPU kernelM_ = kernel_modules.gpu_expand_kernel(E)

eigvals = gpu_devsyev(M_) # run CULA syev on GPU array M_

This is a hypothetical zeolite structure. We currently have a database of over 2 million such structures, yet only a few have been discovered in nature

Help on function gpu_syev in module PyCULA.cula:

gpu_syev(A, vectors=False, uplo='U') Takes symmetric matrix as np.array and returns eigenvalues (optionally eigenvectors) as np.array. Keyword arguments: A -- input matrix as np.array, symmetric vectors -- default == False; use 'True' to compute vectors. uplo -- Defines whether input array has data in Upper or Lower half using 'U' or 'L' respectively default=='U' Note: When vectors==False, gpu_syev returns only the eigenvalues. When vectors==True, gpu_syev returns tuple (eigenvalues,eigenvectors)(END)