starpu_fxt.c 146 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2013 Joris Pablo
  5. * Copyright (C) 2013 Thibaut Lambert
  6. * Copyright (C) 2017-2020 Federal University of Rio Grande do Sul (UFRGS)
  7. *
  8. * StarPU is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2.1 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * StarPU is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. */
  19. #include <starpu.h>
  20. #include <common/config.h>
  21. #include <common/uthash.h>
  22. #include <datawizard/copy_driver.h>
  23. #include <string.h>
  24. #ifdef STARPU_HAVE_POTI
  25. #include <poti.h>
  26. #define STARPU_POTI_STR_LEN 200
  27. #endif
  28. #define STARPU_TRACE_STR_LEN 200
  29. #ifdef STARPU_PAPI
  30. #include <papi.h>
  31. #endif
  32. #ifdef STARPU_USE_FXT
  33. #include "starpu_fxt.h"
  34. #include <inttypes.h>
  35. #include <starpu_hash.h>
  36. #define CPUS_WORKER_COLORS_NB 8
  37. #define CUDA_WORKER_COLORS_NB 9
  38. #define OPENCL_WORKER_COLORS_NB 9
  39. #define MIC_WORKER_COLORS_NB 9
  40. #define MPI_MS_WORKER_COLORS_NB 9
  41. #define OTHER_WORKER_COLORS_NB 4
  42. /* How many times longer an idle period has to be before the smoothing
  43. * heuristics avoids averaging codelet gflops */
  44. #define IDLE_FACTOR 2
  45. static char *cpus_worker_colors[CPUS_WORKER_COLORS_NB] = {"/greens9/7", "/greens9/6", "/greens9/5", "/greens9/4", "/greens9/9", "/greens9/3", "/greens9/2", "/greens9/1" };
  46. static char *cuda_worker_colors[CUDA_WORKER_COLORS_NB] = {"/ylorrd9/9", "/ylorrd9/6", "/ylorrd9/3", "/ylorrd9/1", "/ylorrd9/8", "/ylorrd9/7", "/ylorrd9/4", "/ylorrd9/2", "/ylorrd9/1"};
  47. static char *opencl_worker_colors[OPENCL_WORKER_COLORS_NB] = {"/blues9/9", "/blues9/6", "/blues9/3", "/blues9/1", "/blues9/8", "/blues9/7", "/blues9/4", "/blues9/2", "/blues9/1"};
  48. static char *mic_worker_colors[MIC_WORKER_COLORS_NB] = {"/reds9/9", "/reds9/6", "/reds9/3", "/reds9/1", "/reds9/8", "/reds9/7", "/reds9/4", "/reds9/2", "/reds9/1"};
  49. static char *mpi_ms_worker_colors[MPI_MS_WORKER_COLORS_NB] = {"/reds9/9", "/reds9/6", "/reds9/3", "/reds9/1", "/reds9/8", "/reds9/7", "/reds9/4", "/reds9/2", "/reds9/1"};
  50. static char *other_worker_colors[OTHER_WORKER_COLORS_NB] = {"/greys9/9", "/greys9/8", "/greys9/7", "/greys9/6"};
  51. static char *worker_colors[STARPU_NMAXWORKERS];
  52. static unsigned opencl_index = 0;
  53. static unsigned cuda_index = 0;
  54. static unsigned cpus_index = 0;
  55. static unsigned mic_index = 0;
  56. static unsigned mpi_ms_index = 0;
  57. static unsigned other_index = 0;
  58. static uint64_t* number_events = NULL;
  59. static unsigned long fut_keymask;
  60. /* Get pointer to string starting at nth parameter */
  61. static char *get_fxt_string(struct fxt_ev_64 *ev, int n)
  62. {
  63. char *s = (char *)&ev->param[n];
  64. s[(FXT_MAX_PARAMS-n)*sizeof(unsigned long) - 1] = 0;
  65. return s;
  66. }
  67. /*
  68. * Paje trace file tools
  69. */
  70. static FILE *out_paje_file;
  71. static FILE *distrib_time;
  72. static FILE *activity_file;
  73. static FILE *anim_file;
  74. static FILE *tasks_file;
  75. static FILE *data_file;
  76. #ifdef STARPU_PAPI
  77. static FILE *papi_file;
  78. #endif
  79. static FILE *trace_file;
  80. static FILE *comms_file;
  81. static FILE *sched_tasks_file;
  82. static FILE *number_events_file;
  83. struct data_parameter_info
  84. {
  85. unsigned long handle;
  86. unsigned long size;
  87. int mode;
  88. };
  89. struct task_info
  90. {
  91. UT_hash_handle hh;
  92. char *model_name;
  93. char *name;
  94. int exclude_from_dag;
  95. int show;
  96. unsigned type;
  97. unsigned long job_id;
  98. unsigned long submit_order;
  99. long priority;
  100. int color;
  101. uint64_t tag;
  102. int workerid;
  103. int node;
  104. double submit_time;
  105. double start_time;
  106. double end_time;
  107. unsigned long footprint;
  108. unsigned long kflops;
  109. long iterations[2];
  110. char *parameters;
  111. unsigned int ndeps;
  112. unsigned long *dependencies;
  113. char **dep_labels;
  114. unsigned long ndata;
  115. struct data_parameter_info *data;
  116. int mpi_rank;
  117. };
  118. struct task_info *tasks_info;
  119. static struct task_info *get_task(unsigned long job_id, int mpi_rank)
  120. {
  121. struct task_info *task;
  122. HASH_FIND(hh, tasks_info, &job_id, sizeof(job_id), task);
  123. if (!task)
  124. {
  125. unsigned i;
  126. _STARPU_MALLOC(task, sizeof(*task));
  127. task->model_name = NULL;
  128. task->name = NULL;
  129. task->exclude_from_dag = 0;
  130. task->show = 0;
  131. task->type = 0;
  132. task->job_id = job_id;
  133. task->submit_order = 0;
  134. task->priority = 0;
  135. task->color = 0;
  136. task->tag = 0;
  137. task->workerid = -1;
  138. task->node = -1;
  139. task->submit_time = 0.;
  140. task->start_time = 0.;
  141. task->end_time = 0.;
  142. task->footprint = 0;
  143. task->kflops = 0.;
  144. for (i = 0; i < sizeof(task->iterations)/sizeof(task->iterations[0]); i++)
  145. task->iterations[i] = -1;
  146. task->parameters = NULL;
  147. task->ndeps = 0;
  148. task->dependencies = NULL;
  149. task->dep_labels = NULL;
  150. task->ndata = 0;
  151. task->data = NULL;
  152. task->mpi_rank = mpi_rank;
  153. HASH_ADD(hh, tasks_info, job_id, sizeof(task->job_id), task);
  154. }
  155. else
  156. STARPU_ASSERT(task->mpi_rank == mpi_rank);
  157. return task;
  158. }
  159. /* Return whether to show this task in the DAG or not */
  160. static int show_task(struct task_info *task, struct starpu_fxt_options *options)
  161. {
  162. if (task->show)
  163. return 1;
  164. if (task->type & STARPU_TASK_TYPE_INTERNAL && !options->internal)
  165. return 0;
  166. if (task->type & STARPU_TASK_TYPE_DATA_ACQUIRE && options->no_acquire)
  167. return 0;
  168. return 1;
  169. }
  170. static void task_dump(struct task_info *task, struct starpu_fxt_options *options)
  171. {
  172. char *prefix = options->file_prefix;
  173. unsigned i;
  174. if (task->exclude_from_dag)
  175. goto out;
  176. if (!tasks_file)
  177. goto out;
  178. if (task->name)
  179. {
  180. fprintf(tasks_file, "Name: %s\n", task->name);
  181. free(task->name);
  182. }
  183. if (task->model_name)
  184. {
  185. fprintf(tasks_file, "Model: %s\n", task->model_name);
  186. free(task->model_name);
  187. }
  188. fprintf(tasks_file, "JobId: %s%lu\n", prefix, task->job_id);
  189. if (task->submit_order)
  190. fprintf(tasks_file, "SubmitOrder: %lu\n", task->submit_order);
  191. fprintf(tasks_file, "Priority: %ld\n", task->priority);
  192. if (task->dependencies)
  193. {
  194. fprintf(tasks_file, "DependsOn:");
  195. for (i = 0; i < task->ndeps; i++)
  196. fprintf(tasks_file, " %s%lu", prefix, task->dependencies[i]);
  197. fprintf(tasks_file, "\n");
  198. free(task->dependencies);
  199. }
  200. if (task->dep_labels)
  201. {
  202. fprintf(tasks_file, "DepLabels:");
  203. for (i = 0; i < task->ndeps; i++)
  204. {
  205. fprintf(tasks_file, " %s", task->dep_labels[i]);
  206. free(task->dep_labels[i]);
  207. }
  208. fprintf(tasks_file, "\n");
  209. free(task->dep_labels);
  210. }
  211. fprintf(tasks_file, "Tag: %"PRIx64"\n", task->tag);
  212. if (task->workerid >= 0)
  213. fprintf(tasks_file, "WorkerId: %d\n", task->workerid);
  214. if (task->node >= 0)
  215. fprintf(tasks_file, "MemoryNode: %d\n", task->node);
  216. if (task->submit_time != 0.)
  217. fprintf(tasks_file, "SubmitTime: %f\n", task->submit_time);
  218. if (task->start_time != 0.)
  219. fprintf(tasks_file, "StartTime: %f\n", task->start_time);
  220. if (task->end_time != 0.)
  221. fprintf(tasks_file, "EndTime: %f\n", task->end_time);
  222. fprintf(tasks_file, "Footprint: %lx\n", task->footprint);
  223. if (task->kflops != 0)
  224. fprintf(tasks_file, "GFlop: %f\n", ((double) task->kflops) / 1000000);
  225. if (task->iterations[0] != -1)
  226. {
  227. fprintf(tasks_file, "Iteration:");
  228. for (i = 0; i < sizeof(task->iterations)/sizeof(task->iterations[0]); i++)
  229. {
  230. if (task->iterations[i] == -1)
  231. break;
  232. fprintf(tasks_file, " %ld", task->iterations[i]);
  233. }
  234. fprintf(tasks_file, "\n");
  235. }
  236. if (task->parameters)
  237. {
  238. fprintf(tasks_file, "Parameters: %s\n", task->parameters);
  239. free(task->parameters);
  240. }
  241. if (task->data)
  242. {
  243. fprintf(tasks_file, "Handles:");
  244. for (i = 0; i < task->ndata; i++)
  245. fprintf(tasks_file, " %lx", task->data[i].handle);
  246. fprintf(tasks_file, "\n");
  247. fprintf(tasks_file, "Modes:");
  248. for (i = 0; i < task->ndata; i++)
  249. fprintf(tasks_file, " %s%s%s%s%s",
  250. (task->data[i].mode & STARPU_R)?"R":"",
  251. (task->data[i].mode & STARPU_W)?"W":"",
  252. (task->data[i].mode & STARPU_SCRATCH)?"S":"",
  253. (task->data[i].mode & STARPU_REDUX)?"X":"",
  254. (task->data[i].mode & STARPU_COMMUTE)?"C":"");
  255. fprintf(tasks_file, "\n");
  256. fprintf(tasks_file, "Sizes:");
  257. for (i = 0; i < task->ndata; i++)
  258. fprintf(tasks_file, " %lu", task->data[i].size);
  259. fprintf(tasks_file, "\n");
  260. }
  261. fprintf(tasks_file, "MPIRank: %d\n", task->mpi_rank);
  262. fprintf(tasks_file, "\n");
  263. out:
  264. HASH_DEL(tasks_info, task);
  265. free(task);
  266. }
  267. struct data_info
  268. {
  269. UT_hash_handle hh;
  270. unsigned long handle;
  271. char *name;
  272. size_t size;
  273. starpu_ssize_t max_size;
  274. char *description;
  275. unsigned dimensions;
  276. unsigned long *dims;
  277. int home_node;
  278. int mpi_rank;
  279. int mpi_owner;
  280. long mpi_tag;
  281. };
  282. struct data_info *data_info;
  283. static struct data_info *get_data(unsigned long handle, int mpi_rank)
  284. {
  285. struct data_info *data;
  286. HASH_FIND(hh, data_info, &handle, sizeof(handle), data);
  287. if (!data)
  288. {
  289. _STARPU_MALLOC(data, sizeof(*data));
  290. data->handle = handle;
  291. data->name = NULL;
  292. data->size = 0;
  293. data->max_size = -1;
  294. data->description = 0;
  295. data->dimensions = 0;
  296. data->dims = NULL;
  297. data->home_node = STARPU_MAIN_RAM;
  298. data->mpi_rank = mpi_rank;
  299. data->mpi_owner = mpi_rank;
  300. data->mpi_tag = -1;
  301. HASH_ADD(hh, data_info, handle, sizeof(handle), data);
  302. }
  303. else
  304. STARPU_ASSERT(data->mpi_rank == mpi_rank);
  305. return data;
  306. }
  307. static void handle_papi_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  308. {
  309. #ifdef STARPU_PAPI
  310. int event_code = ev->param[0];
  311. unsigned long task = ev->param[1];
  312. long long int value = ev->param[2];
  313. //char *prefix = options->file_prefix;
  314. if (papi_file)
  315. {
  316. char event_str[PAPI_MAX_STR_LEN];
  317. PAPI_event_code_to_name(event_code, event_str);
  318. fprintf(papi_file, "JobId: %lu\n", task);
  319. fprintf(papi_file, "Event: %s\n", event_str);
  320. fprintf(papi_file, "Value: %lld\n", value);
  321. fprintf(papi_file, "\n");
  322. }
  323. #endif
  324. }
  325. static void data_dump(struct data_info *data)
  326. {
  327. if (!data_file)
  328. goto out;
  329. fprintf(data_file, "Handle: %lx\n", data->handle);
  330. fprintf(data_file, "HomeNode: %d\n", data->home_node);
  331. if (data->mpi_rank >= 0)
  332. fprintf(data_file, "MPIRank: %d\n", data->mpi_rank);
  333. if (data->name)
  334. {
  335. fprintf(data_file, "Name: %s\n", data->name);
  336. free(data->name);
  337. }
  338. fprintf(data_file, "Size: %lu\n", (unsigned long) data->size);
  339. if (data->max_size != -1)
  340. fprintf(data_file, "MaxSize: %lu\n", (unsigned long) data->max_size);
  341. if (data->description)
  342. {
  343. fprintf(data_file, "Description: %s\n", data->description);
  344. free(data->description);
  345. }
  346. if (data->dimensions)
  347. {
  348. unsigned i;
  349. fprintf(data_file, "Coordinates:");
  350. for (i = 0; i < data->dimensions; i++)
  351. fprintf(data_file, " %lu", data->dims[i]);
  352. fprintf(data_file, "\n");
  353. }
  354. if (data->mpi_owner >= 0)
  355. fprintf(data_file, "MPIOwner: %d\n", data->mpi_owner);
  356. if (data->mpi_tag >= 0)
  357. fprintf(data_file, "MPITag: %ld\n", data->mpi_tag);
  358. fprintf(data_file, "\n");
  359. out:
  360. HASH_DEL(data_info, data);
  361. free(data);
  362. }
  363. static void set_next_other_worker_color(int workerid)
  364. {
  365. if (workerid >= STARPU_NMAXWORKERS)
  366. return;
  367. worker_colors[workerid] = other_worker_colors[other_index++];
  368. if (other_index == OTHER_WORKER_COLORS_NB) other_index = 0;
  369. }
  370. static void set_next_cpu_worker_color(int workerid)
  371. {
  372. if (workerid >= STARPU_NMAXWORKERS)
  373. return;
  374. worker_colors[workerid] = cpus_worker_colors[cpus_index++];
  375. if (cpus_index == CPUS_WORKER_COLORS_NB) cpus_index = 0;
  376. }
  377. static void set_next_cuda_worker_color(int workerid)
  378. {
  379. if (workerid >= STARPU_NMAXWORKERS)
  380. return;
  381. worker_colors[workerid] = cuda_worker_colors[cuda_index++];
  382. if (cuda_index == CUDA_WORKER_COLORS_NB) cuda_index = 0;
  383. }
  384. static void set_next_opencl_worker_color(int workerid)
  385. {
  386. if (workerid >= STARPU_NMAXWORKERS)
  387. return;
  388. worker_colors[workerid] = opencl_worker_colors[opencl_index++];
  389. if (opencl_index == OPENCL_WORKER_COLORS_NB) opencl_index = 0;
  390. }
  391. static void set_next_mic_worker_color(int workerid)
  392. {
  393. if (workerid >= STARPU_NMAXWORKERS)
  394. return;
  395. worker_colors[workerid] = mic_worker_colors[mic_index++];
  396. if (mic_index == MIC_WORKER_COLORS_NB) mic_index = 0;
  397. }
  398. static void set_next_mpi_ms_worker_color(int workerid)
  399. {
  400. if (workerid >= STARPU_NMAXWORKERS)
  401. return;
  402. worker_colors[workerid] = mpi_ms_worker_colors[mpi_ms_index++];
  403. if (mpi_ms_index == MPI_MS_WORKER_COLORS_NB) mpi_ms_index = 0;
  404. }
  405. static const char *get_worker_color(int workerid)
  406. {
  407. if (workerid >= STARPU_NMAXWORKERS)
  408. workerid = STARPU_NMAXWORKERS - 1;
  409. return worker_colors[workerid];
  410. }
  411. static unsigned get_colour_symbol_red(char *name)
  412. {
  413. /* choose some colour ... that's disguting yes */
  414. uint32_t hash_symbol = starpu_hash_crc32c_string(name, 0);
  415. return (unsigned)starpu_hash_crc32c_string("red", hash_symbol) % 1024;
  416. }
  417. static unsigned get_colour_symbol_green(char *name)
  418. {
  419. /* choose some colour ... that's disguting yes */
  420. uint32_t hash_symbol = starpu_hash_crc32c_string(name, 0);
  421. return (unsigned)starpu_hash_crc32c_string("green", hash_symbol) % 1024;
  422. }
  423. static unsigned get_colour_symbol_blue(char *name)
  424. {
  425. /* choose some colour ... that's disguting yes */
  426. uint32_t hash_symbol = starpu_hash_crc32c_string(name, 0);
  427. return (unsigned)starpu_hash_crc32c_string("blue", hash_symbol) % 1024;
  428. }
  429. /* Start time of last codelet for this worker */
  430. static double last_codelet_start[STARPU_NMAXWORKERS];
  431. /* End time of last codelet for this worker */
  432. static double last_codelet_end[STARPU_NMAXWORKERS];
  433. /* _STARPU_FUT_DO_PROBE5STR records only 3 longs */
  434. char _starpu_last_codelet_symbol[STARPU_NMAXWORKERS][(FXT_MAX_PARAMS-5)*sizeof(unsigned long)];
  435. static int last_codelet_parameter[STARPU_NMAXWORKERS];
  436. #define MAX_PARAMETERS 8
  437. static char last_codelet_parameter_description[STARPU_NMAXWORKERS][MAX_PARAMETERS][FXT_MAX_PARAMS*sizeof(unsigned long)];
  438. /* If more than a period of time has elapsed, we flush the profiling info,
  439. * otherwise they are accumulated everytime there is a new relevant event. */
  440. #define ACTIVITY_PERIOD 75.0
  441. static double last_activity_flush_timestamp[STARPU_NMAXWORKERS];
  442. static double accumulated_sleep_time[STARPU_NMAXWORKERS];
  443. static double accumulated_exec_time[STARPU_NMAXWORKERS];
  444. static unsigned steal_number = 0;
  445. LIST_TYPE(_starpu_symbol_name,
  446. char *name;
  447. )
  448. static struct _starpu_symbol_name_list symbol_list;
  449. /* List of on-going communications */
  450. LIST_TYPE(_starpu_communication,
  451. unsigned comid;
  452. double comm_start;
  453. double bandwidth;
  454. unsigned src_node;
  455. unsigned dst_node;
  456. unsigned long size;
  457. const char *type;
  458. unsigned long handle;
  459. struct _starpu_communication *peer;
  460. )
  461. static struct _starpu_communication_list communication_list;
  462. static double current_bandwidth_in_per_node[STARPU_MAXNODES] = {0.0};
  463. static double current_bandwidth_out_per_node[STARPU_MAXNODES] = {0.0};
  464. /* List of on-going computations */
  465. LIST_TYPE(_starpu_computation,
  466. double comp_start;
  467. double gflops;
  468. struct _starpu_computation *peer;
  469. )
  470. /* List of ongoing computations */
  471. static struct _starpu_computation_list computation_list;
  472. /* Last computation for each worker */
  473. static struct _starpu_computation *ongoing_computation[STARPU_NMAXWORKERS];
  474. /* Current total GFlops */
  475. static double current_computation;
  476. /* Time of last update of current total GFlops */
  477. static double current_computation_time;
  478. /*
  479. * Generic tools
  480. */
  481. #define WORKER_STATE (1 << 0)
  482. #define THREAD_STATE (1 << 1)
  483. #define COMM_THREAD_STATE (1 << 2)
  484. #define USER_THREAD_STATE (1 << 3)
  485. static struct
  486. {
  487. const char *short_name;
  488. const char *long_name;
  489. uint8_t flags;
  490. } states_list[] =
  491. {
  492. { "Fi", "FetchingInput", WORKER_STATE | THREAD_STATE },
  493. { "Po", "PushingOutput", WORKER_STATE | THREAD_STATE },
  494. { "P", "Progressing", WORKER_STATE | THREAD_STATE },
  495. { "U", "Unpartitioning", WORKER_STATE | THREAD_STATE },
  496. { "B", "Overhead", WORKER_STATE | THREAD_STATE },
  497. { "In", "Initializing", WORKER_STATE | THREAD_STATE },
  498. { "D", "Deinitializing", WORKER_STATE | THREAD_STATE },
  499. { "E", "Executing", WORKER_STATE | THREAD_STATE },
  500. { "C", "Callback", WORKER_STATE | THREAD_STATE | USER_THREAD_STATE },
  501. { "H", "Hypervisor", WORKER_STATE | THREAD_STATE },
  502. { "Sc", "Scheduling", WORKER_STATE | THREAD_STATE },
  503. { "I", "Idle", WORKER_STATE | THREAD_STATE },
  504. { "Sl", "Sleeping", WORKER_STATE | THREAD_STATE | COMM_THREAD_STATE },
  505. { "Bu", "Building task", THREAD_STATE | COMM_THREAD_STATE | USER_THREAD_STATE },
  506. { "Su", "Submitting task", THREAD_STATE | COMM_THREAD_STATE | USER_THREAD_STATE },
  507. { "Th", "Throttling task submission", THREAD_STATE | COMM_THREAD_STATE | USER_THREAD_STATE },
  508. { "MD", "Decoding task for MPI", THREAD_STATE | USER_THREAD_STATE },
  509. { "MPr", "Preparing task for MPI", THREAD_STATE | USER_THREAD_STATE },
  510. { "MPo", "Post-processing task for MPI", THREAD_STATE | USER_THREAD_STATE },
  511. { "P", "Processing", COMM_THREAD_STATE },
  512. { "UT", "UserTesting", COMM_THREAD_STATE },
  513. { "UW", "UserWaiting", COMM_THREAD_STATE },
  514. { "SdS", "SendSubmitted", COMM_THREAD_STATE },
  515. { "RvS", "ReceiveSubmitted", COMM_THREAD_STATE },
  516. { "SdC", "SendCompleted", COMM_THREAD_STATE },
  517. { "RvC", "ReceiveCompleted", COMM_THREAD_STATE },
  518. { "W", "Waiting task", THREAD_STATE | USER_THREAD_STATE },
  519. { "WA", "Waiting all tasks", THREAD_STATE | USER_THREAD_STATE },
  520. { "No", "Nothing", THREAD_STATE | USER_THREAD_STATE },
  521. };
  522. static const char *get_state_name(const char *short_name, uint32_t states)
  523. {
  524. unsigned i;
  525. for (i = 0; i < sizeof(states_list) / sizeof(states_list[0]); i++)
  526. if ((states_list[i].flags & states) &&
  527. !strcmp(states_list[i].short_name, short_name))
  528. return states_list[i].long_name;
  529. return short_name;
  530. }
  531. static double get_event_time_stamp(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  532. {
  533. return (((double)(ev->time-options->file_offset))/1000000.0);
  534. }
  535. /*
  536. * Auxiliary functions for poti handling names
  537. */
  538. #ifdef STARPU_HAVE_POTI
  539. static char *memnode_container_alias(char *output, int len, const char *prefix, long unsigned int memnodeid)
  540. {
  541. snprintf(output, len, "%smn%lu", prefix, memnodeid);
  542. return output;
  543. }
  544. static char *memmanager_container_alias(char *output, int len, const char *prefix, long unsigned int memnodeid)
  545. {
  546. snprintf(output, len, "%smm%lu", prefix, memnodeid);
  547. return output;
  548. }
  549. static char *thread_container_alias(char *output, int len, const char *prefix, long unsigned int threadid)
  550. {
  551. snprintf(output, len, "%st%lu", prefix, threadid);
  552. return output;
  553. }
  554. static char *worker_container_alias(char *output, int len, const char *prefix, long unsigned int workerid)
  555. {
  556. snprintf(output, len, "%sw%lu", prefix, workerid);
  557. return output;
  558. }
  559. static char *mpicommthread_container_alias(char *output, int len, const char *prefix)
  560. {
  561. snprintf(output, len, "%smpict", prefix);
  562. return output;
  563. }
  564. static char *program_container_alias(char *output, int len, const char *prefix)
  565. {
  566. snprintf(output, len, "%sp", prefix);
  567. return output;
  568. }
  569. static char *scheduler_container_alias(char *output, int len, const char *prefix)
  570. {
  571. snprintf(output, len, "%ssched", prefix);
  572. return output;
  573. }
  574. #endif
  575. static int nworkers = 0;
  576. struct worker_entry
  577. {
  578. UT_hash_handle hh;
  579. unsigned long tid;
  580. int workerid;
  581. int sync; /* Set only for workers which are part of the same set, i.e. on thread drivers several workers */
  582. } *worker_ids;
  583. static int register_thread(unsigned long nodeid, unsigned long tid, int workerid, int sync)
  584. {
  585. struct worker_entry *entry = NULL;
  586. tid = nodeid*tid+tid;
  587. HASH_FIND(hh, worker_ids, &tid, sizeof(tid), entry);
  588. /* only register a thread once */
  589. if (entry)
  590. return 0;
  591. _STARPU_MALLOC(entry, sizeof(*entry));
  592. entry->tid = tid;
  593. entry->workerid = workerid;
  594. entry->sync = sync;
  595. HASH_ADD(hh, worker_ids, tid, sizeof(tid), entry);
  596. return 1;
  597. }
  598. static int register_worker_id(unsigned long nodeid, unsigned long tid, int workerid, int sync)
  599. {
  600. nworkers++;
  601. STARPU_ASSERT_MSG(workerid < STARPU_NMAXWORKERS, "Too many workers in this trace, please increase in ./configure invocation the maximum number of CPUs and GPUs to the same value as was used for execution");
  602. return register_thread(nodeid, tid, workerid, sync);
  603. }
  604. static int prefixTOnodeid (const char *prefix)
  605. {
  606. //if we are a single-node trace, prefix is empty, so return 0
  607. if (strcmp(prefix, "")==0) return 0;
  608. char *str;
  609. _STARPU_MALLOC(str, sizeof(char)*strlen(prefix));
  610. strncpy (str, prefix, strlen(prefix));
  611. str[strlen(prefix)-1] = '\0';
  612. unsigned long nodeid = atoi(str);
  613. free(str);
  614. return nodeid;
  615. }
  616. /* Register user threads if not done already */
  617. static void register_user_thread(double timestamp, unsigned long tid, const char *prefix)
  618. {
  619. if (register_thread(prefixTOnodeid(prefix), tid, -1, 0) && out_paje_file)
  620. {
  621. #ifdef STARPU_HAVE_POTI
  622. char program_container[STARPU_POTI_STR_LEN];
  623. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  624. char new_thread_container_alias[STARPU_POTI_STR_LEN];
  625. thread_container_alias (new_thread_container_alias, STARPU_POTI_STR_LEN, prefix, tid);
  626. char new_thread_container_name[STARPU_POTI_STR_LEN];
  627. snprintf(new_thread_container_name, sizeof(new_thread_container_name), "%sUserThread%lu", prefix, tid);
  628. poti_CreateContainer(timestamp, new_thread_container_alias, "UT", program_container, new_thread_container_alias);
  629. #else
  630. fprintf(out_paje_file, "7 %.9f %st%lu UT %sp %sUserThread%lu\n",
  631. timestamp, prefix, tid, prefix, prefix, tid);
  632. #endif
  633. }
  634. }
  635. static void register_mpi_thread(unsigned long nodeid, unsigned long tid)
  636. {
  637. int ret = register_thread(nodeid, tid, -2, 0);
  638. STARPU_ASSERT(ret == 1);
  639. }
  640. static int find_worker_id(unsigned long nodeid, unsigned long tid)
  641. {
  642. struct worker_entry *entry;
  643. tid = nodeid*tid+tid;
  644. HASH_FIND(hh, worker_ids, &tid, sizeof(tid), entry);
  645. if (!entry)
  646. return -1;
  647. return entry->workerid;
  648. }
  649. /* check whether this thread manages several workers */
  650. static int find_sync(unsigned long nodeid, unsigned long tid)
  651. {
  652. struct worker_entry *entry;
  653. tid = nodeid*tid+tid;
  654. HASH_FIND(hh, worker_ids, &tid, sizeof(tid), entry);
  655. if (!entry)
  656. return 0;
  657. return entry->sync;
  658. }
  659. static void update_accumulated_time(int worker, double sleep_time, double exec_time, double current_timestamp, int forceflush)
  660. {
  661. accumulated_sleep_time[worker] += sleep_time;
  662. accumulated_exec_time[worker] += exec_time;
  663. /* If sufficient time has elapsed since the last flush, we have a new
  664. * point in our graph */
  665. double elapsed = current_timestamp - last_activity_flush_timestamp[worker];
  666. if (forceflush || (elapsed > ACTIVITY_PERIOD))
  667. {
  668. if (activity_file)
  669. fprintf(activity_file, "%d\t%.9f\t%.9f\t%.9f\t%.9f\n", worker, current_timestamp, elapsed, accumulated_exec_time[worker], accumulated_sleep_time[worker]);
  670. /* reset the accumulated times */
  671. last_activity_flush_timestamp[worker] = current_timestamp;
  672. accumulated_sleep_time[worker] = 0.0;
  673. accumulated_exec_time[worker] = 0.0;
  674. }
  675. }
  676. static void memnode_set_state(double time, const char *prefix, unsigned int memnodeid, const char *name)
  677. {
  678. #ifdef STARPU_HAVE_POTI
  679. char container[STARPU_POTI_STR_LEN];
  680. memmanager_container_alias(container, STARPU_POTI_STR_LEN, prefix, memnodeid);
  681. poti_SetState(time, container, "MS", name);
  682. #else
  683. fprintf(out_paje_file, "10 %.9f %smm%u MS %s\n", time, prefix, memnodeid, name);
  684. #endif
  685. }
  686. static void memnode_push_state(double time, const char *prefix, unsigned int memnodeid, const char *name)
  687. {
  688. #ifdef STARPU_HAVE_POTI
  689. char container[STARPU_POTI_STR_LEN];
  690. memmanager_container_alias(container, STARPU_POTI_STR_LEN, prefix, memnodeid);
  691. poti_PushState(time, container, "MS", name);
  692. #else
  693. fprintf(out_paje_file, "11 %.9f %smm%u MS %s\n", time, prefix, memnodeid, name);
  694. #endif
  695. }
  696. static void memnode_pop_state(double time, const char *prefix, unsigned int memnodeid)
  697. {
  698. #ifdef STARPU_HAVE_POTI
  699. char container[STARPU_POTI_STR_LEN];
  700. memmanager_container_alias(container, STARPU_POTI_STR_LEN, prefix, memnodeid);
  701. poti_PopState(time, container, "MS");
  702. #else
  703. fprintf(out_paje_file, "12 %.9f %smm%u MS\n", time, prefix, memnodeid);
  704. #endif
  705. }
  706. static void memnode_event(double time, const char *prefix, unsigned int memnodeid, const char *name, unsigned long handle, unsigned long info, unsigned long size, unsigned int dest, struct starpu_fxt_options *options)
  707. {
  708. if (!options->memory_states)
  709. return;
  710. #ifdef STARPU_HAVE_POTI
  711. char container[STARPU_POTI_STR_LEN];
  712. char p_handle[STARPU_POTI_STR_LEN];
  713. memmanager_container_alias(container, STARPU_POTI_STR_LEN, prefix, memnodeid);
  714. snprintf(p_handle, sizeof(p_handle), "%lx", handle);
  715. #ifdef HAVE_POTI_USER_NEWEVENT
  716. char p_dest[STARPU_POTI_STR_LEN];
  717. char p_info[STARPU_POTI_STR_LEN];
  718. char p_size[STARPU_POTI_STR_LEN];
  719. memmanager_container_alias(p_dest, STARPU_POTI_STR_LEN, prefix, dest);
  720. snprintf(p_info, sizeof(p_info), "%lu", info);
  721. snprintf(p_size, sizeof(p_size), "%lu", size);
  722. poti_user_NewEvent(_starpu_poti_MemoryEvent, time, container, name, "0", 4,
  723. p_handle, p_info, p_size, p_dest);
  724. #else
  725. poti_NewEvent(time, container, name, p_handle);
  726. #endif
  727. #else
  728. fprintf(out_paje_file, "22 %.9f %s %smm%u 0 %lx %lu %lu %smm%u\n", time, name, prefix, memnodeid, handle, info, size, prefix, dest);
  729. #endif
  730. }
  731. static void worker_set_state(double time, const char *prefix, long unsigned int workerid, const char *name)
  732. {
  733. if (fut_keymask == FUT_KEYMASK0)
  734. return;
  735. if (!out_paje_file)
  736. return;
  737. #ifdef STARPU_HAVE_POTI
  738. char container[STARPU_POTI_STR_LEN];
  739. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
  740. poti_SetState(time, container, "WS", name);
  741. #else
  742. fprintf(out_paje_file, "10 %.9f %sw%lu WS \"%s\"\n", time, prefix, workerid, name);
  743. #endif
  744. }
  745. static void worker_push_state(double time, const char *prefix, long unsigned int workerid, const char *name)
  746. {
  747. if (fut_keymask == FUT_KEYMASK0)
  748. return;
  749. if (!out_paje_file)
  750. return;
  751. #ifdef STARPU_HAVE_POTI
  752. char container[STARPU_POTI_STR_LEN];
  753. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
  754. poti_PushState(time, container, "WS", name);
  755. #else
  756. fprintf(out_paje_file, "11 %.9f %sw%lu WS %s\n", time, prefix, workerid, name);
  757. #endif
  758. }
  759. static void worker_pop_state(double time, const char *prefix, long unsigned int workerid)
  760. {
  761. if (fut_keymask == FUT_KEYMASK0)
  762. return;
  763. if (!out_paje_file)
  764. return;
  765. #ifdef STARPU_HAVE_POTI
  766. char container[STARPU_POTI_STR_LEN];
  767. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
  768. poti_PopState(time, container, "WS");
  769. #else
  770. fprintf(out_paje_file, "12 %.9f %sw%lu WS\n", time, prefix, workerid);
  771. #endif
  772. }
  773. static void thread_set_state(double time, const char *prefix, long unsigned int threadid, const char *name)
  774. {
  775. if (find_sync(prefixTOnodeid(prefix), threadid))
  776. /* Unless using worker sets, collapse thread and worker */
  777. return worker_set_state(time, prefix, find_worker_id(prefixTOnodeid(prefix), threadid), name);
  778. if (!out_paje_file)
  779. return;
  780. #ifdef STARPU_HAVE_POTI
  781. char container[STARPU_POTI_STR_LEN];
  782. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  783. poti_SetState(time, container, "S", name);
  784. #else
  785. fprintf(out_paje_file, "10 %.9f %st%lu S %s\n", time, prefix, threadid, name);
  786. #endif
  787. }
  788. #if 0
  789. /* currently unused */
  790. static void user_thread_set_state(double time, const char *prefix, long unsigned int threadid, const char *name)
  791. {
  792. register_user_thread(time, threadid, prefix);
  793. if (!out_paje_file)
  794. return;
  795. #ifdef STARPU_HAVE_POTI
  796. char container[STARPU_POTI_STR_LEN];
  797. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  798. poti_SetState(time, container, "US", name);
  799. #else
  800. fprintf(out_paje_file, "10 %.9f %st%lu US %s\n", time, prefix, threadid, name);
  801. #endif
  802. }
  803. #endif
  804. static void user_thread_push_state(double time, const char *prefix, long unsigned int threadid, const char *name)
  805. {
  806. register_user_thread(time, threadid, prefix);
  807. if (out_paje_file)
  808. {
  809. #ifdef STARPU_HAVE_POTI
  810. char container[STARPU_POTI_STR_LEN];
  811. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  812. poti_PushState(time, container, "US", name);
  813. #else
  814. fprintf(out_paje_file, "11 %.9f %st%lu US %s\n", time, prefix, threadid, name);
  815. #endif
  816. }
  817. }
  818. static void user_thread_pop_state(double time, const char *prefix, long unsigned int threadid)
  819. {
  820. register_user_thread(time, threadid, prefix);
  821. if (out_paje_file)
  822. {
  823. #ifdef STARPU_HAVE_POTI
  824. char container[STARPU_POTI_STR_LEN];
  825. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  826. poti_PopState(time, container, "US");
  827. #else
  828. fprintf(out_paje_file, "12 %.9f %st%lu US\n", time, prefix, threadid);
  829. #endif
  830. }
  831. }
  832. static void thread_push_state(double time, const char *prefix, long unsigned int threadid, const char *name)
  833. {
  834. if (find_sync(prefixTOnodeid(prefix), threadid))
  835. /* Unless using worker sets, collapse thread and worker */
  836. return worker_push_state(time, prefix, find_worker_id(prefixTOnodeid(prefix), threadid), name);
  837. if (!out_paje_file)
  838. return;
  839. #ifdef STARPU_HAVE_POTI
  840. char container[STARPU_POTI_STR_LEN];
  841. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  842. poti_PushState(time, container, "S", name);
  843. #else
  844. fprintf(out_paje_file, "11 %.9f %st%lu S %s\n", time, prefix, threadid, name);
  845. #endif
  846. }
  847. static void thread_pop_state(double time, const char *prefix, long unsigned int threadid)
  848. {
  849. if (find_sync(prefixTOnodeid(prefix), threadid))
  850. /* Unless using worker sets, collapse thread and worker */
  851. return worker_pop_state(time, prefix, find_worker_id(prefixTOnodeid(prefix), threadid));
  852. if (!out_paje_file)
  853. return;
  854. #ifdef STARPU_HAVE_POTI
  855. char container[STARPU_POTI_STR_LEN];
  856. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  857. poti_PopState(time, container, "S");
  858. #else
  859. fprintf(out_paje_file, "12 %.9f %st%lu S\n", time, prefix, threadid);
  860. #endif
  861. }
  862. static void worker_set_detailed_state(double time, const char *prefix, long unsigned int workerid, const char *name, unsigned long size, const char *parameters, unsigned long footprint, unsigned long long tag, unsigned long job_id, double gflop, unsigned X, unsigned Y, unsigned Z STARPU_ATTRIBUTE_UNUSED, long iteration, long subiteration, struct starpu_fxt_options *options)
  863. {
  864. struct task_info *task = get_task(job_id, options->file_rank);
  865. #ifdef STARPU_HAVE_POTI
  866. char container[STARPU_POTI_STR_LEN];
  867. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
  868. char size_str[STARPU_POTI_STR_LEN];
  869. char parameters_str[STARPU_POTI_STR_LEN];
  870. char footprint_str[STARPU_POTI_STR_LEN];
  871. char tag_str[STARPU_POTI_STR_LEN];
  872. char jobid_str[STARPU_POTI_STR_LEN];
  873. char submitorder_str[STARPU_POTI_STR_LEN];
  874. char gflop_str[STARPU_POTI_STR_LEN];
  875. char X_str[STARPU_POTI_STR_LEN], Y_str[STARPU_POTI_STR_LEN], Z_str[STARPU_POTI_STR_LEN];
  876. char iteration_str[STARPU_POTI_STR_LEN], subiteration_str[STARPU_POTI_STR_LEN];
  877. snprintf(size_str, sizeof(size_str), "%lu", size);
  878. snprintf(parameters_str, sizeof(parameters_str), "%s", parameters);
  879. snprintf(footprint_str, sizeof(footprint_str), "%08lx", footprint);
  880. snprintf(tag_str, sizeof(tag_str), "%016llx", tag);
  881. snprintf(jobid_str, sizeof(jobid_str), "%s%lu", prefix, job_id);
  882. snprintf(submitorder_str, sizeof(submitorder_str), "%s%lu", prefix, task->submit_order);
  883. snprintf(gflop_str, sizeof(gflop_str), "%f", gflop);
  884. snprintf(X_str, sizeof(X_str), "%u", X);
  885. snprintf(Y_str, sizeof(Y_str), "%u", Y);
  886. snprintf(Z_str, sizeof(Z_str), "%u", Z);
  887. snprintf(iteration_str, sizeof(iteration_str), "%ld", iteration);
  888. snprintf(subiteration_str, sizeof(subiteration_str), "%ld", subiteration);
  889. #ifdef HAVE_POTI_INIT_CUSTOM
  890. poti_user_SetState(_starpu_poti_extendedSetState, time, container, "WS", name, 11, size_str,
  891. parameters_str,
  892. footprint_str,
  893. tag_str,
  894. jobid_str,
  895. submitorder_str,
  896. gflop_str,
  897. X_str,
  898. Y_str,
  899. /* Z_str, */
  900. iteration_str,
  901. subiteration_str);
  902. #else
  903. poti_SetState(time, container, "WS", name);
  904. #endif
  905. #else
  906. fprintf(out_paje_file, "20 %.9f %sw%lu WS %s %lu %s %08lx %016llx %s%lu %s%lu %f %u %u "/*"%u "*/"%ld %ld\n", time, prefix, workerid, name, size, parameters, footprint, tag, prefix, job_id, prefix, task->submit_order, gflop, X, Y, /*Z,*/ iteration, subiteration);
  907. #endif
  908. }
  909. static void mpicommthread_set_state(double time, const char *prefix, const char *name)
  910. {
  911. #ifdef STARPU_HAVE_POTI
  912. char container[STARPU_POTI_STR_LEN];
  913. mpicommthread_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  914. poti_SetState(time, container, "CtS", name);
  915. #else
  916. fprintf(out_paje_file, "10 %.9f %smpict CtS %s\n", time, prefix, name);
  917. #endif
  918. }
  919. static void mpicommthread_push_state(double time, const char *prefix, const char *name)
  920. {
  921. #ifdef STARPU_HAVE_POTI
  922. char container[STARPU_POTI_STR_LEN];
  923. mpicommthread_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  924. poti_PushState(time, container, "CtS", name);
  925. #else
  926. fprintf(out_paje_file, "11 %.9f %smpict CtS %s\n", time, prefix, name);
  927. #endif
  928. }
  929. static void mpicommthread_pop_state(double time, const char *prefix)
  930. {
  931. #ifdef STARPU_HAVE_POTI
  932. char container[STARPU_POTI_STR_LEN];
  933. mpicommthread_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  934. poti_PopState(time, container, "CtS");
  935. #else
  936. fprintf(out_paje_file, "12 %.9f %smpict CtS\n", time, prefix);
  937. #endif
  938. }
  939. static void recfmt_dump_state(double time, const char *event, int workerid, long int threadid, const char *name, const char *type)
  940. {
  941. fprintf(trace_file, "E: %s\n", event);
  942. if (name)
  943. fprintf(trace_file, "N: %s\n", name);
  944. if (type)
  945. fprintf(trace_file, "C: %s\n", type);
  946. fprintf(trace_file, "W: %d\n", workerid);
  947. if (threadid == -1)
  948. fprintf(trace_file, "T: -1\n");
  949. else
  950. fprintf(trace_file, "T: %ld\n", threadid);
  951. fprintf(trace_file, "S: %f\n", time);
  952. fprintf(trace_file, "\n");
  953. }
  954. static void recfmt_set_state(double time, int workerid, long int threadid, const char *name, const char *type)
  955. {
  956. recfmt_dump_state(time, "SetState", workerid, threadid, name, type);
  957. }
  958. static void recfmt_push_state(double time, int workerid, long unsigned int threadid, const char *name, const char *type)
  959. {
  960. recfmt_dump_state(time, "PushState", workerid, threadid, name, type);
  961. }
  962. static void recfmt_pop_state(double time, int workerid, long unsigned int threadid)
  963. {
  964. recfmt_dump_state(time, "PopState", workerid, threadid, NULL, NULL);
  965. }
  966. static void recfmt_worker_set_state(double time, int workerid, const char *name, const char *type)
  967. {
  968. const char *state_name;
  969. /* Special case for task events. */
  970. if (!strcmp(type, "Task"))
  971. state_name = name;
  972. else
  973. state_name = get_state_name(name, WORKER_STATE);
  974. recfmt_set_state(time, workerid, -1, state_name, type);
  975. }
  976. static void recfmt_thread_set_state(double time, unsigned long nodeid, long unsigned int threadid, const char *name, const char *type)
  977. {
  978. const char *state_name;
  979. /* Special case for the end event which is somehow a fake. */
  980. if (!strcmp(name, "End") && !type)
  981. state_name = name;
  982. else
  983. state_name = get_state_name(name, THREAD_STATE);
  984. recfmt_set_state(time, find_worker_id(nodeid, threadid), threadid, state_name, type);
  985. }
  986. static void recfmt_thread_push_state(double time, unsigned long nodeid, long unsigned int threadid, const char *name, const char *type)
  987. {
  988. const char *state_name = get_state_name(name, THREAD_STATE);
  989. recfmt_push_state(time, find_worker_id(nodeid, threadid), threadid, state_name, type);
  990. }
  991. static void recfmt_thread_pop_state(double time, unsigned long nodeid, long unsigned int threadid)
  992. {
  993. recfmt_pop_state(time, find_worker_id(nodeid, threadid), threadid);
  994. }
  995. static void recfmt_mpicommthread_set_state(double time, const char *name)
  996. {
  997. const char *state_name = get_state_name(name, COMM_THREAD_STATE);
  998. recfmt_set_state(time, -1, 0, state_name, "MPI"); /* XXX */
  999. }
  1000. static void recfmt_mpicommthread_push_state(double time, const char *name)
  1001. {
  1002. const char *state_name = get_state_name(name, COMM_THREAD_STATE);
  1003. recfmt_push_state(time, -1, 0, state_name, "MPI"); /* XXX */
  1004. }
  1005. static void recfmt_mpicommthread_pop_state(double time)
  1006. {
  1007. recfmt_pop_state(time, -1, 0);
  1008. }
  1009. static void recfmt_user_thread_push_state(double time, long unsigned threadid, const char *name, const char *type)
  1010. {
  1011. const char *state_name = get_state_name(name, USER_THREAD_STATE);
  1012. recfmt_push_state(time, -1, threadid, state_name, type);
  1013. }
  1014. static void recfmt_user_thread_pop_state(double time, long unsigned threadid)
  1015. {
  1016. recfmt_pop_state(time, -1, threadid);
  1017. }
  1018. /*
  1019. * Initialization
  1020. */
  1021. static void handle_new_mem_node(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1022. {
  1023. char *prefix = options->file_prefix;
  1024. if (out_paje_file)
  1025. {
  1026. double now = get_event_time_stamp(ev, options);
  1027. #ifdef STARPU_HAVE_POTI
  1028. char program_container[STARPU_POTI_STR_LEN];
  1029. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  1030. char new_memnode_container_alias[STARPU_POTI_STR_LEN], new_memnode_container_name[STARPU_POTI_STR_LEN];
  1031. char new_memmanager_container_alias[STARPU_POTI_STR_LEN], new_memmanager_container_name[STARPU_POTI_STR_LEN];
  1032. memnode_container_alias (new_memnode_container_alias, STARPU_POTI_STR_LEN, prefix, ev->param[0]);
  1033. /* TODO: ramkind */
  1034. snprintf(new_memnode_container_name, sizeof(new_memnode_container_name), "%sMEMNODE%"PRIu64"", prefix, ev->param[0]);
  1035. poti_CreateContainer(now, new_memnode_container_alias, "Mn", program_container, new_memnode_container_name);
  1036. memmanager_container_alias (new_memmanager_container_alias, STARPU_POTI_STR_LEN, prefix, ev->param[0]);
  1037. /* TODO: ramkind */
  1038. snprintf(new_memmanager_container_name, sizeof(new_memmanager_container_name), "%sMEMMANAGER%"PRIu64"", prefix, ev->param[0]);
  1039. poti_CreateContainer(now, new_memmanager_container_alias, "Mm", new_memnode_container_alias, new_memmanager_container_name);
  1040. #else
  1041. fprintf(out_paje_file, "7 %.9f %smn%"PRIu64" Mn %sp %sMEMNODE%"PRIu64"\n", now, prefix, ev->param[0], prefix, options->file_prefix, ev->param[0]);
  1042. fprintf(out_paje_file, "7 %.9f %smm%"PRIu64" Mm %smn%"PRIu64" %sMEMMANAGER%"PRIu64"\n", now, prefix, ev->param[0], prefix, ev->param[0], options->file_prefix, ev->param[0]);
  1043. #endif
  1044. if (!options->no_bus)
  1045. {
  1046. #ifdef STARPU_HAVE_POTI
  1047. poti_SetVariable(now, new_memmanager_container_alias, "use", 0.0);
  1048. poti_SetVariable(now, new_memmanager_container_alias, "bwi_mm", 0.0);
  1049. poti_SetVariable(now, new_memmanager_container_alias, "bwo_mm", 0.0);
  1050. #else
  1051. fprintf(out_paje_file, "13 %.9f %smm%"PRIu64" use 0.0\n", now, prefix, ev->param[0]);
  1052. fprintf(out_paje_file, "13 %.9f %smm%"PRIu64" bwi_mm 0.0\n", now, prefix, ev->param[0]);
  1053. fprintf(out_paje_file, "13 %.9f %smm%"PRIu64" bwo_mm 0.0\n", now, prefix, ev->param[0]);
  1054. #endif
  1055. }
  1056. }
  1057. }
  1058. /*
  1059. * Function that creates a synthetic stream id based on the order they appear from the trace
  1060. */
  1061. static int create_ordered_stream_id (int nodeid, int devid)
  1062. {
  1063. static int stable[STARPU_FXT_MAX_FILES][STARPU_MAXCUDADEVS];
  1064. STARPU_ASSERT(nodeid < STARPU_FXT_MAX_FILES);
  1065. STARPU_ASSERT(devid < STARPU_MAXCUDADEVS);
  1066. return stable[nodeid][devid]++;
  1067. }
  1068. static void handle_worker_init_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1069. {
  1070. /*
  1071. arg0 : type of worker (cuda, cpu ..)
  1072. arg1 : memory node
  1073. arg2 : thread id
  1074. */
  1075. char *prefix = options->file_prefix;
  1076. int devid = ev->param[2];
  1077. int workerid = ev->param[1];
  1078. int nodeid = ev->param[3];
  1079. int bindid = ev->param[4];
  1080. int set = ev->param[5];
  1081. long unsigned int threadid = ev->param[6];
  1082. int new_thread;
  1083. new_thread = register_worker_id(prefixTOnodeid(prefix), threadid, workerid, set);
  1084. char *kindstr = "";
  1085. struct starpu_perfmodel_arch arch;
  1086. arch.ndevices = 1;
  1087. _STARPU_MALLOC(arch.devices, sizeof(struct starpu_perfmodel_device));
  1088. switch (ev->param[0])
  1089. {
  1090. case _STARPU_FUT_APPS_KEY:
  1091. set_next_other_worker_color(workerid);
  1092. kindstr = "APPS";
  1093. break;
  1094. case _STARPU_FUT_CPU_KEY:
  1095. set_next_cpu_worker_color(workerid);
  1096. kindstr = "CPU";
  1097. arch.devices[0].type = STARPU_CPU_WORKER;
  1098. arch.devices[0].devid = 0;
  1099. arch.devices[0].ncores = 1;
  1100. break;
  1101. case _STARPU_FUT_CUDA_KEY:
  1102. set_next_cuda_worker_color(workerid);
  1103. kindstr = "CUDA";
  1104. arch.devices[0].type = STARPU_CUDA_WORKER;
  1105. arch.devices[0].devid = devid;
  1106. arch.devices[0].ncores = 1;
  1107. break;
  1108. case _STARPU_FUT_OPENCL_KEY:
  1109. set_next_opencl_worker_color(workerid);
  1110. kindstr = "OPENCL";
  1111. arch.devices[0].type = STARPU_OPENCL_WORKER;
  1112. arch.devices[0].devid = devid;
  1113. arch.devices[0].ncores = 1;
  1114. break;
  1115. case _STARPU_FUT_MIC_KEY:
  1116. set_next_mic_worker_color(workerid);
  1117. kindstr = "mic";
  1118. arch.devices[0].type = STARPU_MIC_WORKER;
  1119. arch.devices[0].devid = devid;
  1120. arch.devices[0].ncores = 1;
  1121. break;
  1122. case _STARPU_FUT_MPI_KEY:
  1123. set_next_mpi_ms_worker_color(workerid);
  1124. kindstr = "mpi_ms";
  1125. arch.devices[0].type = STARPU_MPI_MS_WORKER;
  1126. arch.devices[0].devid = devid;
  1127. arch.devices[0].ncores = 1;
  1128. break;
  1129. default:
  1130. STARPU_ABORT();
  1131. }
  1132. double now = get_event_time_stamp(ev, options);
  1133. if (out_paje_file)
  1134. {
  1135. char new_worker_container_name[STARPU_TRACE_STR_LEN];
  1136. if (arch.devices[0].type == STARPU_CUDA_WORKER)
  1137. {
  1138. // If CUDA, workers might be streams, so create an unique name for each of them
  1139. int streamid = create_ordered_stream_id (prefixTOnodeid(prefix), devid);
  1140. snprintf(new_worker_container_name, sizeof(new_worker_container_name), "%s%s%d_%d", prefix, kindstr, devid, streamid);
  1141. }
  1142. else
  1143. {
  1144. // If not CUDA, we suppose worker name is the prefix, the kindstr, and the devid
  1145. snprintf(new_worker_container_name, sizeof(new_worker_container_name), "%s%s%d", prefix, kindstr, devid);
  1146. }
  1147. #ifdef STARPU_HAVE_POTI
  1148. char new_thread_container_alias[STARPU_POTI_STR_LEN];
  1149. thread_container_alias (new_thread_container_alias, STARPU_POTI_STR_LEN, prefix, threadid);
  1150. char new_worker_container_alias[STARPU_POTI_STR_LEN];
  1151. worker_container_alias (new_worker_container_alias, STARPU_POTI_STR_LEN, prefix, workerid);
  1152. char memnode_container[STARPU_POTI_STR_LEN];
  1153. memnode_container_alias(memnode_container, STARPU_POTI_STR_LEN, prefix, nodeid);
  1154. char new_thread_container_name[STARPU_POTI_STR_LEN];
  1155. snprintf(new_thread_container_name, sizeof(new_thread_container_name), "%sT%d", prefix, bindid);
  1156. if (new_thread)
  1157. poti_CreateContainer(now, new_thread_container_alias, "T", memnode_container, new_thread_container_name);
  1158. poti_CreateContainer(now, new_worker_container_alias, "W", new_thread_container_alias, new_worker_container_name);
  1159. if (!options->no_flops)
  1160. poti_SetVariable(now, new_worker_container_alias, "gf", 0.0);
  1161. #else
  1162. if (new_thread)
  1163. fprintf(out_paje_file, "7 %.9f %st%lu T %smn%d %sT%d\n",
  1164. now, prefix, threadid, prefix, nodeid, prefix, bindid);
  1165. fprintf(out_paje_file, "7 %.9f %sw%d W %st%lu %s\n",
  1166. now, prefix, workerid, prefix, threadid, new_worker_container_name);
  1167. if (!options->no_flops)
  1168. fprintf(out_paje_file, "13 %.9f %sw%d gf 0.0\n",
  1169. now, prefix, workerid);
  1170. #endif
  1171. }
  1172. /* start initialization */
  1173. thread_set_state(now, prefix, threadid, "In");
  1174. if (trace_file)
  1175. recfmt_thread_set_state(now, prefixTOnodeid(prefix), threadid, "In", "Runtime");
  1176. if (activity_file)
  1177. fprintf(activity_file, "name\t%d\t%s %d\n", workerid, kindstr, devid);
  1178. snprintf(options->worker_names[workerid], sizeof(options->worker_names[workerid])-1, "%s %d", kindstr, devid);
  1179. options->worker_names[workerid][sizeof(options->worker_names[workerid])-1] = 0;
  1180. options->worker_archtypes[workerid] = arch;
  1181. }
  1182. static void handle_worker_init_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1183. {
  1184. char *prefix = options->file_prefix;
  1185. int worker;
  1186. if (ev->nb_params < 2)
  1187. {
  1188. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1189. STARPU_ASSERT(worker >= 0);
  1190. }
  1191. else
  1192. worker = ev->param[1];
  1193. thread_set_state(get_event_time_stamp(ev, options), prefix, ev->param[0], "B");
  1194. if (trace_file)
  1195. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "B", "Runtime");
  1196. worker_set_state(get_event_time_stamp(ev, options), prefix, worker, "I");
  1197. if (trace_file)
  1198. recfmt_worker_set_state(get_event_time_stamp(ev, options), worker, "I", "Other");
  1199. /* Initilize the accumulated time counters */
  1200. last_activity_flush_timestamp[worker] = get_event_time_stamp(ev, options);
  1201. accumulated_sleep_time[worker] = 0.0;
  1202. accumulated_exec_time[worker] = 0.0;
  1203. }
  1204. static void handle_worker_deinit_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1205. {
  1206. char *prefix = options->file_prefix;
  1207. long unsigned int threadid = ev->param[0];
  1208. thread_set_state(get_event_time_stamp(ev, options), prefix, threadid, "D");
  1209. if (trace_file)
  1210. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), threadid, "D", "Runtime");
  1211. }
  1212. static void handle_worker_deinit_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1213. {
  1214. char *prefix = options->file_prefix;
  1215. if (out_paje_file)
  1216. {
  1217. #ifdef STARPU_HAVE_POTI
  1218. char worker_container[STARPU_POTI_STR_LEN];
  1219. thread_container_alias(worker_container, STARPU_POTI_STR_LEN, prefix, ev->param[1]);
  1220. poti_DestroyContainer(get_event_time_stamp(ev, options), "T", worker_container);
  1221. #else
  1222. fprintf(out_paje_file, "8 %.9f %st%"PRIu64" T\n",
  1223. get_event_time_stamp(ev, options), prefix, ev->param[1]);
  1224. #endif
  1225. }
  1226. if (trace_file)
  1227. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[1], "End", NULL);
  1228. }
  1229. #ifdef STARPU_HAVE_POTI
  1230. static void create_paje_state_color(char *name, char *type, int ctx, float red, float green, float blue)
  1231. {
  1232. char color[STARPU_POTI_STR_LEN];
  1233. char alias[STARPU_POTI_STR_LEN];
  1234. snprintf(color, sizeof(color), "%f %f %f", red, green, blue);
  1235. if (ctx)
  1236. {
  1237. snprintf(alias, sizeof(alias), "%s_%d", name, ctx);
  1238. }
  1239. else
  1240. {
  1241. snprintf(alias, sizeof(alias), "%s", name);
  1242. }
  1243. poti_DefineEntityValue(alias, type, name, color);
  1244. }
  1245. #endif
  1246. static void create_paje_state_if_not_found(char *name, unsigned color, struct starpu_fxt_options *options)
  1247. {
  1248. struct _starpu_symbol_name *itor;
  1249. for (itor = _starpu_symbol_name_list_begin(&symbol_list);
  1250. itor != _starpu_symbol_name_list_end(&symbol_list);
  1251. itor = _starpu_symbol_name_list_next(itor))
  1252. {
  1253. if (!strcmp(name, itor->name))
  1254. {
  1255. /* we found an entry */
  1256. return;
  1257. }
  1258. }
  1259. /* it's the first time ... */
  1260. struct _starpu_symbol_name *entry = _starpu_symbol_name_new();
  1261. entry->name = strdup(name);
  1262. STARPU_ASSERT(entry->name);
  1263. _starpu_symbol_name_list_push_front(&symbol_list, entry);
  1264. /* choose some colour ... that's disguting yes */
  1265. unsigned hash_symbol_red = get_colour_symbol_red(name);
  1266. unsigned hash_symbol_green = get_colour_symbol_green(name);
  1267. unsigned hash_symbol_blue = get_colour_symbol_blue(name);
  1268. uint32_t hash_sum = hash_symbol_red + hash_symbol_green + hash_symbol_blue;
  1269. float red, green, blue;
  1270. if (color != 0)
  1271. {
  1272. red = color / 0x100 / 0x100;
  1273. green = (color / 0x100) & 0xff;
  1274. blue = color & 0xff;
  1275. }
  1276. else if (options->per_task_colour)
  1277. {
  1278. red = (1.0f * hash_symbol_red) / hash_sum;
  1279. green = (1.0f * hash_symbol_green) / hash_sum;
  1280. blue = (1.0f * hash_symbol_blue) / hash_sum;
  1281. }
  1282. else
  1283. {
  1284. /* Use the hardcoded value for execution mode */
  1285. red = 0.0f;
  1286. green = 0.6f;
  1287. blue = 0.4f;
  1288. }
  1289. /* create the Paje state */
  1290. if (out_paje_file)
  1291. {
  1292. #ifdef STARPU_HAVE_POTI
  1293. create_paje_state_color(name, "WS", 0, red, green, blue);
  1294. int i;
  1295. for(i = 1; i < STARPU_NMAX_SCHED_CTXS; i++)
  1296. {
  1297. char ctx[10];
  1298. snprintf(ctx, sizeof(ctx), "Ctx%d", i);
  1299. if(i%10 == 1)
  1300. create_paje_state_color(name, ctx, i, 1.0, 0.39, 1.0);
  1301. if(i%10 == 2)
  1302. create_paje_state_color(name, ctx, i, .0, 1.0, 0.0);
  1303. if(i%10 == 3)
  1304. create_paje_state_color(name, ctx, i, 1.0, 1.0, .0);
  1305. if(i%10 == 4)
  1306. create_paje_state_color(name, ctx, i, .0, 0.95, 1.0);
  1307. if(i%10 == 5)
  1308. create_paje_state_color(name, ctx, i, .0, .0, .0);
  1309. if(i%10 == 6)
  1310. create_paje_state_color(name, ctx, i, .0, .0, 0.5);
  1311. if(i%10 == 7)
  1312. create_paje_state_color(name, ctx, i, 0.41, 0.41, 0.41);
  1313. if(i%10 == 8)
  1314. create_paje_state_color(name, ctx, i, 1.0, .0, 1.0);
  1315. if(i%10 == 9)
  1316. create_paje_state_color(name, ctx, i, .0, .0, 1.0);
  1317. if(i%10 == 0)
  1318. create_paje_state_color(name, ctx, i, 0.6, 0.80, 50.0);
  1319. }
  1320. /* create_paje_state_color(name, "Ctx1", 1.0, 0.39, 1.0); */
  1321. /* create_paje_state_color(name, "Ctx2", .0, 1.0, 0.0); */
  1322. /* create_paje_state_color(name, "Ctx3", 1.0, 1.0, .0); */
  1323. /* create_paje_state_color(name, "Ctx4", .0, 0.95, 1.0); */
  1324. /* create_paje_state_color(name, "Ctx5", .0, .0, .0); */
  1325. /* create_paje_state_color(name, "Ctx6", .0, .0, 0.5); */
  1326. /* create_paje_state_color(name, "Ctx7", 0.41, 0.41, 0.41); */
  1327. /* create_paje_state_color(name, "Ctx8", 1.0, .0, 1.0); */
  1328. /* create_paje_state_color(name, "Ctx9", .0, .0, 1.0); */
  1329. /* create_paje_state_color(name, "Ctx10", 0.6, 0.80, 0.19); */
  1330. #else
  1331. fprintf(out_paje_file, "6 %s WS %s \"%f %f %f\" \n", name, name, red, green, blue);
  1332. int i;
  1333. for(i = 1; i < STARPU_NMAX_SCHED_CTXS; i++)
  1334. {
  1335. if(i%10 == 1)
  1336. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"1.0 0.39 1.0\" \n", name, i, i, name);
  1337. if(i%10 == 2)
  1338. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 1.0 .0\" \n", name, i, i, name);
  1339. if(i%10 == 3)
  1340. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"0.87 0.87 .0\" \n", name, i, i, name);
  1341. if(i%10 == 4)
  1342. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 0.95 1.0\" \n", name, i, i, name);
  1343. if(i%10 == 5)
  1344. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 .0 .0\" \n", name, i, i, name);
  1345. if(i%10 == 6)
  1346. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 .0 0.5\" \n", name, i, i, name);
  1347. if(i%10 == 7)
  1348. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"0.41 0.41 0.41\" \n", name, i, i, name);
  1349. if(i%10 == 8)
  1350. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"1.0 .0 1.0\" \n", name, i, i, name);
  1351. if(i%10 == 9)
  1352. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 .0 1.0\" \n", name, i, i, name);
  1353. if(i%10 == 0)
  1354. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"0.6 0.80 0.19\" \n", name, i, i, name);
  1355. }
  1356. /* fprintf(out_paje_file, "6 %s Ctx1 %s \"1.0 0.39 1.0\" \n", name, name); */
  1357. /* fprintf(out_paje_file, "6 %s Ctx2 %s \".0 1.0 .0\" \n", name, name); */
  1358. /* fprintf(out_paje_file, "6 %s Ctx3 %s \"0.87 0.87 .0\" \n", name, name); */
  1359. /* fprintf(out_paje_file, "6 %s Ctx4 %s \".0 0.95 1.0\" \n", name, name); */
  1360. /* fprintf(out_paje_file, "6 %s Ctx5 %s \".0 .0 .0\" \n", name, name); */
  1361. /* fprintf(out_paje_file, "6 %s Ctx6 %s \".0 .0 0.5\" \n", name, name); */
  1362. /* fprintf(out_paje_file, "6 %s Ctx7 %s \"0.41 0.41 0.41\" \n", name, name); */
  1363. /* fprintf(out_paje_file, "6 %s Ctx8 %s \"1.0 .0 1.0\" \n", name, name); */
  1364. /* fprintf(out_paje_file, "6 %s Ctx9 %s \".0 .0 1.0\" \n", name, name); */
  1365. /* fprintf(out_paje_file, "6 %s Ctx10 %s \"0.6 0.80 0.19\" \n", name, name); */
  1366. #endif
  1367. }
  1368. }
  1369. static void handle_start_codelet_body(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1370. {
  1371. int worker = ev->param[2];
  1372. int node = ev->param[3];
  1373. if (worker < 0) return;
  1374. unsigned long has_name = ev->param[4];
  1375. char *name = has_name?get_fxt_string(ev, 5):"unknown";
  1376. snprintf(_starpu_last_codelet_symbol[worker], sizeof(_starpu_last_codelet_symbol[worker])-1, "%s", name);
  1377. _starpu_last_codelet_symbol[worker][sizeof(_starpu_last_codelet_symbol[worker])-1] = 0;
  1378. last_codelet_parameter[worker] = 0;
  1379. double start_codelet_time = get_event_time_stamp(ev, options);
  1380. double last_start_codelet_time = last_codelet_start[worker];
  1381. last_codelet_start[worker] = start_codelet_time;
  1382. struct task_info *task = get_task(ev->param[0], options->file_rank);
  1383. create_paje_state_if_not_found(name, task->color, options);
  1384. task->start_time = start_codelet_time;
  1385. task->workerid = worker;
  1386. task->name = strdup(name);
  1387. task->node = node;
  1388. if (out_paje_file)
  1389. {
  1390. char *prefix = options->file_prefix;
  1391. unsigned sched_ctx = ev->param[1];
  1392. worker_set_state(start_codelet_time, prefix, ev->param[2], name);
  1393. if (sched_ctx != 0)
  1394. {
  1395. #ifdef STARPU_HAVE_POTI
  1396. char container[STARPU_POTI_STR_LEN];
  1397. char ctx[6];
  1398. snprintf(ctx, sizeof(ctx), "Ctx%u", sched_ctx);
  1399. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, ev->param[2]);
  1400. poti_SetState(start_codelet_time, container, ctx, name);
  1401. #else
  1402. fprintf(out_paje_file, "10 %.9f %sw%"PRIu64" Ctx%d \"%s\"\n", start_codelet_time, prefix, ev->param[2], sched_ctx, name);
  1403. #endif
  1404. }
  1405. }
  1406. if (trace_file)
  1407. recfmt_worker_set_state(start_codelet_time, ev->param[2], name, "Task");
  1408. struct _starpu_computation *comp = ongoing_computation[worker];
  1409. if (!comp)
  1410. {
  1411. /* First task for this worker */
  1412. comp = ongoing_computation[worker] = _starpu_computation_new();
  1413. comp->peer = NULL;
  1414. comp->comp_start = start_codelet_time;
  1415. if (!options->no_flops)
  1416. _starpu_computation_list_push_back(&computation_list, comp);
  1417. }
  1418. else if (options->no_smooth ||
  1419. (start_codelet_time - last_codelet_end[worker]) >=
  1420. IDLE_FACTOR * (last_codelet_end[worker] - last_start_codelet_time))
  1421. {
  1422. /* Long idle period, move previously-allocated comp to now */
  1423. comp->comp_start = start_codelet_time;
  1424. if (!options->no_flops)
  1425. {
  1426. _starpu_computation_list_erase(&computation_list, comp);
  1427. _starpu_computation_list_push_back(&computation_list, comp);
  1428. }
  1429. }
  1430. }
  1431. static void handle_model_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1432. {
  1433. struct task_info *task = get_task(ev->param[0], options->file_rank);
  1434. char *name = get_fxt_string(ev, 1);
  1435. task->model_name = strdup(name);
  1436. }
  1437. static void handle_codelet_data(struct fxt_ev_64 *ev STARPU_ATTRIBUTE_UNUSED, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
  1438. {
  1439. int worker = ev->param[0];
  1440. if (worker < 0) return;
  1441. int num = last_codelet_parameter[worker]++;
  1442. if (num >= MAX_PARAMETERS)
  1443. return;
  1444. char *name = get_fxt_string(ev, 1);
  1445. snprintf(last_codelet_parameter_description[worker][num], sizeof(last_codelet_parameter_description[worker][num])-1, "%s", name);
  1446. last_codelet_parameter_description[worker][num][sizeof(last_codelet_parameter_description[worker][num])-1] = 0;
  1447. }
  1448. static void handle_codelet_data_handle(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1449. {
  1450. struct task_info *task = get_task(ev->param[0], options->file_rank);
  1451. unsigned alloc = 0;
  1452. if (task->ndata == 0)
  1453. /* Start with 8=2^3, should be plenty in most cases */
  1454. alloc = 8;
  1455. else if (task->ndata >= 8)
  1456. {
  1457. /* Allocate dependencies array by powers of two */
  1458. if (! ((task->ndata - 1) & task->ndata)) /* Is task->ndata a power of two? */
  1459. {
  1460. /* We have filled the previous power of two, get another one */
  1461. alloc = task->ndata * 2;
  1462. }
  1463. }
  1464. if (alloc)
  1465. {
  1466. _STARPU_REALLOC(task->data, sizeof(*task->data) * alloc);
  1467. }
  1468. task->data[task->ndata].handle = ev->param[1];
  1469. task->data[task->ndata].size = ev->param[2];
  1470. task->data[task->ndata].mode = ev->param[3];
  1471. task->ndata++;
  1472. }
  1473. static void handle_codelet_details(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1474. {
  1475. int worker = ev->param[5];
  1476. unsigned long job_id = ev->param[6];
  1477. if (worker < 0) return;
  1478. char parameters[256];
  1479. size_t eaten = 0;
  1480. if (!last_codelet_parameter[worker])
  1481. eaten += snprintf(parameters + eaten, sizeof(parameters) - eaten - 1, "nodata");
  1482. else
  1483. {
  1484. int i;
  1485. for (i = 0; i < last_codelet_parameter[worker] && i < MAX_PARAMETERS; i++)
  1486. {
  1487. eaten += snprintf(parameters + eaten, sizeof(parameters) - eaten - 1, "%s%s", i?" ":"", last_codelet_parameter_description[worker][i]);
  1488. }
  1489. }
  1490. parameters[sizeof(parameters)-1] = 0;
  1491. struct task_info *task = get_task(job_id, options->file_rank);
  1492. task->parameters = strdup(parameters);
  1493. task->footprint = ev->param[2];
  1494. task->kflops = ev->param[3];
  1495. task->tag = ev->param[4];
  1496. unsigned i, X = 0, Y = 0, Z = 0;
  1497. for (i = 0; i < task->ndata; i++)
  1498. {
  1499. if (task->data[i].mode & STARPU_W)
  1500. {
  1501. struct data_info *data = get_data(task->data[i].handle, options->file_rank);
  1502. if (data->dimensions >= 1)
  1503. X = data->dims[0];
  1504. if (data->dimensions >= 2)
  1505. Y = data->dims[1];
  1506. if (data->dimensions >= 3)
  1507. Z = data->dims[2];
  1508. break;
  1509. }
  1510. }
  1511. if (out_paje_file)
  1512. {
  1513. char *prefix = options->file_prefix;
  1514. unsigned sched_ctx = ev->param[0];
  1515. /* Paje won't like spaces or tabs, replace with underscores */
  1516. char *c;
  1517. for (c = parameters; *c; c++)
  1518. if ((*c == ' ') || (*c == '\t'))
  1519. *c = '_';
  1520. worker_set_detailed_state(last_codelet_start[worker], prefix, worker, _starpu_last_codelet_symbol[worker], ev->param[1], parameters, ev->param[2], ev->param[4], job_id, ((double) task->kflops) / 1000000, X, Y, Z, task->iterations[0], task->iterations[1], options);
  1521. if (sched_ctx != 0)
  1522. {
  1523. #ifdef STARPU_HAVE_POTI
  1524. char container[STARPU_POTI_STR_LEN];
  1525. char typectx[STARPU_POTI_STR_LEN];
  1526. snprintf(typectx, sizeof(typectx), "Ctx%u", sched_ctx);
  1527. worker_container_alias(container, sizeof(container), prefix, worker);
  1528. poti_SetState(last_codelet_start[worker], container, typectx, _starpu_last_codelet_symbol[worker]);
  1529. char name[STARPU_POTI_STR_LEN];
  1530. snprintf(name, sizeof(name), "%s", _starpu_last_codelet_symbol[worker]);
  1531. char size_str[STARPU_POTI_STR_LEN];
  1532. char parameters_str[STARPU_POTI_STR_LEN];
  1533. char footprint_str[STARPU_POTI_STR_LEN];
  1534. char tag_str[STARPU_POTI_STR_LEN];
  1535. char jobid_str[STARPU_POTI_STR_LEN];
  1536. char submitorder_str[STARPU_POTI_STR_LEN];
  1537. snprintf(size_str, sizeof(size_str), "%ld", ev->param[1]);
  1538. snprintf(parameters_str, sizeof(parameters_str), "%s", parameters);
  1539. snprintf(footprint_str, sizeof(footprint_str), "%08lx", ev->param[2]);
  1540. snprintf(tag_str, sizeof(tag_str), "%016lx", ev->param[4]);
  1541. snprintf(jobid_str, sizeof(jobid_str), "%s%lu", prefix, job_id);
  1542. snprintf(submitorder_str, sizeof(submitorder_str), "%s%lu", prefix, task->submit_order);
  1543. #ifdef HAVE_POTI_INIT_CUSTOM
  1544. poti_user_SetState(_starpu_poti_semiExtendedSetState, last_codelet_start[worker], container, typectx, name, 6, size_str,
  1545. parameters_str,
  1546. footprint_str,
  1547. tag_str,
  1548. jobid_str,
  1549. submitorder_str);
  1550. #else
  1551. poti_SetState(last_codelet_start[worker], container, typectx, name);
  1552. #endif
  1553. #else
  1554. fprintf(out_paje_file, "21 %.9f %sw%d Ctx%u \"%s\" %ld %s %08lx %016lx %s%lu %s%lu\n", last_codelet_start[worker], prefix, worker, sched_ctx, _starpu_last_codelet_symbol[worker], ev->param[1], parameters, ev->param[2], ev->param[4], prefix, job_id, prefix, task->submit_order);
  1555. #endif
  1556. }
  1557. }
  1558. }
  1559. static long dumped_codelets_count;
  1560. static struct starpu_fxt_codelet_event *dumped_codelets;
  1561. static void handle_end_codelet_body(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1562. {
  1563. int worker = ev->param[3];
  1564. if (worker < 0) return;
  1565. char *prefix = options->file_prefix;
  1566. double end_codelet_time = get_event_time_stamp(ev, options);
  1567. double last_end_codelet_time = last_codelet_end[worker];
  1568. last_codelet_end[worker] = end_codelet_time;
  1569. size_t codelet_size = ev->param[1];
  1570. uint32_t codelet_hash = ev->param[2];
  1571. long unsigned int threadid = ev->param[4];
  1572. char *name = get_fxt_string(ev, 4);
  1573. const char *state = "I";
  1574. if (find_sync(prefixTOnodeid(prefix), threadid))
  1575. state = "B";
  1576. worker_set_state(end_codelet_time, prefix, worker, state);
  1577. if (trace_file)
  1578. recfmt_worker_set_state(end_codelet_time, worker, state, "Other");
  1579. struct task_info *task = get_task(ev->param[0], options->file_rank);
  1580. get_task(ev->param[0], options->file_rank)->end_time = end_codelet_time;
  1581. update_accumulated_time(worker, 0.0, end_codelet_time - task->start_time, end_codelet_time, 0);
  1582. struct _starpu_computation *peer = ongoing_computation[worker];
  1583. double gflops_start = peer->comp_start;
  1584. double codelet_length;
  1585. double gflops;
  1586. struct _starpu_computation *comp;
  1587. codelet_length = end_codelet_time - gflops_start;
  1588. gflops = (((double)task->kflops) / 1000000) / (codelet_length / 1000);
  1589. if (options->no_flops)
  1590. {
  1591. _starpu_computation_delete(peer);
  1592. }
  1593. else
  1594. {
  1595. if (out_paje_file)
  1596. {
  1597. #ifdef STARPU_HAVE_POTI
  1598. char container[STARPU_POTI_STR_LEN];
  1599. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, worker);
  1600. if (gflops_start != last_end_codelet_time)
  1601. {
  1602. if (last_end_codelet_time != 0)
  1603. {
  1604. poti_SetVariable(last_end_codelet_time, container, "gf", 0.);
  1605. }
  1606. }
  1607. poti_SetVariable(gflops_start, container, "gf", gflops);
  1608. #else
  1609. if (gflops_start != last_end_codelet_time)
  1610. {
  1611. if (last_end_codelet_time != 0)
  1612. {
  1613. fprintf(out_paje_file, "13 %.9f %sw%d gf %f\n",
  1614. last_end_codelet_time, prefix, worker, 0.);
  1615. }
  1616. }
  1617. fprintf(out_paje_file, "13 %.9f %sw%d gf %f\n",
  1618. gflops_start, prefix, worker, gflops);
  1619. #endif
  1620. }
  1621. comp = _starpu_computation_new();
  1622. comp->comp_start = end_codelet_time;
  1623. comp->gflops = -gflops;
  1624. peer->gflops = +gflops;
  1625. comp->peer = peer;
  1626. peer->peer = comp;
  1627. _starpu_computation_list_push_back(&computation_list, comp);
  1628. }
  1629. /* Prepare comp for next codelet */
  1630. comp = _starpu_computation_new();
  1631. comp->comp_start = end_codelet_time;
  1632. comp->peer = NULL;
  1633. if (!options->no_flops)
  1634. _starpu_computation_list_push_back(&computation_list, comp);
  1635. ongoing_computation[worker] = comp;
  1636. if (distrib_time)
  1637. fprintf(distrib_time, "%s\t%s%d\t%ld\t%"PRIx32"\t%.9f\n", _starpu_last_codelet_symbol[worker],
  1638. prefix, worker, (unsigned long) codelet_size, codelet_hash, codelet_length);
  1639. if (options->dumped_codelets)
  1640. {
  1641. dumped_codelets_count++;
  1642. _STARPU_REALLOC(dumped_codelets, dumped_codelets_count*sizeof(struct starpu_fxt_codelet_event));
  1643. snprintf(dumped_codelets[dumped_codelets_count - 1].symbol, sizeof(dumped_codelets[dumped_codelets_count - 1].symbol)-1, "%s", _starpu_last_codelet_symbol[worker]);
  1644. dumped_codelets[dumped_codelets_count - 1].symbol[sizeof(dumped_codelets[dumped_codelets_count - 1].symbol)-1] = 0;
  1645. dumped_codelets[dumped_codelets_count - 1].workerid = worker;
  1646. snprintf(dumped_codelets[dumped_codelets_count - 1].perfmodel_archname, sizeof(dumped_codelets[dumped_codelets_count - 1].perfmodel_archname)-1, "%s", name);
  1647. dumped_codelets[dumped_codelets_count - 1].perfmodel_archname[sizeof(dumped_codelets[dumped_codelets_count - 1].perfmodel_archname)-1] = 0;
  1648. dumped_codelets[dumped_codelets_count - 1].size = codelet_size;
  1649. dumped_codelets[dumped_codelets_count - 1].hash = codelet_hash;
  1650. dumped_codelets[dumped_codelets_count - 1].time = codelet_length;
  1651. }
  1652. _starpu_last_codelet_symbol[worker][0] = 0;
  1653. }
  1654. static void handle_start_executing(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1655. {
  1656. char *prefix = options->file_prefix;
  1657. long unsigned int threadid = ev->param[0];
  1658. if (out_paje_file && !find_sync(prefixTOnodeid(prefix), threadid))
  1659. thread_set_state(get_event_time_stamp(ev, options), prefix, threadid, "E");
  1660. if (trace_file && !find_sync(prefixTOnodeid(prefix), threadid))
  1661. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), threadid, "E", "Runtime");
  1662. }
  1663. static void handle_end_executing(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1664. {
  1665. char *prefix = options->file_prefix;
  1666. long unsigned int threadid = ev->param[0];
  1667. if (out_paje_file && !find_sync(prefixTOnodeid(prefix), threadid))
  1668. thread_set_state(get_event_time_stamp(ev, options), prefix, threadid, "B");
  1669. if (trace_file && !find_sync(prefixTOnodeid(prefix), threadid))
  1670. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), threadid, "B", "Runtime");
  1671. }
  1672. static void handle_user_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1673. {
  1674. int worker;
  1675. unsigned long code = ev->param[0];
  1676. #ifdef STARPU_HAVE_POTI
  1677. char paje_value[STARPU_POTI_STR_LEN], container[STARPU_POTI_STR_LEN];
  1678. snprintf(paje_value, sizeof(paje_value), "%lu", code);
  1679. #endif
  1680. char *prefix = options->file_prefix;
  1681. double now = get_event_time_stamp(ev, options);
  1682. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  1683. if (worker < 0)
  1684. {
  1685. if (out_paje_file)
  1686. #ifdef STARPU_HAVE_POTI
  1687. program_container_alias (container, STARPU_POTI_STR_LEN, prefix);
  1688. #else
  1689. fprintf(out_paje_file, "9 %.9f user_user_event %sp %lu\n", now, prefix, code);
  1690. #endif
  1691. }
  1692. else
  1693. {
  1694. if (out_paje_file)
  1695. #ifdef STARPU_HAVE_POTI
  1696. thread_container_alias (container, STARPU_POTI_STR_LEN, prefix, ev->param[1]);
  1697. #else
  1698. fprintf(out_paje_file, "9 %.9f user_event %st%"PRIu64" %lu\n", now, prefix, ev->param[1], code);
  1699. #endif
  1700. }
  1701. #ifdef STARPU_HAVE_POTI
  1702. if (out_paje_file)
  1703. poti_NewEvent(now, container, "user_event", paje_value);
  1704. #endif
  1705. }
  1706. static void handle_start_callback(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1707. {
  1708. int worker;
  1709. char *prefix = options->file_prefix;
  1710. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  1711. if (worker >= 0)
  1712. {
  1713. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], "C");
  1714. if (trace_file)
  1715. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[1], "C", "Runtime");
  1716. }
  1717. else if (worker == -2)
  1718. {
  1719. /* MPI thread */
  1720. mpicommthread_push_state(get_event_time_stamp(ev, options), options->file_prefix, "C");
  1721. recfmt_mpicommthread_push_state(get_event_time_stamp(ev, options), "C");
  1722. }
  1723. else
  1724. {
  1725. user_thread_push_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], "C");
  1726. recfmt_user_thread_push_state(get_event_time_stamp(ev, options), ev->param[1], "C", "UNK"); /* XXX */
  1727. }
  1728. }
  1729. static void handle_end_callback(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1730. {
  1731. int worker;
  1732. char *prefix = options->file_prefix;
  1733. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  1734. if (worker >= 0)
  1735. {
  1736. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], "B");
  1737. if (trace_file)
  1738. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[1], "B", "Runtime");
  1739. }
  1740. else if (worker == -2)
  1741. {
  1742. /* MPI thread */
  1743. mpicommthread_pop_state(get_event_time_stamp(ev, options), options->file_prefix);
  1744. recfmt_mpicommthread_pop_state(get_event_time_stamp(ev, options));
  1745. }
  1746. else
  1747. {
  1748. user_thread_pop_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1]);
  1749. recfmt_user_thread_pop_state(get_event_time_stamp(ev, options), ev->param[1]);
  1750. }
  1751. }
  1752. static void handle_hypervisor_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1753. {
  1754. int worker;
  1755. char *prefix = options->file_prefix;
  1756. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1757. if (worker >= 0)
  1758. {
  1759. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "H");
  1760. if (trace_file)
  1761. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "H", "Runtime");
  1762. }
  1763. else if (worker == -2)
  1764. {
  1765. /* MPI thread */
  1766. mpicommthread_push_state(get_event_time_stamp(ev, options), options->file_prefix, "H");
  1767. recfmt_mpicommthread_push_state(get_event_time_stamp(ev, options), "H");
  1768. }
  1769. else
  1770. {
  1771. user_thread_push_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], "H");
  1772. recfmt_user_thread_push_state(get_event_time_stamp(ev, options), ev->param[1], "H", "UNK"); /* XXX */
  1773. }
  1774. }
  1775. static void handle_hypervisor_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1776. {
  1777. int worker;
  1778. char *prefix = options->file_prefix;
  1779. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1780. if (worker >= 0)
  1781. {
  1782. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "B");
  1783. if (trace_file)
  1784. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "B", "Runtime");
  1785. }
  1786. else if (worker == -2)
  1787. {
  1788. /* MPI thread */
  1789. mpicommthread_pop_state(get_event_time_stamp(ev, options), options->file_prefix);
  1790. recfmt_mpicommthread_pop_state(get_event_time_stamp(ev, options));
  1791. }
  1792. else
  1793. {
  1794. user_thread_pop_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1]);
  1795. recfmt_user_thread_pop_state(get_event_time_stamp(ev, options), ev->param[1]);
  1796. }
  1797. }
  1798. static void handle_worker_status_on_tid(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *newstatus)
  1799. {
  1800. int worker;
  1801. char *prefix = options->file_prefix;
  1802. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  1803. if (worker < 0)
  1804. return;
  1805. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], newstatus);
  1806. if (trace_file)
  1807. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[1], newstatus, "Runtime");
  1808. }
  1809. static void handle_worker_status(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *newstatus)
  1810. {
  1811. int worker;
  1812. worker = ev->param[1];
  1813. if (worker < 0)
  1814. return;
  1815. worker_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], newstatus);
  1816. if (trace_file)
  1817. recfmt_worker_set_state(get_event_time_stamp(ev, options), ev->param[1], newstatus, "Runtime");
  1818. }
  1819. static double last_sleep_start[STARPU_NMAXWORKERS];
  1820. static void handle_worker_scheduling_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1821. {
  1822. int worker;
  1823. char *prefix = options->file_prefix;
  1824. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1825. if (worker < 0) return;
  1826. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "Sc");
  1827. if (trace_file)
  1828. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "Sc", "Runtime");
  1829. }
  1830. static void handle_worker_scheduling_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1831. {
  1832. int worker;
  1833. char *prefix = options->file_prefix;
  1834. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1835. if (worker < 0) return;
  1836. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "B");
  1837. if (trace_file)
  1838. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "B", "Runtime");
  1839. }
  1840. static void handle_worker_scheduling_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1841. {
  1842. int worker;
  1843. char *prefix = options->file_prefix;
  1844. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1845. if (worker < 0) return;
  1846. thread_push_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "Sc");
  1847. if (trace_file)
  1848. recfmt_thread_push_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "Sc", "Runtime");
  1849. }
  1850. static void handle_worker_scheduling_pop(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1851. {
  1852. int worker;
  1853. char *prefix = options->file_prefix;
  1854. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1855. if (worker < 0) return;
  1856. thread_pop_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0]);
  1857. if (trace_file)
  1858. recfmt_thread_pop_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0]);
  1859. }
  1860. static void handle_worker_sleep_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1861. {
  1862. int worker;
  1863. char *prefix = options->file_prefix;
  1864. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1865. if (worker < 0) return;
  1866. double start_sleep_time = get_event_time_stamp(ev, options);
  1867. last_sleep_start[worker] = start_sleep_time;
  1868. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "Sl");
  1869. if (trace_file)
  1870. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "Sl", "Other");
  1871. }
  1872. static void handle_worker_sleep_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1873. {
  1874. int worker;
  1875. char *prefix = options->file_prefix;
  1876. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1877. if (worker < 0) return;
  1878. double end_sleep_timestamp = get_event_time_stamp(ev, options);
  1879. thread_set_state(end_sleep_timestamp, options->file_prefix, ev->param[0], "B");
  1880. if (trace_file)
  1881. recfmt_thread_set_state(end_sleep_timestamp, prefixTOnodeid(prefix), ev->param[0], "B", "Runtime");
  1882. double sleep_length = end_sleep_timestamp - last_sleep_start[worker];
  1883. update_accumulated_time(worker, sleep_length, 0.0, end_sleep_timestamp, 0);
  1884. }
  1885. static void handle_data_register(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1886. {
  1887. unsigned long handle = ev->param[0];
  1888. char *prefix = options->file_prefix;
  1889. struct data_info *data = get_data(handle, options->file_rank);
  1890. char *description = get_fxt_string(ev, 4);
  1891. data->size = ev->param[1];
  1892. data->max_size = ev->param[2];
  1893. data->home_node = ev->param[3];
  1894. if (description[0])
  1895. data->description = strdup(description);
  1896. if (out_paje_file && !options->no_events)
  1897. {
  1898. #ifdef STARPU_HAVE_POTI
  1899. char paje_value[STARPU_POTI_STR_LEN], container[STARPU_POTI_STR_LEN];
  1900. snprintf(paje_value, sizeof(paje_value), "%lx", handle);
  1901. program_container_alias (container, STARPU_POTI_STR_LEN, prefix);
  1902. poti_NewEvent(get_event_time_stamp(ev, options), container, "register", paje_value);
  1903. #else
  1904. fprintf(out_paje_file, "9 %.9f register %sp %lx\n", get_event_time_stamp(ev, options), prefix, handle);
  1905. #endif
  1906. }
  1907. }
  1908. static void handle_data_unregister(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1909. {
  1910. unsigned long handle = ev->param[0];
  1911. char *prefix = options->file_prefix;
  1912. struct data_info *data = get_data(handle, options->file_rank);
  1913. if (out_paje_file && !options->no_events)
  1914. {
  1915. #ifdef STARPU_HAVE_POTI
  1916. char paje_value[STARPU_POTI_STR_LEN], container[STARPU_POTI_STR_LEN];
  1917. snprintf(paje_value, sizeof(paje_value), "%lx", handle);
  1918. program_container_alias (container, STARPU_POTI_STR_LEN, prefix);
  1919. poti_NewEvent(get_event_time_stamp(ev, options), container, "unregister", paje_value);
  1920. #else
  1921. fprintf(out_paje_file, "9 %.9f unregister %sp %lx\n", get_event_time_stamp(ev, options), prefix, handle);
  1922. #endif
  1923. }
  1924. data_dump(data);
  1925. }
  1926. static void handle_data_state(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *state)
  1927. {
  1928. unsigned long handle = ev->param[0];
  1929. unsigned node = ev->param[1];
  1930. char *prefix = options->file_prefix;
  1931. if (out_paje_file)
  1932. {
  1933. #ifdef STARPU_HAVE_POTI
  1934. char paje_value[STARPU_POTI_STR_LEN], memnode_container[STARPU_POTI_STR_LEN];
  1935. memmanager_container_alias(memnode_container, STARPU_POTI_STR_LEN, prefix, node);
  1936. snprintf(paje_value, sizeof(paje_value), "%lx", handle);
  1937. poti_NewEvent(get_event_time_stamp(ev, options), memnode_container, state, paje_value);
  1938. #else
  1939. fprintf(out_paje_file, "9 %.9f %s %smm%u %lx\n", get_event_time_stamp(ev, options), state, prefix, node, handle);
  1940. #endif
  1941. }
  1942. }
  1943. static void handle_data_copy(void)
  1944. {
  1945. }
  1946. static void handle_data_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1947. {
  1948. unsigned long handle = ev->param[0];
  1949. char *name = get_fxt_string(ev, 1);
  1950. struct data_info *data = get_data(handle, options->file_rank);
  1951. data->name = strdup(name);
  1952. }
  1953. static void handle_data_coordinates(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1954. {
  1955. unsigned long handle = ev->param[0];
  1956. unsigned dimensions = ev->param[1];
  1957. struct data_info *data = get_data(handle, options->file_rank);
  1958. unsigned i;
  1959. data->dimensions = dimensions;
  1960. _STARPU_MALLOC(data->dims, dimensions * sizeof(*data->dims));
  1961. for (i = 0; i < dimensions; i++)
  1962. data->dims[i] = ev->param[i+2];
  1963. }
  1964. static void handle_data_wont_use(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1965. {
  1966. unsigned long handle = ev->param[0];
  1967. unsigned long submit_order = ev->param[1];
  1968. unsigned long job_id = ev->param[2];
  1969. fprintf(tasks_file, "Control: WontUse\n");
  1970. fprintf(tasks_file, "JobId: %lu\n", job_id);
  1971. fprintf(tasks_file, "SubmitOrder: %lu\n", submit_order);
  1972. fprintf(tasks_file, "SubmitTime: %f\n", get_event_time_stamp(ev, options));
  1973. fprintf(tasks_file, "Handles: %lx\n", handle);
  1974. fprintf(tasks_file, "MPIRank: %d\n", options->file_rank);
  1975. fprintf(tasks_file, "\n");
  1976. }
  1977. static void handle_data_doing_wont_use(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1978. {
  1979. unsigned long handle = ev->param[0];
  1980. char *prefix = options->file_prefix;
  1981. unsigned node = STARPU_MAIN_RAM;
  1982. const char *event = "WU";
  1983. if (out_paje_file)
  1984. {
  1985. #ifdef STARPU_HAVE_POTI
  1986. char paje_value[STARPU_POTI_STR_LEN], memnode_container[STARPU_POTI_STR_LEN];
  1987. memmanager_container_alias(memnode_container, STARPU_POTI_STR_LEN, prefix, node);
  1988. snprintf(paje_value, sizeof(paje_value), "%lx", handle);
  1989. poti_NewEvent(get_event_time_stamp(ev, options), memnode_container, event, paje_value);
  1990. #else
  1991. fprintf(out_paje_file, "9 %.9f %s %smm%u %lx\n", get_event_time_stamp(ev, options), event, prefix, node, handle);
  1992. #endif
  1993. }
  1994. }
  1995. static void handle_mpi_data_set_rank(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1996. {
  1997. unsigned long handle = ev->param[0];
  1998. unsigned long rank = ev->param[1];
  1999. struct data_info *data = get_data(handle, options->file_rank);
  2000. data->mpi_owner = rank;
  2001. }
  2002. static void handle_mpi_data_set_tag(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2003. {
  2004. unsigned long handle = ev->param[0];
  2005. long tag = ev->param[1];
  2006. struct data_info *data = get_data(handle, options->file_rank);
  2007. data->mpi_tag = tag;
  2008. }
  2009. static const char *copy_link_type(enum _starpu_is_prefetch prefetch)
  2010. {
  2011. switch (prefetch)
  2012. {
  2013. case STARPU_FETCH: return "F";
  2014. case STARPU_TASK_PREFETCH: return "TF";
  2015. case STARPU_PREFETCH: return "PF";
  2016. case STARPU_IDLEFETCH: return "IF";
  2017. default: STARPU_ASSERT(0);
  2018. }
  2019. }
  2020. static void handle_start_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2021. {
  2022. unsigned src = ev->param[0];
  2023. unsigned dst = ev->param[1];
  2024. unsigned size = ev->param[2];
  2025. unsigned comid = ev->param[3];
  2026. enum _starpu_is_prefetch prefetch = ev->param[4];
  2027. unsigned long handle = ev->param[5];
  2028. const char *link_type = copy_link_type(prefetch);
  2029. char *prefix = options->file_prefix;
  2030. if (!options->no_bus)
  2031. {
  2032. if (out_paje_file)
  2033. {
  2034. double time = get_event_time_stamp(ev, options);
  2035. memnode_push_state(time, prefix, dst, "Co");
  2036. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCo", handle, comid, size, src, options);
  2037. #ifdef STARPU_HAVE_POTI
  2038. char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN], src_memnode_container[STARPU_POTI_STR_LEN];
  2039. char program_container[STARPU_POTI_STR_LEN];
  2040. snprintf(paje_value, sizeof(paje_value), "%u", size);
  2041. snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
  2042. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2043. memmanager_container_alias(src_memnode_container, STARPU_POTI_STR_LEN, prefix, src);
  2044. poti_StartLink(time, program_container, link_type, src_memnode_container, paje_value, paje_key);
  2045. #else
  2046. fprintf(out_paje_file, "18 %.9f %s %sp %u %smm%u com_%u\n", time, link_type, prefix, size, prefix, src, comid);
  2047. #endif
  2048. }
  2049. /* create a structure to store the start of the communication, this will be matched later */
  2050. struct _starpu_communication *com = _starpu_communication_new();
  2051. com->comid = comid;
  2052. com->comm_start = get_event_time_stamp(ev, options);
  2053. com->size = size;
  2054. com->src_node = src;
  2055. com->dst_node = dst;
  2056. com->type = link_type;
  2057. com->peer = NULL;
  2058. com->handle = handle;
  2059. _starpu_communication_list_push_back(&communication_list, com);
  2060. }
  2061. }
  2062. static void handle_work_stealing(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2063. {
  2064. if (out_paje_file)
  2065. {
  2066. unsigned dst = ev->param[0];
  2067. unsigned src = ev->param[1];
  2068. char *prefix = options->file_prefix;
  2069. unsigned size = 0;
  2070. double time = get_event_time_stamp(ev, options);
  2071. #ifdef STARPU_HAVE_POTI
  2072. char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN], src_worker_container[STARPU_POTI_STR_LEN], dst_worker_container[STARPU_POTI_STR_LEN];
  2073. char program_container[STARPU_POTI_STR_LEN];
  2074. snprintf(paje_value, sizeof(paje_value), "%u", size);
  2075. snprintf(paje_key, sizeof(paje_key), "steal_%u", steal_number);
  2076. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2077. worker_container_alias(src_worker_container, STARPU_POTI_STR_LEN, prefix, src);
  2078. worker_container_alias(dst_worker_container, STARPU_POTI_STR_LEN, prefix, dst);
  2079. poti_StartLink(time, program_container, "WSL", src_worker_container, paje_value, paje_key);
  2080. poti_EndLink(time+0.000000001, program_container, "WSL", dst_worker_container, paje_value, paje_key);
  2081. #else
  2082. fprintf(out_paje_file, "18 %.9f WSL %sp %u %sw%u steal_%u\n", time, prefix, size, prefix, src, steal_number);
  2083. fprintf(out_paje_file, "19 %.9f WSL %sp %u %sw%u steal_%u\n", time+0.000000001, prefix, size, prefix, dst, steal_number);
  2084. #endif
  2085. }
  2086. steal_number++;
  2087. }
  2088. static void handle_end_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2089. {
  2090. int src = -1;
  2091. unsigned long handle = 0;
  2092. unsigned dst = ev->param[1];
  2093. unsigned long size = ev->param[2];
  2094. unsigned comid = ev->param[3];
  2095. enum _starpu_is_prefetch prefetch = ev->param[4];
  2096. const char *link_type = copy_link_type(prefetch);
  2097. char *prefix = options->file_prefix;
  2098. if (!options->no_bus)
  2099. {
  2100. /* look for a data transfer to match */
  2101. #ifdef STARPU_DEVEL
  2102. #warning FIXME: use hash table instead
  2103. #endif
  2104. struct _starpu_communication *itor;
  2105. for (itor = _starpu_communication_list_begin(&communication_list);
  2106. itor != _starpu_communication_list_end(&communication_list);
  2107. itor = _starpu_communication_list_next(itor))
  2108. {
  2109. if (itor->comid == comid)
  2110. {
  2111. double comm_end = get_event_time_stamp(ev, options);
  2112. double bandwidth = (double)((0.001*size)/(comm_end - itor->comm_start));
  2113. itor->bandwidth = bandwidth;
  2114. struct _starpu_communication *com = _starpu_communication_new();
  2115. com->comid = comid;
  2116. com->comm_start = get_event_time_stamp(ev, options);
  2117. com->bandwidth = -bandwidth;
  2118. com->size = size;
  2119. src = com->src_node = itor->src_node;
  2120. com->dst_node = itor->dst_node;
  2121. com->type = itor->type;
  2122. link_type = itor->type;
  2123. handle = itor->handle;
  2124. com->peer = itor;
  2125. itor->peer = com;
  2126. _starpu_communication_list_push_back(&communication_list, com);
  2127. break;
  2128. }
  2129. }
  2130. if (out_paje_file)
  2131. {
  2132. double time = get_event_time_stamp(ev, options);
  2133. memnode_pop_state(time, prefix, dst);
  2134. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCoE", handle, comid, size, src, options);
  2135. #ifdef STARPU_HAVE_POTI
  2136. char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN];
  2137. char dst_memnode_container[STARPU_POTI_STR_LEN], program_container[STARPU_POTI_STR_LEN];
  2138. snprintf(paje_value, sizeof(paje_value), "%lu", size);
  2139. snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
  2140. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2141. memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, dst);
  2142. poti_EndLink(time, program_container, link_type, dst_memnode_container, paje_value, paje_key);
  2143. #else
  2144. fprintf(out_paje_file, "19 %.9f %s %sp %lu %smm%u com_%u\n", time, link_type, prefix, size, prefix, dst, comid);
  2145. #endif
  2146. }
  2147. }
  2148. }
  2149. static void handle_start_driver_copy_async(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2150. {
  2151. unsigned src = ev->param[0];
  2152. unsigned dst = ev->param[1];
  2153. char *prefix = options->file_prefix;
  2154. if (!options->no_bus)
  2155. if (out_paje_file)
  2156. {
  2157. memnode_push_state(get_event_time_stamp(ev, options), prefix, dst, "CoA");
  2158. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCoA", 0, 0, 0, src, options);
  2159. }
  2160. }
  2161. static void handle_end_driver_copy_async(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2162. {
  2163. unsigned src = ev->param[0];
  2164. unsigned dst = ev->param[1];
  2165. char *prefix = options->file_prefix;
  2166. if (!options->no_bus)
  2167. if (out_paje_file)
  2168. {
  2169. memnode_pop_state(get_event_time_stamp(ev, options), prefix, dst);
  2170. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCoAE", 0, 0, 0, src, options);
  2171. }
  2172. }
  2173. /* Currently unused */
  2174. STARPU_ATTRIBUTE_UNUSED
  2175. static void handle_memnode_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2176. {
  2177. unsigned memnode = ev->param[0];
  2178. if (out_paje_file)
  2179. memnode_set_state(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr);
  2180. }
  2181. static void handle_memnode_event_start_3(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2182. {
  2183. unsigned memnode = ev->param[0];
  2184. unsigned size = ev->param[2];
  2185. unsigned long handle = ev->param[3];
  2186. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, 0, size, memnode, options);
  2187. }
  2188. static void handle_memnode_event_start_4(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2189. {
  2190. unsigned memnode = ev->param[0];
  2191. unsigned dest = ev->param[1];
  2192. if(strcmp(eventstr, "rc")==0)
  2193. {
  2194. //If it is a Request Create, use dest normally
  2195. }
  2196. else
  2197. {
  2198. dest = memnode;
  2199. }
  2200. unsigned size = ev->param[2];
  2201. unsigned long handle = ev->param[3];
  2202. unsigned prefe = ev->param[4];
  2203. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, prefe, size, dest, options);
  2204. }
  2205. static void handle_memnode_event_end_3(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2206. {
  2207. unsigned memnode = ev->param[0];
  2208. unsigned long handle = ev->param[2];
  2209. unsigned info = ev->param[3];
  2210. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, info, 0, memnode, options);
  2211. }
  2212. static void handle_memnode_event_start_2(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2213. {
  2214. unsigned memnode = ev->param[0];
  2215. unsigned long handle = ev->param[2];
  2216. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, 0, 0, memnode, options);
  2217. }
  2218. static void handle_memnode_event_end_2(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2219. {
  2220. unsigned memnode = ev->param[0];
  2221. unsigned long handle = ev->param[2];
  2222. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, 0, 0, memnode, options);
  2223. }
  2224. static void handle_push_memnode_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2225. {
  2226. unsigned memnode = ev->param[0];
  2227. if (out_paje_file)
  2228. memnode_push_state(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr);
  2229. }
  2230. static void handle_pop_memnode_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2231. {
  2232. unsigned memnode = ev->param[0];
  2233. if (out_paje_file)
  2234. memnode_pop_state(get_event_time_stamp(ev, options), options->file_prefix, memnode);
  2235. }
  2236. static void handle_used_mem(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2237. {
  2238. unsigned memnode = ev->param[0];
  2239. if (out_paje_file)
  2240. {
  2241. #ifdef STARPU_HAVE_POTI
  2242. char memnode_container[STARPU_POTI_STR_LEN];
  2243. memmanager_container_alias(memnode_container, STARPU_POTI_STR_LEN, options->file_prefix, memnode);
  2244. poti_SetVariable(get_event_time_stamp(ev, options), memnode_container, "use", (double)ev->param[1] / (1<<20));
  2245. #else
  2246. fprintf(out_paje_file, "13 %.9f %smm%u use %f\n",
  2247. get_event_time_stamp(ev, options), options->file_prefix, memnode, (double)ev->param[1] / (1<<20));
  2248. #endif
  2249. }
  2250. }
  2251. static void handle_task_submit_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, unsigned long tid, const char *eventstr)
  2252. {
  2253. char *prefix = options->file_prefix;
  2254. int workerid = find_worker_id(prefixTOnodeid(prefix), tid);
  2255. double timestamp = get_event_time_stamp(ev, options);
  2256. if (workerid >= 0)
  2257. {
  2258. /* Normal worker */
  2259. if (eventstr)
  2260. {
  2261. thread_push_state(timestamp, prefix, tid, eventstr);
  2262. recfmt_thread_push_state(timestamp, prefixTOnodeid(prefix), tid, eventstr, "Runtime");
  2263. }
  2264. else
  2265. {
  2266. thread_pop_state(timestamp, prefix, tid);
  2267. recfmt_thread_pop_state(timestamp, prefixTOnodeid(prefix), tid);
  2268. }
  2269. }
  2270. else if (workerid == -2)
  2271. {
  2272. /* MPI thread */
  2273. if (eventstr)
  2274. {
  2275. mpicommthread_push_state(timestamp, prefix, eventstr);
  2276. recfmt_mpicommthread_push_state(get_event_time_stamp(ev, options), eventstr);
  2277. }
  2278. else
  2279. {
  2280. mpicommthread_pop_state(timestamp, prefix);
  2281. recfmt_mpicommthread_pop_state(get_event_time_stamp(ev, options));
  2282. }
  2283. }
  2284. else
  2285. {
  2286. if (eventstr)
  2287. {
  2288. user_thread_push_state(timestamp, prefix, tid, eventstr);
  2289. recfmt_user_thread_push_state(timestamp, tid, eventstr, "User");
  2290. }
  2291. else
  2292. {
  2293. user_thread_pop_state(timestamp, prefix, tid);
  2294. recfmt_user_thread_pop_state(timestamp, tid);
  2295. }
  2296. }
  2297. }
  2298. /*
  2299. * Number of task submitted to the scheduler
  2300. */
  2301. static int curq_size = 0;
  2302. static int nsubmitted = 0;
  2303. static void handle_job_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2304. {
  2305. double current_timestamp = get_event_time_stamp(ev, options);
  2306. unsigned task = ev->param[0];
  2307. int priority = ev->param[1];
  2308. curq_size++;
  2309. _starpu_fxt_component_update_ntasks(nsubmitted, curq_size);
  2310. if (!options->no_counter && out_paje_file)
  2311. {
  2312. #ifdef STARPU_HAVE_POTI
  2313. char container[STARPU_POTI_STR_LEN];
  2314. scheduler_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix);
  2315. poti_SetVariable(current_timestamp, container, "nready", (double)curq_size);
  2316. char paje_value[STARPU_POTI_STR_LEN];
  2317. snprintf(paje_value, sizeof(paje_value), "%u", task);
  2318. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2319. poti_NewEvent(get_event_time_stamp(ev, options), container, "pu", paje_value);
  2320. #else
  2321. fprintf(out_paje_file, "13 %.9f %ssched nready %f\n", current_timestamp, options->file_prefix, (float)curq_size);
  2322. fprintf(out_paje_file, "9 %.9f %s %sp %u\n", get_event_time_stamp(ev, options), "pu", options->file_prefix, task);
  2323. #endif
  2324. }
  2325. if (activity_file)
  2326. fprintf(activity_file, "cnt_ready\t%.9f\t%d\n", current_timestamp, curq_size);
  2327. if (sched_tasks_file)
  2328. {
  2329. fprintf(sched_tasks_file, "Type: push\n");
  2330. fprintf(sched_tasks_file, "Time: %.9f\n", current_timestamp);
  2331. fprintf(sched_tasks_file, "Priority: %d\n", priority);
  2332. if (options->file_rank < 0)
  2333. fprintf(sched_tasks_file, "JobId: %d\n", task);
  2334. else
  2335. fprintf(sched_tasks_file, "JobId: %d_%d\n", options->file_rank, task);
  2336. fprintf(sched_tasks_file, "\n");
  2337. }
  2338. }
  2339. static void handle_job_pop(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2340. {
  2341. double current_timestamp = get_event_time_stamp(ev, options);
  2342. unsigned task = ev->param[0];
  2343. int priority = ev->param[1];
  2344. curq_size--;
  2345. nsubmitted--;
  2346. _starpu_fxt_component_update_ntasks(nsubmitted, curq_size);
  2347. if (!options->no_counter && out_paje_file)
  2348. {
  2349. #ifdef STARPU_HAVE_POTI
  2350. char container[STARPU_POTI_STR_LEN];
  2351. scheduler_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix);
  2352. poti_SetVariable(current_timestamp, container, "nready", (double)curq_size);
  2353. poti_SetVariable(current_timestamp, container, "nsubmitted", (double)nsubmitted);
  2354. char paje_value[STARPU_POTI_STR_LEN];
  2355. snprintf(paje_value, sizeof(paje_value), "%u", task);
  2356. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2357. poti_NewEvent(get_event_time_stamp(ev, options), container, "po", paje_value);
  2358. #else
  2359. fprintf(out_paje_file, "13 %.9f %ssched nready %f\n", current_timestamp, options->file_prefix, (float)curq_size);
  2360. fprintf(out_paje_file, "13 %.9f %ssched nsubmitted %f\n", current_timestamp, options->file_prefix, (float)nsubmitted);
  2361. fprintf(out_paje_file, "9 %.9f %s %sp %u\n", get_event_time_stamp(ev, options), "po", options->file_prefix, task);
  2362. #endif
  2363. }
  2364. if (activity_file)
  2365. {
  2366. fprintf(activity_file, "cnt_ready\t%.9f\t%d\n", current_timestamp, curq_size);
  2367. fprintf(activity_file, "cnt_submitted\t%.9f\t%d\n", current_timestamp, nsubmitted);
  2368. }
  2369. if (sched_tasks_file)
  2370. {
  2371. fprintf(sched_tasks_file, "Type: pop\n");
  2372. fprintf(sched_tasks_file, "Time: %.9f\n", current_timestamp);
  2373. fprintf(sched_tasks_file, "Priority: %d\n", priority);
  2374. if (options->file_rank < 0)
  2375. fprintf(sched_tasks_file, "JobId: %d\n", task);
  2376. else
  2377. fprintf(sched_tasks_file, "JobId: %d_%d\n", options->file_rank, task);
  2378. fprintf(sched_tasks_file, "\n");
  2379. }
  2380. }
  2381. static void handle_component_new(struct fxt_ev_64 *ev, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
  2382. {
  2383. _starpu_fxt_component_new(ev->param[0], get_fxt_string(ev, 1));
  2384. }
  2385. static void handle_component_connect(struct fxt_ev_64 *ev, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
  2386. {
  2387. _starpu_fxt_component_connect(ev->param[0], ev->param[1]);
  2388. }
  2389. static void handle_component_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2390. {
  2391. char *prefix = options->file_prefix;
  2392. double current_timestamp = get_event_time_stamp(ev, options);
  2393. int workerid = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  2394. _starpu_fxt_component_push(anim_file, options, current_timestamp, workerid, ev->param[1], ev->param[2], ev->param[3], ev->param[4]);
  2395. }
  2396. static void handle_component_pull(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2397. {
  2398. char *prefix = options->file_prefix;
  2399. double current_timestamp = get_event_time_stamp(ev, options);
  2400. int workerid = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  2401. _starpu_fxt_component_pull(anim_file, options, current_timestamp, workerid, ev->param[1], ev->param[2], ev->param[3], ev->param[4]);
  2402. }
  2403. static
  2404. void handle_update_task_cnt(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2405. {
  2406. double current_timestamp = get_event_time_stamp(ev, options);
  2407. nsubmitted++;
  2408. _starpu_fxt_component_update_ntasks(nsubmitted, curq_size);
  2409. if (!options->no_counter && out_paje_file)
  2410. {
  2411. #ifdef STARPU_HAVE_POTI
  2412. char container[STARPU_POTI_STR_LEN];
  2413. scheduler_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix);
  2414. poti_SetVariable(current_timestamp, container, "nsubmitted", (double)nsubmitted);
  2415. #else
  2416. fprintf(out_paje_file, "13 %.9f %ssched nsubmitted %f\n", current_timestamp, options->file_prefix, (float)nsubmitted);
  2417. #endif
  2418. }
  2419. if (activity_file)
  2420. fprintf(activity_file, "cnt_submitted\t%.9f\t%d\n", current_timestamp, nsubmitted);
  2421. }
  2422. static void handle_tag(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2423. {
  2424. uint64_t tag;
  2425. unsigned long job;
  2426. tag = ev->param[0];
  2427. job = ev->param[1];
  2428. if (options->label_deps)
  2429. _starpu_fxt_dag_add_tag(options->file_prefix, tag, job, "tag");
  2430. else
  2431. _starpu_fxt_dag_add_tag(options->file_prefix, tag, job, NULL);
  2432. }
  2433. static void handle_tag_deps(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2434. {
  2435. uint64_t child;
  2436. uint64_t father;
  2437. child = ev->param[0];
  2438. father = ev->param[1];
  2439. if (options->label_deps)
  2440. _starpu_fxt_dag_add_tag_deps(options->file_prefix, child, father, "tag");
  2441. else
  2442. _starpu_fxt_dag_add_tag_deps(options->file_prefix, child, father, NULL);
  2443. }
  2444. static void handle_task_deps(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2445. {
  2446. unsigned long dep_prev = ev->param[0];
  2447. unsigned long dep_succ = ev->param[1];
  2448. unsigned dep_succ_type = ev->param[2];
  2449. char *name = get_fxt_string(ev,4);
  2450. struct task_info *task = get_task(dep_succ, options->file_rank);
  2451. struct task_info *prev_task = get_task(dep_prev, options->file_rank);
  2452. unsigned alloc = 0;
  2453. task->type = dep_succ_type;
  2454. if (task->ndeps == 0)
  2455. /* Start with 8=2^3, should be plenty in most cases */
  2456. alloc = 8;
  2457. else if (task->ndeps >= 8)
  2458. {
  2459. /* Allocate dependencies array by powers of two */
  2460. if (! ((task->ndeps - 1) & task->ndeps)) /* Is task->ndeps a power of two? */
  2461. {
  2462. /* We have filled the previous power of two, get another one */
  2463. alloc = task->ndeps * 2;
  2464. }
  2465. }
  2466. if (alloc)
  2467. {
  2468. _STARPU_REALLOC(task->dependencies, sizeof(*task->dependencies) * alloc);
  2469. _STARPU_REALLOC(task->dep_labels, sizeof(*task->dep_labels) * alloc);
  2470. }
  2471. task->dependencies[task->ndeps] = dep_prev;
  2472. task->dep_labels[task->ndeps] = strdup(name);
  2473. task->ndeps++;
  2474. /* There is a dependency between both job id : dep_prev -> dep_succ */
  2475. if (show_task(task, options))
  2476. {
  2477. if (!options->label_deps) name = NULL;
  2478. /* We should show the name of the predecessor, then. */
  2479. prev_task->show = 1;
  2480. _starpu_fxt_dag_add_task_deps(options->file_prefix, dep_prev, dep_succ, name);
  2481. }
  2482. }
  2483. static void handle_task_submit(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2484. {
  2485. unsigned long job_id = ev->param[0];
  2486. unsigned long iteration = ev->param[1];
  2487. unsigned long subiteration = ev->param[2];
  2488. unsigned long submit_order = ev->param[3];
  2489. long priority = (long) ev->param[4];
  2490. unsigned type = ev->param[5];
  2491. struct task_info *task = get_task(job_id, options->file_rank);
  2492. task->submit_time = get_event_time_stamp(ev, options);
  2493. task->submit_order = submit_order;
  2494. task->priority = priority;
  2495. task->iterations[0] = iteration;
  2496. task->iterations[1] = subiteration;
  2497. task->type = type;
  2498. }
  2499. static void handle_task_color(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2500. {
  2501. unsigned long job_id = ev->param[0];
  2502. struct task_info *task = get_task(job_id, options->file_rank);
  2503. int color = (long) ev->param[1];
  2504. task->color = color;
  2505. }
  2506. static void handle_task_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2507. {
  2508. char *prefix = options->file_prefix;
  2509. unsigned long job_id = ev->param[0];
  2510. struct task_info *task = get_task(job_id, options->file_rank);
  2511. unsigned long has_name = ev->param[3];
  2512. char *name = has_name?get_fxt_string(ev,4):"unknown";
  2513. int worker;
  2514. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  2515. const char *colour;
  2516. char buffer[32];
  2517. if (task->color != 0)
  2518. {
  2519. snprintf(buffer, sizeof(buffer), "#%06x", task->color);
  2520. colour = &buffer[0];
  2521. }
  2522. else if (options->per_task_colour)
  2523. {
  2524. snprintf(buffer, sizeof(buffer), "#%x%x%x",
  2525. get_colour_symbol_red(name)/4,
  2526. get_colour_symbol_green(name)/4,
  2527. get_colour_symbol_blue(name)/4);
  2528. colour = &buffer[0];
  2529. }
  2530. else
  2531. {
  2532. colour= (worker < 0)?"#aaaaaa":get_worker_color(worker);
  2533. }
  2534. if (!task->name)
  2535. task->name = strdup(name);
  2536. unsigned exclude_from_dag = ev->param[2];
  2537. task->exclude_from_dag = exclude_from_dag;
  2538. if (!exclude_from_dag && show_task(task, options))
  2539. _starpu_fxt_dag_set_task_name(options->file_prefix, job_id, name, colour);
  2540. }
  2541. static void handle_task_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2542. {
  2543. /* Ideally, we would be able to dump tasks as they terminate, to save
  2544. * memory.
  2545. * We however may have to change their state later, e.g. the show field,
  2546. * due to dependencies added way later. */
  2547. #if 0
  2548. unsigned long job_id;
  2549. job_id = ev->param[0];
  2550. struct task_info *task = get_task(job_id, options->file_rank);
  2551. task_dump(task, options);
  2552. #else
  2553. (void) ev;
  2554. (void) options;
  2555. #endif
  2556. }
  2557. static void handle_tag_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2558. {
  2559. char *prefix = options->file_prefix;
  2560. uint64_t tag_id;
  2561. tag_id = ev->param[0];
  2562. unsigned long has_name = ev->param[2];
  2563. char *name = has_name?get_fxt_string(ev,3):"unknown";
  2564. int worker;
  2565. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  2566. const char *colour;
  2567. char buffer[32];
  2568. if (options->per_task_colour)
  2569. {
  2570. snprintf(buffer, sizeof(buffer), "%.4f,%.4f,%.4f",
  2571. get_colour_symbol_red(name)/1024.0,
  2572. get_colour_symbol_green(name)/1024.0,
  2573. get_colour_symbol_blue(name)/1024.0);
  2574. colour = &buffer[0];
  2575. }
  2576. else
  2577. {
  2578. colour= (worker < 0)?"white":get_worker_color(worker);
  2579. }
  2580. _starpu_fxt_dag_set_tag_done(options->file_prefix, tag_id, colour);
  2581. }
  2582. static void handle_mpi_barrier(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2583. {
  2584. int rank = ev->param[0];
  2585. STARPU_ASSERT(rank == options->file_rank || options->file_rank == -1);
  2586. /* Add an event in the trace */
  2587. if (out_paje_file)
  2588. {
  2589. #ifdef STARPU_HAVE_POTI
  2590. char container[STARPU_POTI_STR_LEN], paje_value[STARPU_POTI_STR_LEN];
  2591. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2592. snprintf(paje_value, sizeof(paje_value), "%d", rank);
  2593. poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", paje_value);
  2594. #else
  2595. fprintf(out_paje_file, "9 %.9f prog_event %sp %d\n", get_event_time_stamp(ev, options), options->file_prefix, rank);
  2596. #endif
  2597. }
  2598. }
  2599. static void handle_mpi_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2600. {
  2601. double date = get_event_time_stamp(ev, options);
  2602. char *prefix = options->file_prefix;
  2603. register_mpi_thread(prefixTOnodeid(prefix), ev->param[2]);
  2604. if (out_paje_file)
  2605. {
  2606. #ifdef STARPU_HAVE_POTI
  2607. char program_container[STARPU_POTI_STR_LEN];
  2608. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2609. char new_mpicommthread_container_alias[STARPU_POTI_STR_LEN];
  2610. mpicommthread_container_alias(new_mpicommthread_container_alias, STARPU_POTI_STR_LEN, prefix);
  2611. snprintf(new_mpicommthread_container_alias, STARPU_POTI_STR_LEN, "%smpict", prefix);
  2612. poti_CreateContainer(date, new_mpicommthread_container_alias, "MPICt", program_container, new_mpicommthread_container_alias);
  2613. //set bandwidth variables to zero when they start
  2614. poti_SetVariable(date, new_mpicommthread_container_alias, "bwi_mpi", 0.);
  2615. poti_SetVariable(date, new_mpicommthread_container_alias, "bwo_mpi", 0.);
  2616. #else
  2617. fprintf(out_paje_file, "7 %.9f %smpict MPICt %sp %smpict\n", date, prefix, prefix, prefix);
  2618. //set bandwidth variables to zero when they start
  2619. fprintf(out_paje_file, "13 %.9f %smpict bwi_mpi 0.0\n", date, prefix);
  2620. fprintf(out_paje_file, "13 %.9f %smpict bwo_mpi 0.0\n", date, prefix);
  2621. #endif
  2622. mpicommthread_set_state(date, prefix, "Sl");
  2623. }
  2624. if (trace_file)
  2625. recfmt_mpicommthread_set_state(date, "Sl");
  2626. }
  2627. static void handle_mpi_stop(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2628. {
  2629. double date = get_event_time_stamp(ev, options);
  2630. char *prefix = options->file_prefix;
  2631. if (out_paje_file)
  2632. {
  2633. #ifdef STARPU_HAVE_POTI
  2634. char mpicommthread_container[STARPU_POTI_STR_LEN];
  2635. mpicommthread_container_alias(mpicommthread_container, STARPU_POTI_STR_LEN, prefix);
  2636. poti_DestroyContainer(date, "MPICt", mpicommthread_container);
  2637. #else
  2638. fprintf(out_paje_file, "8 %.9f %smpict MPICt\n",
  2639. date, prefix);
  2640. #endif
  2641. }
  2642. }
  2643. static void handle_mpi_isend_submit_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2644. {
  2645. double date = get_event_time_stamp(ev, options);
  2646. if (out_paje_file)
  2647. mpicommthread_set_state(date, options->file_prefix, "SdS");
  2648. if (trace_file)
  2649. recfmt_mpicommthread_set_state(date, "SdS");
  2650. }
  2651. static int mpi_warned;
  2652. static void handle_mpi_isend_submit_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2653. {
  2654. int dest = ev->param[0];
  2655. int mpi_tag = ev->param[1];
  2656. size_t size = ev->param[2];
  2657. long jobid = ev->param[3];
  2658. unsigned long handle = ev->param[4];
  2659. double date = get_event_time_stamp(ev, options);
  2660. if (out_paje_file)
  2661. mpicommthread_set_state(date, options->file_prefix, "P");
  2662. if (trace_file)
  2663. recfmt_mpicommthread_set_state(date, "P");
  2664. if (options->file_rank < 0)
  2665. {
  2666. if (!mpi_warned)
  2667. {
  2668. _STARPU_MSG("Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
  2669. mpi_warned = 1;
  2670. }
  2671. }
  2672. else
  2673. _starpu_fxt_mpi_add_send_transfer(options->file_rank, dest, mpi_tag, size, date, jobid, handle);
  2674. }
  2675. static void handle_mpi_irecv_submit_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2676. {
  2677. double date = get_event_time_stamp(ev, options);
  2678. if (out_paje_file)
  2679. mpicommthread_set_state(date, options->file_prefix, "RvS");
  2680. if (trace_file)
  2681. recfmt_mpicommthread_set_state(date, "RvS");
  2682. }
  2683. static void handle_mpi_irecv_submit_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2684. {
  2685. double date = get_event_time_stamp(ev, options);
  2686. if (out_paje_file)
  2687. mpicommthread_set_state(date, options->file_prefix, "P");
  2688. if (trace_file)
  2689. recfmt_mpicommthread_set_state(date, "P");
  2690. }
  2691. static void handle_mpi_isend_complete_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2692. {
  2693. double date = get_event_time_stamp(ev, options);
  2694. if (out_paje_file)
  2695. mpicommthread_set_state(date, options->file_prefix, "SdC");
  2696. if (trace_file)
  2697. recfmt_mpicommthread_set_state(date, "SdC");
  2698. }
  2699. static void handle_mpi_isend_complete_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2700. {
  2701. double date = get_event_time_stamp(ev, options);
  2702. if (out_paje_file)
  2703. mpicommthread_set_state(date, options->file_prefix, "P");
  2704. if (trace_file)
  2705. recfmt_mpicommthread_set_state(date, "P");
  2706. }
  2707. static void handle_mpi_irecv_complete_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2708. {
  2709. double date = get_event_time_stamp(ev, options);
  2710. if (out_paje_file)
  2711. mpicommthread_set_state(date, options->file_prefix, "RvC");
  2712. if (trace_file)
  2713. recfmt_mpicommthread_set_state(date, "RvC");
  2714. }
  2715. static void handle_mpi_irecv_complete_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2716. {
  2717. double date = get_event_time_stamp(ev, options);
  2718. if (out_paje_file)
  2719. mpicommthread_set_state(date, options->file_prefix, "P");
  2720. if (trace_file)
  2721. recfmt_mpicommthread_set_state(date, "P");
  2722. }
  2723. static void handle_mpi_irecv_terminated(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2724. {
  2725. int src = ev->param[0];
  2726. int mpi_tag = ev->param[1];
  2727. long jobid = ev->param[2];
  2728. unsigned long handle = ev->param[4];
  2729. double date = get_event_time_stamp(ev, options);
  2730. if (options->file_rank < 0)
  2731. {
  2732. if (!mpi_warned)
  2733. {
  2734. _STARPU_MSG("Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
  2735. mpi_warned = 1;
  2736. }
  2737. }
  2738. else
  2739. _starpu_fxt_mpi_add_recv_transfer(src, options->file_rank, mpi_tag, date, jobid, handle);
  2740. }
  2741. static void handle_mpi_sleep_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2742. {
  2743. double date = get_event_time_stamp(ev, options);
  2744. if (out_paje_file)
  2745. mpicommthread_set_state(date, options->file_prefix, "Sl");
  2746. if (trace_file)
  2747. recfmt_mpicommthread_set_state(date, "Sl");
  2748. }
  2749. static void handle_mpi_sleep_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2750. {
  2751. double date = get_event_time_stamp(ev, options);
  2752. if (out_paje_file)
  2753. mpicommthread_set_state(date, options->file_prefix, "Pl");
  2754. if (trace_file)
  2755. recfmt_mpicommthread_set_state(date, "Pl");
  2756. }
  2757. static void handle_mpi_dtesting_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2758. {
  2759. double date = get_event_time_stamp(ev, options);
  2760. if (out_paje_file)
  2761. mpicommthread_set_state(date, options->file_prefix, "DT");
  2762. if (trace_file)
  2763. recfmt_mpicommthread_set_state(date, "DT");
  2764. }
  2765. static void handle_mpi_dtesting_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2766. {
  2767. double date = get_event_time_stamp(ev, options);
  2768. if (out_paje_file)
  2769. mpicommthread_set_state(date, options->file_prefix, "P");
  2770. if (trace_file)
  2771. recfmt_mpicommthread_set_state(date, "P");
  2772. }
  2773. static void handle_mpi_utesting_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2774. {
  2775. double date = get_event_time_stamp(ev, options);
  2776. if (out_paje_file)
  2777. mpicommthread_set_state(date, options->file_prefix, "UT");
  2778. if (trace_file)
  2779. recfmt_mpicommthread_set_state(date, "UT");
  2780. }
  2781. static void handle_mpi_utesting_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2782. {
  2783. double date = get_event_time_stamp(ev, options);
  2784. if (out_paje_file)
  2785. mpicommthread_set_state(date, options->file_prefix, "P");
  2786. if (trace_file)
  2787. recfmt_mpicommthread_set_state(date, "P");
  2788. }
  2789. static void handle_mpi_uwait_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2790. {
  2791. double date = get_event_time_stamp(ev, options);
  2792. if (out_paje_file)
  2793. mpicommthread_set_state(date, options->file_prefix, "UW");
  2794. if (trace_file)
  2795. recfmt_mpicommthread_set_state(date, "UW");
  2796. }
  2797. static void handle_mpi_uwait_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2798. {
  2799. double date = get_event_time_stamp(ev, options);
  2800. if (out_paje_file)
  2801. mpicommthread_set_state(date, options->file_prefix, "P");
  2802. if (trace_file)
  2803. recfmt_mpicommthread_set_state(date, "P");
  2804. }
  2805. static void handle_mpi_testing_detached_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2806. {
  2807. double date = get_event_time_stamp(ev, options);
  2808. if (out_paje_file)
  2809. mpicommthread_push_state(date, options->file_prefix, "TD");
  2810. if (trace_file)
  2811. recfmt_mpicommthread_push_state(date, "TD");
  2812. }
  2813. static void handle_mpi_testing_detached_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2814. {
  2815. double date = get_event_time_stamp(ev, options);
  2816. if (out_paje_file)
  2817. mpicommthread_pop_state(date, options->file_prefix);
  2818. if (trace_file)
  2819. recfmt_mpicommthread_pop_state(date);
  2820. }
  2821. static void handle_mpi_test_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2822. {
  2823. double date = get_event_time_stamp(ev, options);
  2824. if (out_paje_file)
  2825. mpicommthread_push_state(date, options->file_prefix, "MT");
  2826. if (trace_file)
  2827. recfmt_mpicommthread_push_state(date, "MT");
  2828. }
  2829. static void handle_mpi_test_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2830. {
  2831. double date = get_event_time_stamp(ev, options);
  2832. if (out_paje_file)
  2833. mpicommthread_pop_state(date, options->file_prefix);
  2834. if (trace_file)
  2835. recfmt_mpicommthread_pop_state(date);
  2836. }
  2837. static void handle_mpi_polling_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2838. {
  2839. double date = get_event_time_stamp(ev, options);
  2840. if (out_paje_file)
  2841. mpicommthread_set_state(date, options->file_prefix, "Pl");
  2842. }
  2843. static void handle_mpi_polling_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2844. {
  2845. double date = get_event_time_stamp(ev, options);
  2846. if (out_paje_file)
  2847. mpicommthread_set_state(date, options->file_prefix, "P");
  2848. }
  2849. static void handle_mpi_driver_run_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2850. {
  2851. double date = get_event_time_stamp(ev, options);
  2852. if (out_paje_file)
  2853. mpicommthread_set_state(date, options->file_prefix, "Dr");
  2854. }
  2855. static void handle_mpi_driver_run_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2856. {
  2857. double date = get_event_time_stamp(ev, options);
  2858. if (out_paje_file)
  2859. mpicommthread_set_state(date, options->file_prefix, "Pl");
  2860. }
  2861. static void handle_set_profiling(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2862. {
  2863. int status = ev->param[0];
  2864. if (activity_file)
  2865. fprintf(activity_file, "set_profiling\t%.9f\t%d\n", get_event_time_stamp(ev, options), status);
  2866. }
  2867. static void handle_task_wait_for_all(void)
  2868. {
  2869. _starpu_fxt_dag_add_sync_point();
  2870. }
  2871. static void handle_string_event(struct fxt_ev_64 *ev, const char *event, struct starpu_fxt_options *options)
  2872. {
  2873. /* Add an event in the trace */
  2874. if (out_paje_file)
  2875. {
  2876. #ifdef STARPU_HAVE_POTI
  2877. char container[STARPU_POTI_STR_LEN];
  2878. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2879. poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", event);
  2880. #else
  2881. fprintf(out_paje_file, "9 %.9f prog_event %sp \"%s\"\n", get_event_time_stamp(ev, options), options->file_prefix, event);
  2882. #endif
  2883. }
  2884. if (trace_file)
  2885. recfmt_dump_state(get_event_time_stamp(ev, options), "ProgEvent", -1, 0, event, "Program");
  2886. }
  2887. static void handle_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2888. {
  2889. char *event = get_fxt_string(ev, 0);
  2890. handle_string_event(ev, event, options);
  2891. }
  2892. static void handle_thread_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2893. {
  2894. /* Add an event in the trace */
  2895. if (out_paje_file)
  2896. {
  2897. char *event = get_fxt_string(ev, 1);
  2898. #ifdef STARPU_HAVE_POTI
  2899. char container[STARPU_POTI_STR_LEN];
  2900. thread_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix, ev->param[0]);
  2901. poti_NewEvent(get_event_time_stamp(ev, options), container, "thread_event", event);
  2902. #else
  2903. fprintf(out_paje_file, "9 %.9f thread_event %st%"PRIu64" %s\n", get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], event);
  2904. #endif
  2905. }
  2906. }
  2907. static
  2908. void _starpu_fxt_process_bandwidth(struct starpu_fxt_options *options)
  2909. {
  2910. char *prefix = options->file_prefix;
  2911. /* Loop through completed communications */
  2912. while (!_starpu_communication_list_empty(&communication_list)
  2913. && _starpu_communication_list_begin(&communication_list)->peer)
  2914. {
  2915. struct _starpu_communication*itor;
  2916. /* This communication is complete */
  2917. itor = _starpu_communication_list_pop_front(&communication_list);
  2918. current_bandwidth_out_per_node[itor->src_node] += itor->bandwidth;
  2919. if (out_paje_file)
  2920. {
  2921. #ifdef STARPU_HAVE_POTI
  2922. char src_memnode_container[STARPU_POTI_STR_LEN];
  2923. memmanager_container_alias(src_memnode_container, STARPU_POTI_STR_LEN, prefix, itor->src_node);
  2924. poti_SetVariable(itor->comm_start, src_memnode_container, "bwo_mm", current_bandwidth_out_per_node[itor->src_node]);
  2925. #else
  2926. fprintf(out_paje_file, "13 %.9f %smm%u bwo_mm %f\n",
  2927. itor->comm_start, prefix, itor->src_node, current_bandwidth_out_per_node[itor->src_node]);
  2928. #endif
  2929. }
  2930. current_bandwidth_in_per_node[itor->dst_node] += itor->bandwidth;
  2931. if (out_paje_file)
  2932. {
  2933. #ifdef STARPU_HAVE_POTI
  2934. char dst_memnode_container[STARPU_POTI_STR_LEN];
  2935. memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, itor->dst_node);
  2936. poti_SetVariable(itor->comm_start, dst_memnode_container, "bwi_mm", current_bandwidth_in_per_node[itor->dst_node]);
  2937. #else
  2938. fprintf(out_paje_file, "13 %.9f %smm%u bwi_mm %f\n",
  2939. itor->comm_start, prefix, itor->dst_node, current_bandwidth_in_per_node[itor->dst_node]);
  2940. #endif
  2941. }
  2942. _starpu_communication_delete(itor);
  2943. }
  2944. }
  2945. static
  2946. void _starpu_fxt_process_computations(struct starpu_fxt_options *options)
  2947. {
  2948. char *prefix = options->file_prefix;
  2949. /* Loop through completed computations */
  2950. struct _starpu_computation*itor;
  2951. while (!_starpu_computation_list_empty(&computation_list)
  2952. && _starpu_computation_list_begin(&computation_list)->peer)
  2953. {
  2954. /* This computation is complete */
  2955. itor = _starpu_computation_list_pop_front(&computation_list);
  2956. if (out_paje_file && itor->comp_start != current_computation_time)
  2957. {
  2958. /* flush last value */
  2959. #ifdef STARPU_HAVE_POTI
  2960. char container[STARPU_POTI_STR_LEN];
  2961. scheduler_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  2962. poti_SetVariable(current_computation_time, container, "gft", (double)current_computation);
  2963. #else
  2964. fprintf(out_paje_file, "13 %.9f %ssched gft %f\n", current_computation_time, prefix, (float)current_computation);
  2965. #endif
  2966. }
  2967. current_computation += itor->gflops;
  2968. current_computation_time = itor->comp_start;
  2969. _starpu_computation_delete(itor);
  2970. }
  2971. }
  2972. static
  2973. void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *options)
  2974. {
  2975. /* Open the trace file */
  2976. int fd_in;
  2977. fd_in = open(filename_in, O_RDONLY);
  2978. if (fd_in < 0)
  2979. {
  2980. perror("open failed :");
  2981. exit(-1);
  2982. }
  2983. static fxt_t fut;
  2984. fut = fxt_fdopen(fd_in);
  2985. if (!fut)
  2986. {
  2987. perror("fxt_fdopen :");
  2988. exit(-1);
  2989. }
  2990. fxt_blockev_t block;
  2991. block = fxt_blockev_enter(fut);
  2992. char *prefix = options->file_prefix;
  2993. /* TODO starttime ...*/
  2994. /* create the "program" container */
  2995. current_computation = 0.0;
  2996. current_computation_time = 0.0;
  2997. if (out_paje_file)
  2998. {
  2999. #ifdef STARPU_HAVE_POTI
  3000. char new_program_container_alias[STARPU_POTI_STR_LEN], new_program_container_name[STARPU_POTI_STR_LEN];
  3001. program_container_alias(new_program_container_alias, STARPU_POTI_STR_LEN, prefix);
  3002. snprintf(new_program_container_name, sizeof(new_program_container_name), "program %s", prefix);
  3003. poti_CreateContainer (0, new_program_container_alias, "P", "MPIroot", new_program_container_name);
  3004. char new_scheduler_container_alias[STARPU_POTI_STR_LEN], new_scheduler_container_name[STARPU_POTI_STR_LEN];
  3005. scheduler_container_alias(new_scheduler_container_alias, STARPU_POTI_STR_LEN, prefix);
  3006. snprintf(new_scheduler_container_name, sizeof(new_scheduler_container_name), "%sscheduler", prefix);
  3007. if (!options->no_counter || !options->no_flops)
  3008. {
  3009. poti_CreateContainer(0.0, new_scheduler_container_alias, "Sc", new_program_container_alias, new_scheduler_container_name);
  3010. }
  3011. if (!options->no_counter)
  3012. {
  3013. poti_SetVariable(0.0, new_scheduler_container_alias, "nsubmitted", 0.0);
  3014. poti_SetVariable(0.0, new_scheduler_container_alias, "nready", 0.0);
  3015. }
  3016. if (!options->no_flops)
  3017. {
  3018. poti_SetVariable(0.0, new_scheduler_container_alias, "gft", 0.0);
  3019. }
  3020. #else
  3021. fprintf(out_paje_file, "7 0.0 %sp P MPIroot %sprogram \n", prefix, prefix);
  3022. if (!options->no_counter || !options->no_flops)
  3023. {
  3024. fprintf(out_paje_file, "7 0.0 %ssched Sc %sp %sscheduler\n", prefix, prefix, prefix);
  3025. }
  3026. if (!options->no_counter)
  3027. {
  3028. /* create a variable with the number of tasks */
  3029. fprintf(out_paje_file, "13 0.0 %ssched nsubmitted 0.0\n", prefix);
  3030. fprintf(out_paje_file, "13 0.0 %ssched nready 0.0\n", prefix);
  3031. }
  3032. if (!options->no_flops)
  3033. {
  3034. fprintf(out_paje_file, "13 0.0 %ssched gft 0.0\n", prefix);
  3035. }
  3036. #endif
  3037. }
  3038. struct fxt_ev_64 ev;
  3039. while(1)
  3040. {
  3041. unsigned i;
  3042. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  3043. for (i = ev.nb_params; i < FXT_MAX_PARAMS; i++)
  3044. ev.param[i] = 0;
  3045. if (ret != FXT_EV_OK)
  3046. {
  3047. break;
  3048. }
  3049. if (number_events_file != NULL)
  3050. {
  3051. assert(number_events != NULL);
  3052. assert(ev.code <= FUT_SETUP_CODE);
  3053. number_events[ev.code]++;
  3054. }
  3055. switch (ev.code)
  3056. {
  3057. case _STARPU_FUT_WORKER_INIT_START:
  3058. handle_worker_init_start(&ev, options);
  3059. break;
  3060. case _STARPU_FUT_WORKER_INIT_END:
  3061. handle_worker_init_end(&ev, options);
  3062. break;
  3063. case _STARPU_FUT_NEW_MEM_NODE:
  3064. handle_new_mem_node(&ev, options);
  3065. break;
  3066. /* detect when the workers were idling or not */
  3067. case _STARPU_FUT_START_CODELET_BODY:
  3068. handle_start_codelet_body(&ev, options);
  3069. break;
  3070. case _STARPU_FUT_MODEL_NAME:
  3071. handle_model_name(&ev, options);
  3072. break;
  3073. case _STARPU_FUT_CODELET_DATA:
  3074. handle_codelet_data(&ev, options);
  3075. break;
  3076. case _STARPU_FUT_CODELET_DATA_HANDLE:
  3077. handle_codelet_data_handle(&ev, options);
  3078. break;
  3079. case _STARPU_FUT_CODELET_DETAILS:
  3080. handle_codelet_details(&ev, options);
  3081. break;
  3082. case _STARPU_FUT_END_CODELET_BODY:
  3083. handle_end_codelet_body(&ev, options);
  3084. break;
  3085. case _STARPU_FUT_START_EXECUTING:
  3086. handle_start_executing(&ev, options);
  3087. break;
  3088. case _STARPU_FUT_END_EXECUTING:
  3089. handle_end_executing(&ev, options);
  3090. break;
  3091. case _STARPU_FUT_START_CALLBACK:
  3092. handle_start_callback(&ev, options);
  3093. break;
  3094. case _STARPU_FUT_END_CALLBACK:
  3095. handle_end_callback(&ev, options);
  3096. break;
  3097. case _STARPU_FUT_UPDATE_TASK_CNT:
  3098. handle_update_task_cnt(&ev, options);
  3099. break;
  3100. /* monitor stack size and generate sched_tasks.rec */
  3101. case _STARPU_FUT_JOB_PUSH:
  3102. handle_job_push(&ev, options);
  3103. break;
  3104. case _STARPU_FUT_JOB_POP:
  3105. handle_job_pop(&ev, options);
  3106. break;
  3107. case _STARPU_FUT_SCHED_COMPONENT_NEW:
  3108. handle_component_new(&ev, options);
  3109. break;
  3110. case _STARPU_FUT_SCHED_COMPONENT_CONNECT:
  3111. handle_component_connect(&ev, options);
  3112. break;
  3113. case _STARPU_FUT_SCHED_COMPONENT_PUSH:
  3114. handle_component_push(&ev, options);
  3115. break;
  3116. case _STARPU_FUT_SCHED_COMPONENT_PULL:
  3117. handle_component_pull(&ev, options);
  3118. break;
  3119. /* check the memory transfer overhead */
  3120. case _STARPU_FUT_START_FETCH_INPUT_ON_TID:
  3121. handle_worker_status_on_tid(&ev, options, "Fi");
  3122. break;
  3123. case _STARPU_FUT_START_PUSH_OUTPUT_ON_TID:
  3124. handle_worker_status_on_tid(&ev, options, "Po");
  3125. break;
  3126. case _STARPU_FUT_START_PROGRESS_ON_TID:
  3127. handle_worker_status_on_tid(&ev, options, "P");
  3128. break;
  3129. case _STARPU_FUT_START_UNPARTITION_ON_TID:
  3130. handle_worker_status_on_tid(&ev, options, "U");
  3131. break;
  3132. case _STARPU_FUT_END_FETCH_INPUT_ON_TID:
  3133. case _STARPU_FUT_END_PROGRESS_ON_TID:
  3134. case _STARPU_FUT_END_PUSH_OUTPUT_ON_TID:
  3135. case _STARPU_FUT_END_UNPARTITION_ON_TID:
  3136. handle_worker_status_on_tid(&ev, options, "B");
  3137. break;
  3138. case _STARPU_FUT_START_FETCH_INPUT:
  3139. handle_worker_status(&ev, options, "Fi");
  3140. break;
  3141. case _STARPU_FUT_END_FETCH_INPUT:
  3142. handle_worker_status(&ev, options, "B");
  3143. break;
  3144. case _STARPU_FUT_WORKER_SCHEDULING_START:
  3145. handle_worker_scheduling_start(&ev, options);
  3146. break;
  3147. case _STARPU_FUT_WORKER_SCHEDULING_END:
  3148. handle_worker_scheduling_end(&ev, options);
  3149. break;
  3150. case _STARPU_FUT_WORKER_SCHEDULING_PUSH:
  3151. handle_worker_scheduling_push(&ev, options);
  3152. break;
  3153. case _STARPU_FUT_WORKER_SCHEDULING_POP:
  3154. handle_worker_scheduling_pop(&ev, options);
  3155. break;
  3156. case _STARPU_FUT_WORKER_SLEEP_START:
  3157. handle_worker_sleep_start(&ev, options);
  3158. break;
  3159. case _STARPU_FUT_WORKER_SLEEP_END:
  3160. handle_worker_sleep_end(&ev, options);
  3161. break;
  3162. case _STARPU_FUT_TAG:
  3163. handle_tag(&ev, options);
  3164. break;
  3165. case _STARPU_FUT_TAG_DEPS:
  3166. handle_tag_deps(&ev, options);
  3167. break;
  3168. case _STARPU_FUT_TASK_DEPS:
  3169. handle_task_deps(&ev, options);
  3170. break;
  3171. case _STARPU_FUT_TASK_SUBMIT:
  3172. handle_task_submit(&ev, options);
  3173. break;
  3174. case _STARPU_FUT_TASK_BUILD_START:
  3175. handle_task_submit_event(&ev, options, ev.param[0], "Bu");
  3176. break;
  3177. case _STARPU_FUT_TASK_SUBMIT_START:
  3178. handle_task_submit_event(&ev, options, ev.param[0], "Su");
  3179. break;
  3180. case _STARPU_FUT_TASK_THROTTLE_START:
  3181. handle_task_submit_event(&ev, options, ev.param[0], "Th");
  3182. break;
  3183. case _STARPU_FUT_TASK_MPI_DECODE_START:
  3184. handle_task_submit_event(&ev, options, ev.param[0], "MD");
  3185. break;
  3186. case _STARPU_FUT_TASK_MPI_PRE_START:
  3187. handle_task_submit_event(&ev, options, ev.param[0], "MPr");
  3188. break;
  3189. case _STARPU_FUT_TASK_MPI_POST_START:
  3190. handle_task_submit_event(&ev, options, ev.param[0], "MPo");
  3191. break;
  3192. case _STARPU_FUT_TASK_WAIT_START:
  3193. handle_task_submit_event(&ev, options, ev.param[1], "W");
  3194. break;
  3195. case _STARPU_FUT_TASK_WAIT_FOR_ALL_START:
  3196. handle_task_submit_event(&ev, options, ev.param[0], "WA");
  3197. break;
  3198. case _STARPU_FUT_TASK_BUILD_END:
  3199. case _STARPU_FUT_TASK_SUBMIT_END:
  3200. case _STARPU_FUT_TASK_THROTTLE_END:
  3201. case _STARPU_FUT_TASK_MPI_DECODE_END:
  3202. case _STARPU_FUT_TASK_MPI_PRE_END:
  3203. case _STARPU_FUT_TASK_MPI_POST_END:
  3204. case _STARPU_FUT_TASK_WAIT_FOR_ALL_END:
  3205. handle_task_submit_event(&ev, options, ev.param[0], NULL);
  3206. break;
  3207. case _STARPU_FUT_TASK_WAIT_END:
  3208. handle_task_submit_event(&ev, options, ev.param[0], NULL);
  3209. break;
  3210. case _STARPU_FUT_TASK_NAME:
  3211. handle_task_name(&ev, options);
  3212. break;
  3213. case _STARPU_FUT_TASK_COLOR:
  3214. handle_task_color(&ev, options);
  3215. break;
  3216. case _STARPU_FUT_TASK_DONE:
  3217. handle_task_done(&ev, options);
  3218. break;
  3219. case _STARPU_FUT_TAG_DONE:
  3220. handle_tag_done(&ev, options);
  3221. break;
  3222. case _STARPU_FUT_HANDLE_DATA_REGISTER:
  3223. handle_data_register(&ev, options);
  3224. break;
  3225. case _STARPU_FUT_HANDLE_DATA_UNREGISTER:
  3226. handle_data_unregister(&ev, options);
  3227. break;
  3228. case _STARPU_FUT_DATA_STATE_INVALID:
  3229. if (options->memory_states)
  3230. handle_data_state(&ev, options, "SI");
  3231. break;
  3232. case _STARPU_FUT_DATA_STATE_OWNER:
  3233. if (options->memory_states)
  3234. handle_data_state(&ev, options, "SO");
  3235. break;
  3236. case _STARPU_FUT_DATA_STATE_SHARED:
  3237. if (options->memory_states)
  3238. handle_data_state(&ev, options, "SS");
  3239. break;
  3240. case _STARPU_FUT_DATA_REQUEST_CREATED:
  3241. if (!options->no_bus && options->memory_states)
  3242. {
  3243. handle_memnode_event_start_4(&ev, options, "rc");
  3244. }
  3245. break;
  3246. case _STARPU_FUT_PAPI_TASK_EVENT_VALUE:
  3247. handle_papi_event(&ev, options);
  3248. break;
  3249. case _STARPU_FUT_DATA_COPY:
  3250. if (!options->no_bus)
  3251. handle_data_copy();
  3252. break;
  3253. case _STARPU_FUT_DATA_LOAD:
  3254. break;
  3255. case _STARPU_FUT_DATA_NAME:
  3256. handle_data_name(&ev, options);
  3257. break;
  3258. case _STARPU_FUT_DATA_COORDINATES:
  3259. handle_data_coordinates(&ev, options);
  3260. break;
  3261. case _STARPU_FUT_DATA_WONT_USE:
  3262. handle_data_wont_use(&ev, options);
  3263. break;
  3264. case _STARPU_FUT_DATA_DOING_WONT_USE:
  3265. if (options->memory_states)
  3266. handle_data_doing_wont_use(&ev, options);
  3267. break;
  3268. case _STARPU_FUT_START_DRIVER_COPY:
  3269. if (!options->no_bus)
  3270. handle_start_driver_copy(&ev, options);
  3271. break;
  3272. case _STARPU_FUT_END_DRIVER_COPY:
  3273. if (!options->no_bus)
  3274. handle_end_driver_copy(&ev, options);
  3275. break;
  3276. case _STARPU_FUT_START_DRIVER_COPY_ASYNC:
  3277. if (!options->no_bus)
  3278. handle_start_driver_copy_async(&ev, options);
  3279. break;
  3280. case _STARPU_FUT_END_DRIVER_COPY_ASYNC:
  3281. if (!options->no_bus)
  3282. handle_end_driver_copy_async(&ev, options);
  3283. break;
  3284. case _STARPU_FUT_WORK_STEALING:
  3285. handle_work_stealing(&ev, options);
  3286. break;
  3287. case _STARPU_FUT_WORKER_DEINIT_START:
  3288. handle_worker_deinit_start(&ev, options);
  3289. break;
  3290. case _STARPU_FUT_WORKER_DEINIT_END:
  3291. handle_worker_deinit_end(&ev, options);
  3292. break;
  3293. case _STARPU_FUT_START_ALLOC:
  3294. if (!options->no_bus)
  3295. {
  3296. handle_push_memnode_event(&ev, options, "A");
  3297. handle_memnode_event_start_4(&ev, options, "Al");
  3298. }
  3299. break;
  3300. case _STARPU_FUT_START_ALLOC_REUSE:
  3301. if (!options->no_bus)
  3302. {
  3303. handle_push_memnode_event(&ev, options, "Ar");
  3304. handle_memnode_event_start_4(&ev, options, "Alr");
  3305. }
  3306. break;
  3307. case _STARPU_FUT_END_ALLOC:
  3308. if (!options->no_bus)
  3309. {
  3310. handle_pop_memnode_event(&ev, options);
  3311. handle_memnode_event_end_3(&ev, options, "AlE");
  3312. }
  3313. break;
  3314. case _STARPU_FUT_END_ALLOC_REUSE:
  3315. if (!options->no_bus)
  3316. {
  3317. handle_pop_memnode_event(&ev, options);
  3318. handle_memnode_event_end_3(&ev, options, "AlrE");
  3319. }
  3320. break;
  3321. case _STARPU_FUT_START_FREE:
  3322. if (!options->no_bus)
  3323. {
  3324. handle_push_memnode_event(&ev, options, "F");
  3325. handle_memnode_event_start_3(&ev, options, "Fe");
  3326. }
  3327. break;
  3328. case _STARPU_FUT_END_FREE:
  3329. if (!options->no_bus)
  3330. {
  3331. handle_pop_memnode_event(&ev, options);
  3332. handle_memnode_event_end_2(&ev, options, "FeE");
  3333. }
  3334. break;
  3335. case _STARPU_FUT_START_WRITEBACK:
  3336. if (!options->no_bus)
  3337. {
  3338. handle_push_memnode_event(&ev, options, "W");
  3339. handle_memnode_event_start_2(&ev, options, "Wb");
  3340. }
  3341. break;
  3342. case _STARPU_FUT_END_WRITEBACK:
  3343. if (!options->no_bus)
  3344. {
  3345. handle_pop_memnode_event(&ev, options);
  3346. handle_memnode_event_start_2(&ev, options, "WbE");
  3347. }
  3348. break;
  3349. case _STARPU_FUT_START_WRITEBACK_ASYNC:
  3350. if (!options->no_bus)
  3351. handle_push_memnode_event(&ev, options, "Wa");
  3352. break;
  3353. case _STARPU_FUT_END_WRITEBACK_ASYNC:
  3354. if (!options->no_bus)
  3355. handle_pop_memnode_event(&ev, options);
  3356. break;
  3357. case _STARPU_FUT_START_MEMRECLAIM:
  3358. if (!options->no_bus)
  3359. handle_push_memnode_event(&ev, options, "R");
  3360. break;
  3361. case _STARPU_FUT_END_MEMRECLAIM:
  3362. if (!options->no_bus)
  3363. handle_pop_memnode_event(&ev, options);
  3364. break;
  3365. case _STARPU_FUT_USED_MEM:
  3366. handle_used_mem(&ev, options);
  3367. break;
  3368. case _STARPU_FUT_USER_EVENT:
  3369. if (!options->no_events)
  3370. handle_user_event(&ev, options);
  3371. break;
  3372. case _STARPU_MPI_FUT_START:
  3373. handle_mpi_start(&ev, options);
  3374. break;
  3375. case _STARPU_MPI_FUT_STOP:
  3376. handle_mpi_stop(&ev, options);
  3377. break;
  3378. case _STARPU_MPI_FUT_BARRIER:
  3379. handle_mpi_barrier(&ev, options);
  3380. break;
  3381. case _STARPU_MPI_FUT_ISEND_SUBMIT_BEGIN:
  3382. handle_mpi_isend_submit_begin(&ev, options);
  3383. break;
  3384. case _STARPU_MPI_FUT_ISEND_SUBMIT_END:
  3385. handle_mpi_isend_submit_end(&ev, options);
  3386. break;
  3387. case _STARPU_MPI_FUT_IRECV_SUBMIT_BEGIN:
  3388. handle_mpi_irecv_submit_begin(&ev, options);
  3389. break;
  3390. case _STARPU_MPI_FUT_IRECV_SUBMIT_END:
  3391. handle_mpi_irecv_submit_end(&ev, options);
  3392. break;
  3393. case _STARPU_MPI_FUT_ISEND_COMPLETE_BEGIN:
  3394. handle_mpi_isend_complete_begin(&ev, options);
  3395. break;
  3396. case _STARPU_MPI_FUT_ISEND_COMPLETE_END:
  3397. handle_mpi_isend_complete_end(&ev, options);
  3398. break;
  3399. case _STARPU_MPI_FUT_IRECV_COMPLETE_BEGIN:
  3400. handle_mpi_irecv_complete_begin(&ev, options);
  3401. break;
  3402. case _STARPU_MPI_FUT_IRECV_COMPLETE_END:
  3403. handle_mpi_irecv_complete_end(&ev, options);
  3404. break;
  3405. case _STARPU_MPI_FUT_ISEND_TERMINATED:
  3406. break;
  3407. case _STARPU_MPI_FUT_IRECV_TERMINATED:
  3408. handle_mpi_irecv_terminated(&ev, options);
  3409. break;
  3410. case _STARPU_MPI_FUT_SLEEP_BEGIN:
  3411. handle_mpi_sleep_begin(&ev, options);
  3412. break;
  3413. case _STARPU_MPI_FUT_SLEEP_END:
  3414. handle_mpi_sleep_end(&ev, options);
  3415. break;
  3416. case _STARPU_MPI_FUT_DTESTING_BEGIN:
  3417. handle_mpi_dtesting_begin(&ev, options);
  3418. break;
  3419. case _STARPU_MPI_FUT_DTESTING_END:
  3420. handle_mpi_dtesting_end(&ev, options);
  3421. break;
  3422. case _STARPU_MPI_FUT_UTESTING_BEGIN:
  3423. handle_mpi_utesting_begin(&ev, options);
  3424. break;
  3425. case _STARPU_MPI_FUT_UTESTING_END:
  3426. handle_mpi_utesting_end(&ev, options);
  3427. break;
  3428. case _STARPU_MPI_FUT_UWAIT_BEGIN:
  3429. handle_mpi_uwait_begin(&ev, options);
  3430. break;
  3431. case _STARPU_MPI_FUT_UWAIT_END:
  3432. handle_mpi_uwait_end(&ev, options);
  3433. break;
  3434. case _STARPU_MPI_FUT_DATA_SET_RANK:
  3435. handle_mpi_data_set_rank(&ev, options);
  3436. break;
  3437. case _STARPU_MPI_FUT_DATA_SET_TAG:
  3438. handle_mpi_data_set_tag(&ev, options);
  3439. break;
  3440. case _STARPU_MPI_FUT_TESTING_DETACHED_BEGIN:
  3441. handle_mpi_testing_detached_begin(&ev, options);
  3442. break;
  3443. case _STARPU_MPI_FUT_TESTING_DETACHED_END:
  3444. handle_mpi_testing_detached_end(&ev, options);
  3445. break;
  3446. case _STARPU_MPI_FUT_TEST_BEGIN:
  3447. handle_mpi_test_begin(&ev, options);
  3448. break;
  3449. case _STARPU_MPI_FUT_TEST_END:
  3450. handle_mpi_test_end(&ev, options);
  3451. break;
  3452. case _STARPU_MPI_FUT_POLLING_BEGIN:
  3453. handle_mpi_polling_begin(&ev, options);
  3454. break;
  3455. case _STARPU_MPI_FUT_POLLING_END:
  3456. handle_mpi_polling_end(&ev, options);
  3457. break;
  3458. case _STARPU_MPI_FUT_DRIVER_RUN_BEGIN:
  3459. handle_mpi_driver_run_begin(&ev, options);
  3460. break;
  3461. case _STARPU_MPI_FUT_DRIVER_RUN_END:
  3462. handle_mpi_driver_run_end(&ev, options);
  3463. break;
  3464. case _STARPU_FUT_SET_PROFILING:
  3465. handle_set_profiling(&ev, options);
  3466. break;
  3467. case _STARPU_FUT_TASK_WAIT_FOR_ALL:
  3468. handle_task_wait_for_all();
  3469. break;
  3470. case _STARPU_FUT_EVENT:
  3471. if (!options->no_events)
  3472. handle_event(&ev, options);
  3473. break;
  3474. case _STARPU_FUT_THREAD_EVENT:
  3475. if (!options->no_events)
  3476. handle_thread_event(&ev, options);
  3477. break;
  3478. case _STARPU_FUT_LOCKING_MUTEX:
  3479. break;
  3480. case _STARPU_FUT_MUTEX_LOCKED:
  3481. break;
  3482. case _STARPU_FUT_UNLOCKING_MUTEX:
  3483. break;
  3484. case _STARPU_FUT_MUTEX_UNLOCKED:
  3485. break;
  3486. case _STARPU_FUT_TRYLOCK_MUTEX:
  3487. break;
  3488. case _STARPU_FUT_RDLOCKING_RWLOCK:
  3489. break;
  3490. case _STARPU_FUT_RWLOCK_RDLOCKED:
  3491. break;
  3492. case _STARPU_FUT_WRLOCKING_RWLOCK:
  3493. break;
  3494. case _STARPU_FUT_RWLOCK_WRLOCKED:
  3495. break;
  3496. case _STARPU_FUT_UNLOCKING_RWLOCK:
  3497. break;
  3498. case _STARPU_FUT_RWLOCK_UNLOCKED:
  3499. break;
  3500. case _STARPU_FUT_LOCKING_SPINLOCK:
  3501. break;
  3502. case _STARPU_FUT_SPINLOCK_LOCKED:
  3503. break;
  3504. case _STARPU_FUT_UNLOCKING_SPINLOCK:
  3505. break;
  3506. case _STARPU_FUT_SPINLOCK_UNLOCKED:
  3507. break;
  3508. case _STARPU_FUT_TRYLOCK_SPINLOCK:
  3509. break;
  3510. case _STARPU_FUT_COND_WAIT_BEGIN:
  3511. break;
  3512. case _STARPU_FUT_COND_WAIT_END:
  3513. break;
  3514. case _STARPU_FUT_BARRIER_WAIT_BEGIN:
  3515. break;
  3516. case _STARPU_FUT_BARRIER_WAIT_END:
  3517. break;
  3518. case _STARPU_FUT_MEMORY_FULL:
  3519. break;
  3520. case _STARPU_FUT_SCHED_COMPONENT_POP_PRIO:
  3521. break;
  3522. case _STARPU_FUT_SCHED_COMPONENT_PUSH_PRIO:
  3523. break;
  3524. case _STARPU_FUT_HYPERVISOR_BEGIN:
  3525. handle_hypervisor_begin(&ev, options);
  3526. break;
  3527. case _STARPU_FUT_HYPERVISOR_END:
  3528. handle_hypervisor_end(&ev, options);
  3529. break;
  3530. case FUT_SETUP_CODE:
  3531. fut_keymask = ev.param[0];
  3532. break;
  3533. case FUT_KEYCHANGE_CODE:
  3534. fut_keymask = ev.param[0];
  3535. break;
  3536. case FUT_START_FLUSH_CODE:
  3537. handle_string_event(&ev, "fxt_start_flush", options);
  3538. break;
  3539. case FUT_STOP_FLUSH_CODE:
  3540. handle_string_event(&ev, "fxt_stop_flush", options);
  3541. break;
  3542. /* We can safely ignore FUT internal events */
  3543. case FUT_CALIBRATE0_CODE:
  3544. case FUT_CALIBRATE1_CODE:
  3545. case FUT_CALIBRATE2_CODE:
  3546. case FUT_NEW_LWP_CODE:
  3547. case FUT_GCC_INSTRUMENT_ENTRY_CODE:
  3548. break;
  3549. default:
  3550. #ifdef STARPU_VERBOSE
  3551. _STARPU_MSG("unknown event.. %x at time %llx WITH OFFSET %llx\n",
  3552. (unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time-options->file_offset));
  3553. #endif
  3554. break;
  3555. }
  3556. _starpu_fxt_process_bandwidth(options);
  3557. if (!options->no_flops)
  3558. _starpu_fxt_process_computations(options);
  3559. }
  3560. if (!options->no_flops)
  3561. {
  3562. /* computations are supposed to be over, drop any pending comp */
  3563. unsigned i;
  3564. for (i = 0; i < STARPU_NMAXWORKERS; i++)
  3565. {
  3566. struct _starpu_computation *comp = ongoing_computation[i];
  3567. if (comp)
  3568. {
  3569. STARPU_ASSERT(!comp->peer);
  3570. _starpu_computation_list_erase(&computation_list, comp);
  3571. ongoing_computation[i] = 0;
  3572. }
  3573. }
  3574. /* And flush completed computations */
  3575. _starpu_fxt_process_computations(options);
  3576. }
  3577. if (out_paje_file && !options->no_bus)
  3578. {
  3579. while (!_starpu_communication_list_empty(&communication_list)) {
  3580. struct _starpu_communication*itor;
  3581. itor = _starpu_communication_list_pop_front(&communication_list);
  3582. /* Trace finished with this communication uncompleted, fake its termination */
  3583. unsigned comid = itor->comid;
  3584. unsigned long size = itor->size;
  3585. unsigned dst = itor->dst_node;
  3586. double time = current_computation_time;
  3587. const char *link_type = itor->type;
  3588. #ifdef STARPU_HAVE_POTI
  3589. char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN];
  3590. char dst_memnode_container[STARPU_POTI_STR_LEN], program_container[STARPU_POTI_STR_LEN];
  3591. snprintf(paje_value, sizeof(paje_value), "%lu", size);
  3592. snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
  3593. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  3594. memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, dst);
  3595. poti_EndLink(time, program_container, link_type, dst_memnode_container, paje_value, paje_key);
  3596. #else
  3597. fprintf(out_paje_file, "19 %.9f %s %sp %lu %smm%u com_%u\n", time, link_type, prefix, size, prefix, dst, comid);
  3598. #endif
  3599. _starpu_communication_delete(itor);
  3600. }
  3601. }
  3602. if (out_paje_file && !options->no_flops)
  3603. {
  3604. unsigned i;
  3605. for (i = 0; i < STARPU_NMAXWORKERS; i++)
  3606. {
  3607. if (last_codelet_end[i] != 0.0)
  3608. {
  3609. #ifdef STARPU_HAVE_POTI
  3610. char container[STARPU_POTI_STR_LEN];
  3611. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, i);
  3612. poti_SetVariable(last_codelet_end[i], container, "gf", 0.);
  3613. #else
  3614. fprintf(out_paje_file, "13 %.9f %sw%u gf %f\n",
  3615. last_codelet_end[i], prefix, i, 0.);
  3616. #endif
  3617. last_codelet_end[i] = 0.0;
  3618. }
  3619. }
  3620. /* flush last value */
  3621. #ifdef STARPU_HAVE_POTI
  3622. char container[STARPU_POTI_STR_LEN];
  3623. scheduler_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  3624. poti_SetVariable(current_computation_time, container, "gft", (double)current_computation);
  3625. #else
  3626. fprintf(out_paje_file, "13 %.9f %ssched gft %f\n", current_computation_time, prefix, (float)current_computation);
  3627. #endif
  3628. }
  3629. {
  3630. struct data_info *data=NULL, *tmp=NULL;
  3631. HASH_ITER(hh, data_info, data, tmp)
  3632. {
  3633. data_dump(data);
  3634. }
  3635. }
  3636. {
  3637. struct task_info *task=NULL, *tmp=NULL;
  3638. HASH_ITER(hh, tasks_info, task, tmp)
  3639. {
  3640. task_dump(task, options);
  3641. }
  3642. }
  3643. /* Close the trace file */
  3644. if (close(fd_in))
  3645. {
  3646. perror("close failed :");
  3647. exit(-1);
  3648. }
  3649. }
  3650. /* Initialize FxT options to default values */
  3651. void starpu_fxt_options_init(struct starpu_fxt_options *options)
  3652. {
  3653. options->per_task_colour = 0;
  3654. options->no_events = 0;
  3655. options->no_counter = 0;
  3656. options->no_bus = 0;
  3657. options->no_flops = 0;
  3658. options->no_smooth = 0;
  3659. options->no_acquire = 0;
  3660. options->memory_states = 0;
  3661. options->internal = 0;
  3662. options->label_deps = 0;
  3663. options->ninputfiles = 0;
  3664. options->out_paje_path = "paje.trace";
  3665. options->dag_path = "dag.dot";
  3666. options->tasks_path = "tasks.rec";
  3667. options->comms_path = "comms.rec";
  3668. options->number_events_path = NULL;
  3669. options->data_path = "data.rec";
  3670. options->papi_path = "papi.rec";
  3671. options->anim_path = "trace.html";
  3672. options->states_path = "trace.rec";
  3673. options->distrib_time_path = "distrib.data";
  3674. options->dumped_codelets = NULL;
  3675. options->activity_path = "activity.data";
  3676. options->sched_tasks_path = "sched_tasks.rec";
  3677. }
  3678. static
  3679. void _starpu_fxt_distrib_file_init(struct starpu_fxt_options *options)
  3680. {
  3681. dumped_codelets_count = 0;
  3682. dumped_codelets = NULL;
  3683. if (options->distrib_time_path)
  3684. {
  3685. distrib_time = fopen(options->distrib_time_path, "w+");
  3686. }
  3687. else
  3688. {
  3689. distrib_time = NULL;
  3690. }
  3691. }
  3692. static
  3693. void _starpu_fxt_distrib_file_close(struct starpu_fxt_options *options)
  3694. {
  3695. if (distrib_time)
  3696. fclose(distrib_time);
  3697. if (options->dumped_codelets)
  3698. {
  3699. *options->dumped_codelets = dumped_codelets;
  3700. options->dumped_codelets_count = dumped_codelets_count;
  3701. }
  3702. }
  3703. static
  3704. void _starpu_fxt_activity_file_init(struct starpu_fxt_options *options)
  3705. {
  3706. if (options->activity_path)
  3707. activity_file = fopen(options->activity_path, "w+");
  3708. else
  3709. activity_file = NULL;
  3710. }
  3711. static
  3712. void _starpu_fxt_sched_tasks_file_init(struct starpu_fxt_options *options)
  3713. {
  3714. if (options->sched_tasks_path)
  3715. sched_tasks_file = fopen(options->sched_tasks_path, "w+");
  3716. else
  3717. sched_tasks_file = NULL;
  3718. }
  3719. static
  3720. void _starpu_fxt_anim_file_init(struct starpu_fxt_options *options)
  3721. {
  3722. if (options->anim_path)
  3723. {
  3724. anim_file = fopen(options->anim_path, "w+");
  3725. _starpu_fxt_component_print_header(anim_file);
  3726. }
  3727. else
  3728. anim_file = NULL;
  3729. }
  3730. static
  3731. void _starpu_fxt_tasks_file_init(struct starpu_fxt_options *options)
  3732. {
  3733. if (options->tasks_path)
  3734. tasks_file = fopen(options->tasks_path, "w+");
  3735. else
  3736. tasks_file = NULL;
  3737. }
  3738. static
  3739. void _starpu_fxt_data_file_init(struct starpu_fxt_options *options)
  3740. {
  3741. if (options->data_path)
  3742. data_file = fopen(options->data_path, "w+");
  3743. else
  3744. data_file = NULL;
  3745. }
  3746. static
  3747. void _starpu_fxt_comms_file_init(struct starpu_fxt_options *options)
  3748. {
  3749. if (options->comms_path)
  3750. comms_file = fopen(options->comms_path, "w+");
  3751. else
  3752. comms_file = NULL;
  3753. }
  3754. static
  3755. void _starpu_fxt_number_events_file_init(struct starpu_fxt_options *options)
  3756. {
  3757. if (options->number_events_path)
  3758. {
  3759. number_events_file = fopen(options->number_events_path, "w+");
  3760. /* FUT_SETUP_CODE is the event with the maximal value */
  3761. number_events = calloc(FUT_SETUP_CODE+1, sizeof(uint64_t));
  3762. }
  3763. else
  3764. number_events_file = NULL;
  3765. }
  3766. static
  3767. void _starpu_fxt_papi_file_init(struct starpu_fxt_options *options)
  3768. {
  3769. #ifdef STARPU_PAPI
  3770. if (options->papi_path)
  3771. papi_file = fopen(options->papi_path, "w+");
  3772. else
  3773. papi_file = NULL;
  3774. #endif
  3775. }
  3776. static
  3777. void _starpu_fxt_write_trace_header(FILE *f)
  3778. {
  3779. fprintf(f, "#\n");
  3780. fprintf(f, "# E: Event type\n");
  3781. fprintf(f, "# N: Event name\n");
  3782. fprintf(f, "# C: Event category\n");
  3783. fprintf(f, "# W: Worker ID\n");
  3784. fprintf(f, "# T: Thread ID\n");
  3785. fprintf(f, "# S: Start time\n");
  3786. fprintf(f, "#\n");
  3787. fprintf(f, "\n");
  3788. }
  3789. static
  3790. void _starpu_fxt_trace_file_init(struct starpu_fxt_options *options)
  3791. {
  3792. if (options->states_path)
  3793. trace_file = fopen(options->states_path, "w+");
  3794. else
  3795. trace_file = NULL;
  3796. if (trace_file)
  3797. _starpu_fxt_write_trace_header(trace_file);
  3798. }
  3799. static
  3800. void _starpu_fxt_activity_file_close(void)
  3801. {
  3802. if (activity_file)
  3803. fclose(activity_file);
  3804. }
  3805. static
  3806. void _starpu_fxt_sched_tasks_file_close(void)
  3807. {
  3808. if (sched_tasks_file)
  3809. fclose(sched_tasks_file);
  3810. }
  3811. static
  3812. void _starpu_fxt_anim_file_close(void)
  3813. {
  3814. //_starpu_fxt_component_dump(stderr);
  3815. if (anim_file)
  3816. {
  3817. _starpu_fxt_component_finish(anim_file);
  3818. fclose(anim_file);
  3819. }
  3820. }
  3821. static
  3822. void _starpu_fxt_tasks_file_close(void)
  3823. {
  3824. if (tasks_file)
  3825. fclose(tasks_file);
  3826. }
  3827. static
  3828. void _starpu_fxt_comms_file_close(void)
  3829. {
  3830. if (comms_file)
  3831. fclose(comms_file);
  3832. }
  3833. static
  3834. void _starpu_fxt_number_events_file_close(void)
  3835. {
  3836. if (number_events_file)
  3837. {
  3838. assert(number_events != NULL);
  3839. fprintf(number_events_file, "# Use starpu_fxt_number_events_to_names.py to convert event keys to event names.\n");
  3840. for (int i = 0; i <= FUT_SETUP_CODE; i++)
  3841. {
  3842. if (number_events[i] > 0)
  3843. fprintf(number_events_file, "0x%x\t%lu\n", i, number_events[i]);
  3844. }
  3845. free(number_events);
  3846. number_events = NULL;
  3847. fclose(number_events_file);
  3848. }
  3849. }
  3850. static
  3851. void _starpu_fxt_data_file_close(void)
  3852. {
  3853. if (data_file)
  3854. fclose(data_file);
  3855. }
  3856. static
  3857. void _starpu_fxt_papi_file_close(void)
  3858. {
  3859. #ifdef STARPU_PAPI
  3860. if (papi_file)
  3861. fclose(papi_file);
  3862. #endif
  3863. }
  3864. static
  3865. void _starpu_fxt_trace_file_close(void)
  3866. {
  3867. if (trace_file)
  3868. fclose(trace_file);
  3869. }
  3870. static
  3871. void _starpu_fxt_paje_file_init(struct starpu_fxt_options *options)
  3872. {
  3873. /* create a new file */
  3874. if (options->out_paje_path)
  3875. {
  3876. out_paje_file = fopen(options->out_paje_path, "w+");
  3877. if (!out_paje_file)
  3878. {
  3879. _STARPU_MSG("error while opening %s\n", options->out_paje_path);
  3880. perror("fopen");
  3881. exit(1);
  3882. }
  3883. #ifdef STARPU_HAVE_POTI
  3884. #ifdef HAVE_POTI_INIT_CUSTOM
  3885. fclose(out_paje_file);
  3886. poti_init_custom (options->out_paje_path,
  3887. 0, //if false, allow extended events
  3888. 1, //if true, an old header (pj_dump -n)
  3889. 0, //if false, the trace has no comments
  3890. 1, //if true, events have aliases
  3891. 1);//if true, relative timestamps
  3892. #else
  3893. poti_init (out_paje_file);
  3894. #endif
  3895. #endif
  3896. _starpu_fxt_write_paje_header(out_paje_file, options);
  3897. }
  3898. else
  3899. {
  3900. out_paje_file = NULL;
  3901. }
  3902. /* create lists for symbols (kernel states) and communications */
  3903. _starpu_symbol_name_list_init(&symbol_list);
  3904. _starpu_communication_list_init(&communication_list);
  3905. if (!options->no_flops)
  3906. _starpu_computation_list_init(&computation_list);
  3907. }
  3908. static
  3909. void _starpu_fxt_paje_file_close(void)
  3910. {
  3911. if (out_paje_file)
  3912. fclose(out_paje_file);
  3913. }
  3914. static
  3915. uint64_t _starpu_fxt_find_start_time(char *filename_in)
  3916. {
  3917. /* Open the trace file */
  3918. int fd_in;
  3919. fd_in = open(filename_in, O_RDONLY);
  3920. if (fd_in < 0)
  3921. {
  3922. perror("open failed :");
  3923. exit(-1);
  3924. }
  3925. static fxt_t fut;
  3926. fut = fxt_fdopen(fd_in);
  3927. if (!fut)
  3928. {
  3929. perror("fxt_fdopen :");
  3930. exit(-1);
  3931. }
  3932. fxt_blockev_t block;
  3933. block = fxt_blockev_enter(fut);
  3934. struct fxt_ev_64 ev;
  3935. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  3936. STARPU_ASSERT (ret == FXT_EV_OK);
  3937. /* Close the trace file */
  3938. if (close(fd_in))
  3939. {
  3940. perror("close failed :");
  3941. exit(-1);
  3942. }
  3943. return (ev.time);
  3944. }
  3945. void starpu_fxt_generate_trace(struct starpu_fxt_options *options)
  3946. {
  3947. _starpu_fxt_dag_init(options->dag_path);
  3948. _starpu_fxt_distrib_file_init(options);
  3949. _starpu_fxt_activity_file_init(options);
  3950. _starpu_fxt_sched_tasks_file_init(options);
  3951. _starpu_fxt_anim_file_init(options);
  3952. _starpu_fxt_tasks_file_init(options);
  3953. _starpu_fxt_data_file_init(options);
  3954. _starpu_fxt_papi_file_init(options);
  3955. _starpu_fxt_comms_file_init(options);
  3956. _starpu_fxt_number_events_file_init(options);
  3957. _starpu_fxt_trace_file_init(options);
  3958. _starpu_fxt_paje_file_init(options);
  3959. if (options->ninputfiles == 0)
  3960. {
  3961. return;
  3962. }
  3963. else if (options->ninputfiles == 1)
  3964. {
  3965. /* we usually only have a single trace */
  3966. uint64_t file_start_time = _starpu_fxt_find_start_time(options->filenames[0]);
  3967. options->file_prefix = strdup("");
  3968. options->file_offset = file_start_time;
  3969. options->file_rank = -1;
  3970. _starpu_fxt_parse_new_file(options->filenames[0], options);
  3971. }
  3972. else
  3973. {
  3974. unsigned inputfile;
  3975. uint64_t offsets[options->ninputfiles];
  3976. /*
  3977. * Find the trace offsets:
  3978. * - If there is no sync point
  3979. * psi_k(x) = x - start_k
  3980. * - If there is a sync point sync_k
  3981. * psi_k(x) = x - sync_k + M
  3982. * where M = max { sync_i - start_i | there exists sync_i}
  3983. * More generally:
  3984. * - psi_k(x) = x - offset_k
  3985. */
  3986. int unique_keys[options->ninputfiles];
  3987. int rank_k[options->ninputfiles];
  3988. uint64_t start_k[options->ninputfiles];
  3989. uint64_t sync_k[options->ninputfiles];
  3990. unsigned sync_k_exists[options->ninputfiles];
  3991. uint64_t M = 0;
  3992. unsigned found_one_sync_point = 0;
  3993. int key = 0;
  3994. unsigned display_mpi = 0;
  3995. /* Compute all start_k */
  3996. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  3997. {
  3998. uint64_t file_start = _starpu_fxt_find_start_time(options->filenames[inputfile]);
  3999. start_k[inputfile] = file_start;
  4000. }
  4001. /* Compute all sync_k if they exist */
  4002. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4003. {
  4004. int ret = _starpu_fxt_mpi_find_sync_point(options->filenames[inputfile],
  4005. &sync_k[inputfile],
  4006. &unique_keys[inputfile],
  4007. &rank_k[inputfile]);
  4008. if (ret == -1)
  4009. {
  4010. /* There was no sync point, we assume there is no offset */
  4011. sync_k_exists[inputfile] = 0;
  4012. }
  4013. else
  4014. {
  4015. if (!found_one_sync_point)
  4016. {
  4017. key = unique_keys[inputfile];
  4018. display_mpi = 1;
  4019. found_one_sync_point = 1;
  4020. }
  4021. else
  4022. {
  4023. if (key != unique_keys[inputfile])
  4024. {
  4025. _STARPU_MSG("Warning: traces are coming from different run so we will not try to display MPI communications.\n");
  4026. display_mpi = 0;
  4027. }
  4028. }
  4029. STARPU_ASSERT(sync_k[inputfile] >= start_k[inputfile]);
  4030. sync_k_exists[inputfile] = 1;
  4031. uint64_t diff = sync_k[inputfile] - start_k[inputfile];
  4032. if (diff > M)
  4033. M = diff;
  4034. }
  4035. }
  4036. /* Compute the offset */
  4037. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4038. {
  4039. offsets[inputfile] = sync_k_exists[inputfile]?
  4040. (sync_k[inputfile]-M):start_k[inputfile];
  4041. }
  4042. /* generate the Paje trace for the different files */
  4043. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4044. {
  4045. int filerank = rank_k[inputfile];
  4046. _STARPU_DISP("Parsing file %s (rank %d)\n", options->filenames[inputfile], filerank);
  4047. char file_prefix[32];
  4048. snprintf(file_prefix, sizeof(file_prefix), "%d_", filerank);
  4049. free(options->file_prefix);
  4050. options->file_prefix = strdup(file_prefix);
  4051. options->file_offset = offsets[inputfile];
  4052. options->file_rank = filerank;
  4053. _starpu_fxt_parse_new_file(options->filenames[inputfile], options);
  4054. }
  4055. /* display the MPI transfers if possible */
  4056. if (display_mpi)
  4057. _starpu_fxt_display_mpi_transfers(options, rank_k, out_paje_file, comms_file);
  4058. }
  4059. /* close the different files */
  4060. _starpu_fxt_paje_file_close();
  4061. _starpu_fxt_activity_file_close();
  4062. _starpu_fxt_sched_tasks_file_close();
  4063. _starpu_fxt_distrib_file_close(options);
  4064. _starpu_fxt_anim_file_close();
  4065. _starpu_fxt_tasks_file_close();
  4066. _starpu_fxt_data_file_close();
  4067. _starpu_fxt_papi_file_close();
  4068. _starpu_fxt_comms_file_close();
  4069. _starpu_fxt_number_events_file_close();
  4070. _starpu_fxt_trace_file_close();
  4071. _starpu_fxt_dag_terminate();
  4072. options->nworkers = nworkers;
  4073. free(options->file_prefix);
  4074. }
  4075. #define DATA_STR_MAX_SIZE 15
  4076. struct parse_task
  4077. {
  4078. unsigned exec_time;
  4079. unsigned data_total;
  4080. unsigned workerid;
  4081. char *codelet_name;
  4082. };
  4083. static struct parse_task tasks[STARPU_NMAXWORKERS];
  4084. struct starpu_data_trace_kernel
  4085. {
  4086. UT_hash_handle hh;
  4087. char *name;
  4088. FILE *file;
  4089. } *kernels;
  4090. #define NANO_SEC_TO_MILI_SEC 0.000001
  4091. static FILE *codelet_list;
  4092. static void write_task(struct parse_task pt)
  4093. {
  4094. struct starpu_data_trace_kernel *kernel;
  4095. char *codelet_name = pt.codelet_name;
  4096. HASH_FIND_STR(kernels, codelet_name, kernel);
  4097. //fprintf(stderr, "%p %p %s\n", kernel, kernels, codelet_name);
  4098. if(kernel == NULL)
  4099. {
  4100. _STARPU_MALLOC(kernel, sizeof(*kernel));
  4101. kernel->name = strdup(codelet_name);
  4102. //fprintf(stderr, "%s\n", kernel->name);
  4103. kernel->file = fopen(codelet_name, "w+");
  4104. if(!kernel->file)
  4105. {
  4106. perror("open failed :");
  4107. exit(-1);
  4108. }
  4109. HASH_ADD_STR(kernels, name, kernel);
  4110. fprintf(codelet_list, "%s\n", codelet_name);
  4111. }
  4112. double time = pt.exec_time * NANO_SEC_TO_MILI_SEC;
  4113. fprintf(kernel->file, "%lf %u %u\n", time, pt.data_total, pt.workerid);
  4114. }
  4115. void starpu_fxt_write_data_trace(char *filename_in)
  4116. {
  4117. int fd_in;
  4118. fd_in = open(filename_in, O_RDONLY);
  4119. if (fd_in < 0)
  4120. {
  4121. perror("open failed :");
  4122. exit(-1);
  4123. }
  4124. static fxt_t fut;
  4125. fut = fxt_fdopen(fd_in);
  4126. if (!fut)
  4127. {
  4128. perror("fxt_fdopen :");
  4129. exit(-1);
  4130. }
  4131. codelet_list = fopen("codelet_list", "w+");
  4132. if(!codelet_list)
  4133. {
  4134. perror("open failed :");
  4135. exit(-1);
  4136. }
  4137. fxt_blockev_t block;
  4138. block = fxt_blockev_enter(fut);
  4139. struct fxt_ev_64 ev;
  4140. int workerid=-1;
  4141. unsigned long has_name = 0;
  4142. while(1)
  4143. {
  4144. unsigned i;
  4145. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  4146. for (i = ev.nb_params; i < FXT_MAX_PARAMS; i++)
  4147. ev.param[i] = 0;
  4148. if (ret != FXT_EV_OK)
  4149. {
  4150. break;
  4151. }
  4152. switch (ev.code)
  4153. {
  4154. case _STARPU_FUT_WORKER_INIT_START:
  4155. register_worker_id(0 /* TODO: Add nodeid here instead */, ev.param[6], ev.param[1], ev.param[5]);
  4156. break;
  4157. case _STARPU_FUT_START_CODELET_BODY:
  4158. workerid = ev.param[2];
  4159. tasks[workerid].workerid = (unsigned)workerid;
  4160. tasks[workerid].exec_time = ev.time;
  4161. has_name = ev.param[4];
  4162. tasks[workerid].codelet_name = strdup(has_name ? get_fxt_string(&ev, 5): "unknown");
  4163. //fprintf(stderr, "start codelet :[%d][%s]\n", workerid, tasks[workerid].codelet_name);
  4164. break;
  4165. case _STARPU_FUT_END_CODELET_BODY:
  4166. workerid = ev.param[3];
  4167. assert(workerid != -1);
  4168. tasks[workerid].exec_time = ev.time - tasks[workerid].exec_time;
  4169. write_task(tasks[workerid]);
  4170. break;
  4171. case _STARPU_FUT_DATA_LOAD:
  4172. workerid = ev.param[0];
  4173. tasks[workerid].data_total = ev.param[1];
  4174. break;
  4175. default:
  4176. #ifdef STARPU_VERBOSE
  4177. _STARPU_MSG("unknown event.. %x at time %llx WITH OFFSET %llx\n",
  4178. (unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time));
  4179. #endif
  4180. break;
  4181. }
  4182. }
  4183. if (close(fd_in))
  4184. {
  4185. perror("close failed :");
  4186. exit(-1);
  4187. }
  4188. if(fclose(codelet_list))
  4189. {
  4190. perror("close failed :");
  4191. exit(-1);
  4192. }
  4193. struct starpu_data_trace_kernel *kernel=NULL, *tmp=NULL;
  4194. HASH_ITER(hh, kernels, kernel, tmp)
  4195. {
  4196. if(fclose(kernel->file))
  4197. {
  4198. perror("close failed :");
  4199. exit(-1);
  4200. }
  4201. HASH_DEL(kernels, kernel);
  4202. free(kernel->name);
  4203. free(kernel);
  4204. }
  4205. }
  4206. #endif // STARPU_USE_FXT