Int ern at i onal  Journ al of Ele ctrical  an d  Co mput er  En gin eeri ng   (IJ E C E)   Vo l.   8 , No .   6 Decem ber   201 8 , p p.   5457 ~ 5471   IS S N: 20 88 - 8708 DOI: 10 .11 591/ ijece . v8 i 6 . pp 5457 - 54 71          5457       Journ al h om e page http: // ia es core .c om/ journa ls /i ndex. ph p/IJECE   Real - Ti me Impl ement ation and P er f orma nce Opti mizati on  of  Local De rivati ve P attern  Alg or ith m on  GP Us       Nisha C handr an   S, Dur gapr as ad G ang odkar,  Ankus Mittal   Depa rtment  o C om pute Scie n ce a nd  Engi n ee rin g,   Graphi c Era  Univer sit y ,   Indi a       Art ic le  In f o     ABSTR A CT   Art ic le  history:   Re cei ved   Ja n   2 1 , 2 01 8   Re vised  Me i   2 8 , 2 01 8   Accepte J un   14 , 201 8       Patt ern   base t e xture   desc rip tor are   widely   us ed  in  Conte nt  B ase Im age   Ret ri eva (CBIR for  eff icient   r etriev a of  m at ching  images.   Loca Deri va ti v e   Patt ern   ( LDP),  a   highe ord er  lo ca p at t ern   op er at or,   o rigi n al l y   proposed  for   fac r ec ogn it ion ,   enc odes  th dis ti nctive  spa ti a r el a ti onships  con ta in ed  in  loc a reg ion  of  an  image  as  the   fea tur vec tor .   L DP   eff ic ie ntly   e xtra c ts  fine r   det a il and  prov ide eff i cient  re t rie va howeve r ,   it   was  proposed  for  images  of  li m it ed  resolu ti on.   Over  th p eri od  of  ti m th developm ent   i the   digita l   image  sensors   h ad  pa id  wa y   for   ca p turi ng  imag es  at  a   ver y   h i g resolution.   LDP  al gorit hm   though  ver y   eff i c ie nt  in  content - b ase image  ret ri eva did  not   sca le   wel when   ca pturi ng  fe at u res  from   such  h igh - resolut ion  i m age as  it   bec om es  computat ion al l y   ver expe nsive .   Th is  pape propo ses  how  to  eff icientl y   ex tract  par allelism   from   the   LDP  a lgori thm  and  st rat eg ie for   opti m al l y   imple m ent ing  it   b y   expl oiting  som inhe ren Gene ral - Purpos e   Graphi cs  Proce ss ing  Unit  (GP G PU cha rac teristi cs.   B y   opti m a lly c onfiguri ng   the   GP GP U ke rn el s,  image  r et ri e val   was pe rform ed  at   m uch  f ast er  rate.   Th e   LDP  al gorit hm   was  porte on  to  Com pute   U nifi ed  Devi ce   Archi tectur e   (CUD A)  suppor te GP GP U   and  m axi m um  sp ee up  of  aro un 240x  was   ac hi eve d   as  compare to its  sequ ent i al   counterpa r t .     Ke yw or d:   CB IR   CUD A   GPGP U   Local  Der iv at ive Patt er n   Parall ei zat ion   Textu re  Descr i ptor   Copyright   ©   201 8   Instit ut o f Ad vanc ed   Engi n ee r ing  and  S cienc e   Al l   rights re serv ed .   Corres pond in Aut h or :   Nish a  Cha ndra S .,    Dep a rtem ent o Com pu te r  Sci ence a nd E ng i neer i ng,   Gr a phic  Er a  Unive rsity ,   Dehra dun  248002,  U tt ara kha nd, In dia.   Em a il : nisha. unni kr is hn a n@ gm ail.co m       1.   INTROD U CTION   In   C on te nt  Ba sed  Im age  Re trie val  (CBIR ),  i m ages  are  in dex e a uto m atical ly   by  their  own  visu a l   con te nt  instea of   t he  te xt - bas ed  key  wor ds The  basic  ste involve in  C BIR  is  extracti ng   a nd  in dex i ng  th e   visu al   co ntent   (low   le vel  fe at ur es from   t he  i m ages.  F eat ur vect or   e xtracti on  is  per f or m ed  as  pr e - processi ng   ste in  m os of   the  CB IR  syst em s.  An   eff ic ie nt  i m age  featu re  desc ript or   m us hav exc el le nt  discrim inati on   prop e rty   to  di scrim inate   var i ou im age  cl asses  and   it   m us be  com pu ta ti on al ly   inex pe nsi ve.   Diff e re nt  featu re  de script or s   li ke  colo r,   s ha pe  a nd   te xture   are  us ed   f or   eff ic ie nt  im age  retrieval  i CB IR  syst e m s.  A m on the  var i ous   visu al   featu re   descr ipt or s te xture  desc riptor  play sign i ficant  ro le   in  f eat ur e   extracti on  an it   ref ers  to  t he   visu al   patte rns  that  ha ve  ho m og eneit pr operty Te xture  descr i ptor  re presents   structu ral  ar ra ngem ent  of   s urf aces  in  relat ion   to  t he  s urr ound i ng  en vir on m ent.  Patt ern   base te xt ur f eat ur es   li ke  Local  Bi nar Patt ern   (L BP)  [1 ]   re pr es ents  i m ages  based   on  the  first  or der   de riv at ive  m ic ro   patte rns   wh ic a ppare nt ly   fail   to  extr a ct   detai le in f orm ation   c on ta i ned  in   the  im a ges.  Re searc he rs  the refo re,  f urt her   inv est igate th e possibil it y of usi ng h i gh e r o rd e r op e rato rs for ca pturin g m or e d et ai le inf or m at ion     LDP   op e rato r   pr op os e by  Zha ng   et   al [2 ]   is  te xtu re  descr ipt or   w hi ch  encodes  hig he ord e r   der i vative  inf orm ation L DP   r epr ese nts  the  hi gh e orde pat te rn   in form ation   of  local   regi on   by  e ncodin th e   change  i the   neig hbou rho od  der i vative  di recti on a nd  therefo re  c on t ai ns   m or det ai le discrim i native   featur e than  t he  first  or der   de rivati ves  us ed   in  LBP.  H ow e ver,  LDP   bein highe orde operat or   produces  a   Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om En g,   V ol.  8 , N o.   6 Dece m ber  2 01 8   :   5457   -   5471   5458   ver la rg featur vector   wh i ch  m akes  the  al gorithm   co m pu ta ti onal ly   ver exp e ns ive Currentl y,  with  th e   adv a nc em ents  in  the  dig it al   sign al   te ch nolog im ages  ar bein ca ptur ed  at   ver high  re so l utio a nd  extracti ng  LD featur e us i ng   the  c urren t   gen e ral - pu rpo se  hardw a re  f r om   la rg data bases  of  su c hig h - reso l ution   im ages  beco m es  ver chall en ging.  T his  li m it t he   ap plica ble  do m ai ns   of   t hi powe rful  al gorithm   with  high  dis crim inati ve  prop e rty L DP   li ke  m os i mage  processin al gorithm perf or m   the  sam com pu ta ti on   on  num ber   of   pix el s,  wh ic is  ty pical   data  par al le operat ion T he refor e ,   com pu ti ng   the   LD P   featur e f r om   diff e re nt  re gions  of  the  high - reso l ution  im a ge  in   pa rall el   will   reduce  t he   com pu ta ti on  tim of  the alg or it hm  ther e by m aking it  eff ic ie nt  for real  tim e app li cat ion s.     Curre ntly Graph ic Process ing   Un it   (G P U has   ente red   t he  G ene ral - P urp os C om pu ti ng   D om ai (G P GPU ).   I com par ison  to   the  si ng le   pro cesso CP U,  G PG P Us   ha ve  ve ry  hi gh  c om pu ta ti on  po wer .   The y   are  inex pe ns iv and   scal able  than  CP Us.   T he   hig hly  data  par al le i m age  processi ng   al gorithm exp loi ts  the   Sing le   I ns tr uct ion   Mult iple  Data  (S IM D)   arch it ect ure  an can  be   eff ic i ently   par al le li zed  on  GPGP [ 3].  Howe ver,  tradi ti on al   GPGP dev el op m ent  is  based   on  gra phic functi on  li br a ry  li ke  Op e nGL  and   Direc 3D wh ic re stric ts  it us by  pr of essi onal s,  w ho  are  fam ilia with   gra ph ic API.  The   e m erg ence   of  Com pu te   Un i fied  Dev ic Ar c hitec ture   (CU DA),  N VIDIA’ pa ra ll el   arch it ect ur im ple m entat ion rem ov es   these  inco nv e nien ce as  it  pr ovi des  APIs  f or  pr og ram m ers  to  dev el op  par al le app li c at ion us i ng   the  C   pro gr am m ing   la ngua ge.   GPU are  ine xp e ns i ve,   scal a bl an ha ve  ve ry  hi gh   c om pu ta ti on   po wer   c om par ed  to   sing le   process or   CP Us.  GPU ha ve  bee widely   us e no w   for  acce le rati ng   m any  eff ic i ent  CB IR  al go rithm s   [4] ,   [5 ]   in  t he   fiel of  im age  visio n,   m edical   i m aging   [ 6] rem ote  sensing   [7 ]   et c.  T his  pa per   pro poses   par al le im ple m entat ion   of  the  L DP  al gorit hm   on   N VIDIA  GPUs.   Th i m ple m entat io e xp l oits  the   featur e s   li ke  the  gl obal   m e m or y,  sh ar ed  m e m or y,  L1  cac he,   C UDA  stream and  op ti m al   us of  re gisters.   W e   ha ve   m easur ed   the  GPU  im ple m e ntati on on  Fe rm as  well   a s   the  la te st  Kepl er  arc hitec tur e.  To  t he  best  of   our   knowle dge  t his  is  the   first r e porte e ffor t par al le li ze  the LD P   al gorithm   us i ng  G PU s . Mai co ntri bu t ion s   of   the  pa per   a re  s umm arized  as  fo ll ows:  ( 1)   W pr ese nt  an  e f fici ent  strat egy   for  pa rall el   cal cu la ti on   of  the   LDP  featur vecto of   an  im age  by  op ti m a ll us in the  GPU  gl obal   m e m or and   the  faster  s ha red   m e m or (2 W hav e furthe tu ned   t he  sp ee du of  L DP   com pu ta ti ons b usi ng   the  L data   cache.  ( 3) W e h ave  acce le rated  the   GPU  op e rati on us i ng  the  c o nc ept  of  C UDA   stream s.  (4 )   We  hav e   ex ploi te the  asy nchron ou s   nat ur e   of   t he  CUD ke r nel  cal ls  by  dep l oying   cal c ulati on   on  host  whil the  dev ic execu te t he  GPU  ke rnel there by   extracti ng e nh a nced pa rall el ism .     The  rest  of  th pap e is  org anized  as  fo ll ows We  be gin   with  disc us si on   on  the  relat ed  w ork  i sect ion   2.  Sec ti on   re vie ws   the  m at he m atical   fo undati on  of  the  LD P   al go rithm   and   desc ribes  t he   m ain   con ce pts  of   pr ogram m ing   G PU us in N V IDIA’s  C UDA   m od el In   sec ti on   4,   we  pr e sent  ou ap pro ach  f or  com pu ti ng   t he  LDP   us in the   GPU.  Fi nally sect ion   pres ents  the  e xp e ri m ents  done  a nd  detai le a na ly sis   of   the  res ults  that  dem on strat es  the  eff ic ie nc of   our  GPU   al go rithm   and   sect ion   dr a ws  so m con cl us io ns   about the  prese nted w ork  a nd  su ggest so m e o ptim i zation s a s futu re  work .       2.   RE LATE D  W ORK   The  m os co m pu ta ti onal ly   exp en sive  pa rt  of  the  CB IR  alg ori thm is   the  featur ext ra ct ion Col or ,   te xtu re  or   sh a pe  feat ur es  or  com bin at ion   of  these  a re   gen e rall extr act ed  from   the  i m ages  for  ef fici ent   i m age  m a tc hin g   an retrieval.  G PG P Us  are  now  bei ng  ef fi ci ently  u sed  for  i m ple m enting  this com pu ta ti on al ly   exp e ns i ve  f eat ur e   extra ct ion  ta sk   as  well   as   the  m at ching   ta sk   in   CB IR  al gorithm s.  It  is  well - kn own  fact   that  the G P Us  perform   m uch  f ast er  t han  CP Us  a nd  at ta in  e x cel le nt  s peedup  f or  im age  pr oces sin a pp li cat ion s   wh ic are  sp e ci fical ly   ta il or ed  for  pa rall el   pr og ram m ing .   Sever al   nota bl wo r ks   sho w ing   the  ad va ntage  of  us in GPU   and   the  subs ta ntial   a m ou nt  of   sp ee up   ob ta ine ove the  seq uen ti al   ver sio n,   f or  su c h   app li cat io ns   ar avail able  in  the  li te ratur e.  Ba sic   i m age  pr oces sin al gorithm li ke  histogram   equ al izati on,   Discrete  Co sin Tra ns f or m   (D CT)  e nc od e   and  dec ode,  cl oud  rem ov al   et c.  are  ef fici en tl par al le li zed  us in CUD an is  repor te to  ha ve  at ta ined  ex cel le nt  sp eed up  [8 ] I Re f.   [9 ]   par al le ver si on   of   the  fr act al   i m age  enco di ng  al gorithm   is   bu il on   the  GPU  an the   resu lt ind ic a te   the  enco di ng  was  achie ve in   m illi secon ds  ti m without  c om pr omi sing   on  the   qu al it of  the  dec od e im age.  Te et   al [ 10 ]   e ff i ci ently   par al le li zed  a   f ace  rec ogniti on  fr am ewo r usi ng  CU DA  a nd  repo rted  a   s peedu of  29x.  Ga ngod kar  et   al i [11]  i m ple m ented  par al le ver si on   of   fast  norm alized  cro ss  co rr el at io fo real  tim tem plate   m at c hing   wh ic at ta ined   sp eedup  of  17x  com par ed  to  the  sequ e ntial   execu ti on.  I Re f.   [ 12 ]   pa rall el   al go rith m   fo acce le rati ng   t he   i m age  inp ai nting  proce ss  is  pro po se d.  T he  inte ns c om pu ta ti on al   ta sk   of   proces sing  the  four t orde P DE  eq uatio ns   is  acce le rated  by  36x  us in the  N VIDIA  G EFO RC GT 67 GPU  c ard.  A   par al le im ple m entat ion   of   c on te nt - based  vi deo   searc a nd  retrieval  of  vid e os   is  pro pose in   Re f.  [ 13] T he   Evaluation Warning : The document was created with Spire.PDF for Python.
In t J  Elec  &  C om En g     IS S N: 20 88 - 8708       Real -   Time  I m pleme nta ti on  and Perf orm anc e Opti miza ti on  o f L oc al D e riv ative     ( Ni sh a C handr an S )   5459   auth or ac hie ve ar ound  80%  accur acy   in   vid e sea rch   and   retrie val  and   sp ee dup  of   5x  com par e to  t he   seq uen ti al   versi on   of  the  al gorit hm In   Re f.   [ 14 ]   paral le i m ple m e ntati on   of  the   aud io  c om pr essio al gorithm   Ap pl Loss le ss   A udio  C odec  (A L AC)  is   prese nted  a nd  s pee dup  of  80 - 90%  is  achieve d.  H ei dari   et   al [1 5]  pro pose par al le i m ple m entation   of  colo m o m ents  and   te xt ur feat ur a n achieve spe ed  up   of   144x  over  t he  se qu e ntial   im ple m entat ion Zh et   al .   [ 16]   ha ve  par al le li zed  the  S UR al gorithm   an hav e   achieve a   s pe edup   of  15x  ov e it se que ntial   co un te rp a rt.  I [ 17 ]   Pr i scariu   an Re i have  im ple m ented  Histo gr am   of   Or ie nted  Gr a di ents  ( HOG)  in  GP U   an ha ve  ac hieve sp ee dup  of   67 x.   In  [ 18 ]   Pa r et   al .   exp l or e the  desig an i m plem entat ion   i ssu es  of  i m age  pr oce ssin al gorithm on   GP Us  with  CU D A   fr am ewo r k.   T hey  have  sel ect ed  m ult vie ste reo   m at c hing,  li near   fe at ur ext racti on,  JPE G 2000  i m age  encodin no n - photoreal ist ic   r end e rin a e xam ple  ap plica ti on s   an e ff ic i ently   par al le li zed  them   on  the   GPU.   In  [ 19]   the  a ut hors  pro pose an  im ple m enta ti on   of  I sin si m ula ti on   work  us i ng  the   CU DA  f ram ewo r k.  T hey   hav at ta ine per f or m ance  i m pr ove m ent  of   20 - 40   ti m es  co m par ed  to  the  co nv e ntio nal  CPU  i m ple m entat io n.   I [ 20]   the  auth or have  im ple m ented  par al le al gorithm   in  GPU  for  value  pr e dicti on   a nd   sp ec ulati ve  ex ecuti on.  T hey  hav obser ve that  so ftwa re   value  pre dicti on   te c hn i qu es  did   no at ta in  m uch   perform ance  ga in  w her ea the  s of tw are  s pecu la ti on  te c hn i qu e at ta ined  c on si der a bl perf or m ance  gain .   Howe ver,  opti m iz ing   par al le GP c od is   no trivia ta sk T achie ve  good  pe rfor m ance  the  pro gra m m er   sh oul fi ne  tu ne  the c od e  taki ng into   acco un t t he  un der ly in a rch it ect ure.    Seve ral  tun i ng  strat egies  usi ng  di ff e ren as pe ct of   t he  G P arc hitec tures   have  bee dis cusse in  t he  sta nd a rd   C UDA  bo ok [21 ] - [ 23] I [ 24 ]   auth or giv i ns ig hts  into  t he   relat ion s hip   betwee occ upancy,   threa bl ock   si ze  and   s ha pe,   cache  hie rar c hy   con fi gurati on  an th read   a ccess  patte r to  gl ob al   m e m or y.  By   ta kin sim ple  m at rix  m ulti pli cat ion   as  a e xam ple  they   relat the  threa blo c siz an sh a pe  to  bo t cache   m isses  and   oc cup a ncy.  L ob e iras  et   al in  [2 5],  by  ta kin Fast  Fo uri er  Transf or m   (F FT)  al gorithm   as  a exam ple,  hav e   analy zed  different  as pects  of   t he  G PU   a r chite ct ur es li ke   the  infl ue nc of   m e m or acce ss  patte rn a nd  r egiste press ure  on   pe rfor m ance.  T hey  ha ve   sh ow that  the  pe rfor m ance  of   reg ist er - base so lu ti ons  is  m uch   bette tha the  sh are m e m or du to  the  hi gh e re gis te band width.   In   [ 26]   Lia ng  et   al .   hav e   fine   tu ne their  3D  loc al iz at ion   ap plica ti on   in  GPU   by  opti m iz ing   the  num ber   of  thr eads  pe thre a blo c an reg i ste rs  per   th rea d.   By   exp erim enting  with  di ff e ren val ues  of   the  th read   blo c siz and  the   nu m ber  o f   re gisters  they  h ave   fou nd  an   opti m al   set ti ng   whic gi ves  the   be st  perform ance.  To rr e et   al . in   [ 27 ]   hav e   stu died  t he  relat io between  dif fer e nt   threa blo c siz es  an sha pe with  t he  gl ob al   m e m or and  the   cache  m e m or acce ss  patte rn s I [ 28 ]   L ee  et   al hav e   discu ssed  opti m iz at i on  strat e gies  f or  c om pu te   bo und  as   well   as  m e m o ry  bound  al go rithm s.  They  hav op ti m iz e the  com pu te   bound  al gorithm by  red ucing   the   nu m ber   of  r egi ste rs  a nd  by   in creas in t he  th read  bl ock  siz e   w her eas   m e m or boun al go rithm are  opti m iz ed  by sto rin the   data in lim it ed  GPU r e sourc es  li ke  co ns ta nt or share m e m or y i a n o pti m i zed  way .       3.   LDP  DESCRI PTOR  A ND  USAGE F OR  IMAGE  RETRIEV AL   LDP   al gorithm   con ta ins  ve ry   detai le discrim inati ve  featur es  of   a i m age  as  it  enco des   the  hig he r   order   de rivati ve  in form at io n.   F or  an   im age  ( )   the  fi r st  order   de riv at ives  al ong   0 ° 45 °   90 °   an 135 ° directi ons  are  denoted  as  ( )   where  α 0 ° 45 °   90 °   an 135 ° Let   us   co ns id er  pix el   0   in  ( )   a nd   it ei gh t   nei ghbors     w her e   =1…   as   s how i Fig ur e   1a .   T he  fou first  order  der i vativ es  [ 2]  for  t he  pi xel   0   al ong  t he fo ur  diff e re nt d ir ect ion s  are give n as i ( 1 )   t ( 4 ).     , ( 0 ) = ( 0 ) ( 4 )   ;     (1)       45° , ( 0 ) = ( 0 ) ( 3 ) ;   (2)       9 0 ° , ( 0 ) = ( 0 ) ( 2 ) ;   (3)     135° , ( 0 ) = ( 0 ) ( 1 )       (4)     The direct io nal  d if fer e ntial  cha nn el s  for t he f our direct io ns   are as  sho wn in F i gure  1b.   The  sec ond o r der directi on al   [2 ]  L DP ,  fo th e p ixel   0      2 ( 0   ) , in α   directi on is g i ve as  in (5 ).      2 ( 0 ) = { ( ( 0 ) , ( ( 1 ) ) , ( ( 0 ) , ( ( 2 ) ) , ( ( 0 ) , ( ( 8 ) ) }     (5)     Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om En g,   V ol.  8 , N o.   6 Dece m ber  2 01 8   :   5457   -   5471   5460   wh e re  ( . , . )   is   bina ry  e ncodin f un ct io w hich   determ ines  the   tra ns it ion s   in   the  l ocal  patte r a nd  is   gi ve as in  (6).     ( ( 0 ) , ( ) ) = {   0 ,    ( ) . ( 0 ) > 0 1   ,    ( ) . ( 0 ) 0     (6)     i= 1,   . ..8.    wh e re  ‘.’  re pr e sents  m ulti plication  operat or.   The  thir ord er  local   der i va ti ve  patte rn   is  com pu te us i ng  the  seco nd   orde de rivati ves.  T he   third  or der   dir ect ion al   L DP   [ 2],  f or  the  pixe 0      3 ( 0   ) in   α   direc ti on   is   giv e as  in (7 ).      3 ( 0 ) = { ( ′′ ( 0 ) , ( ′′ ( 1 ) ) , ( ′′ ( 0 ) , ( ′′ ( 2 ) ) , ( ′′ ( 0 ) , ( ′′ ( 8 ) ) }     (7)     In g e ner al ,  the   n th   or der   LD P i s co m pu te d usi ng the  ( n - 1)   th   orde r deri vative s.  T he n th   or der  directi onal  L D [2 ] , f or  t he pix el   0 ,  ( 0   )   in α  directi on is  giv e as  in  (8) .      ( 0 ) = { ( 1 ( 0 ) , ( 1 ( 1 ) ) , ( 1 ( 0 ) , ( 1 ( 2 ) ) , ( 1 ( 0 ) , ( 1 ( 8 ) ) }     (8)           (a)   (b)     Figure  1. (a S chem at ic  sh owing  t he  loc at io n of t he pixel  0   and the  neig hb or i ng p i xels Z 1 ...Z 8   us e i th LDP   al gorithm  [2],  ( b) Sc hem at ic  sh owin g f our  directi onal   diff e re ntial  ch a nn el s       Higher  orde LDP e xtract  higher  s patia fr e qu e ncies  th at   con ta in   fine detai ls  of  an   i m age.  This  is   ver us ef ul  f or   i m age  retriev al   and   patte r m at ching   op e r at ion s.  H ow e ve r,   if  t he  im age  co ntains  no i se  the  higher  order   L DP al so   e nh a nces  the  noise ,   especial ly   fr om   the  fo urt orde an ab ove LDP   th us   re present s   the  hi g he ord er  patte r in f or m at ion   by  l abeli ng  the  pix el of  a im age  by  com par in tw de ri vative  directi ons  at   ne ighborin pixe ls  an c on cat enati ng  the  res ults  into   32 - bit  bin a ry  se quence.  Fig ur es   2b  an 2c  show  the  vi su al iz at ion   of  the  second  order   an thir order   L DP   in  zero   di recti on   resp ect ively   f or  an   exam ple  i m age   show in  Fig ure  2a A sho w in  fig ur es   the   third   orde L D giv e m or de ta il ed  inform a ti on  than  t he  sec on order.  We  ha ve  us e the   thir order  LD in  our   ex pe r i m ents  as  it   extracts  higher   sp a ti al   fr e qu e ncies  th ereb ext racti ng  fine detai ls  of   a i m age.  A our  prel i m inary  work   we  ha ve  im ple m ented  the  LDP   al gorithm   for  m edium   si zed  im ages  us i ng  only   the  G PU   global  m e m or [2 9 ] Th e   ps e udo  c ode   of  the   LDP   al gorith m   is  giv e i Ta ble  a nd  it im p lem e ntati on   us i ng  the  gl ob al   m em or sp ace  c an  be     fou nd in [2 9].     3.1.  GP U and   NV I DI A CUD A   An  ove rv ie of  the  basic  G PG P a rc hitec ture  is  prese nted  in   this  sect ion .   G PGPU   ge ner al ly   co ns is ts  of   hundre ds   of  S tream ing - P r oc essors  (S P s)  c al le cor es  w hich  are  f urt he gro up e in to  Stream ing   Mult i   Pr oc esso rs  ( S MPs)  [ 21 ] T he   cor es  pe rfo r m   data  pr ocess i ng   in  the  Sin gl In str uction  Mult iple  Thr ea (SIM T)  m od el Ma pp ing   of   the  al go rithm   to  the  GP is  done  by   first  identify ing   the  hi ghly   par al le ph ase s   of   the  al gorithm Those  par al le pha ses  are  the offloa ded   t the  GPU  an a re  then  cal le the  CUD kernel s Th e   rest  of   t he  phas es  are  m app ed  on t the  CP U.  O c om pleti on   of   e xecu ti on  of  CUD ke r nel  the  CPU  c ol le ct s   the  exec utio r esults  an the  GPU  is  the s cheduled  with  new   ke rn el   f or   e xec ution.  CUD ex pl oits  data  le vel  pa rall el is m   by  m aking   ever th rea d   work  on  dif f eren set   of  da ta The  li ght  weig ht  CU DA  threa ds   com bin to  f orm   thread   blo c ks   a nd   t he  th re ad  bl oc ks   com bin t f or m   com pu ta ti on al   gr i d.   T he  gr i ds  an the  th reads  ca be   ar range i on e t wo  or  t hr ee   dim ensio ns .   Eac th rea a nd  th rea bl oc can   be   id entifi ed  by uniq ue  i ds  a nd the  ke rn el  is  laun c he d by a  gr i d of  t hr ea d bloc ks .   Evaluation Warning : The document was created with Spire.PDF for Python.
In t J  Elec  &  C om En g     IS S N: 20 88 - 8708       Real -   Time  I m pleme nta ti on  and Perf orm anc e Opti miza ti on  o f L oc al D e riv ative     ( Ni sh a C handr an S )   5461         (a)   (b)   (c)     Figure  2. (a S a m ple q ue ry i m age f r om  Corel  d at abase , (b )  Secon d order   LDP   of the  que ry im age in  zer directi on. Deci m al  eq uiv al e nt of th e  b i nar pa tt ern  is s how n, (c T hir d Ord er L DP   of the   qu e ry im age in  zer directi on. Deci m al  eq uiv al e nt of th e  b i nar pa tt ern  is s how n       Ferm [3 0]  the  world ’s  fi rst  c om plete   GP arch it ect ure  w as  sig nificant   le ap  f orward  f ro m   the  G80   chipset  se ries.   The   SMPs   in   t he  F erm arch it ect ur c on sist of  32   co res  a nd  eac of  these   can   e xecu te     on e   floati ng - point  or   i nteger  instru ct io per  cl ock .   Ke pler  a rch it ect ure  la unche i 20 10  is  the  la te st  N VIDIA  gen e rati on  of   GPU  arc hitec tures   an is   buil base on  the  f oundat io of   Fe rm i.  Each  SMP   in  K epler   arch it ect ure  ha 192  sin gle  preci sion   CU DA  cor es,  eac on with  floati ng - point  an inte ger   arit hm et ic   log ic   un it s.  Tesl K 40 c   la unche in  20 12   is  N VIDIA’ fla gship  c om pu te   GPU,  base on  the  Ke pler  GK1 10  arch it ect ure  [ 31] W it 5G or   6GB  of  GDDR5  m e m or y,  they   pro vid up  to  3.9 TF L OP sin gle  pre ci sion  and  1.33 T FL O PS  double   pr e ci sion   floati ng   point  pe rfor m ance.   To   hid the  lo ng  off  c hip  m e m or acce ss  la te ncies  NVI DIA  Fe rm an d   Ke pler  GPU inclu de  s of t war m anag e caches,  t he  s ha red   m e m or and   t he  hard war m anag ed  c aches the  L data  cac hes.   Sh a red  m e m or is  on  ch ip  an the  C U DA   c om piler   treat s   var ia bles  in  t he   sh a red  m e m o ry  dif fer e nt  fro m   the  ty pical   va riables.  It  cre at es  co py  of  the  va riable  for  eac blo c that  is  la un c he on  t he  GPU.  E ver th read   in  t he  bloc sh a res  the  m e m or and   thu ca com m un ic at e   and   c ollaborat on   the  com pu ta ti on do ne.   Fu rt her m or e,  s har e m e m or and   L1 -   cache  on  GP util iz e   the  sam ph ysi cal   stora ge  an their  ca pacit can  be  c onfi gure at   r un ti m [3 2 ] Eac SM  in  the  Fe rm and   Kep le arch it e ct ur has  64KB  of   on - c hip   m e m or y,  di vid e into  s ha red   m e m or and   L cach e.  The   pro gr am m ers  m ay   cho os be tween  the  tw config ur at io ns :   48KB  of  sh a r ed  m e m or and   16KB  of   L cache  or   16KB  of  s har e m e m or and   48KB  of  L1  cache H oweve r,   a inc r ease  in  cache  m e m or red uc es  the   a m ou nt  of s hared m e m or y t o 16KB,  w hich  c an  le ad  to  t he r edu ct io i n occ up a ncy  of the  SMs.   In   a dd it io to  sh are m e m or and   L cach e,  CUD strea m s   [3 3],  [ 34]   al so   play an  i m po rtant  ro l e   in  acce le ra ti ng  the  com pu ta ti on done  on  th GPU.  CU D A   stream   rep rese nts  queue  of  GPU  operati on that  get  execu te in  sp eci fic  order.  Both  ke rnel la un ch an m e m or copi es  can  be  added  into  stream .   The   order  in  w hich   the  operati on are  a dde to   the  str eam   sp ec ifie the  ord er  in   w hich   th ey   will   be  e xe cuted .   Wh e us in st ream s,  instea of   c opyi ng  th input  bu ff e rs   entirel to  th GPU,  t hey  are  sp li into   s m al le chun ks   a nd   t he   m e m or cop ie to  a nd   from   the  GP as  well   as  th kernel  la un ches  are   pe rfor m ed     on each   ch unk.       Table  1.   T he  pseu do code  for t he  L DP  calc ulati on   [29]   Alg o rith m : Pseu d o  cod e f o th e L DP   calculatio n   Inp u t: Query   I m ag e; Outp u t: r etri ev al r esu lt     Step  1: Div id e the  in p u t i m ag e  of   ×   p ix els in to  blo ck s o f   ×   su b -   i m ag es.  Each s u b  i m ag e has     ×   p ix els.   Step  2: Fo i=  1 to   2   d o  step s 3  to 5   Step   3 Fo th e   i m ag p ix el   ( 0 ) th lo ca tio n   o f   wh ich   is  as  sh o wn   in   Fig .1,  c alcu late  th f irst  o rder  d erivativ es  al o n g   0 0 45 0 9 0 an d  135 0   d irection s as g iv e n  in eq s.1  to 4 .   Step  4: Calcu late b in ary  enco d in g  f u n ctio n  as giv en  in eq .6.   Step  5: Calcu late t h e his to g ra m s  of  the b in ary  patte rns .   Step  6: Co n catenate th e his to g ra m s o f  all  th e su b  i m ag es  to co n stru ct the f eatu re  v ecto o f  the  i m ag e.        4.   OPTIM U S IZ ING   OF E ES   The  a ppr oac ada pted   to  pa rall el iz the  LDP  al gorith m   is  to  br ea the  data  le ve par al le li s m   involve in   the   al gorithm Th al gorithm   is  div ide i nto   t w par ts:   CP ( Ho st a nd  G P ( De vice)  pro cessi ng   as  sh ow in  Figure  3.  The  im age  is  read   by  the  h ost co pied  to  the  de vice   m e m or y,  sp at i al   histog ram of   the   i m age  is  com pu te a nd  is  c op ie bac t the  h os m e m or y. The  im ages  are   div i ded  into   16x1 s ub  bl oc ks  an the  bl ocks  are   processe by  the  GPU.  T s how   the  c om pu ta ti on   of   LD a   sam ple  7x bl ock  siz is  ta ke a s   sh ow i Fi gure  4.   blo c of  threa ds  is   re qu ire t c al culat the  th ird  orde L DP  of  the   blac sq ua r e   reg i on   i Fig ure  4.   T he  L DP   patte rn f or   th blo c are  cal culat ed  usi ng  the  bi nar e ncodin f unct ion gi ve Z e r o   d i r e c t i o n 50 100 150 200 250 50 100 150 200 250 Z e r o   d i r e c t i o n 50 100 150 200 250 50 100 150 200 250 Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om En g,   V ol.  8 , N o.   6 Dece m ber  2 01 8   :   5457   -   5471   5462   in  Eq uatio 7.  The  bin a ry  enc od i ng   f un ct io ns  for  the  pix el   16   the  po sit io of   w hich  is  s how in  Fig ur 4,  for  the  fo ur   dif fer e nt d i recti ons   0 ° , 45 °   90 °   an 135 ° is give as  in (9 ) .        3 ( 16 )   =   {         ( ′′ ( 16 ) , ′′ ( 8 ) ) , ( ′′ ( 16 ) , ′′ ( 9 ) ) ( ′′ ( 16 ) , ′′ ( 10 ) )   ( ′′ ( 16 ) , ′′ ( 17 ) ) ( ′′ ( 16 ) , ′′ ( 24 ) ) ( ′′ ( 16 ) , ′′ ( 23 ) ) ( ′′ ( 16 ) , ′′ ( 22 ) ) ( ′′ ( 16 ) , ′′ ( 15 ) ) whe re   α =   0 ° , 45 °   , 90 °   a nd   135 ° }             (9)     4 . 1.   GP U and   NV I DI A CUD A   This  sect io de scribes  how  our  im ple m ent at ion   pa rall el iz es  the  L DP   al gorithm The  al gorithm   is   div ide into  tw o   m a in  ste ps   the  LDP   histo gr a m   cal culat ion   and   the  histogr a m   intersect ion O ut  of   the  t wo   th e   m os crit ic a st ep  in  t otal  exe cution  ti m is  t he  L DP   histogram   cal culat io an th ere fore   al op ti m iz at io ns   ar e   done  to  s pee dup  this  ke r nel.  T he  G PU   al gorithm   thu s   consi sts  of   tw ke r ne ls  to  execu te   th op e rati ons  of   the   two basic st e ps o the  LDP al gorithm .   The  L DP _com pu te   kernel  co m pu te the  LDP   values  of   al the  pix el in  th 16x16  blo c of   the  im age   al ong  al the  f our  directi ons   0 ° 45 °   90 °   and   135 ° The  s um   o the  decim al  equ i valent  of  t he  patte r ns   is  then   us e to  f or m   the  L DP   hist ogram Thr eads  are  al locat ed  f or   eac pix el   of   t he  im age  blo ck  a nd   eac threa cal culat es  and  stores  the  LD histogram   values.   The  histogram   values  are  then  tra ns f err e to  the  host  f or  norm al iz a ti on .           Figure  3. Steps  in  the  co m pu t at ion   of LDP           Figure  4. Im age b loc k o siz 7x7  t o dem on s trat e the c om pu ta ti on   of a t hread  blo c k.   LDP   of the  r e gi on  i n black  r e ct ang le  is t o be  co m pu te d       The  Hist_i ntersect   ker nel  co m pu te the  histogram   intersect ion   of   the  norm alized  qu ery   i m age  LDP  histo gr am   and  the  databa se  i m age  histo gra m H ist og ram   intersect io [ 2]   is  us e t m easur e   the   sim il arit betwee tw o hi stogram s an i s g i ven b y t he (1 0).        ( , ) = min   ( = 1 )     (10)     wh e re    ( , )   is  the  hi stogram   intersect ion   sta ti sti c T his  m easure   cal culat es  t he   com m on   part of  t w histo gr am s.  Histogram   intersect ion   th us   fi nd t he  com m on   par ts  of   t he   qu e ry  i m age  histogram   and   the   database  im age  histogram s.  Dep e ndin up on   the  siz of  the  histo gr am thread a re  al locat ed  f or   c om par ing   the ele m ents in  the  qu e ry a nd  the d at a base i m age h ist ogr a m s.     CPU   N o r m al i ze  q u e r y   i m ag e  h i sto g r am   N o r m al i ze   d atab ase  i m ag e   h i sto g r am s   R e ad  d atab ase  i m ag e   h i sto g r am s   R e ad  q u e r y   i m ag e   D i sp l ay   r e su l ts   G PU   Co m p u te  LDP     Co m p u te   H i sto g r am     Tr an sf e r  im ag e   to   GPU   Tr an sf e r  r e su l ts  to  Host   Tr an sf e r   h i sto g r am to  G PU   Co m p u te  h i sto g r am   i n te r sec tion   Tr an sf e r  r e su l ts  to  Host   Evaluation Warning : The document was created with Spire.PDF for Python.
In t J  Elec  &  C om En g     IS S N: 20 88 - 8708       Real -   Time  I m pleme nta ti on  and Perf orm anc e Opti miza ti on  o f L oc al D e riv ative     ( Ni sh a C handr an S )   5463   4 . 2 Desi gn  S p ace E xp lor at i on   and O pt im iz at ion   In   t he  fo ll owin sect io ns   we  discuss  in  deta il   the  arch it ect ur relat ed  des ign   s pace  e xplorati on  a nd   op ti m iz ation  fo cusin m ai nly on the C U DA thr ea d bloc siz es, r e gisters , mem or y space s a nd CU DA stre a m s.     4 . 2 . Thre ad  Bl ock  Siz e   The  ge ne ral  m et hodo l og a da pted  w he op tim iz ing   GPU  acce le rated  app li cat io is  to  increas the  o ccu pa ncy  of   the  SMPs.  It  is  essenti al   to  ru as  m any  th read as  possi ble  on   the  SM Ps  to  hid the   lon m e m or la te ncy.  To  inc rease  occupa ncy  ei ther  the  num ber   of   reg ist er pe r   threa has  t be  dec rease or  the  nu m ber  o f   thr e ads  in   the  t hr ea blo c ks  h as  t b a dju ste ac cordin t the n um ber  o f   re gi ste rs  pe t hr ea d.  Th occupa ncy  of   GPU  of  c ompu te   capa bili ty  2.1  f or  42  re gi ste rs  pe t hr ea is  m or t han  68%  us i ng  12 8,1 92   and   256  th reads  wh e reas  with   64   th read it   is  33 % W ex plore  the  opti m u m   thread   bl ock   s iz f or   diff e rent   i m age sizes tha t gives  the m axi m u m  o ccu pancy  as w el l as t he  least  ex ec ution t i m e.     4 . 2 . 2 Reg is ter s   Re du ci ng   th nu m ber   of  re gi ste rs  us e by  t he  threa ds   is  a no t her   op ti on  t increa se  occ up a ncy.  T he  CUD nvcc  c om piler  perfor m la rg scal r e gister  al loc at ion   t rem ove  in struc ti on  dep e ndencies   and  to  m axi m iz sing le   thread   pe rfo rm ance  [2 7] ,   [ 35 ] Re gisters  bein li m it ed  resou rce  f or   a   blo c an  i ncr e m ental  increase   i re gi ste al locat ion  will   le ad  to  r unni ng  fe wer  th read   bloc ks.  T hu s the re  is  a   trade off  be twe en  the  sing le   t hr ea pe rfor m ance  an the   nu m ber   of  act ive  t hr ea ds   at   a   ti m e.  In   [35]  the   aut hors   ha ve   us e m et ric   Re gRati w hic is  th rati of   t he  reg ist er us e per  th r ead  to   the  m axim u m   al lowed   r egiste rs   pe r   threa d.   Using  this  m etr ic we  ha ve  optim iz ed  the  usa ge  of   the  re gi ste rs.   W kee the  Re gRati value  betwee an and   c hoos hi gh   value  of  R egRat io  so   tha there  is  good   tra de off  bet ween   t he  sin gle  thread   perf orm ance  and  the num ber   of  sim ultaneo us ly   act ive  th re ads.  For  a   p a rtic ular  kernel  th m axi m u m   nu m ber   of  r e gisters p er   threa can  be  sp eci fied  to  th nv cc  com piler  at   com pile - t i m us ing   the  ma xr regc ount  op ti on.  T he or e ti cal ly,   the  act ual  reg i ste us m igh be  le ss  than  th lim it W ha ve  al so   ve rified  the  perf or m a nce  gain   ac hieved   by  Re gRati us in he ur ist ic   appr oach   wh e re   fo eac im a ge  siz e,  threa siz and   bloc siz the  num ber   of   reg ist ers   is  va r ie an t he  c om bin at ion   w hich  giv es  t he  m axim u m   occu pa ncy  an m inim u m   ker nel  ex ecuti on  tim e is fo und.      4 . 2 . S ha re Mem ory   and  L1 Cach e   To  f ur t her   im pr ove  the  pe rfo r m ance  of   the  L DP   al gorithm in  the  ne xt  ste we  m ake  us e   of   the  faste r   on   c hip   sh a re m e m or y.  The  nu m ber   of   r egiste rs  an th thread   blo c siz is  kep a an  op ti m u m   value   ob ta ine from   the  earli er  st udy.  Furthe we  choose  betwee the  t wo  co nfi gurati on s:  48 KB  of  s har e m e m or y   and   16 KB  of  L1  cac he   or  vi ce  versa  to   st ud t he  pe rform ance  im pr ove m ent  obta ine by  us in L cache  instea d of s hared m e m or y.     4 . 2 . 4 CUD S trea m s   Ferm and   Kep le arc hitec ture - ba sed  GPUs  sup por de vice  overlap   wh ic is  the   capaci ty   to   si m ultaneou sly   execu te   CU DA   kernel  w hi le   per f orm ing   m e m or copy   op erati on   bet ween   de vice  and   host  m e m or y.  This  is  facil it at ed  us ing   CU DA   stre a m s.  The  us of  stream is  ver prof it able  in   app li cat ion w her e   inpu data  inst ances  are  i nd e pende nt.  st r ea m   is  sequence  of  com m ands  that  is  execu te in  ord er.  By   def a ult,  CU DA   pro gr am   has  only   on str ea m   cal le the  def a ult  stream   [22] ,   [ 23] Wh en  m ulti ple  stream are  in vo l ved   t he  or der   in  w hich  the  opera ti on are  done   beco m es  an  im po rtant  issue The re  are  t w ba sic   appr oach es  us e to  orde the  op e rati ons,  bre adth  fir st  and   de pth   fir st.  I de pth   fir st  appr oach   al operat ion of   giv en  s tream   are  gr ou ped   t og et her   an in  br ea dth   fir st  appr oach   sim i lar   op e rati ons  of  diff ere nt  strea m s   are   gro up e t og et he r.   C orrect  res ults  are  obta in ed  with  bo t a ppr oach es   th ough  both  pe rfo rm   diff ere ntly   on  the   sp eci fic  ge ner a ti on   of  GPU  [ 34 ] I [ 35]   the  aut hors  hav e   sh ow that  for  certai ap pl ic at ion   wh ic us es   D   input  data  inst ances  a nd   de fines  blo c ks   of   t hr ea ds   for  kernel  exec ution   t he  data  ins ta nces  can  be  bro ke into  nStre am   stream s.  Ther efore,  each  stre a m   no w ork with  D/ nStre am   data  instances  an B/ nStre am   blo c ks   an the   m e m or cop of   one  stream   ov e rlaps  the  kernel  exec ution   of   th oth e stream   achie ving  a   perform ance im pr ov em ent. In our a ppli cat i on d e pe nd i ng  on the  siz e of t he  im age th va lue of  nS trea m  v aries.       5.   E X PERI MEN TS   AND   A NAL YS IS   OF   RE SU L TS     All  ex per im ents  in  t his  pap e are  done  on  t w diff e re nt  m a chines P reli m i nar e xperim e nts  are   done   on   In te Co re  i3 - 2375M  with   4G RAM  a nd  Ge force 720m   (G PU   1)   a nd  are  f urt her   r epeate on   In t el   Xeon  CPU  E 5 - 1650  with  64 GB  RA and   Tesl K 40 (GPU  2).  The  a uthors  in  the  or i gin al   pa per   [2 ]   ha ve  re porte the  CPU  e xec ut ion   ti m fo th seq uen ti al   L DP   al go rithm   as  0.1 8s ec  f or  an  im age  of   si ze  88  88  pi xe ls  on   PC  with 3  GH CPU  a nd 2  GB   RAM. In  our  ex per im ents  w ha ve  us ed   ou ow se quenti al   i m ple m entation  o f   Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om En g,   V ol.  8 , N o.   6 Dece m ber  2 01 8   :   5457   -   5471   5464   the  al gorithm Using  our  im ple m entat ion t he   tim ta ken   f or  88 x88  pixe ls  on  G PU  is   0. 078s ec   an t he   ti m e   ta ken   on  G PU   is  0.0 36sec.   We  hav us e high  re so l ution  i m ages  rangin f ro m   siz es  256x 256  t 40 96x4 096  for  our  e xperi m ents.  The  e xperim ents  fo m ed ium   i m age  siz es  us in th global  m e m o ry  on   GeF orce   720m   i s   pr ese nted   in   [ 29] I t his  pap e the   LD al gorithm   is  i m ple m ented  on  la rge  siz ed  im ages  us i ng  the  fast - sh ar e m e m or and  f urt her  im pr ov e us in t he  c onc ept  of  L data cache  a nd  CU DA  stream s.  H igh  r es olu ti on  i m ages   rangin g from  size 256 x256 to  4096 x4096 pi xels are  consi de red in t his pap er.    Gefor ce   72 0m   is  car of  co m pu te   capab il it 2. an a   th r ead b loc ca con ta in   m axim u m   of   1024   threa ds   a nd  ev ery  SMP  ca process  a   m axim u m   of   1536  threa ds   wh e r ea Tesl K 40C  is  car of   c om pu te  capab il it 3.5,  in  w hich  t hr e ad  bl oc can  c on ta in   m axi m u m   of   10 24   t hr ea ds   a nd  eve ry  SMP  can   pr ocess  a   m axi m u m   of   2048  t hr ea ds .   T he  te st  im ages  are  ta ke from   Corel  data bas [ 36 ]   a nd  Ess ex  face  databa se  [ 37 ] Corel  da ta bas consi sts  of   var i ou s   cat egories  li ke  a nim a ls,  cars,  distract ions  a nd   t ran s port.  Fo r   our   exp e rim ents  we  ha ve  colle ct e 10 00  im ages  from   var ious  c at egories  of  th Corel  databa se  to  f or m   the  dataset The  Esse fac database  c on sist of   20  im a ges  eac of   153  pe rs ons.  We   hav e   ta ke 10   i m ages  of   eac 15 per s ons  f or   ou exp e rim ents.  The  ap proac fo ll owe in  our  par al le i m pl e m entat ion   is  t achieve  al m os th e   sam e   retrieval  resu lt as  that  of   the  se qu e ntial   i m ple m entation T he  i m ages  are  div ide into  non - ov e rlapp i ng  i m age  blo c ks   of  siz 16x16.  T he  e xp e rim ent  is  rep eat e for  diff e re nt  im ag siz es  an t he   pe rfor m ance  ga in  of   the  kernel  is  an al yz ed.   CUD A   Visu al   Profile is  us ed  t ana ly ze  the  CUD ke rn el  p er form ance  [38] . W ha ve  dev el op e tw ke rn el f or  im age   retrieval,   one  for  L DP  his togram   co m pu ta ti on   a nd  a no t her  f or  the  sim il arity   m at ching   us in hist ogram   intersect ion .   F or  the  im ple m entat ion   the  query   i m age  is  cop i ed  to  t he  G PU  global  m e m or y.  The  i m age  is  div ide into  16x1 bl ock a nd  the  LDP   histo gr a m   valu es  of  ea ch  bl ock   a re  ca lc ulate d.  We  hav e   ch ose blo c siz of  25 th rea ds   s that  e ve r SMP  in  GPU1  with   com pu te   capa bili ty   2.1  ca sche du le   six  bl ock wh e reas   GP U with  com pu te   capa bili ty   3. can   schedule  ei ght  blo c ks   by  op ti m u m   resou rce  util iz at ion Th kern el   is  la un che with  the  neces sary  threads  to  cal culat the  LDP   hist ogra m   values.   The  c om pu te LDP   histo gr a m   is  then  tra nsfer red   bac t the  CP for   norm al iz ation.  The  m at chin is  the n   done by t he  se cond ke rn el   us i ng the  histo gr a m   intersect ion  m et ho d.     To  a void  t he  CPU  from   being  idle  w hen  the  GPU  is  cal culat ing ,   we  e ff ic ie ntly   di vide   the  ta s of   histo gr am   intersect ion  b et wee the  t wo   i s uc a w ay   that  in  m ini m u m   tim the  cal culat ion   is  c om pleted T his   is  done  by  la unchi ng  the  kernel  asy nc hro nous ly i .e.  wh e ne ver   t he  ke r nel  is  execu ti ng   i the  GPU,  t he   CPU  is   no blo c ked  an is  f ree  to  perform   i ts  own  c om pu ta ti on s.  Our  strat e gy  f or   balanci ng   t he  w ork  l oad   betwee CPU  an GPU   is  giv e bel ow.  Let   be  t he   rati of  the  ti m ta ken   by  th CPU  to  perf orm   the   ta sk   to  the  ti m e   ta ken   by  the  G PU   to  perf or m   the  ta sk If   is  the  total   num ber   of   im age to  be  process ed  the im ages  to  the   GPU is  giv e n b 1 +   an im ages to  the  CP is  giv en  b 1 +   w her e   R =                         .     Figure  s hows  the  pe rcent age  of  al loca ti on   of  the   im ages  to  the  CPU  a nd   GPU.  T he  rati os   CPU/T= 1/1+R   an G PU/T =  R/1+ R   are p lot te agai ns the log a rithm ic   val ues  of   t he  s pee dup.  From   Figu re  5  it   can  be  seen  that  if  the  exec ution   ti m ta ken   by  the  CP and   t he  GPU  is  alm os the  sam then  the  im ages  can  be  e qual ly   div ide betw een  the  CP a nd   t he  G PU.  I our  e xperim ents  we  al lott e 50  im ages  of   siz 256x25 pix el to  t he  CP a nd  95 im ages  to  the   GPU.   F or  im ages  of  siz 4096 x4096  we  al lott ed   30  i m ages  to  the  C PU   a nd  97 to   the   GPU.   As   G P U2,  the   Tesl m achine  is  m or e   pow er fu and  m or su it able  f or  sci entifi cal cu la ti on we  ha v done  al the  c om pu ta ti on in   the  GPU.  I the  f ollo wing  s ect ion   we  disc us the   perform ance im pr ov em ent achieve d by ou r  d esi gn sp ace  e xp l or at io n.           Figure  5. O ptim al  w ork  l oad  balance  bet wee CP a nd GP U     0 1 2 3 4 5 6 0 10 20 30 40 50 60 70 80 90 100 l o g 10   ( S p e e d u p   t i m e ) I m a g e   a l l o c a t i o n   i n   %     C PU   a l l o c a ti o n G PU   a l l o c a ti o n Evaluation Warning : The document was created with Spire.PDF for Python.
In t J  Elec  &  C om En g     IS S N: 20 88 - 8708       Real -   Time  I m pleme nta ti on  and Perf orm anc e Opti miza ti on  o f L oc al D e riv ative     ( Ni sh a C handr an S )   5465   5 . 1 Op timi z in g the  Nu m ber  of Threa ds  and  Re gister s   We  ha ve  fou nd  opti m iz ed  values  f or   re gisters  us i ng   t he   m et ho discu ssed  in   sect io 4.1 .2.  We   consi der   th rea ds   pe threa blo c (N)  an reg ist er  al locat ion   pe threa (R)  as  input  va riables.  T he  de fau lt   reg ist er   us e   ( w it ho ut  re gister  lim it of   our   L DP   im ple m ent at ion   is  42.  T he   m axi m u m   va lue  f or  N   is  76 due   to  the  c onstrai nt  of  reg ist er   us e.  We   ex plore  var io us  co m bin at ion of   a nd  values  a nd  a naly ze  the   perform ance  i m pr ov em ent.  On ly   su bse of   the  res ults  is  disp la ye he r e.  As  sho wn   in   Figu r es  6a  an 6b  the   desig sp ace  e xh i bits  high  va riat ion   in  te rm of   exec utio tim e.  The  ov er al per form ance  crit ic al l dep en ds   on both N a nd  R. For  e xam ple,   f or  a im age o f  size 2 56x2 56 the  opti m a l set ti ng  is N = 12 a nd  R= 23, w her eas  for  an  im age  of   siz 1024x1 0 24   the  optim al  set ti ng   is  at   N=2 56  R= 32.  W hav done  a opti m a cho ic by   ta kin int co nsi der at io the  m axi m u m   occu pa ncy  an m i nim u m   tim e.  W it the  de faul nu m ber   of   re gisters ,   42   in  our  case the  m axi m u m   nu m ber   of   act ive  threads  per   m ulti pr oce sso is  li m it ed  to  768  in  de vice  of  com pu te   capa bi li t 2. 1.  By   de creasin the  nu m ber   of   re giste rs  to  t he  opti m al   value  i.e.   23   and  th read   bl ock   siz of   12 8,   th act ive  num ber   of  th rea ds   pe m ulti pr oces so r   is  incr ease to  1024.   I de vice  of  c om pu te  capab il it 3 . t he  nu m ber   of  threa ds   is   incre ased  from   1280  to   20 48  with   the  opti m al   cho ic of  t he  num ber   of  reg ist ers  p e t hread  and t he num ber  o t hr ea ds pe th rea d block.   Com bin ing   the   afo r em entioned   va rio us   re ne wab le   e nergy  r eso ur ces with  energy  stora ge  syst e m an diesel   en gin e   gen e rato in   a inte rcon nected  syst em the  ge ner at e e le ct ric  energy   can  be  e ff ec ti vely  distrib uted an d co ntr olled to   m eet  the en er gy  r eq uirem ent o f  the c onnecte loa ds.           (a)   (b)     Figure  6. (a ) O pti m al  n o.   of  r egiste rs  a nd th r ead  blo c siz for  a im age o f  size 2 56x2 56 ,   (b) Optim al  n o.  of  reg ist er s a nd th read bl oc siz for  a i m age of  siz 1024 x1024       5 . 2 I mple men tation usin g G loba Mem or y   The  first  ve rsi on   of   the  al go rithm   was  i m p lem ented  us in the  global  m e m or sp ace.  The  detai le i m ple m entat io proce dure  of  the  L DP  al gor it h m   us in the   global  m e m or an the   tim com par ison  bet wee the  seq ue ntial   an pa rall el   ver si on  f or   m edium   i m age  siz es  on  G PU1  w as  prese nt ed  in  [ 29 ] O pti m iz ed   nu m ber   of  re gi ste rs  an th rea ds   we re  co ns i de red   fo each  i m age  siz e.  Fig ur sho ws  th tim co m par ison   of   LDP_c om pu te   on   GPU f or  i m age  siz es  2 56x256,  512x 512,   1024x1 024,  2048 x204 an 4096 x4096.   As  sh ow in   Fig ure  the  C U D kernel  gi ve m or perf orm ance  gain   f or  hi gher  siz i m ages  tha s m al le r   i m ages.  This  is   beca us the   host  m e m or to  de vice  m e m or cop ta ke c on si der a ble  am ount  of   ti m a nd  th e   sp ee dup  obta in ed  m us payof f   fo this  co py  over hea d.   I cas of   sm aller  sized   i m ages  su ch   as  25 6x 256  pi xels   or   512x 512  pix el s,  the   sp ee dup  obta ine is   no e noug to   payo ff   for  thi co py  over he ad.   Howe ver,  as  the   i m age  siz in creases  to  20 46x204 pix el and   40 96x4 096  pi xels  this  ov e rh ea is  paid  off  an the  perform ance gai inc reases.             Figure  7. Tim e  co m par iso n be tween  seq ue ntial  v ersi on and  par al le l ve rsion  in  Tesla  K40   wh e n glo bal m e m or y i s used . L ogarit hm ic  scale s ar us e f or p l otti ng   N o .   o f   T h r e a d s N o . o f   R e g i s t e r s     128 192 256 42 36 34 32 23 20 1 8 . 4 1 8 . 5 1 8 . 6 1 8 . 7 1 8 . 8 1 8 . 9 19 1 9 . 1 1 9 . 2 1 9 . 3 1 9 . 4 N o .   o f   T h r e a d s N o .   o f   R e g i s t e r s     128 192 256 42 36 34 32 23 20 180 185 190 195 200 205 10 2 10 3 10 4 10 -2 10 -1 10 0 10 1 10 2 I m a g e   s i z e ( i n   p i x e l s ) T i m e   i n   s e c o n d s Tim e  com parison for diffe re nt im age  size s     Se q u e n ti a l Pa r a l l e l Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om En g,   V ol.  8 , N o.   6 Dece m ber  2 01 8   :   5457   -   5471   5466   This  s hows  t ha the  GPUs  give   excell ent  pe r form ance  for  la rg w orkloa ds  w hich  a re  hi gh ly   pa rall el   and  thr ough pu t   or ie nted H ow ever,  the  la rg e   nu m ber   of  re gisters  re quire b the  t hr ea will   lim it   the  num ber   of   act ive  th rea ds   pe m ulti pr ocess or.  By   red uci ng   th nu m ber   of   reg ist e rs  pe threa a nd   by  sel ect ing  an  idea l   threa bl ock  siz the  num ber   of   act ive   thr ea ds   per   m ulti process or   ca be  increase wh ic in  t urn  will   increase   the ove rall  p e rfor m ance.     5 . 3 I ml ement at i on  u sing  Shared  Mem or y and L 1 C ache   The  nex op ti m iz at ion   done  is  to  us the  s oft war m anag e faste on  c hip   sh a re m e mo ry  instea of   the  gl ob al   m e m or y.  Sh are m e m or enab l es  inter  t hr ea data  re us e   as  t he  th rea ds   i t he  th rea blo c s har e   the   data  store in  t he  sh a re m e mo ry.  I our  im plem e ntati on   we  ha ve  care ful ly   div ided  the  i m ages  in  su ch   way   that  the  48KB   per  bl ock  c on s trai nt  of  sh a re m e m or is  ne ver  vi olate a nd  al so  w us e   the  m axi m um  sh a re m e m or avail able  for  pr ocess ing T he  im age  is  div ide into   16x16  ti le an seve s uch   ti le are  cop ie to  the   sh are m e m or fo r   LD c om pu ta ti on T he   su m of   the   LDP   value in   the  f our  direct ion a re  the wr it te to  the  sh a red   m em or fo f ur t he us e T otal  am ou nt  of   s ha re m e m or us ed  pe bl oc is  7K B. We  ha ve   ta ken   the  threa blo c siz as  12 in   G PU   s that  blo cks  a re  act ive  in  on SM and   the  total   sh are m e m or us ed   per   SMP  is  42KB.  T his  fall within  the  48KB  li m it   at  t he  sam t i m e   sche du le the  m axi m u m   nu m ber   of   threa ds   possibl e.  T he  s peedu ob ta ine f or   in  G PU1  w hen  sh a red  m e m or is  us e is  s how i Ta ble  2a.   I GPU2  t he  th re ad  bl ock  siz is  ta ken   a 25 and   blo c ks   a re  act ive  in  on SMP  an the   total   sh are m e m or us e d per SM P i s 42K B . T he  s peedu p ob ta i ne in  GPU 2 w he s har e m e m or y i us e is  s how in  Ta ble  2b.    The  tim ta ke for  the  c om pu ta ti on  w hen  sh are m e m o ry  is  us ed  is  m uch   le ss  com par ed  to  the   par al le ve rsion  w hich   us es   the  gl ob al   m e m or y.  T his  is  be cause  as  t he  s har e m e m or is  on - c hip   it   is  m uch   faster  tha nth global  m e m or y.  Howe ver t ensure  co rrec resu lt the re  m us be  sync hro nizat ion   bet ween   t he  threa ds   w hich   sh are  t he  m e m or y.  CU D A’ sim ple  ba rr ie sy nchr oniz at ion   pr im i ti ve  __ synct hre ads  ()     is use d for this .   This  av oid th race  conditi on  as  the  thread’s  exec ution   proceed  past  __ sy ncthre ads  ( )   bar rier  only   after all  the   thr eads i the  b l oc k hav e  ex e cut ed  the  b a rr ie s ynch ronizat ion.    We  ha ve  furth er  stu died  the  op ti on  of   us in la r ger   L cache  in  place   of   s ha red   m em or and   it eff ect   on  im pr ov i ng   the  perf or m ance  of   the   LDP_com pu te   kernel.  De fau l L1  siz is  16KB  but  in  c ases  wh e reg ist er  s pill in is  pro blem at ic   increasin the  siz of  L1  to  48K i m pr ov e the  pe rfo rm ance.  The   cuda Device Set CacheC on fi g   f un ct io is  us e to  set   prefe re nc betwee the   sh ar ed  m e m or and   L1  cac he The   sli gh i m pr ove m ent  in  sp eed up   ob ta ine by   us i ng   L1  ca che  w hen   com par e to  sh a re m e m or fo the  two  GPUs  is  as  show in  Ta bles  3a  an 3b.  T he   L1  cache  ver s ion   s hows  onl sli gh per f or m ance  i m pr ovem ent   wh e c om par e to  the  sh a red  m e m or y vers i on.      5 . 4 I mple men tation usin S trea m s   LDP_c om pu te   kernel  is  furth er  optim iz ed  us ing   stream s.  To  al locat op erati on t dif f eren stream s   the  input  i m age  is  div ided  in to  s m al l   chu nk and   the  re qu i red   ope rati ons  are  perform ed  on   eac ch unk.  The  three  m ai ope rati on s   in   the   LDP  com pu ta ti on  is  m e m or co py  from   host  to  de vice,  e xecu ti on   of  t he   ke rn el s   and  c op yi ng  t he   res ult  bac f r om   dev ic t host.  For  a in put  im age  of  siz say   N=  256x 256  siz e,  the  sta ge execu ti on  of   nStre ams t ran s f ers  ch unks  of  N/ nStre ams   si ze  i.e.  12 8x12 pi xels.  If   blo c ks   a re   us e f or   t he  com pu ta ti on   of  the  w ho le   i m age  in  the   non - sta ge ve rsion  the i the  sta ge e xe cution  of  nStre ams B/ nS tre ams   bl ocks  are u se f or   c om pu ta ti on.  Als o,  w hile  the  fir st  ch unk  i bein c om pu te by  t he  B/ nS tre am s   blo c ks the  se cond  ch unk  is   being   tra nsfe rr e there by  gi vin a im pr ov em ent  in  pe rfor m ance.  Fig ur 8a  sh ows  s uc con c urre ncy  be tween  tra ns fe an com pu ta ti on   with  nS tre am   set   as  4.   T he  host  m e m or ie are   al locat ed  as  pa ge  loc ke d.   We   ha ve  ass um ed  that  the  ke rn e execu ti on  an m e m or copi e ta ke  r oughl the   sam e   execu ti on  tim e.  The  ex ecuti on   ti m l i ne  is  as  sho wn  in  Fig ur 8b.  The  inter  e ngine  de pe nd e nci es  are   highli gh te with  ar rows.  O GeF or ce   72 0m   there  is  on l sing le   c op eng i ne  a nd  s ing le   kernel  e ng i ne.   Dep t first  ap proac does  no giv any  s pe edup  w he reas   br ea dth   first  s earch  giv es  sp ee dup  as  show in  Table  4a.   I K 40 the re  are  two  c op en gine on f or   host   to  dev ic tran sfer   an an othe for  de vice  to  host  trans fer   a nd  a   sing le   ke rn el   en gin e.   Both   de pth first  a nd  breadt fir st   achieve  t he   sam sp eedup.  T he   op e rati ons  a re  qu e ue ac ro s the  stream in  su c way  th at   the  ope rati on  of   one  st rea m   do es  not  blo ck   the  op e rati on  of   th oth er  stream s.  This  al lows   the  GPU  to  ex ecute  cop ie a nd   kernels  in  par al le l,  al lowi ng   the  app li cat io to  run faste as  show i Ta ble  4b.      The  im age  retrieval  res ults  us in the  par a ll el   i m p lem ent at ion   of  LD is  giv en  i Ta ble  5.   T he  perform ance  evaluati on  was  done  by  cal cul at ing   two  par a m et ers -   true  posit ive  rate  (T PR)  an false  po sit ive   rate  (F PR)   give by    =  / (  +  )   an  =  / (  +  )   w he re  TP   is  T r ue   P os it ive,   F i False   Ne gative FP   is  False   Po sit ive  a nd  T is  T r ue  Ne gative.  The   f our   pa ram et ers  TP,  FN ,   FP T a re   evaluate as  fol lows Firstl y,  the  G rou nd  Tr uth   (GT)  f or   al the  im ag es  in  the  database   is  rec orde as  TR U E   or   F ALS depend i ng   on   wh e ther  the  im age   belongs  to  th TRUE  cl ass  or   the  F ALS E   cl ass.  In   the  s eco nd   Evaluation Warning : The document was created with Spire.PDF for Python.