GPU Programming in MATLAB
First Edition
Nikolaos Ploskas
Nikolaos Samaras
Copyright
Morgan Kaufmann is an imprint of Elsevier
50 Hampshire Street, 5th Floor, Cambridge, MA 02139, United States
2016 Elsevier Inc. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or any information storage and retrieval system, without permission in writing from the publisher. Details on how to seek permission, further information about the Publishers permissions policies and our arrangements with organizations such as the Copyright Clearance Center and the Copyright Licensing Agency, can be found at our website: www.elsevier.com/permissions.
This book and the individual contributions contained in it are protected under copyright by the Publisher (other than as may be noted herein).
Notices
Knowledge and best practice in this field are constantly changing. As new research and experience broaden our understanding, changes in research methods, professional practices, or medical treatment may become necessary.
Practitioners and researchers must always rely on their own experience and knowledge in evaluating and using any information, methods, compounds, or experiments described herein. In using such information or methods they should be mindful of their own safety and the safety of others, including parties for whom they have a professional responsibility.
To the fullest extent of the law, neither the Publisher nor the authors, contributors, or editors, assume any liability for any injury and/or damage to persons or property as a matter of products liability, negligence or otherwise, or from any use or operation of any methods, products, instructions, or ideas contained in the material herein.
Library of Congress Cataloging-in-Publication Data
A catalog record for this book is available from the Library of Congress
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
ISBN: 978-0-12-805132-0
For information on all Morgan Kaufmann publications visit our website at https://www.elsevier.com/
Publisher: Todd Green
Acquisition Editor: Todd Green
Editorial Project Manager: Lindsay Lawrence
Production Project Manager: Priya Kumaraguruparan
Cover Designer: Mark Rogers
Typeset by SPi Global, India
Dedication
To my family
Nikolaos Ploskas
To my son, Stathis
Nikolaos Samaras
About the Authors
Nikolaos Ploskas is a Postdoctoral Researcher at the Department of Chemical Engineering, Carnegie Mellon University, USA. He received his Bachelor of Science degree, Masters degree, and Ph.D. in Computer Systems from the Department of Applied Informatics of the University of Macedonia, Greece. His primary research interests are in
Operations research,
Mathematical programming,
Linear programming,
Parallel programming,
GPU programming,
Decision support systems.
Dr. Ploskas has participated in several international and national research projects. He is the author or co-author of writings in more than 40 publications, including high-impact journals and book chapters, and conference publications. He has also served as a reviewer for many scientific journals. He received an honorary award from HELORS (Hellenic Operations Research Society) for the best doctoral dissertation in operations research (2014).
Nikolaos Samaras is a Professor at the Department of Applied Informatics, School of Information Sciences, University of Macedonia, Greece. Professor Samarass current research interests are at the interface between computer science and operations research, which apply to a variety of engineering and scientific systems:
Linear/Non Linear optimization: theory, algorithms, and software
Network optimization: theory, algorithms, and software
Scientific computing: HPC, and GPU-programming
He has served on the editorial board of the Operations Research: An International Journal , and as a reviewer in many scientific journals. He has also held numerous positions within HELORS (Hellenic Operations Research Society). He was awarded with the Thomson ISI/ASIS&T Citation Analysis Research Grant (2005).
Dr. Samaras has published more than 35 journal papers in high-impact journals, including Computational Optimization and Applications, Computers and Operations Research, European Journal of Operational Research, Annals of Operations Research, Journal of Artificial Intelligence Research, Discrete Optimization, Applied Mathematics and Computation, International Journal of Computer Mathematics, Electronics Letters, Computer Applications in Engineering Education, Journal of Computational Science, and Applied Thermal Engineering . He has also published more than 85 conference papers.
Foreword
Yair Altman
This book represents an important addition to the library of professional MATLAB reference texts. Whereas most other MATLAB-related texts typically focus on a specific engineering domain, this book targets general MATLAB users, who are already familiar with MATLAB and wish to improve their programs speed using multicore and GPU parallelization. Until recently, parallelization was employed by supercomputers and were outside the reach of the regular MATLAB user. But with multiple CPU cores and powerful GPU cards ubiquitous in modern computers, parallelization is now available to anyone, and it would seem a waste not to use all this available power for our compute-intensive MATLAB programs. Unfortunately, MATLAB users have few resources explaining the fine details about how exactly to make their MATLAB programs run on the GPU. MATLABs internal documentation, good as it may be, may not be enough for professional development. I believe that this book successfully fills this gap. A detailed discussion of GPU programming in MATLAB is presented, starting with a general overview, continuing with a discussion about how to employ easy-to-use gpuArrays, all the way to the detailed intricacies of compiling CUDA kernels and integrating GPU code into MEX-files. The reader therefore benefits from a discussion at various levels of increasing complexity. Multiple usage examples are presented to enable users in different engineering disciplines to understand the material, including a discussion about real-world limitations such as memory or bandwidth. MATLAB error messages, which are sometimes difficult to understand and overcome, are explained alongside suggested solutions/workarounds. Multiple tips and best practices are suggested throughout the book. While this book does not cover other aspects of MATLAB performance tuning in any great detail, its discussion of GPU programming for MATLAB is very detailed and quite up-to-date. With GPU programming becoming commonplace, such a dedicated, detailed and highly readable book about this subject is a welcome addition. This textbook should be on the bookself of any MATLAB programmer who plans to employ GPU parallelization.
Accelerating MATLAB Performance, http://UndocumentedMatlab.com