pycuda Jin Kwon Kim May 25, 2017 Hi my name is jin kwon kim.

Slides:



Advertisements
Similar presentations
GPU programming: CUDA Acknowledgement: the lecture materials are based on the materials in NVIDIA teaching center CUDA course materials, including materials.
Advertisements

Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 7. Systems Software 1 System Software This software is used to provide the.
1 ITCS 5/4145 Parallel computing, B. Wilkinson, April 11, CUDAMultiDimBlocks.ppt CUDA Grids, Blocks, and Threads These notes will introduce: One.
GPU programming: CUDA Acknowledgement: the lecture materials are based on the materials in NVIDIA teaching center CUDA course materials, including materials.
Introduction to Computer Programming in C
Introduction to a Programming Environment
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Shekoofeh Azizi Spring  CUDA is a parallel computing platform and programming model invented by NVIDIA  With CUDA, you can send C, C++ and Fortran.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
A Moderately Directed Rant.  It’s very likely that you’ve been writing totally incorrect code without realizing it  Once you do realize it, it’s usually.
2012/06/22 Contents  GPU (Graphic Processing Unit)  CUDA Programming  Target: Clustering with Kmeans  How to use.
A genda for Today What is memory management Source code to execution Address binding Logical and physical address spaces Dynamic loading, dynamic linking,
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
CSC 253 Lecture 2. Some differences between Java and C  Compiled C code is machine specific, whereas Java compiles for a virt. machine.  Virtual machines.
CUDA - 2.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Chapter 1 Introduction. Chapter 1 -- Introduction2  Def: Compiler --  a program that translates a program written in a language like Pascal, C, PL/I,
CUDA Basics. Overview What is CUDA? Data Parallelism Host-Device model Thread execution Matrix-multiplication.
Compilers and Interpreters. HARDWARE Machine LanguageAssembly Language High Level Language C++ Visual Basic JAVA Humans.
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
You will need Dev C++ to help you with this project. If you do not already have this programming tool on your device you can visit
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Heterogeneous Computing With GPGPUs Matthew Piehl Overview Introduction to CUDA Project Overview Issues faced nvcc Implementation Performance Metrics Conclusions.
Compilers and Interpreters
GPU Programming Contest. Contents Target: Clustering with Kmeans How to use toolkit1.0 Towards the fastest program.
GPU Computing for GIS James Mower Department of Geography and Planning University at Albany.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
1 ITCS 4/5145GPU Programming, UNC-Charlotte, B. Wilkinson, Nov 4, 2013 CUDAProgModel.ppt CUDA Programming Model These notes will introduce: Basic GPU programming.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Foundations of Programming: Java
General Purpose computing on Graphics Processing Units
Computer Basics.
Chapter 1 Introduction 2nd Semester H
CUDA C/C++ Basics Part 2 - Blocks and Threads
Applications Active Web Documents Active Web Documents.
Why don’t programmers have to program in machine code?
Advanced Computer Systems
CUDA Programming Model
CSC391/691 Intro to OpenCV Dr. Rongzhong Li Fall 2016
Introduction to programming
Lecture 1: Introduction to JAVA
Basic CUDA Programming
Introduction Enosis Learning.
Teaching Computing to GCSE
TRANSLATORS AND IDEs Key Revision Points.
Introduction Enosis Learning.
CMSC 341 Prof. Michael Neary
Programming Languages
Operation System Program 4
Virtualization Layer Virtual Hardware Virtual Networking
Lesson Objectives Aims Key Words Compiler, interpreter, assembler
Coding Concepts (Basics)
Creating your first C program
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
APACHE MXNET By Beni Mulyana.
1.1 The Characteristics of Contemporary Processors, Input, Output and Storage Devices Types of Processors.
Programming.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
(Computer fundamental Lab)
Lab 4: Introduction to Scripting
Chapter 1 Introduction.
Chapter 1 Introduction to Programming
Programming language translators
Introduction to C CS 3410.
Presentation transcript:

pycuda Jin Kwon Kim May 25, 2017 Hi my name is jin kwon kim. I will going to tell you about the pycuda. Jin Kwon Kim May 25, 2017

Outline Introduction to python Introduction to pycuda Conclusions What is python Introduction to pycuda What is pycuda & characteristic Installation Tutorial Compare pycuda & cuda in c Conclusions This is my outline. I will going to tell you what the python is. And then tell you pycuda and characteristic and installation and pycuda tutorial and compare pycuda and cuda in c and finaly conclusion.

Introduction to python First I will going to tell you about python. Introduction to python

What is python Python Advantage disadvantage Interpreter : directly executes instructions written in a programming language Advantage Can learn easily Can include a programming written by another language Automatic memory management. disadvantage slow Python is a one of the programming language. most important feature in python is python is a interpreter that directly executes instructions written in a programming language. While c ,c++ and java have a compiler that change from programming language to other object file. Python can learn easily cause their grammer is easier than other language. Python can include a programming written by another language. For example you program python for the structure. Just import another program written by another language for the function. Python has automatic memory management. So it has a garbage collection. So you don’t need call the free function to free the memory. But python is a little bit slow

Introduction to pycuda I will going to tell you about pycuda. Introduction to pycuda

What is pycuda & characteristic a Python programming environment for CUDA characteristic Object cleanup tied to lifetime of objects Completeness Automatic Error Checking Speed Pycuda is a python programming environment for cuda. This is a pycuda’s characteristic First, object cleanup tied to lifetime of objects. So, resource allocation is done during object creaton by the constructor, while release is done during object destruction by the destructor. I told you python has a garbage collection so object destruction can be done automatically. So object’s resource also be released automatically. Second. Completeness. PyCUDA puts the full power of CUDA’s driver API at your disposal, if you wish. Third. Automatic Error Checking. All CUDA errors are automatically translated into Python exceptions. Finally. Speed. Cause PyCUDA’s base layer is written in C++,

Installation Step 0: Ensure that CUDA is installed and settings are correct Step 1: Install gcc Step 2: Install Boost C++ libraries Step 3: Install numpy Step 4: Download, unpack and install PyCUDA I will going to tell you stage of installation. First ensure that cuda is installed and setting are correct. Second install gcc Third install boost c++ libraries. Boost c++ library is a library for c++ programming language and provide multithreading and image processing. Next install numpy is the fundamental package for scientific computing with Python And finally download pycuda and install that .

Tutorial Step 1: import module Step 2 : initialize data This is tutorial for pycuda. I just show you simple program that just double the value. Left one is cuda in c and right one is pycuda. First you should import module. In c, include header file. In python, import some modules. second. Initialized data for calculation. In c, you should malloc array for saving the input data in host and then init them random value. In python, using numpy, you can allocate random variable to the array. And set the type to integer.

Tutorial Step 3: allocate device memory & data transfer Step 4 : define kernel function & launch a kernel and then allocate device memory & and transfer the data from host to device. In c , using cudaMalloc and cudaMemcpy In python using mem_alloc, memcpy_htod and then define kernel function & launch a kernel In c , you define the kernel using function define. In python you define the kernel using object creation.

Tutorial Step 5: get a result from the device Step 6: cuda memory free To get a data from the device. You should transfer the data from device to host. In c, first allocate a array for saving data. And then using cudamemcpy, you can get a data from the device. In python, first allocate a array using numpy.empty_like function that create the empty arrary that have same struction in a. and then using memcpy_dtoh, you can get a data from device. Finally, to free the data, in c you should call the cudaFree function. But in python, you don’t need call the function. Cause python have garabage collection and resource tied to lifetime of object.

Compare pycuda & cuda in c Running time This is the graph that show the running time comparison pycuda and cuda in c. As you can see the graph, pycuda is four time slower than cuda in c. I will tell you the reason in next slide.

Compare pycuda & cuda in c 1. Initialize step before cudamalloc, we initialize some data. 2. Data transfer size Same representation data can have different size in different language First reason point is initialize step. Before cudamalloc, we initialize some data. And I told you python is slow language. And initialize step is totally depend on the programming language. So pycuda is slower than cuda in c . Second reason point is data transfer size. In the below, you can see the nvprof result of both programs. Pycuda have the completeness in the driver. So actually there is no difference about that. You can check this fact in kernel function. but pycuda have more data to transfer between host and device. Same representation data can have different size in differen language. pycuda Cuda in c

Conclusions Pycuda give you the full power of gpu driver. But pycuda is just a python, so naturally they are slow. When you use kernel intensive program, the pycuda is perfect choice. When you use memory intensive program, the pycuda is poor choice.

Thank you for listening