Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Parallel For Loops with the Parallel Programming Library

11,026 views

Published on

Parallel For Loops are a hassle-free way to supercharge your program with the Parallel Programming Library. The syntax is similar to the standard For loop, with the advantage of each iteration running on in a different task on the thread pool. This allows multiple iterations to run at the same time, taking advantage of the multi-core and hyper-threaded architecture common on laptops, desktops and mobile devices today.

New to XE7 and works across Windows, OS X, Android and iOS

Published in: Software
  • I have always found it hard to meet the requirements of being a student. Ever since my years of high school, I really have no idea what professors are looking for to give good grades. After some google searching, I found this service ⇒ www.HelpWriting.net ⇐ who helped me write my research paper.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • ▶▶▶ https://dwz1.cc/DU3z4dss
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Making a living taking surveys at home! I have been a stay at home mom for almost 5 years and I am so excited to be able to still stay home, take care of my children and make a living taking surveys on my own computer! It's so easy to get started and I plan to make enough money each week so that my husband can actuallly quit his second job!!! Thank you so much! ➤➤ http://t.cn/AieXAuZz
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • MADE $30 ON MY FIRST DAY! Being a fresh graduate and having lots of free time, I stumbled upon your site when I was searching for work at home opportunities, good thing I did! Just on my first day of joining I already made $30! Now I'm averaging close to $80 a day just for filling out surveys! ★★★ http://t.cn/AieXAuZz
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ❤❤❤ http://bit.ly/2ZDZFYj ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Parallel For Loops with the Parallel Programming Library

  1. 1. EMBARCADERO  TECHNOLOGIES  EMBARCADERO  TECHNOLOGIES   Parallel  For  Loops   with  the  PPL   Jim  McKeeth   Lead  World  Wide  Developer  Evangelist  /  Engineer   jim.mckeeth@embarcadero.com   @JimMcKeeth   Tuesday,  the  3rd  February,  2015  Download  a  free  trial  –  NOW!   hOp://embt.co/trialdownloads    
  2. 2. EMBARCADERO  TECHNOLOGIES   How  Skill  Sprints  Work.  -­‐  Agenda   •  READY   –  Tips  tricks  &  short  URLS       •  SET   –  20  minutes,  1  topic     •  GO   –  Demo  and  discussion   –  Live  Q&A     Download  a  free  trial  –  NOW!   hOp://embt.co/trialdownloads    
  3. 3. EMBARCADERO  TECHNOLOGIES   This  Skill  Sprint  Works  with  .  .  .   •  Windows   •  Mac  OS  X   •  Android   •  iOS   •  RAD  Studio   •  Appmethod   •  Object  Pascal   •  C++   •  RAD  Studio  XE7  DocWiki   –  hOp://embt.co/latestdocwiki   hOp://docwiki.embarcadero.com/RADStudio/en/     •  Appmethod  September  2014  DocWiki   –  hOp://embt.co/AppmethodTopics   hOp://docwiki.appmethod.com/appmethod/topics/en/   •  Appmethod  supports  the  FireMonkey   framework  on  all  4  pla]orms  while  RAD   Studio,  Delphi  and  C++Builder  also  support   VCL  on  Windows.  Contact  sales  with  any   quesaons!  
  4. 4. EMBARCADERO  TECHNOLOGIES   Parallel  For  Loops  with  the  PPL   •  Quickly  and  easily  supercharge  your  code  with   Parallel  For  Loops   •  Part  of  the  new  Parallel  Programming  Library   •  Works  with  C++  and  Object  Pascal  on  all  pla]orms   •  Take  advantage  of  processor  architectures  like   hyper-­‐threading  and  mulaple  cores  present  in  most   mobile  devices,  desktops  and  laptops  
  5. 5. EMBARCADERO  TECHNOLOGIES   Parallel  For  Loops  with  the  PPL   •  Uses  System.Threading  unit   •  Like  a  normal  For  loop,  but  spread  across  thread  pool   •  Each  iteraaon  is  a  TTask  in  the  thread  pool   •  Order  of  iteraaons  is  undetermined   •  Pool  opamizes  for  CPU  architecture   •  Stride  allows  for  control  of  iteraaon  grouping  
  6. 6. EMBARCADERO  TECHNOLOGIES   Parallel  For  Loop  Syntax   TParallel.For(Stride,  Min,  Max,  procedure  (Idx:  Integer)   begin      if  IsPrime(Idx)  then        begin          TInterlocked.Increment  (Tot);          TThread.Queue(TThread.CurrentThread,  procedure            begin              Memo1.Lines.Add(Idx.ToString);          end);      end;   end);   You  can  use  Queue  and   Synchronize  from  a  Parallel  For,   but  it  reduces  the  performance.  
  7. 7. EMBARCADERO  TECHNOLOGIES   Parallel  For  Loop  Syntax   //  .  .  .   TParallel::For(NULL,  Min,  Max,  MyIteratorEvent);   //  .  .  .       void  __fastcall  TFormThreading::MyIteratorEvent(TObject   *Sender,  int  AIndex)   {    if(IsPrime(AIndex)){      TInterlocked::Increment(Tot);    };   }  
  8. 8. EMBARCADERO  TECHNOLOGIES   DEMONSTRATION   Parallel  For  Loops  with  the  Parallel  Programming  Library  
  9. 9. EMBARCADERO  TECHNOLOGIES   Parallel  For  Loops  with  the  PPL   •  Uses  System.Threading  unit   •  Quickly  and  easily  supercharge  your  code  with   Parallel  For  Loops   •  Each  iteraaon  must  be  independent  of  order   •  Reduce  runame  on  mulaprocessor  systems  
  10. 10. EMBARCADERO  TECHNOLOGIES   Parallel  For  Resources   •  Samples   –  C:UsersPublicDocumentsEmbarcaderoStudio15.0SamplesObject  PascalRTLParallel  Library   –  C:UsersPublicDocumentsEmbarcaderoStudio15.0SamplesCPPRTLParallel  Library   •  DocWiki  Tutorials   –  hOp://docwiki.embarcadero.com/RADStudio/XE7/en/ Using_TParallel.For_from_the_Parallel_Programming_Library     •  Blog  Posts   –  CodeRage  9  Video  hOp://dannywind.nl/delphi/coderage9/     –  Stephen  Ball’s  series  hOp://delphiaball.co.uk/tag/parallel-­‐programming/     –  Malcolm  Groves’  series  hOp://www.malcolmgroves.com/blog/?cat=109     –  Examples,  links  and  more:  hIp://delphi.org/?p=1886  (Including  the  C++  Lambda  links)   Special  offers:   hOp://embarcadero.com/radoffer/    
  11. 11. EMBARCADERO  TECHNOLOGIES   Next  Time….   •  FireDAC:  Cached  Updates  and  Auto-­‐inc  Fields   •  Defer  posang  updates  to  a  database   •  Post  mulaple  updates  in  a  single  batch   •  Thursday  the  5th  of  February   –  6AM  San  Francisco  /  9AM  New  York  /  2PM  London  /  3PM  Milan   –  11AM  San  Francisco  /  2PM  New  York  /  7PM  London  /  8PM  Milan   –  5PM  San  Francisco  /  Fri  9AM  Tokyo  /  Fri  10AM  Sydney   Sign-­‐up:  hOp://www.embarcadero.com/landing-­‐pages/skill-­‐sprints    
  12. 12. EMBARCADERO  TECHNOLOGIES   Next  Time….   •  Deep  Dive  into  Futures  and  the  PPL   •  Create  more  responsive  apps   •  Futures  calculate  values  asynchronously   •  Tuesday  the  10th  of  February   –  6AM  San  Francisco  /  9AM  New  York  /  2PM  London  /  3PM  Milan   –  11AM  San  Francisco  /  2PM  New  York  /  7PM  London  /  8PM  Milan   –  5PM  San  Francisco  /  Wed  9AM  Tokyo  /  Wed  10AM  Sydney   Special  offers:  hOp://embarcadero.com/radoffer/    
  13. 13. EMBARCADERO  TECHNOLOGIES   RAD  Studio  XE7  Special  Offers   More  details  hOp://www.embarcadero.com/radoffer   Save  45%  when   upgrading  from  any   previous  version     When  you  purchase  the   upgrade  with  1  year  Support   and  Maintenance!   Build  a  Mobile  Pla]orm   for  the  Enterprise     With  Enterprise  ediCon  or  higher.   Powerful  Tools  to  Boost  Your   Coding  (Worth  Over  $700)   •  New  Object  Pascal  Handbook  by   Marco  Cantu     •  Castalia  for  Delphi  2014.11   •  VCL  and  FireMonkey  Premium  Styles   •  Mida  Converter  Basic  
  14. 14. EMBARCADERO  TECHNOLOGIES  EMBARCADERO  TECHNOLOGIES   Q  &  A     @EmbarcaderoTech   Special  offers:   hOp://embarcadero.com/radoffer/    

×