starpu_fxt.c 150 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992
  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 STARPU_ATTRIBUTE_UNUSED, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
  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_color_symbol_red(char *name)
  412. {
  413. /* choose some color ... 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_color_symbol_green(char *name)
  418. {
  419. /* choose some color ... 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_color_symbol_blue(char *name)
  424. {
  425. /* choose some color ... 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 = strdup(prefix);
  609. str[strlen(prefix)-1] = '\0';
  610. unsigned long nodeid = atoi(str);
  611. free(str);
  612. return nodeid;
  613. }
  614. /* Register user threads if not done already */
  615. static void register_user_thread(double timestamp, unsigned long tid, const char *prefix)
  616. {
  617. if (register_thread(prefixTOnodeid(prefix), tid, -1, 0) && out_paje_file)
  618. {
  619. #ifdef STARPU_HAVE_POTI
  620. char program_container[STARPU_POTI_STR_LEN];
  621. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  622. char new_thread_container_alias[STARPU_POTI_STR_LEN];
  623. thread_container_alias (new_thread_container_alias, STARPU_POTI_STR_LEN, prefix, tid);
  624. char new_thread_container_name[STARPU_POTI_STR_LEN];
  625. snprintf(new_thread_container_name, sizeof(new_thread_container_name), "%sUserThread%lu", prefix, tid);
  626. poti_CreateContainer(timestamp, new_thread_container_alias, "UT", program_container, new_thread_container_alias);
  627. #else
  628. fprintf(out_paje_file, "7 %.9f %st%lu UT %sp %sUserThread%lu\n",
  629. timestamp, prefix, tid, prefix, prefix, tid);
  630. #endif
  631. }
  632. }
  633. static void register_mpi_thread(unsigned long nodeid, unsigned long tid)
  634. {
  635. int ret = register_thread(nodeid, tid, -2, 0);
  636. STARPU_ASSERT(ret == 1);
  637. }
  638. static int find_worker_id(unsigned long nodeid, unsigned long tid)
  639. {
  640. struct worker_entry *entry;
  641. tid = nodeid*tid+tid;
  642. HASH_FIND(hh, worker_ids, &tid, sizeof(tid), entry);
  643. if (!entry)
  644. return -1;
  645. return entry->workerid;
  646. }
  647. /* check whether this thread manages several workers */
  648. static int find_sync(unsigned long nodeid, unsigned long tid)
  649. {
  650. struct worker_entry *entry;
  651. tid = nodeid*tid+tid;
  652. HASH_FIND(hh, worker_ids, &tid, sizeof(tid), entry);
  653. if (!entry)
  654. return 0;
  655. return entry->sync;
  656. }
  657. static void update_accumulated_time(int worker, double sleep_time, double exec_time, double current_timestamp, int forceflush)
  658. {
  659. accumulated_sleep_time[worker] += sleep_time;
  660. accumulated_exec_time[worker] += exec_time;
  661. /* If sufficient time has elapsed since the last flush, we have a new
  662. * point in our graph */
  663. double elapsed = current_timestamp - last_activity_flush_timestamp[worker];
  664. if (forceflush || (elapsed > ACTIVITY_PERIOD))
  665. {
  666. if (activity_file)
  667. 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]);
  668. /* reset the accumulated times */
  669. last_activity_flush_timestamp[worker] = current_timestamp;
  670. accumulated_sleep_time[worker] = 0.0;
  671. accumulated_exec_time[worker] = 0.0;
  672. }
  673. }
  674. static void memnode_set_state(double time, const char *prefix, unsigned int memnodeid, const char *name)
  675. {
  676. #ifdef STARPU_HAVE_POTI
  677. char container[STARPU_POTI_STR_LEN];
  678. memmanager_container_alias(container, STARPU_POTI_STR_LEN, prefix, memnodeid);
  679. poti_SetState(time, container, "MS", name);
  680. #else
  681. fprintf(out_paje_file, "10 %.9f %smm%u MS %s\n", time, prefix, memnodeid, name);
  682. #endif
  683. }
  684. static void memnode_push_state(double time, const char *prefix, unsigned int memnodeid, const char *name)
  685. {
  686. #ifdef STARPU_HAVE_POTI
  687. char container[STARPU_POTI_STR_LEN];
  688. memmanager_container_alias(container, STARPU_POTI_STR_LEN, prefix, memnodeid);
  689. poti_PushState(time, container, "MS", name);
  690. #else
  691. fprintf(out_paje_file, "11 %.9f %smm%u MS %s\n", time, prefix, memnodeid, name);
  692. #endif
  693. }
  694. static void memnode_pop_state(double time, const char *prefix, unsigned int memnodeid)
  695. {
  696. #ifdef STARPU_HAVE_POTI
  697. char container[STARPU_POTI_STR_LEN];
  698. memmanager_container_alias(container, STARPU_POTI_STR_LEN, prefix, memnodeid);
  699. poti_PopState(time, container, "MS");
  700. #else
  701. fprintf(out_paje_file, "12 %.9f %smm%u MS\n", time, prefix, memnodeid);
  702. #endif
  703. }
  704. 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)
  705. {
  706. if (!options->memory_states)
  707. return;
  708. #ifdef STARPU_HAVE_POTI
  709. char container[STARPU_POTI_STR_LEN];
  710. char p_handle[STARPU_POTI_STR_LEN];
  711. memmanager_container_alias(container, STARPU_POTI_STR_LEN, prefix, memnodeid);
  712. snprintf(p_handle, sizeof(p_handle), "%lx", handle);
  713. #ifdef HAVE_POTI_USER_NEWEVENT
  714. char p_dest[STARPU_POTI_STR_LEN];
  715. char p_info[STARPU_POTI_STR_LEN];
  716. char p_size[STARPU_POTI_STR_LEN];
  717. memmanager_container_alias(p_dest, STARPU_POTI_STR_LEN, prefix, dest);
  718. snprintf(p_info, sizeof(p_info), "%lu", info);
  719. snprintf(p_size, sizeof(p_size), "%lu", size);
  720. poti_user_NewEvent(_starpu_poti_MemoryEvent, time, container, name, "0", 4,
  721. p_handle, p_info, p_size, p_dest);
  722. #else
  723. poti_NewEvent(time, container, name, p_handle);
  724. #endif
  725. #else
  726. 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);
  727. #endif
  728. }
  729. static void worker_set_state(double time, const char *prefix, long unsigned int workerid, const char *name)
  730. {
  731. if (fut_keymask == FUT_KEYMASK0)
  732. return;
  733. if (!out_paje_file)
  734. return;
  735. #ifdef STARPU_HAVE_POTI
  736. char container[STARPU_POTI_STR_LEN];
  737. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
  738. poti_SetState(time, container, "WS", name);
  739. #else
  740. fprintf(out_paje_file, "10 %.9f %sw%lu WS \"%s\"\n", time, prefix, workerid, name);
  741. #endif
  742. }
  743. static void worker_push_state(double time, const char *prefix, long unsigned int workerid, const char *name)
  744. {
  745. if (fut_keymask == FUT_KEYMASK0)
  746. return;
  747. if (!out_paje_file)
  748. return;
  749. #ifdef STARPU_HAVE_POTI
  750. char container[STARPU_POTI_STR_LEN];
  751. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
  752. poti_PushState(time, container, "WS", name);
  753. #else
  754. fprintf(out_paje_file, "11 %.9f %sw%lu WS %s\n", time, prefix, workerid, name);
  755. #endif
  756. }
  757. static void worker_pop_state(double time, const char *prefix, long unsigned int workerid)
  758. {
  759. if (fut_keymask == FUT_KEYMASK0)
  760. return;
  761. if (!out_paje_file)
  762. return;
  763. #ifdef STARPU_HAVE_POTI
  764. char container[STARPU_POTI_STR_LEN];
  765. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
  766. poti_PopState(time, container, "WS");
  767. #else
  768. fprintf(out_paje_file, "12 %.9f %sw%lu WS\n", time, prefix, workerid);
  769. #endif
  770. }
  771. static void thread_set_state(double time, const char *prefix, long unsigned int threadid, const char *name)
  772. {
  773. if (find_sync(prefixTOnodeid(prefix), threadid))
  774. /* Unless using worker sets, collapse thread and worker */
  775. return worker_set_state(time, prefix, find_worker_id(prefixTOnodeid(prefix), threadid), name);
  776. if (!out_paje_file)
  777. return;
  778. #ifdef STARPU_HAVE_POTI
  779. char container[STARPU_POTI_STR_LEN];
  780. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  781. poti_SetState(time, container, "S", name);
  782. #else
  783. fprintf(out_paje_file, "10 %.9f %st%lu S %s\n", time, prefix, threadid, name);
  784. #endif
  785. }
  786. #if 0
  787. /* currently unused */
  788. static void user_thread_set_state(double time, const char *prefix, long unsigned int threadid, const char *name)
  789. {
  790. register_user_thread(time, threadid, prefix);
  791. if (!out_paje_file)
  792. return;
  793. #ifdef STARPU_HAVE_POTI
  794. char container[STARPU_POTI_STR_LEN];
  795. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  796. poti_SetState(time, container, "US", name);
  797. #else
  798. fprintf(out_paje_file, "10 %.9f %st%lu US %s\n", time, prefix, threadid, name);
  799. #endif
  800. }
  801. #endif
  802. static void user_thread_push_state(double time, const char *prefix, long unsigned int threadid, const char *name)
  803. {
  804. register_user_thread(time, threadid, prefix);
  805. if (out_paje_file)
  806. {
  807. #ifdef STARPU_HAVE_POTI
  808. char container[STARPU_POTI_STR_LEN];
  809. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  810. poti_PushState(time, container, "US", name);
  811. #else
  812. fprintf(out_paje_file, "11 %.9f %st%lu US %s\n", time, prefix, threadid, name);
  813. #endif
  814. }
  815. }
  816. static void user_thread_pop_state(double time, const char *prefix, long unsigned int threadid)
  817. {
  818. register_user_thread(time, threadid, prefix);
  819. if (out_paje_file)
  820. {
  821. #ifdef STARPU_HAVE_POTI
  822. char container[STARPU_POTI_STR_LEN];
  823. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  824. poti_PopState(time, container, "US");
  825. #else
  826. fprintf(out_paje_file, "12 %.9f %st%lu US\n", time, prefix, threadid);
  827. #endif
  828. }
  829. }
  830. static void thread_push_state(double time, const char *prefix, long unsigned int threadid, const char *name)
  831. {
  832. if (find_sync(prefixTOnodeid(prefix), threadid))
  833. /* Unless using worker sets, collapse thread and worker */
  834. return worker_push_state(time, prefix, find_worker_id(prefixTOnodeid(prefix), threadid), name);
  835. if (!out_paje_file)
  836. return;
  837. #ifdef STARPU_HAVE_POTI
  838. char container[STARPU_POTI_STR_LEN];
  839. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  840. poti_PushState(time, container, "S", name);
  841. #else
  842. fprintf(out_paje_file, "11 %.9f %st%lu S %s\n", time, prefix, threadid, name);
  843. #endif
  844. }
  845. static void thread_pop_state(double time, const char *prefix, long unsigned int threadid)
  846. {
  847. if (find_sync(prefixTOnodeid(prefix), threadid))
  848. /* Unless using worker sets, collapse thread and worker */
  849. return worker_pop_state(time, prefix, find_worker_id(prefixTOnodeid(prefix), threadid));
  850. if (!out_paje_file)
  851. return;
  852. #ifdef STARPU_HAVE_POTI
  853. char container[STARPU_POTI_STR_LEN];
  854. thread_container_alias(container, STARPU_POTI_STR_LEN, prefix, threadid);
  855. poti_PopState(time, container, "S");
  856. #else
  857. fprintf(out_paje_file, "12 %.9f %st%lu S\n", time, prefix, threadid);
  858. #endif
  859. }
  860. 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)
  861. {
  862. struct task_info *task = get_task(job_id, options->file_rank);
  863. #ifdef STARPU_HAVE_POTI
  864. char container[STARPU_POTI_STR_LEN];
  865. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
  866. char size_str[STARPU_POTI_STR_LEN];
  867. char parameters_str[STARPU_POTI_STR_LEN];
  868. char footprint_str[STARPU_POTI_STR_LEN];
  869. char tag_str[STARPU_POTI_STR_LEN];
  870. char jobid_str[STARPU_POTI_STR_LEN];
  871. char submitorder_str[STARPU_POTI_STR_LEN];
  872. char gflop_str[STARPU_POTI_STR_LEN];
  873. char X_str[STARPU_POTI_STR_LEN], Y_str[STARPU_POTI_STR_LEN], Z_str[STARPU_POTI_STR_LEN];
  874. char iteration_str[STARPU_POTI_STR_LEN], subiteration_str[STARPU_POTI_STR_LEN];
  875. snprintf(size_str, sizeof(size_str), "%lu", size);
  876. snprintf(parameters_str, sizeof(parameters_str), "%s", parameters);
  877. snprintf(footprint_str, sizeof(footprint_str), "%08lx", footprint);
  878. snprintf(tag_str, sizeof(tag_str), "%016llx", tag);
  879. snprintf(jobid_str, sizeof(jobid_str), "%s%lu", prefix, job_id);
  880. snprintf(submitorder_str, sizeof(submitorder_str), "%s%lu", prefix, task->submit_order);
  881. snprintf(gflop_str, sizeof(gflop_str), "%f", gflop);
  882. snprintf(X_str, sizeof(X_str), "%u", X);
  883. snprintf(Y_str, sizeof(Y_str), "%u", Y);
  884. snprintf(Z_str, sizeof(Z_str), "%u", Z);
  885. snprintf(iteration_str, sizeof(iteration_str), "%ld", iteration);
  886. snprintf(subiteration_str, sizeof(subiteration_str), "%ld", subiteration);
  887. #ifdef HAVE_POTI_INIT_CUSTOM
  888. poti_user_SetState(_starpu_poti_extendedSetState, time, container, "WS", name, 11, size_str,
  889. parameters_str,
  890. footprint_str,
  891. tag_str,
  892. jobid_str,
  893. submitorder_str,
  894. gflop_str,
  895. X_str,
  896. Y_str,
  897. /* Z_str, */
  898. iteration_str,
  899. subiteration_str);
  900. #else
  901. poti_SetState(time, container, "WS", name);
  902. #endif
  903. #else
  904. 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);
  905. #endif
  906. }
  907. static void mpicommthread_set_state(double time, const char *prefix, const char *name)
  908. {
  909. #ifdef STARPU_HAVE_POTI
  910. char container[STARPU_POTI_STR_LEN];
  911. mpicommthread_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  912. poti_SetState(time, container, "CtS", name);
  913. #else
  914. fprintf(out_paje_file, "10 %.9f %smpict CtS %s\n", time, prefix, name);
  915. #endif
  916. }
  917. static void mpicommthread_push_state(double time, const char *prefix, const char *name)
  918. {
  919. #ifdef STARPU_HAVE_POTI
  920. char container[STARPU_POTI_STR_LEN];
  921. mpicommthread_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  922. poti_PushState(time, container, "CtS", name);
  923. #else
  924. fprintf(out_paje_file, "11 %.9f %smpict CtS %s\n", time, prefix, name);
  925. #endif
  926. }
  927. static void mpicommthread_pop_state(double time, const char *prefix)
  928. {
  929. #ifdef STARPU_HAVE_POTI
  930. char container[STARPU_POTI_STR_LEN];
  931. mpicommthread_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  932. poti_PopState(time, container, "CtS");
  933. #else
  934. fprintf(out_paje_file, "12 %.9f %smpict CtS\n", time, prefix);
  935. #endif
  936. }
  937. static void recfmt_dump_state(double time, const char *event, int workerid, long int threadid, const char *name, const char *type)
  938. {
  939. fprintf(trace_file, "E: %s\n", event);
  940. if (name)
  941. fprintf(trace_file, "N: %s\n", name);
  942. if (type)
  943. fprintf(trace_file, "C: %s\n", type);
  944. fprintf(trace_file, "W: %d\n", workerid);
  945. if (threadid == -1)
  946. fprintf(trace_file, "T: -1\n");
  947. else
  948. fprintf(trace_file, "T: %ld\n", threadid);
  949. fprintf(trace_file, "S: %f\n", time);
  950. fprintf(trace_file, "\n");
  951. }
  952. static void recfmt_set_state(double time, int workerid, long int threadid, const char *name, const char *type)
  953. {
  954. recfmt_dump_state(time, "SetState", workerid, threadid, name, type);
  955. }
  956. static void recfmt_push_state(double time, int workerid, long unsigned int threadid, const char *name, const char *type)
  957. {
  958. recfmt_dump_state(time, "PushState", workerid, threadid, name, type);
  959. }
  960. static void recfmt_pop_state(double time, int workerid, long unsigned int threadid)
  961. {
  962. recfmt_dump_state(time, "PopState", workerid, threadid, NULL, NULL);
  963. }
  964. static void recfmt_worker_set_state(double time, int workerid, const char *name, const char *type)
  965. {
  966. const char *state_name;
  967. /* Special case for task events. */
  968. if (!strcmp(type, "Task"))
  969. state_name = name;
  970. else
  971. state_name = get_state_name(name, WORKER_STATE);
  972. recfmt_set_state(time, workerid, -1, state_name, type);
  973. }
  974. static void recfmt_thread_set_state(double time, unsigned long nodeid, long unsigned int threadid, const char *name, const char *type)
  975. {
  976. const char *state_name;
  977. /* Special case for the end event which is somehow a fake. */
  978. if (!strcmp(name, "End") && !type)
  979. state_name = name;
  980. else
  981. state_name = get_state_name(name, THREAD_STATE);
  982. recfmt_set_state(time, find_worker_id(nodeid, threadid), threadid, state_name, type);
  983. }
  984. static void recfmt_thread_push_state(double time, unsigned long nodeid, long unsigned int threadid, const char *name, const char *type)
  985. {
  986. const char *state_name = get_state_name(name, THREAD_STATE);
  987. recfmt_push_state(time, find_worker_id(nodeid, threadid), threadid, state_name, type);
  988. }
  989. static void recfmt_thread_pop_state(double time, unsigned long nodeid, long unsigned int threadid)
  990. {
  991. recfmt_pop_state(time, find_worker_id(nodeid, threadid), threadid);
  992. }
  993. static void recfmt_mpicommthread_set_state(double time, const char *name)
  994. {
  995. const char *state_name = get_state_name(name, COMM_THREAD_STATE);
  996. recfmt_set_state(time, -1, 0, state_name, "MPI"); /* XXX */
  997. }
  998. static void recfmt_mpicommthread_push_state(double time, const char *name)
  999. {
  1000. const char *state_name = get_state_name(name, COMM_THREAD_STATE);
  1001. recfmt_push_state(time, -1, 0, state_name, "MPI"); /* XXX */
  1002. }
  1003. static void recfmt_mpicommthread_pop_state(double time)
  1004. {
  1005. recfmt_pop_state(time, -1, 0);
  1006. }
  1007. static void recfmt_user_thread_push_state(double time, long unsigned threadid, const char *name, const char *type)
  1008. {
  1009. const char *state_name = get_state_name(name, USER_THREAD_STATE);
  1010. recfmt_push_state(time, -1, threadid, state_name, type);
  1011. }
  1012. static void recfmt_user_thread_pop_state(double time, long unsigned threadid)
  1013. {
  1014. recfmt_pop_state(time, -1, threadid);
  1015. }
  1016. /*
  1017. * Initialization
  1018. */
  1019. static void handle_new_mem_node(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1020. {
  1021. char *prefix = options->file_prefix;
  1022. if (out_paje_file)
  1023. {
  1024. double now = get_event_time_stamp(ev, options);
  1025. #ifdef STARPU_HAVE_POTI
  1026. char program_container[STARPU_POTI_STR_LEN];
  1027. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  1028. char new_memnode_container_alias[STARPU_POTI_STR_LEN], new_memnode_container_name[STARPU_POTI_STR_LEN];
  1029. char new_memmanager_container_alias[STARPU_POTI_STR_LEN], new_memmanager_container_name[STARPU_POTI_STR_LEN];
  1030. memnode_container_alias (new_memnode_container_alias, STARPU_POTI_STR_LEN, prefix, ev->param[0]);
  1031. /* TODO: ramkind */
  1032. snprintf(new_memnode_container_name, sizeof(new_memnode_container_name), "%sMEMNODE%"PRIu64"", prefix, ev->param[0]);
  1033. poti_CreateContainer(now, new_memnode_container_alias, "Mn", program_container, new_memnode_container_name);
  1034. memmanager_container_alias (new_memmanager_container_alias, STARPU_POTI_STR_LEN, prefix, ev->param[0]);
  1035. /* TODO: ramkind */
  1036. snprintf(new_memmanager_container_name, sizeof(new_memmanager_container_name), "%sMEMMANAGER%"PRIu64"", prefix, ev->param[0]);
  1037. poti_CreateContainer(now, new_memmanager_container_alias, "Mm", new_memnode_container_alias, new_memmanager_container_name);
  1038. #else
  1039. 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]);
  1040. 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]);
  1041. #endif
  1042. if (!options->no_bus)
  1043. {
  1044. #ifdef STARPU_HAVE_POTI
  1045. poti_SetVariable(now, new_memmanager_container_alias, "use", 0.0);
  1046. poti_SetVariable(now, new_memmanager_container_alias, "bwi_mm", 0.0);
  1047. poti_SetVariable(now, new_memmanager_container_alias, "bwo_mm", 0.0);
  1048. #else
  1049. fprintf(out_paje_file, "13 %.9f %smm%"PRIu64" use 0.0\n", now, prefix, ev->param[0]);
  1050. fprintf(out_paje_file, "13 %.9f %smm%"PRIu64" bwi_mm 0.0\n", now, prefix, ev->param[0]);
  1051. fprintf(out_paje_file, "13 %.9f %smm%"PRIu64" bwo_mm 0.0\n", now, prefix, ev->param[0]);
  1052. #endif
  1053. }
  1054. }
  1055. }
  1056. /*
  1057. * Function that creates a synthetic stream id based on the order they appear from the trace
  1058. */
  1059. static int create_ordered_stream_id (int nodeid, int devid)
  1060. {
  1061. static int stable[STARPU_FXT_MAX_FILES][STARPU_MAXCUDADEVS];
  1062. STARPU_ASSERT(nodeid < STARPU_FXT_MAX_FILES);
  1063. STARPU_ASSERT(devid < STARPU_MAXCUDADEVS);
  1064. return stable[nodeid][devid]++;
  1065. }
  1066. static void handle_worker_init_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1067. {
  1068. /*
  1069. arg0 : type of worker (cuda, cpu ..)
  1070. arg1 : memory node
  1071. arg2 : thread id
  1072. */
  1073. char *prefix = options->file_prefix;
  1074. int devid = ev->param[2];
  1075. int workerid = ev->param[1];
  1076. int nodeid = ev->param[3];
  1077. int bindid = ev->param[4];
  1078. int set = ev->param[5];
  1079. long unsigned int threadid = ev->param[6];
  1080. int new_thread;
  1081. new_thread = register_worker_id(prefixTOnodeid(prefix), threadid, workerid, set);
  1082. char *kindstr = "";
  1083. struct starpu_perfmodel_arch arch;
  1084. arch.ndevices = 1;
  1085. _STARPU_MALLOC(arch.devices, sizeof(struct starpu_perfmodel_device));
  1086. switch (ev->param[0])
  1087. {
  1088. case _STARPU_FUT_APPS_KEY:
  1089. set_next_other_worker_color(workerid);
  1090. kindstr = "APPS";
  1091. break;
  1092. case _STARPU_FUT_CPU_KEY:
  1093. set_next_cpu_worker_color(workerid);
  1094. kindstr = "CPU";
  1095. arch.devices[0].type = STARPU_CPU_WORKER;
  1096. arch.devices[0].devid = 0;
  1097. arch.devices[0].ncores = 1;
  1098. break;
  1099. case _STARPU_FUT_CUDA_KEY:
  1100. set_next_cuda_worker_color(workerid);
  1101. kindstr = "CUDA";
  1102. arch.devices[0].type = STARPU_CUDA_WORKER;
  1103. arch.devices[0].devid = devid;
  1104. arch.devices[0].ncores = 1;
  1105. break;
  1106. case _STARPU_FUT_OPENCL_KEY:
  1107. set_next_opencl_worker_color(workerid);
  1108. kindstr = "OPENCL";
  1109. arch.devices[0].type = STARPU_OPENCL_WORKER;
  1110. arch.devices[0].devid = devid;
  1111. arch.devices[0].ncores = 1;
  1112. break;
  1113. case _STARPU_FUT_MIC_KEY:
  1114. set_next_mic_worker_color(workerid);
  1115. kindstr = "mic";
  1116. arch.devices[0].type = STARPU_MIC_WORKER;
  1117. arch.devices[0].devid = devid;
  1118. arch.devices[0].ncores = 1;
  1119. break;
  1120. case _STARPU_FUT_MPI_KEY:
  1121. set_next_mpi_ms_worker_color(workerid);
  1122. kindstr = "mpi_ms";
  1123. arch.devices[0].type = STARPU_MPI_MS_WORKER;
  1124. arch.devices[0].devid = devid;
  1125. arch.devices[0].ncores = 1;
  1126. break;
  1127. default:
  1128. STARPU_ABORT();
  1129. }
  1130. double now = get_event_time_stamp(ev, options);
  1131. if (out_paje_file)
  1132. {
  1133. char new_worker_container_name[STARPU_TRACE_STR_LEN];
  1134. if (arch.devices[0].type == STARPU_CUDA_WORKER)
  1135. {
  1136. // If CUDA, workers might be streams, so create an unique name for each of them
  1137. int streamid = create_ordered_stream_id (prefixTOnodeid(prefix), devid);
  1138. snprintf(new_worker_container_name, sizeof(new_worker_container_name), "%s%s%d_%d", prefix, kindstr, devid, streamid);
  1139. }
  1140. else
  1141. {
  1142. // If not CUDA, we suppose worker name is the prefix, the kindstr, and the devid
  1143. snprintf(new_worker_container_name, sizeof(new_worker_container_name), "%s%s%d", prefix, kindstr, devid);
  1144. }
  1145. #ifdef STARPU_HAVE_POTI
  1146. char new_thread_container_alias[STARPU_POTI_STR_LEN];
  1147. thread_container_alias (new_thread_container_alias, STARPU_POTI_STR_LEN, prefix, threadid);
  1148. char new_worker_container_alias[STARPU_POTI_STR_LEN];
  1149. worker_container_alias (new_worker_container_alias, STARPU_POTI_STR_LEN, prefix, workerid);
  1150. char memnode_container[STARPU_POTI_STR_LEN];
  1151. memnode_container_alias(memnode_container, STARPU_POTI_STR_LEN, prefix, nodeid);
  1152. char new_thread_container_name[STARPU_POTI_STR_LEN];
  1153. snprintf(new_thread_container_name, sizeof(new_thread_container_name), "%sT%d", prefix, bindid);
  1154. if (new_thread)
  1155. poti_CreateContainer(now, new_thread_container_alias, "T", memnode_container, new_thread_container_name);
  1156. poti_CreateContainer(now, new_worker_container_alias, "W", new_thread_container_alias, new_worker_container_name);
  1157. if (!options->no_flops)
  1158. poti_SetVariable(now, new_worker_container_alias, "gf", 0.0);
  1159. #else
  1160. if (new_thread)
  1161. fprintf(out_paje_file, "7 %.9f %st%lu T %smn%d %sT%d\n",
  1162. now, prefix, threadid, prefix, nodeid, prefix, bindid);
  1163. fprintf(out_paje_file, "7 %.9f %sw%d W %st%lu %s\n",
  1164. now, prefix, workerid, prefix, threadid, new_worker_container_name);
  1165. if (!options->no_flops)
  1166. fprintf(out_paje_file, "13 %.9f %sw%d gf 0.0\n",
  1167. now, prefix, workerid);
  1168. #endif
  1169. }
  1170. /* start initialization */
  1171. thread_set_state(now, prefix, threadid, "In");
  1172. if (trace_file)
  1173. recfmt_thread_set_state(now, prefixTOnodeid(prefix), threadid, "In", "Runtime");
  1174. if (activity_file)
  1175. fprintf(activity_file, "name\t%d\t%s %d\n", workerid, kindstr, devid);
  1176. snprintf(options->worker_names[workerid], sizeof(options->worker_names[workerid])-1, "%s %d", kindstr, devid);
  1177. options->worker_names[workerid][sizeof(options->worker_names[workerid])-1] = 0;
  1178. options->worker_archtypes[workerid] = arch;
  1179. }
  1180. static void handle_worker_init_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1181. {
  1182. char *prefix = options->file_prefix;
  1183. int worker;
  1184. if (ev->nb_params < 2)
  1185. {
  1186. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1187. STARPU_ASSERT(worker >= 0);
  1188. }
  1189. else
  1190. worker = ev->param[1];
  1191. thread_set_state(get_event_time_stamp(ev, options), prefix, ev->param[0], "B");
  1192. if (trace_file)
  1193. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "B", "Runtime");
  1194. worker_set_state(get_event_time_stamp(ev, options), prefix, worker, "I");
  1195. if (trace_file)
  1196. recfmt_worker_set_state(get_event_time_stamp(ev, options), worker, "I", "Other");
  1197. /* Initilize the accumulated time counters */
  1198. last_activity_flush_timestamp[worker] = get_event_time_stamp(ev, options);
  1199. accumulated_sleep_time[worker] = 0.0;
  1200. accumulated_exec_time[worker] = 0.0;
  1201. }
  1202. static void handle_worker_deinit_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1203. {
  1204. char *prefix = options->file_prefix;
  1205. long unsigned int threadid = ev->param[0];
  1206. thread_set_state(get_event_time_stamp(ev, options), prefix, threadid, "D");
  1207. if (trace_file)
  1208. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), threadid, "D", "Runtime");
  1209. }
  1210. static void handle_worker_deinit_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1211. {
  1212. char *prefix = options->file_prefix;
  1213. if (out_paje_file)
  1214. {
  1215. #ifdef STARPU_HAVE_POTI
  1216. char worker_container[STARPU_POTI_STR_LEN];
  1217. thread_container_alias(worker_container, STARPU_POTI_STR_LEN, prefix, ev->param[1]);
  1218. poti_DestroyContainer(get_event_time_stamp(ev, options), "T", worker_container);
  1219. #else
  1220. fprintf(out_paje_file, "8 %.9f %st%"PRIu64" T\n",
  1221. get_event_time_stamp(ev, options), prefix, ev->param[1]);
  1222. #endif
  1223. }
  1224. if (trace_file)
  1225. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[1], "End", NULL);
  1226. }
  1227. #ifdef STARPU_HAVE_POTI
  1228. static void create_paje_state_color(char *name, char *type, int ctx, float red, float green, float blue)
  1229. {
  1230. char color[STARPU_POTI_STR_LEN];
  1231. char alias[STARPU_POTI_STR_LEN];
  1232. snprintf(color, sizeof(color), "%f %f %f", red, green, blue);
  1233. if (ctx)
  1234. {
  1235. snprintf(alias, sizeof(alias), "%s_%d", name, ctx);
  1236. }
  1237. else
  1238. {
  1239. snprintf(alias, sizeof(alias), "%s", name);
  1240. }
  1241. poti_DefineEntityValue(alias, type, name, color);
  1242. }
  1243. #endif
  1244. static void create_paje_state_if_not_found(char *name, unsigned color, struct starpu_fxt_options *options)
  1245. {
  1246. struct _starpu_symbol_name *itor;
  1247. for (itor = _starpu_symbol_name_list_begin(&symbol_list);
  1248. itor != _starpu_symbol_name_list_end(&symbol_list);
  1249. itor = _starpu_symbol_name_list_next(itor))
  1250. {
  1251. if (!strcmp(name, itor->name))
  1252. {
  1253. /* we found an entry */
  1254. return;
  1255. }
  1256. }
  1257. /* it's the first time ... */
  1258. struct _starpu_symbol_name *entry = _starpu_symbol_name_new();
  1259. entry->name = strdup(name);
  1260. STARPU_ASSERT(entry->name);
  1261. _starpu_symbol_name_list_push_front(&symbol_list, entry);
  1262. /* choose some color ... that's disguting yes */
  1263. unsigned hash_symbol_red = get_color_symbol_red(name);
  1264. unsigned hash_symbol_green = get_color_symbol_green(name);
  1265. unsigned hash_symbol_blue = get_color_symbol_blue(name);
  1266. uint32_t hash_sum = hash_symbol_red + hash_symbol_green + hash_symbol_blue;
  1267. float red, green, blue;
  1268. if (color != 0)
  1269. {
  1270. red = color / 0x100 / 0x100;
  1271. green = (color / 0x100) & 0xff;
  1272. blue = color & 0xff;
  1273. }
  1274. else if (options->per_task_colour)
  1275. {
  1276. red = (1.0f * hash_symbol_red) / hash_sum;
  1277. green = (1.0f * hash_symbol_green) / hash_sum;
  1278. blue = (1.0f * hash_symbol_blue) / hash_sum;
  1279. }
  1280. else
  1281. {
  1282. /* Use the hardcoded value for execution mode */
  1283. red = 0.0f;
  1284. green = 0.6f;
  1285. blue = 0.4f;
  1286. }
  1287. /* create the Paje state */
  1288. if (out_paje_file)
  1289. {
  1290. #ifdef STARPU_HAVE_POTI
  1291. create_paje_state_color(name, "WS", 0, red, green, blue);
  1292. int i;
  1293. for(i = 1; i < STARPU_NMAX_SCHED_CTXS; i++)
  1294. {
  1295. char ctx[10];
  1296. snprintf(ctx, sizeof(ctx), "Ctx%d", i);
  1297. if(i%10 == 1)
  1298. create_paje_state_color(name, ctx, i, 1.0, 0.39, 1.0);
  1299. if(i%10 == 2)
  1300. create_paje_state_color(name, ctx, i, .0, 1.0, 0.0);
  1301. if(i%10 == 3)
  1302. create_paje_state_color(name, ctx, i, 1.0, 1.0, .0);
  1303. if(i%10 == 4)
  1304. create_paje_state_color(name, ctx, i, .0, 0.95, 1.0);
  1305. if(i%10 == 5)
  1306. create_paje_state_color(name, ctx, i, .0, .0, .0);
  1307. if(i%10 == 6)
  1308. create_paje_state_color(name, ctx, i, .0, .0, 0.5);
  1309. if(i%10 == 7)
  1310. create_paje_state_color(name, ctx, i, 0.41, 0.41, 0.41);
  1311. if(i%10 == 8)
  1312. create_paje_state_color(name, ctx, i, 1.0, .0, 1.0);
  1313. if(i%10 == 9)
  1314. create_paje_state_color(name, ctx, i, .0, .0, 1.0);
  1315. if(i%10 == 0)
  1316. create_paje_state_color(name, ctx, i, 0.6, 0.80, 50.0);
  1317. }
  1318. /* create_paje_state_color(name, "Ctx1", 1.0, 0.39, 1.0); */
  1319. /* create_paje_state_color(name, "Ctx2", .0, 1.0, 0.0); */
  1320. /* create_paje_state_color(name, "Ctx3", 1.0, 1.0, .0); */
  1321. /* create_paje_state_color(name, "Ctx4", .0, 0.95, 1.0); */
  1322. /* create_paje_state_color(name, "Ctx5", .0, .0, .0); */
  1323. /* create_paje_state_color(name, "Ctx6", .0, .0, 0.5); */
  1324. /* create_paje_state_color(name, "Ctx7", 0.41, 0.41, 0.41); */
  1325. /* create_paje_state_color(name, "Ctx8", 1.0, .0, 1.0); */
  1326. /* create_paje_state_color(name, "Ctx9", .0, .0, 1.0); */
  1327. /* create_paje_state_color(name, "Ctx10", 0.6, 0.80, 0.19); */
  1328. #else
  1329. fprintf(out_paje_file, "6 %s WS %s \"%f %f %f\" \n", name, name, red, green, blue);
  1330. int i;
  1331. for(i = 1; i < STARPU_NMAX_SCHED_CTXS; i++)
  1332. {
  1333. if(i%10 == 1)
  1334. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"1.0 0.39 1.0\" \n", name, i, i, name);
  1335. if(i%10 == 2)
  1336. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 1.0 .0\" \n", name, i, i, name);
  1337. if(i%10 == 3)
  1338. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"0.87 0.87 .0\" \n", name, i, i, name);
  1339. if(i%10 == 4)
  1340. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 0.95 1.0\" \n", name, i, i, name);
  1341. if(i%10 == 5)
  1342. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 .0 .0\" \n", name, i, i, name);
  1343. if(i%10 == 6)
  1344. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 .0 0.5\" \n", name, i, i, name);
  1345. if(i%10 == 7)
  1346. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"0.41 0.41 0.41\" \n", name, i, i, name);
  1347. if(i%10 == 8)
  1348. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"1.0 .0 1.0\" \n", name, i, i, name);
  1349. if(i%10 == 9)
  1350. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \".0 .0 1.0\" \n", name, i, i, name);
  1351. if(i%10 == 0)
  1352. fprintf(out_paje_file, "6 %s_%d Ctx%d %s \"0.6 0.80 0.19\" \n", name, i, i, name);
  1353. }
  1354. /* fprintf(out_paje_file, "6 %s Ctx1 %s \"1.0 0.39 1.0\" \n", name, name); */
  1355. /* fprintf(out_paje_file, "6 %s Ctx2 %s \".0 1.0 .0\" \n", name, name); */
  1356. /* fprintf(out_paje_file, "6 %s Ctx3 %s \"0.87 0.87 .0\" \n", name, name); */
  1357. /* fprintf(out_paje_file, "6 %s Ctx4 %s \".0 0.95 1.0\" \n", name, name); */
  1358. /* fprintf(out_paje_file, "6 %s Ctx5 %s \".0 .0 .0\" \n", name, name); */
  1359. /* fprintf(out_paje_file, "6 %s Ctx6 %s \".0 .0 0.5\" \n", name, name); */
  1360. /* fprintf(out_paje_file, "6 %s Ctx7 %s \"0.41 0.41 0.41\" \n", name, name); */
  1361. /* fprintf(out_paje_file, "6 %s Ctx8 %s \"1.0 .0 1.0\" \n", name, name); */
  1362. /* fprintf(out_paje_file, "6 %s Ctx9 %s \".0 .0 1.0\" \n", name, name); */
  1363. /* fprintf(out_paje_file, "6 %s Ctx10 %s \"0.6 0.80 0.19\" \n", name, name); */
  1364. #endif
  1365. }
  1366. }
  1367. static void handle_start_codelet_body(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1368. {
  1369. int worker = ev->param[2];
  1370. int node = ev->param[3];
  1371. if (worker < 0) return;
  1372. unsigned long has_name = ev->param[4];
  1373. char *name = has_name?get_fxt_string(ev, 5):"unknown";
  1374. snprintf(_starpu_last_codelet_symbol[worker], sizeof(_starpu_last_codelet_symbol[worker]), "%.*s", (int) sizeof(_starpu_last_codelet_symbol[worker])-1, name);
  1375. _starpu_last_codelet_symbol[worker][sizeof(_starpu_last_codelet_symbol[worker])-1] = 0;
  1376. last_codelet_parameter[worker] = 0;
  1377. double start_codelet_time = get_event_time_stamp(ev, options);
  1378. double last_start_codelet_time = last_codelet_start[worker];
  1379. last_codelet_start[worker] = start_codelet_time;
  1380. struct task_info *task = get_task(ev->param[0], options->file_rank);
  1381. create_paje_state_if_not_found(name, task->color, options);
  1382. task->start_time = start_codelet_time;
  1383. task->workerid = worker;
  1384. task->name = strdup(name);
  1385. task->node = node;
  1386. if (out_paje_file)
  1387. {
  1388. char *prefix = options->file_prefix;
  1389. unsigned sched_ctx = ev->param[1];
  1390. worker_set_state(start_codelet_time, prefix, ev->param[2], name);
  1391. if (sched_ctx != 0)
  1392. {
  1393. #ifdef STARPU_HAVE_POTI
  1394. char container[STARPU_POTI_STR_LEN];
  1395. char ctx[6];
  1396. snprintf(ctx, sizeof(ctx), "Ctx%u", sched_ctx);
  1397. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, ev->param[2]);
  1398. poti_SetState(start_codelet_time, container, ctx, name);
  1399. #else
  1400. fprintf(out_paje_file, "10 %.9f %sw%"PRIu64" Ctx%d \"%s\"\n", start_codelet_time, prefix, ev->param[2], sched_ctx, name);
  1401. #endif
  1402. }
  1403. }
  1404. if (trace_file)
  1405. recfmt_worker_set_state(start_codelet_time, ev->param[2], name, "Task");
  1406. struct _starpu_computation *comp = ongoing_computation[worker];
  1407. if (!comp)
  1408. {
  1409. /* First task for this worker */
  1410. comp = ongoing_computation[worker] = _starpu_computation_new();
  1411. comp->peer = NULL;
  1412. comp->comp_start = start_codelet_time;
  1413. if (!options->no_flops)
  1414. _starpu_computation_list_push_back(&computation_list, comp);
  1415. }
  1416. else if (options->no_smooth ||
  1417. (start_codelet_time - last_codelet_end[worker]) >=
  1418. IDLE_FACTOR * (last_codelet_end[worker] - last_start_codelet_time))
  1419. {
  1420. /* Long idle period, move previously-allocated comp to now */
  1421. comp->comp_start = start_codelet_time;
  1422. if (!options->no_flops)
  1423. {
  1424. _starpu_computation_list_erase(&computation_list, comp);
  1425. _starpu_computation_list_push_back(&computation_list, comp);
  1426. }
  1427. }
  1428. }
  1429. static void handle_model_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1430. {
  1431. struct task_info *task = get_task(ev->param[0], options->file_rank);
  1432. char *name = get_fxt_string(ev, 1);
  1433. task->model_name = strdup(name);
  1434. }
  1435. static void handle_codelet_data(struct fxt_ev_64 *ev STARPU_ATTRIBUTE_UNUSED, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
  1436. {
  1437. int worker = ev->param[0];
  1438. if (worker < 0) return;
  1439. int num = last_codelet_parameter[worker]++;
  1440. if (num >= MAX_PARAMETERS)
  1441. return;
  1442. char *name = get_fxt_string(ev, 1);
  1443. snprintf(last_codelet_parameter_description[worker][num], sizeof(last_codelet_parameter_description[worker][num]), "%.*s", (int) sizeof(last_codelet_parameter_description[worker][num])-1, name);
  1444. last_codelet_parameter_description[worker][num][sizeof(last_codelet_parameter_description[worker][num])-1] = 0;
  1445. }
  1446. static void handle_codelet_data_handle(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1447. {
  1448. struct task_info *task = get_task(ev->param[0], options->file_rank);
  1449. unsigned alloc = 0;
  1450. if (task->ndata == 0)
  1451. /* Start with 8=2^3, should be plenty in most cases */
  1452. alloc = 8;
  1453. else if (task->ndata >= 8)
  1454. {
  1455. /* Allocate dependencies array by powers of two */
  1456. if (! ((task->ndata - 1) & task->ndata)) /* Is task->ndata a power of two? */
  1457. {
  1458. /* We have filled the previous power of two, get another one */
  1459. alloc = task->ndata * 2;
  1460. }
  1461. }
  1462. if (alloc)
  1463. {
  1464. _STARPU_REALLOC(task->data, sizeof(*task->data) * alloc);
  1465. }
  1466. task->data[task->ndata].handle = ev->param[1];
  1467. task->data[task->ndata].size = ev->param[2];
  1468. task->data[task->ndata].mode = ev->param[3];
  1469. task->ndata++;
  1470. }
  1471. static void handle_codelet_details(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1472. {
  1473. int worker = ev->param[5];
  1474. unsigned long job_id = ev->param[6];
  1475. if (worker < 0) return;
  1476. char parameters[256];
  1477. size_t eaten = 0;
  1478. if (!last_codelet_parameter[worker])
  1479. eaten += snprintf(parameters + eaten, sizeof(parameters) - eaten - 1, "nodata");
  1480. else
  1481. {
  1482. int i;
  1483. for (i = 0; i < last_codelet_parameter[worker] && i < MAX_PARAMETERS; i++)
  1484. {
  1485. eaten += snprintf(parameters + eaten, sizeof(parameters) - eaten - 1, "%s%s", i?" ":"", last_codelet_parameter_description[worker][i]);
  1486. }
  1487. }
  1488. parameters[sizeof(parameters)-1] = 0;
  1489. struct task_info *task = get_task(job_id, options->file_rank);
  1490. task->parameters = strdup(parameters);
  1491. task->footprint = ev->param[2];
  1492. task->kflops = ev->param[3];
  1493. task->tag = ev->param[4];
  1494. unsigned i, X = 0, Y = 0, Z = 0;
  1495. for (i = 0; i < task->ndata; i++)
  1496. {
  1497. if (task->data[i].mode & STARPU_W)
  1498. {
  1499. struct data_info *data = get_data(task->data[i].handle, options->file_rank);
  1500. if (data->dimensions >= 1)
  1501. X = data->dims[0];
  1502. if (data->dimensions >= 2)
  1503. Y = data->dims[1];
  1504. if (data->dimensions >= 3)
  1505. Z = data->dims[2];
  1506. break;
  1507. }
  1508. }
  1509. if (out_paje_file)
  1510. {
  1511. char *prefix = options->file_prefix;
  1512. unsigned sched_ctx = ev->param[0];
  1513. /* Paje won't like spaces or tabs, replace with underscores */
  1514. char *c;
  1515. for (c = parameters; *c; c++)
  1516. if ((*c == ' ') || (*c == '\t'))
  1517. *c = '_';
  1518. 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);
  1519. if (sched_ctx != 0)
  1520. {
  1521. #ifdef STARPU_HAVE_POTI
  1522. char container[STARPU_POTI_STR_LEN];
  1523. char typectx[STARPU_POTI_STR_LEN];
  1524. snprintf(typectx, sizeof(typectx), "Ctx%u", sched_ctx);
  1525. worker_container_alias(container, sizeof(container), prefix, worker);
  1526. poti_SetState(last_codelet_start[worker], container, typectx, _starpu_last_codelet_symbol[worker]);
  1527. char name[STARPU_POTI_STR_LEN];
  1528. snprintf(name, sizeof(name), "%s", _starpu_last_codelet_symbol[worker]);
  1529. char size_str[STARPU_POTI_STR_LEN];
  1530. char parameters_str[STARPU_POTI_STR_LEN];
  1531. char footprint_str[STARPU_POTI_STR_LEN];
  1532. char tag_str[STARPU_POTI_STR_LEN];
  1533. char jobid_str[STARPU_POTI_STR_LEN];
  1534. char submitorder_str[STARPU_POTI_STR_LEN];
  1535. snprintf(size_str, sizeof(size_str), "%ld", ev->param[1]);
  1536. snprintf(parameters_str, sizeof(parameters_str), "%s", parameters);
  1537. snprintf(footprint_str, sizeof(footprint_str), "%08lx", ev->param[2]);
  1538. snprintf(tag_str, sizeof(tag_str), "%016lx", ev->param[4]);
  1539. snprintf(jobid_str, sizeof(jobid_str), "%s%lu", prefix, job_id);
  1540. snprintf(submitorder_str, sizeof(submitorder_str), "%s%lu", prefix, task->submit_order);
  1541. #ifdef HAVE_POTI_INIT_CUSTOM
  1542. poti_user_SetState(_starpu_poti_semiExtendedSetState, last_codelet_start[worker], container, typectx, name, 6, size_str,
  1543. parameters_str,
  1544. footprint_str,
  1545. tag_str,
  1546. jobid_str,
  1547. submitorder_str);
  1548. #else
  1549. poti_SetState(last_codelet_start[worker], container, typectx, name);
  1550. #endif
  1551. #else
  1552. 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);
  1553. #endif
  1554. }
  1555. }
  1556. }
  1557. static long dumped_codelets_count;
  1558. static struct starpu_fxt_codelet_event *dumped_codelets;
  1559. static void handle_end_codelet_body(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1560. {
  1561. int worker = ev->param[3];
  1562. if (worker < 0) return;
  1563. char *prefix = options->file_prefix;
  1564. double end_codelet_time = get_event_time_stamp(ev, options);
  1565. double last_end_codelet_time = last_codelet_end[worker];
  1566. last_codelet_end[worker] = end_codelet_time;
  1567. size_t codelet_size = ev->param[1];
  1568. uint32_t codelet_hash = ev->param[2];
  1569. long unsigned int threadid = ev->param[4];
  1570. char *name = get_fxt_string(ev, 4);
  1571. const char *state = "I";
  1572. if (find_sync(prefixTOnodeid(prefix), threadid))
  1573. state = "B";
  1574. worker_set_state(end_codelet_time, prefix, worker, state);
  1575. if (trace_file)
  1576. recfmt_worker_set_state(end_codelet_time, worker, state, "Other");
  1577. struct task_info *task = get_task(ev->param[0], options->file_rank);
  1578. get_task(ev->param[0], options->file_rank)->end_time = end_codelet_time;
  1579. update_accumulated_time(worker, 0.0, end_codelet_time - task->start_time, end_codelet_time, 0);
  1580. struct _starpu_computation *peer = ongoing_computation[worker];
  1581. double gflops_start = peer->comp_start;
  1582. double codelet_length;
  1583. double gflops;
  1584. struct _starpu_computation *comp;
  1585. codelet_length = end_codelet_time - gflops_start;
  1586. gflops = (((double)task->kflops) / 1000000) / (codelet_length / 1000);
  1587. if (options->no_flops)
  1588. {
  1589. _starpu_computation_delete(peer);
  1590. }
  1591. else
  1592. {
  1593. if (out_paje_file)
  1594. {
  1595. #ifdef STARPU_HAVE_POTI
  1596. char container[STARPU_POTI_STR_LEN];
  1597. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, worker);
  1598. if (gflops_start != last_end_codelet_time)
  1599. {
  1600. if (last_end_codelet_time != 0)
  1601. {
  1602. poti_SetVariable(last_end_codelet_time, container, "gf", 0.);
  1603. }
  1604. }
  1605. poti_SetVariable(gflops_start, container, "gf", gflops);
  1606. #else
  1607. if (gflops_start != last_end_codelet_time)
  1608. {
  1609. if (last_end_codelet_time != 0)
  1610. {
  1611. fprintf(out_paje_file, "13 %.9f %sw%d gf %f\n",
  1612. last_end_codelet_time, prefix, worker, 0.);
  1613. }
  1614. }
  1615. fprintf(out_paje_file, "13 %.9f %sw%d gf %f\n",
  1616. gflops_start, prefix, worker, gflops);
  1617. #endif
  1618. }
  1619. comp = _starpu_computation_new();
  1620. comp->comp_start = end_codelet_time;
  1621. comp->gflops = -gflops;
  1622. peer->gflops = +gflops;
  1623. comp->peer = peer;
  1624. peer->peer = comp;
  1625. _starpu_computation_list_push_back(&computation_list, comp);
  1626. }
  1627. /* Prepare comp for next codelet */
  1628. comp = _starpu_computation_new();
  1629. comp->comp_start = end_codelet_time;
  1630. comp->peer = NULL;
  1631. if (!options->no_flops)
  1632. _starpu_computation_list_push_back(&computation_list, comp);
  1633. ongoing_computation[worker] = comp;
  1634. if (distrib_time)
  1635. fprintf(distrib_time, "%s\t%s%d\t%ld\t%"PRIx32"\t%.9f\n", _starpu_last_codelet_symbol[worker],
  1636. prefix, worker, (unsigned long) codelet_size, codelet_hash, codelet_length);
  1637. if (options->dumped_codelets)
  1638. {
  1639. dumped_codelets_count++;
  1640. _STARPU_REALLOC(dumped_codelets, dumped_codelets_count*sizeof(struct starpu_fxt_codelet_event));
  1641. snprintf(dumped_codelets[dumped_codelets_count - 1].symbol, sizeof(dumped_codelets[dumped_codelets_count - 1].symbol)-1, "%s", _starpu_last_codelet_symbol[worker]);
  1642. dumped_codelets[dumped_codelets_count - 1].symbol[sizeof(dumped_codelets[dumped_codelets_count - 1].symbol)-1] = 0;
  1643. dumped_codelets[dumped_codelets_count - 1].workerid = worker;
  1644. snprintf(dumped_codelets[dumped_codelets_count - 1].perfmodel_archname, sizeof(dumped_codelets[dumped_codelets_count - 1].perfmodel_archname), "%.*s", (int) sizeof(dumped_codelets[dumped_codelets_count - 1].perfmodel_archname)-1, name);
  1645. dumped_codelets[dumped_codelets_count - 1].perfmodel_archname[sizeof(dumped_codelets[dumped_codelets_count - 1].perfmodel_archname)-1] = 0;
  1646. dumped_codelets[dumped_codelets_count - 1].size = codelet_size;
  1647. dumped_codelets[dumped_codelets_count - 1].hash = codelet_hash;
  1648. dumped_codelets[dumped_codelets_count - 1].time = codelet_length;
  1649. }
  1650. _starpu_last_codelet_symbol[worker][0] = 0;
  1651. }
  1652. static void handle_start_executing(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1653. {
  1654. char *prefix = options->file_prefix;
  1655. long unsigned int threadid = ev->param[0];
  1656. if (out_paje_file && !find_sync(prefixTOnodeid(prefix), threadid))
  1657. thread_set_state(get_event_time_stamp(ev, options), prefix, threadid, "E");
  1658. if (trace_file && !find_sync(prefixTOnodeid(prefix), threadid))
  1659. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), threadid, "E", "Runtime");
  1660. }
  1661. static void handle_end_executing(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1662. {
  1663. char *prefix = options->file_prefix;
  1664. long unsigned int threadid = ev->param[0];
  1665. if (out_paje_file && !find_sync(prefixTOnodeid(prefix), threadid))
  1666. thread_set_state(get_event_time_stamp(ev, options), prefix, threadid, "B");
  1667. if (trace_file && !find_sync(prefixTOnodeid(prefix), threadid))
  1668. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), threadid, "B", "Runtime");
  1669. }
  1670. static void handle_user_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1671. {
  1672. int worker;
  1673. unsigned long code = ev->param[0];
  1674. #ifdef STARPU_HAVE_POTI
  1675. char paje_value[STARPU_POTI_STR_LEN], container[STARPU_POTI_STR_LEN];
  1676. snprintf(paje_value, sizeof(paje_value), "%lu", code);
  1677. #endif
  1678. char *prefix = options->file_prefix;
  1679. double now = get_event_time_stamp(ev, options);
  1680. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  1681. if (worker < 0)
  1682. {
  1683. if (out_paje_file)
  1684. #ifdef STARPU_HAVE_POTI
  1685. program_container_alias (container, STARPU_POTI_STR_LEN, prefix);
  1686. #else
  1687. fprintf(out_paje_file, "9 %.9f user_user_event %sp %lu\n", now, prefix, code);
  1688. #endif
  1689. }
  1690. else
  1691. {
  1692. if (out_paje_file)
  1693. #ifdef STARPU_HAVE_POTI
  1694. thread_container_alias (container, STARPU_POTI_STR_LEN, prefix, ev->param[1]);
  1695. #else
  1696. fprintf(out_paje_file, "9 %.9f user_event %st%"PRIu64" %lu\n", now, prefix, ev->param[1], code);
  1697. #endif
  1698. }
  1699. #ifdef STARPU_HAVE_POTI
  1700. if (out_paje_file)
  1701. poti_NewEvent(now, container, "user_event", paje_value);
  1702. #endif
  1703. }
  1704. static void handle_start_callback(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1705. {
  1706. int worker;
  1707. char *prefix = options->file_prefix;
  1708. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  1709. if (worker >= 0)
  1710. {
  1711. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], "C");
  1712. if (trace_file)
  1713. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[1], "C", "Runtime");
  1714. }
  1715. else if (worker == -2)
  1716. {
  1717. /* MPI thread */
  1718. mpicommthread_push_state(get_event_time_stamp(ev, options), options->file_prefix, "C");
  1719. recfmt_mpicommthread_push_state(get_event_time_stamp(ev, options), "C");
  1720. }
  1721. else
  1722. {
  1723. user_thread_push_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], "C");
  1724. recfmt_user_thread_push_state(get_event_time_stamp(ev, options), ev->param[1], "C", "UNK"); /* XXX */
  1725. }
  1726. }
  1727. static void handle_end_callback(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1728. {
  1729. int worker;
  1730. char *prefix = options->file_prefix;
  1731. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  1732. if (worker >= 0)
  1733. {
  1734. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], "B");
  1735. if (trace_file)
  1736. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[1], "B", "Runtime");
  1737. }
  1738. else if (worker == -2)
  1739. {
  1740. /* MPI thread */
  1741. mpicommthread_pop_state(get_event_time_stamp(ev, options), options->file_prefix);
  1742. recfmt_mpicommthread_pop_state(get_event_time_stamp(ev, options));
  1743. }
  1744. else
  1745. {
  1746. user_thread_pop_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1]);
  1747. recfmt_user_thread_pop_state(get_event_time_stamp(ev, options), ev->param[1]);
  1748. }
  1749. }
  1750. static void handle_hypervisor_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1751. {
  1752. int worker;
  1753. char *prefix = options->file_prefix;
  1754. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1755. if (worker >= 0)
  1756. {
  1757. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "H");
  1758. if (trace_file)
  1759. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "H", "Runtime");
  1760. }
  1761. else if (worker == -2)
  1762. {
  1763. /* MPI thread */
  1764. mpicommthread_push_state(get_event_time_stamp(ev, options), options->file_prefix, "H");
  1765. recfmt_mpicommthread_push_state(get_event_time_stamp(ev, options), "H");
  1766. }
  1767. else
  1768. {
  1769. user_thread_push_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], "H");
  1770. recfmt_user_thread_push_state(get_event_time_stamp(ev, options), ev->param[1], "H", "UNK"); /* XXX */
  1771. }
  1772. }
  1773. static void handle_hypervisor_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1774. {
  1775. int worker;
  1776. char *prefix = options->file_prefix;
  1777. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1778. if (worker >= 0)
  1779. {
  1780. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "B");
  1781. if (trace_file)
  1782. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "B", "Runtime");
  1783. }
  1784. else if (worker == -2)
  1785. {
  1786. /* MPI thread */
  1787. mpicommthread_pop_state(get_event_time_stamp(ev, options), options->file_prefix);
  1788. recfmt_mpicommthread_pop_state(get_event_time_stamp(ev, options));
  1789. }
  1790. else
  1791. {
  1792. user_thread_pop_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1]);
  1793. recfmt_user_thread_pop_state(get_event_time_stamp(ev, options), ev->param[1]);
  1794. }
  1795. }
  1796. static void handle_worker_status_on_tid(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *newstatus)
  1797. {
  1798. int worker;
  1799. char *prefix = options->file_prefix;
  1800. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  1801. if (worker < 0)
  1802. return;
  1803. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], newstatus);
  1804. if (trace_file)
  1805. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[1], newstatus, "Runtime");
  1806. }
  1807. static void handle_worker_status(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *newstatus)
  1808. {
  1809. int worker;
  1810. worker = ev->param[1];
  1811. if (worker < 0)
  1812. return;
  1813. worker_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], newstatus);
  1814. if (trace_file)
  1815. recfmt_worker_set_state(get_event_time_stamp(ev, options), ev->param[1], newstatus, "Runtime");
  1816. }
  1817. static double last_sleep_start[STARPU_NMAXWORKERS];
  1818. static void handle_worker_scheduling_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1819. {
  1820. int worker;
  1821. char *prefix = options->file_prefix;
  1822. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1823. if (worker < 0) return;
  1824. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "Sc");
  1825. if (trace_file)
  1826. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "Sc", "Runtime");
  1827. }
  1828. static void handle_worker_scheduling_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1829. {
  1830. int worker;
  1831. char *prefix = options->file_prefix;
  1832. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1833. if (worker < 0) return;
  1834. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "B");
  1835. if (trace_file)
  1836. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "B", "Runtime");
  1837. }
  1838. static void handle_worker_scheduling_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1839. {
  1840. int worker;
  1841. char *prefix = options->file_prefix;
  1842. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1843. if (worker < 0) return;
  1844. thread_push_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "Sc");
  1845. if (trace_file)
  1846. recfmt_thread_push_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "Sc", "Runtime");
  1847. }
  1848. static void handle_worker_scheduling_pop(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1849. {
  1850. int worker;
  1851. char *prefix = options->file_prefix;
  1852. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1853. if (worker < 0) return;
  1854. thread_pop_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0]);
  1855. if (trace_file)
  1856. recfmt_thread_pop_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0]);
  1857. }
  1858. static void handle_worker_sleep_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1859. {
  1860. int worker;
  1861. char *prefix = options->file_prefix;
  1862. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1863. if (worker < 0) return;
  1864. double start_sleep_time = get_event_time_stamp(ev, options);
  1865. last_sleep_start[worker] = start_sleep_time;
  1866. thread_set_state(get_event_time_stamp(ev, options), options->file_prefix, ev->param[0], "Sl");
  1867. if (trace_file)
  1868. recfmt_thread_set_state(get_event_time_stamp(ev, options), prefixTOnodeid(prefix), ev->param[0], "Sl", "Other");
  1869. }
  1870. static void handle_worker_sleep_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1871. {
  1872. int worker;
  1873. char *prefix = options->file_prefix;
  1874. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  1875. if (worker < 0) return;
  1876. double end_sleep_timestamp = get_event_time_stamp(ev, options);
  1877. thread_set_state(end_sleep_timestamp, options->file_prefix, ev->param[0], "B");
  1878. if (trace_file)
  1879. recfmt_thread_set_state(end_sleep_timestamp, prefixTOnodeid(prefix), ev->param[0], "B", "Runtime");
  1880. double sleep_length = end_sleep_timestamp - last_sleep_start[worker];
  1881. update_accumulated_time(worker, sleep_length, 0.0, end_sleep_timestamp, 0);
  1882. }
  1883. static void handle_data_register(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1884. {
  1885. unsigned long handle = ev->param[0];
  1886. char *prefix = options->file_prefix;
  1887. struct data_info *data = get_data(handle, options->file_rank);
  1888. char *description = get_fxt_string(ev, 4);
  1889. data->size = ev->param[1];
  1890. data->max_size = ev->param[2];
  1891. data->home_node = ev->param[3];
  1892. if (description[0])
  1893. data->description = strdup(description);
  1894. if (out_paje_file && !options->no_events)
  1895. {
  1896. #ifdef STARPU_HAVE_POTI
  1897. char paje_value[STARPU_POTI_STR_LEN], container[STARPU_POTI_STR_LEN];
  1898. snprintf(paje_value, sizeof(paje_value), "%lx", handle);
  1899. program_container_alias (container, STARPU_POTI_STR_LEN, prefix);
  1900. poti_NewEvent(get_event_time_stamp(ev, options), container, "register", paje_value);
  1901. #else
  1902. fprintf(out_paje_file, "9 %.9f register %sp %lx\n", get_event_time_stamp(ev, options), prefix, handle);
  1903. #endif
  1904. }
  1905. }
  1906. static void handle_data_unregister(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1907. {
  1908. unsigned long handle = ev->param[0];
  1909. char *prefix = options->file_prefix;
  1910. struct data_info *data = get_data(handle, options->file_rank);
  1911. if (out_paje_file && !options->no_events)
  1912. {
  1913. #ifdef STARPU_HAVE_POTI
  1914. char paje_value[STARPU_POTI_STR_LEN], container[STARPU_POTI_STR_LEN];
  1915. snprintf(paje_value, sizeof(paje_value), "%lx", handle);
  1916. program_container_alias (container, STARPU_POTI_STR_LEN, prefix);
  1917. poti_NewEvent(get_event_time_stamp(ev, options), container, "unregister", paje_value);
  1918. #else
  1919. fprintf(out_paje_file, "9 %.9f unregister %sp %lx\n", get_event_time_stamp(ev, options), prefix, handle);
  1920. #endif
  1921. }
  1922. data_dump(data);
  1923. }
  1924. static void handle_data_state(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *state)
  1925. {
  1926. unsigned long handle = ev->param[0];
  1927. unsigned node = ev->param[1];
  1928. char *prefix = options->file_prefix;
  1929. if (out_paje_file)
  1930. {
  1931. #ifdef STARPU_HAVE_POTI
  1932. char paje_value[STARPU_POTI_STR_LEN], memnode_container[STARPU_POTI_STR_LEN];
  1933. memmanager_container_alias(memnode_container, STARPU_POTI_STR_LEN, prefix, node);
  1934. snprintf(paje_value, sizeof(paje_value), "%lx", handle);
  1935. poti_NewEvent(get_event_time_stamp(ev, options), memnode_container, state, paje_value);
  1936. #else
  1937. fprintf(out_paje_file, "9 %.9f %s %smm%u %lx\n", get_event_time_stamp(ev, options), state, prefix, node, handle);
  1938. #endif
  1939. }
  1940. }
  1941. static void handle_data_copy(void)
  1942. {
  1943. }
  1944. static void handle_data_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1945. {
  1946. unsigned long handle = ev->param[0];
  1947. char *name = get_fxt_string(ev, 1);
  1948. struct data_info *data = get_data(handle, options->file_rank);
  1949. data->name = strdup(name);
  1950. }
  1951. static void handle_data_coordinates(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1952. {
  1953. unsigned long handle = ev->param[0];
  1954. unsigned dimensions = ev->param[1];
  1955. struct data_info *data = get_data(handle, options->file_rank);
  1956. unsigned i;
  1957. data->dimensions = dimensions;
  1958. _STARPU_MALLOC(data->dims, dimensions * sizeof(*data->dims));
  1959. for (i = 0; i < dimensions; i++)
  1960. data->dims[i] = ev->param[i+2];
  1961. }
  1962. static void handle_data_wont_use(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1963. {
  1964. unsigned long handle = ev->param[0];
  1965. unsigned long submit_order = ev->param[1];
  1966. unsigned long job_id = ev->param[2];
  1967. fprintf(tasks_file, "Control: WontUse\n");
  1968. fprintf(tasks_file, "JobId: %lu\n", job_id);
  1969. fprintf(tasks_file, "SubmitOrder: %lu\n", submit_order);
  1970. fprintf(tasks_file, "SubmitTime: %f\n", get_event_time_stamp(ev, options));
  1971. fprintf(tasks_file, "Handles: %lx\n", handle);
  1972. fprintf(tasks_file, "MPIRank: %d\n", options->file_rank);
  1973. fprintf(tasks_file, "\n");
  1974. }
  1975. static void handle_data_doing_wont_use(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1976. {
  1977. unsigned long handle = ev->param[0];
  1978. char *prefix = options->file_prefix;
  1979. unsigned node = STARPU_MAIN_RAM;
  1980. const char *event = "WU";
  1981. if (out_paje_file)
  1982. {
  1983. #ifdef STARPU_HAVE_POTI
  1984. char paje_value[STARPU_POTI_STR_LEN], memnode_container[STARPU_POTI_STR_LEN];
  1985. memmanager_container_alias(memnode_container, STARPU_POTI_STR_LEN, prefix, node);
  1986. snprintf(paje_value, sizeof(paje_value), "%lx", handle);
  1987. poti_NewEvent(get_event_time_stamp(ev, options), memnode_container, event, paje_value);
  1988. #else
  1989. fprintf(out_paje_file, "9 %.9f %s %smm%u %lx\n", get_event_time_stamp(ev, options), event, prefix, node, handle);
  1990. #endif
  1991. }
  1992. }
  1993. static void handle_mpi_data_set_rank(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  1994. {
  1995. unsigned long handle = ev->param[0];
  1996. unsigned long rank = ev->param[1];
  1997. struct data_info *data = get_data(handle, options->file_rank);
  1998. data->mpi_owner = rank;
  1999. }
  2000. static void handle_mpi_data_set_tag(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2001. {
  2002. unsigned long handle = ev->param[0];
  2003. long tag = ev->param[1];
  2004. struct data_info *data = get_data(handle, options->file_rank);
  2005. data->mpi_tag = tag;
  2006. }
  2007. static const char *copy_link_type(enum _starpu_is_prefetch prefetch)
  2008. {
  2009. switch (prefetch)
  2010. {
  2011. case STARPU_FETCH: return "F";
  2012. case STARPU_TASK_PREFETCH: return "TF";
  2013. case STARPU_PREFETCH: return "PF";
  2014. case STARPU_IDLEFETCH: return "IF";
  2015. default: STARPU_ASSERT(0);
  2016. }
  2017. }
  2018. static void handle_start_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2019. {
  2020. unsigned src = ev->param[0];
  2021. unsigned dst = ev->param[1];
  2022. unsigned size = ev->param[2];
  2023. unsigned comid = ev->param[3];
  2024. enum _starpu_is_prefetch prefetch = ev->param[4];
  2025. unsigned long handle = ev->param[5];
  2026. const char *link_type = copy_link_type(prefetch);
  2027. char *prefix = options->file_prefix;
  2028. if (!options->no_bus)
  2029. {
  2030. if (out_paje_file)
  2031. {
  2032. double time = get_event_time_stamp(ev, options);
  2033. memnode_push_state(time, prefix, dst, "Co");
  2034. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCo", handle, comid, size, src, options);
  2035. #ifdef STARPU_HAVE_POTI
  2036. char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN], src_memnode_container[STARPU_POTI_STR_LEN];
  2037. char program_container[STARPU_POTI_STR_LEN];
  2038. snprintf(paje_value, sizeof(paje_value), "%u", size);
  2039. snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
  2040. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2041. memmanager_container_alias(src_memnode_container, STARPU_POTI_STR_LEN, prefix, src);
  2042. char str_handle[STARPU_POTI_STR_LEN];
  2043. snprintf(str_handle, sizeof(str_handle), "%lx", handle);
  2044. poti_user_StartLink(_starpu_poti_CommLinkStart, time, program_container, link_type, src_memnode_container, paje_value, paje_key, 1, str_handle);
  2045. #else
  2046. fprintf(out_paje_file, "24 %.9f %s %sp %u %smm%u com_%u %lx\n", time, link_type, prefix, size, prefix, src, comid, handle);
  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. if (!options->no_events)
  2320. poti_NewEvent(get_event_time_stamp(ev, options), container, "pu", paje_value);
  2321. #else
  2322. fprintf(out_paje_file, "13 %.9f %ssched nready %f\n", current_timestamp, options->file_prefix, (float)curq_size);
  2323. if (!options->no_events)
  2324. fprintf(out_paje_file, "9 %.9f %s %sp %u\n", get_event_time_stamp(ev, options), "pu", options->file_prefix, task);
  2325. #endif
  2326. }
  2327. if (activity_file)
  2328. fprintf(activity_file, "cnt_ready\t%.9f\t%d\n", current_timestamp, curq_size);
  2329. if (sched_tasks_file)
  2330. {
  2331. fprintf(sched_tasks_file, "Type: push\n");
  2332. fprintf(sched_tasks_file, "Time: %.9f\n", current_timestamp);
  2333. fprintf(sched_tasks_file, "Priority: %d\n", priority);
  2334. if (options->file_rank < 0)
  2335. fprintf(sched_tasks_file, "JobId: %u\n", task);
  2336. else
  2337. fprintf(sched_tasks_file, "JobId: %d_%u\n", options->file_rank, task);
  2338. fprintf(sched_tasks_file, "\n");
  2339. }
  2340. }
  2341. static void handle_job_pop(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2342. {
  2343. double current_timestamp = get_event_time_stamp(ev, options);
  2344. unsigned task = ev->param[0];
  2345. int priority = ev->param[1];
  2346. curq_size--;
  2347. nsubmitted--;
  2348. _starpu_fxt_component_update_ntasks(nsubmitted, curq_size);
  2349. if (!options->no_counter && out_paje_file)
  2350. {
  2351. #ifdef STARPU_HAVE_POTI
  2352. char container[STARPU_POTI_STR_LEN];
  2353. scheduler_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix);
  2354. poti_SetVariable(current_timestamp, container, "nready", (double)curq_size);
  2355. poti_SetVariable(current_timestamp, container, "nsubmitted", (double)nsubmitted);
  2356. char paje_value[STARPU_POTI_STR_LEN];
  2357. snprintf(paje_value, sizeof(paje_value), "%u", task);
  2358. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2359. if (!options->no_events)
  2360. poti_NewEvent(get_event_time_stamp(ev, options), container, "po", paje_value);
  2361. #else
  2362. fprintf(out_paje_file, "13 %.9f %ssched nready %f\n", current_timestamp, options->file_prefix, (float)curq_size);
  2363. fprintf(out_paje_file, "13 %.9f %ssched nsubmitted %f\n", current_timestamp, options->file_prefix, (float)nsubmitted);
  2364. if (!options->no_events)
  2365. fprintf(out_paje_file, "9 %.9f %s %sp %u\n", get_event_time_stamp(ev, options), "po", options->file_prefix, task);
  2366. #endif
  2367. }
  2368. if (activity_file)
  2369. {
  2370. fprintf(activity_file, "cnt_ready\t%.9f\t%d\n", current_timestamp, curq_size);
  2371. fprintf(activity_file, "cnt_submitted\t%.9f\t%d\n", current_timestamp, nsubmitted);
  2372. }
  2373. if (sched_tasks_file)
  2374. {
  2375. fprintf(sched_tasks_file, "Type: pop\n");
  2376. fprintf(sched_tasks_file, "Time: %.9f\n", current_timestamp);
  2377. fprintf(sched_tasks_file, "Priority: %d\n", priority);
  2378. if (options->file_rank < 0)
  2379. fprintf(sched_tasks_file, "JobId: %u\n", task);
  2380. else
  2381. fprintf(sched_tasks_file, "JobId: %d_%u\n", options->file_rank, task);
  2382. fprintf(sched_tasks_file, "\n");
  2383. }
  2384. }
  2385. static void handle_component_new(struct fxt_ev_64 *ev, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
  2386. {
  2387. _starpu_fxt_component_new(ev->param[0], get_fxt_string(ev, 1));
  2388. }
  2389. static void handle_component_connect(struct fxt_ev_64 *ev, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
  2390. {
  2391. _starpu_fxt_component_connect(ev->param[0], ev->param[1]);
  2392. }
  2393. static void handle_component_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2394. {
  2395. char *prefix = options->file_prefix;
  2396. double current_timestamp = get_event_time_stamp(ev, options);
  2397. int workerid = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  2398. _starpu_fxt_component_push(anim_file, options, current_timestamp, workerid, ev->param[1], ev->param[2], ev->param[3], ev->param[4]);
  2399. }
  2400. static void handle_component_pull(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2401. {
  2402. char *prefix = options->file_prefix;
  2403. double current_timestamp = get_event_time_stamp(ev, options);
  2404. int workerid = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  2405. _starpu_fxt_component_pull(anim_file, options, current_timestamp, workerid, ev->param[1], ev->param[2], ev->param[3], ev->param[4]);
  2406. }
  2407. static
  2408. void handle_update_task_cnt(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2409. {
  2410. double current_timestamp = get_event_time_stamp(ev, options);
  2411. nsubmitted++;
  2412. _starpu_fxt_component_update_ntasks(nsubmitted, curq_size);
  2413. if (!options->no_counter && out_paje_file)
  2414. {
  2415. #ifdef STARPU_HAVE_POTI
  2416. char container[STARPU_POTI_STR_LEN];
  2417. scheduler_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix);
  2418. poti_SetVariable(current_timestamp, container, "nsubmitted", (double)nsubmitted);
  2419. #else
  2420. fprintf(out_paje_file, "13 %.9f %ssched nsubmitted %f\n", current_timestamp, options->file_prefix, (float)nsubmitted);
  2421. #endif
  2422. }
  2423. if (activity_file)
  2424. fprintf(activity_file, "cnt_submitted\t%.9f\t%d\n", current_timestamp, nsubmitted);
  2425. }
  2426. static void handle_tag(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2427. {
  2428. uint64_t tag;
  2429. unsigned long job;
  2430. tag = ev->param[0];
  2431. job = ev->param[1];
  2432. if (options->label_deps)
  2433. _starpu_fxt_dag_add_tag(options->file_prefix, tag, job, "tag");
  2434. else
  2435. _starpu_fxt_dag_add_tag(options->file_prefix, tag, job, NULL);
  2436. }
  2437. static void handle_tag_deps(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2438. {
  2439. uint64_t child;
  2440. uint64_t father;
  2441. child = ev->param[0];
  2442. father = ev->param[1];
  2443. if (options->label_deps)
  2444. _starpu_fxt_dag_add_tag_deps(options->file_prefix, child, father, "tag");
  2445. else
  2446. _starpu_fxt_dag_add_tag_deps(options->file_prefix, child, father, NULL);
  2447. }
  2448. static void handle_task_deps(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2449. {
  2450. unsigned long dep_prev = ev->param[0];
  2451. unsigned long dep_succ = ev->param[1];
  2452. unsigned dep_succ_type = ev->param[2];
  2453. char *name = get_fxt_string(ev,4);
  2454. struct task_info *task = get_task(dep_succ, options->file_rank);
  2455. struct task_info *prev_task = get_task(dep_prev, options->file_rank);
  2456. unsigned alloc = 0;
  2457. task->type = dep_succ_type;
  2458. if (task->ndeps == 0)
  2459. /* Start with 8=2^3, should be plenty in most cases */
  2460. alloc = 8;
  2461. else if (task->ndeps >= 8)
  2462. {
  2463. /* Allocate dependencies array by powers of two */
  2464. if (! ((task->ndeps - 1) & task->ndeps)) /* Is task->ndeps a power of two? */
  2465. {
  2466. /* We have filled the previous power of two, get another one */
  2467. alloc = task->ndeps * 2;
  2468. }
  2469. }
  2470. if (alloc)
  2471. {
  2472. _STARPU_REALLOC(task->dependencies, sizeof(*task->dependencies) * alloc);
  2473. _STARPU_REALLOC(task->dep_labels, sizeof(*task->dep_labels) * alloc);
  2474. }
  2475. task->dependencies[task->ndeps] = dep_prev;
  2476. task->dep_labels[task->ndeps] = strdup(name);
  2477. task->ndeps++;
  2478. /* There is a dependency between both job id : dep_prev -> dep_succ */
  2479. if (show_task(task, options) && show_task(prev_task, options))
  2480. {
  2481. if (!options->label_deps) name = NULL;
  2482. /* We should show the name of the predecessor, then. */
  2483. prev_task->show = 1;
  2484. _starpu_fxt_dag_add_task_deps(options->file_prefix, dep_prev, dep_succ, name);
  2485. }
  2486. }
  2487. static void handle_task_submit(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2488. {
  2489. unsigned long job_id = ev->param[0];
  2490. unsigned long iteration = ev->param[1];
  2491. unsigned long subiteration = ev->param[2];
  2492. unsigned long submit_order = ev->param[3];
  2493. long priority = (long) ev->param[4];
  2494. unsigned type = ev->param[5];
  2495. struct task_info *task = get_task(job_id, options->file_rank);
  2496. task->submit_time = get_event_time_stamp(ev, options);
  2497. task->submit_order = submit_order;
  2498. task->priority = priority;
  2499. task->iterations[0] = iteration;
  2500. task->iterations[1] = subiteration;
  2501. task->type = type;
  2502. }
  2503. static void handle_task_color(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2504. {
  2505. unsigned long job_id = ev->param[0];
  2506. struct task_info *task = get_task(job_id, options->file_rank);
  2507. int color = (long) ev->param[1];
  2508. task->color = color;
  2509. }
  2510. static void handle_task_exclude_from_dag(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2511. {
  2512. unsigned long job_id = ev->param[0];
  2513. unsigned exclude_from_dag = ev->param[1];
  2514. struct task_info *task = get_task(job_id, options->file_rank);
  2515. task->exclude_from_dag = exclude_from_dag;
  2516. }
  2517. static void handle_task_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2518. {
  2519. unsigned long job_id = ev->param[0];
  2520. char *name = get_fxt_string(ev,1);
  2521. char *prefix = options->file_prefix;
  2522. struct task_info *task = get_task(job_id, options->file_rank);
  2523. int worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  2524. const char *color;
  2525. char buffer[32];
  2526. if (task->color != 0)
  2527. {
  2528. snprintf(buffer, sizeof(buffer), "#%06x", task->color);
  2529. color = &buffer[0];
  2530. }
  2531. else if (options->per_task_colour)
  2532. {
  2533. snprintf(buffer, sizeof(buffer), "#%x%x%x",
  2534. get_color_symbol_red(name)/4,
  2535. get_color_symbol_green(name)/4,
  2536. get_color_symbol_blue(name)/4);
  2537. color = &buffer[0];
  2538. }
  2539. else
  2540. {
  2541. color= (worker < 0)?"#aaaaaa":get_worker_color(worker);
  2542. }
  2543. if (!task->name)
  2544. task->name = strdup(name);
  2545. if (!task->exclude_from_dag && show_task(task, options))
  2546. _starpu_fxt_dag_set_task_name(options->file_prefix, job_id, task->name, color);
  2547. }
  2548. static void handle_task_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2549. {
  2550. /* Ideally, we would be able to dump tasks as they terminate, to save
  2551. * memory.
  2552. * We however may have to change their state later, e.g. the show field,
  2553. * due to dependencies added way later. */
  2554. #if 0
  2555. unsigned long job_id;
  2556. job_id = ev->param[0];
  2557. struct task_info *task = get_task(job_id, options->file_rank);
  2558. task_dump(task, options);
  2559. #else
  2560. (void) ev;
  2561. (void) options;
  2562. #endif
  2563. }
  2564. static void handle_tag_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2565. {
  2566. char *prefix = options->file_prefix;
  2567. uint64_t tag_id;
  2568. tag_id = ev->param[0];
  2569. unsigned long has_name = ev->param[2];
  2570. char *name = has_name?get_fxt_string(ev,3):"unknown";
  2571. int worker;
  2572. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  2573. const char *color;
  2574. char buffer[32];
  2575. if (options->per_task_colour)
  2576. {
  2577. snprintf(buffer, sizeof(buffer), "%.4f,%.4f,%.4f",
  2578. get_color_symbol_red(name)/1024.0,
  2579. get_color_symbol_green(name)/1024.0,
  2580. get_color_symbol_blue(name)/1024.0);
  2581. color = &buffer[0];
  2582. }
  2583. else
  2584. {
  2585. color= (worker < 0)?"white":get_worker_color(worker);
  2586. }
  2587. _starpu_fxt_dag_set_tag_done(options->file_prefix, tag_id, color);
  2588. }
  2589. static void handle_mpi_barrier(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2590. {
  2591. int rank = ev->param[0];
  2592. STARPU_ASSERT(rank == options->file_rank || options->file_rank == -1);
  2593. /* Add an event in the trace */
  2594. if (out_paje_file)
  2595. {
  2596. #ifdef STARPU_HAVE_POTI
  2597. char container[STARPU_POTI_STR_LEN], paje_value[STARPU_POTI_STR_LEN];
  2598. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2599. snprintf(paje_value, sizeof(paje_value), "%d", rank);
  2600. poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", paje_value);
  2601. #else
  2602. fprintf(out_paje_file, "9 %.9f prog_event %sp %d\n", get_event_time_stamp(ev, options), options->file_prefix, rank);
  2603. #endif
  2604. }
  2605. }
  2606. static void handle_mpi_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2607. {
  2608. double date = get_event_time_stamp(ev, options);
  2609. char *prefix = options->file_prefix;
  2610. register_mpi_thread(prefixTOnodeid(prefix), ev->param[2]);
  2611. if (out_paje_file)
  2612. {
  2613. #ifdef STARPU_HAVE_POTI
  2614. char program_container[STARPU_POTI_STR_LEN];
  2615. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2616. char new_mpicommthread_container_alias[STARPU_POTI_STR_LEN];
  2617. mpicommthread_container_alias(new_mpicommthread_container_alias, STARPU_POTI_STR_LEN, prefix);
  2618. snprintf(new_mpicommthread_container_alias, STARPU_POTI_STR_LEN, "%smpict", prefix);
  2619. poti_CreateContainer(date, new_mpicommthread_container_alias, "MPICt", program_container, new_mpicommthread_container_alias);
  2620. //set bandwidth variables to zero when they start
  2621. poti_SetVariable(date, new_mpicommthread_container_alias, "bwi_mpi", 0.);
  2622. poti_SetVariable(date, new_mpicommthread_container_alias, "bwo_mpi", 0.);
  2623. #else
  2624. fprintf(out_paje_file, "7 %.9f %smpict MPICt %sp %smpict\n", date, prefix, prefix, prefix);
  2625. //set bandwidth variables to zero when they start
  2626. fprintf(out_paje_file, "13 %.9f %smpict bwi_mpi 0.0\n", date, prefix);
  2627. fprintf(out_paje_file, "13 %.9f %smpict bwo_mpi 0.0\n", date, prefix);
  2628. #endif
  2629. mpicommthread_set_state(date, prefix, "Sl");
  2630. }
  2631. if (trace_file)
  2632. recfmt_mpicommthread_set_state(date, "Sl");
  2633. }
  2634. static void handle_mpi_stop(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2635. {
  2636. double date = get_event_time_stamp(ev, options);
  2637. char *prefix = options->file_prefix;
  2638. if (out_paje_file)
  2639. {
  2640. #ifdef STARPU_HAVE_POTI
  2641. char mpicommthread_container[STARPU_POTI_STR_LEN];
  2642. mpicommthread_container_alias(mpicommthread_container, STARPU_POTI_STR_LEN, prefix);
  2643. poti_DestroyContainer(date, "MPICt", mpicommthread_container);
  2644. #else
  2645. fprintf(out_paje_file, "8 %.9f %smpict MPICt\n",
  2646. date, prefix);
  2647. #endif
  2648. }
  2649. }
  2650. static void handle_mpi_isend_submit_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2651. {
  2652. double date = get_event_time_stamp(ev, options);
  2653. if (out_paje_file)
  2654. mpicommthread_set_state(date, options->file_prefix, "SdS");
  2655. if (trace_file)
  2656. recfmt_mpicommthread_set_state(date, "SdS");
  2657. }
  2658. static int mpi_warned;
  2659. static void handle_mpi_isend_submit_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2660. {
  2661. int dest = ev->param[0];
  2662. int mpi_tag = ev->param[1];
  2663. size_t size = ev->param[2];
  2664. long jobid = ev->param[3];
  2665. unsigned long handle = ev->param[4];
  2666. double date = get_event_time_stamp(ev, options);
  2667. if (out_paje_file)
  2668. mpicommthread_set_state(date, options->file_prefix, "P");
  2669. if (trace_file)
  2670. recfmt_mpicommthread_set_state(date, "P");
  2671. if (options->file_rank < 0)
  2672. {
  2673. if (!mpi_warned)
  2674. {
  2675. _STARPU_MSG("Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
  2676. mpi_warned = 1;
  2677. }
  2678. }
  2679. else
  2680. _starpu_fxt_mpi_add_send_transfer(options->file_rank, dest, mpi_tag, size, date, jobid, handle);
  2681. }
  2682. static void handle_mpi_irecv_submit_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2683. {
  2684. double date = get_event_time_stamp(ev, options);
  2685. if (out_paje_file)
  2686. mpicommthread_set_state(date, options->file_prefix, "RvS");
  2687. if (trace_file)
  2688. recfmt_mpicommthread_set_state(date, "RvS");
  2689. }
  2690. static void handle_mpi_irecv_submit_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2691. {
  2692. double date = get_event_time_stamp(ev, options);
  2693. if (out_paje_file)
  2694. mpicommthread_set_state(date, options->file_prefix, "P");
  2695. if (trace_file)
  2696. recfmt_mpicommthread_set_state(date, "P");
  2697. }
  2698. static void handle_mpi_isend_complete_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2699. {
  2700. double date = get_event_time_stamp(ev, options);
  2701. if (out_paje_file)
  2702. mpicommthread_set_state(date, options->file_prefix, "SdC");
  2703. if (trace_file)
  2704. recfmt_mpicommthread_set_state(date, "SdC");
  2705. }
  2706. static void handle_mpi_isend_complete_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2707. {
  2708. double date = get_event_time_stamp(ev, options);
  2709. if (out_paje_file)
  2710. mpicommthread_set_state(date, options->file_prefix, "P");
  2711. if (trace_file)
  2712. recfmt_mpicommthread_set_state(date, "P");
  2713. }
  2714. static void handle_mpi_irecv_complete_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2715. {
  2716. double date = get_event_time_stamp(ev, options);
  2717. if (out_paje_file)
  2718. mpicommthread_set_state(date, options->file_prefix, "RvC");
  2719. if (trace_file)
  2720. recfmt_mpicommthread_set_state(date, "RvC");
  2721. }
  2722. static void handle_mpi_irecv_complete_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2723. {
  2724. double date = get_event_time_stamp(ev, options);
  2725. if (out_paje_file)
  2726. mpicommthread_set_state(date, options->file_prefix, "P");
  2727. if (trace_file)
  2728. recfmt_mpicommthread_set_state(date, "P");
  2729. }
  2730. static void handle_mpi_irecv_terminated(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2731. {
  2732. int src = ev->param[0];
  2733. int mpi_tag = ev->param[1];
  2734. long jobid = ev->param[2];
  2735. unsigned long handle = ev->param[4];
  2736. double date = get_event_time_stamp(ev, options);
  2737. if (options->file_rank < 0)
  2738. {
  2739. if (!mpi_warned)
  2740. {
  2741. _STARPU_MSG("Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
  2742. mpi_warned = 1;
  2743. }
  2744. }
  2745. else
  2746. _starpu_fxt_mpi_add_recv_transfer(src, options->file_rank, mpi_tag, date, jobid, handle);
  2747. }
  2748. static void handle_mpi_sleep_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2749. {
  2750. double date = get_event_time_stamp(ev, options);
  2751. if (out_paje_file)
  2752. mpicommthread_set_state(date, options->file_prefix, "Sl");
  2753. if (trace_file)
  2754. recfmt_mpicommthread_set_state(date, "Sl");
  2755. }
  2756. static void handle_mpi_sleep_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2757. {
  2758. double date = get_event_time_stamp(ev, options);
  2759. if (out_paje_file)
  2760. mpicommthread_set_state(date, options->file_prefix, "Pl");
  2761. if (trace_file)
  2762. recfmt_mpicommthread_set_state(date, "Pl");
  2763. }
  2764. static void handle_mpi_dtesting_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2765. {
  2766. double date = get_event_time_stamp(ev, options);
  2767. if (out_paje_file)
  2768. mpicommthread_set_state(date, options->file_prefix, "DT");
  2769. if (trace_file)
  2770. recfmt_mpicommthread_set_state(date, "DT");
  2771. }
  2772. static void handle_mpi_dtesting_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2773. {
  2774. double date = get_event_time_stamp(ev, options);
  2775. if (out_paje_file)
  2776. mpicommthread_set_state(date, options->file_prefix, "P");
  2777. if (trace_file)
  2778. recfmt_mpicommthread_set_state(date, "P");
  2779. }
  2780. static void handle_mpi_utesting_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2781. {
  2782. double date = get_event_time_stamp(ev, options);
  2783. if (out_paje_file)
  2784. mpicommthread_set_state(date, options->file_prefix, "UT");
  2785. if (trace_file)
  2786. recfmt_mpicommthread_set_state(date, "UT");
  2787. }
  2788. static void handle_mpi_utesting_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2789. {
  2790. double date = get_event_time_stamp(ev, options);
  2791. if (out_paje_file)
  2792. mpicommthread_set_state(date, options->file_prefix, "P");
  2793. if (trace_file)
  2794. recfmt_mpicommthread_set_state(date, "P");
  2795. }
  2796. static void handle_mpi_uwait_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2797. {
  2798. double date = get_event_time_stamp(ev, options);
  2799. if (out_paje_file)
  2800. mpicommthread_set_state(date, options->file_prefix, "UW");
  2801. if (trace_file)
  2802. recfmt_mpicommthread_set_state(date, "UW");
  2803. }
  2804. static void handle_mpi_uwait_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2805. {
  2806. double date = get_event_time_stamp(ev, options);
  2807. if (out_paje_file)
  2808. mpicommthread_set_state(date, options->file_prefix, "P");
  2809. if (trace_file)
  2810. recfmt_mpicommthread_set_state(date, "P");
  2811. }
  2812. static void handle_mpi_testing_detached_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2813. {
  2814. double date = get_event_time_stamp(ev, options);
  2815. if (out_paje_file)
  2816. mpicommthread_push_state(date, options->file_prefix, "TD");
  2817. if (trace_file)
  2818. recfmt_mpicommthread_push_state(date, "TD");
  2819. }
  2820. static void handle_mpi_testing_detached_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2821. {
  2822. double date = get_event_time_stamp(ev, options);
  2823. if (out_paje_file)
  2824. mpicommthread_pop_state(date, options->file_prefix);
  2825. if (trace_file)
  2826. recfmt_mpicommthread_pop_state(date);
  2827. }
  2828. static void handle_mpi_test_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2829. {
  2830. double date = get_event_time_stamp(ev, options);
  2831. if (out_paje_file)
  2832. mpicommthread_push_state(date, options->file_prefix, "MT");
  2833. if (trace_file)
  2834. recfmt_mpicommthread_push_state(date, "MT");
  2835. }
  2836. static void handle_mpi_test_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2837. {
  2838. double date = get_event_time_stamp(ev, options);
  2839. if (out_paje_file)
  2840. mpicommthread_pop_state(date, options->file_prefix);
  2841. if (trace_file)
  2842. recfmt_mpicommthread_pop_state(date);
  2843. }
  2844. static void handle_mpi_polling_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2845. {
  2846. double date = get_event_time_stamp(ev, options);
  2847. if (out_paje_file)
  2848. mpicommthread_set_state(date, options->file_prefix, "Pl");
  2849. }
  2850. static void handle_mpi_polling_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2851. {
  2852. double date = get_event_time_stamp(ev, options);
  2853. if (out_paje_file)
  2854. mpicommthread_set_state(date, options->file_prefix, "P");
  2855. }
  2856. static void handle_mpi_driver_run_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2857. {
  2858. double date = get_event_time_stamp(ev, options);
  2859. if (out_paje_file)
  2860. mpicommthread_set_state(date, options->file_prefix, "Dr");
  2861. }
  2862. static void handle_mpi_driver_run_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2863. {
  2864. double date = get_event_time_stamp(ev, options);
  2865. if (out_paje_file)
  2866. mpicommthread_set_state(date, options->file_prefix, "Pl");
  2867. }
  2868. static void handle_set_profiling(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2869. {
  2870. int status = ev->param[0];
  2871. if (activity_file)
  2872. fprintf(activity_file, "set_profiling\t%.9f\t%d\n", get_event_time_stamp(ev, options), status);
  2873. }
  2874. static void handle_task_wait_for_all(void)
  2875. {
  2876. _starpu_fxt_dag_add_sync_point();
  2877. }
  2878. static void handle_string_event(struct fxt_ev_64 *ev, const char *event, struct starpu_fxt_options *options)
  2879. {
  2880. /* Add an event in the trace */
  2881. if (out_paje_file)
  2882. {
  2883. #ifdef STARPU_HAVE_POTI
  2884. char container[STARPU_POTI_STR_LEN];
  2885. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2886. poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", event);
  2887. #else
  2888. fprintf(out_paje_file, "9 %.9f prog_event %sp \"%s\"\n", get_event_time_stamp(ev, options), options->file_prefix, event);
  2889. #endif
  2890. }
  2891. if (trace_file)
  2892. recfmt_dump_state(get_event_time_stamp(ev, options), "ProgEvent", -1, 0, event, "Program");
  2893. }
  2894. static void handle_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2895. {
  2896. char *event = get_fxt_string(ev, 0);
  2897. handle_string_event(ev, event, options);
  2898. }
  2899. static void handle_thread_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2900. {
  2901. /* Add an event in the trace */
  2902. if (out_paje_file)
  2903. {
  2904. char *event = get_fxt_string(ev, 1);
  2905. #ifdef STARPU_HAVE_POTI
  2906. char container[STARPU_POTI_STR_LEN];
  2907. thread_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix, ev->param[0]);
  2908. poti_NewEvent(get_event_time_stamp(ev, options), container, "thread_event", event);
  2909. #else
  2910. 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);
  2911. #endif
  2912. }
  2913. }
  2914. static
  2915. void _starpu_fxt_process_bandwidth(struct starpu_fxt_options *options)
  2916. {
  2917. char *prefix = options->file_prefix;
  2918. struct _starpu_communication *itor, *next;
  2919. /* Loop through completed communications */
  2920. for (itor = _starpu_communication_list_begin(&communication_list);
  2921. itor != _starpu_communication_list_end(&communication_list);
  2922. itor = next)
  2923. {
  2924. next = _starpu_communication_list_next(itor);
  2925. if (!itor->peer)
  2926. continue;
  2927. /* This communication is complete */
  2928. _starpu_communication_list_erase(&communication_list, itor);
  2929. current_bandwidth_out_per_node[itor->src_node] += itor->bandwidth;
  2930. if (out_paje_file)
  2931. {
  2932. #ifdef STARPU_HAVE_POTI
  2933. char src_memnode_container[STARPU_POTI_STR_LEN];
  2934. memmanager_container_alias(src_memnode_container, STARPU_POTI_STR_LEN, prefix, itor->src_node);
  2935. poti_SetVariable(itor->comm_start, src_memnode_container, "bwo_mm", current_bandwidth_out_per_node[itor->src_node]);
  2936. #else
  2937. fprintf(out_paje_file, "13 %.9f %smm%u bwo_mm %f\n",
  2938. itor->comm_start, prefix, itor->src_node, current_bandwidth_out_per_node[itor->src_node]);
  2939. #endif
  2940. }
  2941. current_bandwidth_in_per_node[itor->dst_node] += itor->bandwidth;
  2942. if (out_paje_file)
  2943. {
  2944. #ifdef STARPU_HAVE_POTI
  2945. char dst_memnode_container[STARPU_POTI_STR_LEN];
  2946. memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, itor->dst_node);
  2947. poti_SetVariable(itor->comm_start, dst_memnode_container, "bwi_mm", current_bandwidth_in_per_node[itor->dst_node]);
  2948. #else
  2949. fprintf(out_paje_file, "13 %.9f %smm%u bwi_mm %f\n",
  2950. itor->comm_start, prefix, itor->dst_node, current_bandwidth_in_per_node[itor->dst_node]);
  2951. #endif
  2952. }
  2953. _starpu_communication_delete(itor);
  2954. }
  2955. }
  2956. static
  2957. void _starpu_fxt_process_computations(struct starpu_fxt_options *options)
  2958. {
  2959. char *prefix = options->file_prefix;
  2960. /* Loop through completed computations */
  2961. struct _starpu_computation*itor;
  2962. while (!_starpu_computation_list_empty(&computation_list)
  2963. && _starpu_computation_list_begin(&computation_list)->peer)
  2964. {
  2965. /* This computation is complete */
  2966. itor = _starpu_computation_list_pop_front(&computation_list);
  2967. if (out_paje_file && itor->comp_start != current_computation_time)
  2968. {
  2969. /* flush last value */
  2970. #ifdef STARPU_HAVE_POTI
  2971. char container[STARPU_POTI_STR_LEN];
  2972. scheduler_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  2973. poti_SetVariable(current_computation_time, container, "gft", (double)current_computation);
  2974. #else
  2975. fprintf(out_paje_file, "13 %.9f %ssched gft %f\n", current_computation_time, prefix, (float)current_computation);
  2976. #endif
  2977. }
  2978. current_computation += itor->gflops;
  2979. current_computation_time = itor->comp_start;
  2980. _starpu_computation_delete(itor);
  2981. }
  2982. }
  2983. static
  2984. void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *options)
  2985. {
  2986. /* Open the trace file */
  2987. int fd_in;
  2988. fd_in = open(filename_in, O_RDONLY);
  2989. if (fd_in < 0)
  2990. {
  2991. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", filename_in, strerror(errno));
  2992. }
  2993. static fxt_t fut;
  2994. fut = fxt_fdopen(fd_in);
  2995. if (!fut)
  2996. {
  2997. perror("fxt_fdopen :");
  2998. exit(-1);
  2999. }
  3000. fxt_blockev_t block;
  3001. block = fxt_blockev_enter(fut);
  3002. char *prefix = options->file_prefix;
  3003. /* TODO starttime ...*/
  3004. /* create the "program" container */
  3005. current_computation = 0.0;
  3006. current_computation_time = 0.0;
  3007. if (out_paje_file)
  3008. {
  3009. #ifdef STARPU_HAVE_POTI
  3010. char new_program_container_alias[STARPU_POTI_STR_LEN], new_program_container_name[STARPU_POTI_STR_LEN];
  3011. program_container_alias(new_program_container_alias, STARPU_POTI_STR_LEN, prefix);
  3012. snprintf(new_program_container_name, sizeof(new_program_container_name), "program %s", prefix);
  3013. poti_CreateContainer (0, new_program_container_alias, "P", "MPIroot", new_program_container_name);
  3014. char new_scheduler_container_alias[STARPU_POTI_STR_LEN], new_scheduler_container_name[STARPU_POTI_STR_LEN];
  3015. scheduler_container_alias(new_scheduler_container_alias, STARPU_POTI_STR_LEN, prefix);
  3016. snprintf(new_scheduler_container_name, sizeof(new_scheduler_container_name), "%sscheduler", prefix);
  3017. if (!options->no_counter || !options->no_flops)
  3018. {
  3019. poti_CreateContainer(0.0, new_scheduler_container_alias, "Sc", new_program_container_alias, new_scheduler_container_name);
  3020. }
  3021. if (!options->no_counter)
  3022. {
  3023. poti_SetVariable(0.0, new_scheduler_container_alias, "nsubmitted", 0.0);
  3024. poti_SetVariable(0.0, new_scheduler_container_alias, "nready", 0.0);
  3025. }
  3026. if (!options->no_flops)
  3027. {
  3028. poti_SetVariable(0.0, new_scheduler_container_alias, "gft", 0.0);
  3029. }
  3030. #else
  3031. fprintf(out_paje_file, "7 0.0 %sp P MPIroot %sprogram \n", prefix, prefix);
  3032. if (!options->no_counter || !options->no_flops)
  3033. {
  3034. fprintf(out_paje_file, "7 0.0 %ssched Sc %sp %sscheduler\n", prefix, prefix, prefix);
  3035. }
  3036. if (!options->no_counter)
  3037. {
  3038. /* create a variable with the number of tasks */
  3039. fprintf(out_paje_file, "13 0.0 %ssched nsubmitted 0.0\n", prefix);
  3040. fprintf(out_paje_file, "13 0.0 %ssched nready 0.0\n", prefix);
  3041. }
  3042. if (!options->no_flops)
  3043. {
  3044. fprintf(out_paje_file, "13 0.0 %ssched gft 0.0\n", prefix);
  3045. }
  3046. #endif
  3047. }
  3048. struct fxt_ev_64 ev;
  3049. while(1)
  3050. {
  3051. unsigned i;
  3052. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  3053. for (i = ev.nb_params; i < FXT_MAX_PARAMS; i++)
  3054. ev.param[i] = 0;
  3055. if (ret != FXT_EV_OK)
  3056. {
  3057. break;
  3058. }
  3059. if (number_events_file != NULL)
  3060. {
  3061. assert(number_events != NULL);
  3062. assert(ev.code <= FUT_SETUP_CODE);
  3063. number_events[ev.code]++;
  3064. }
  3065. switch (ev.code)
  3066. {
  3067. case _STARPU_FUT_WORKER_INIT_START:
  3068. handle_worker_init_start(&ev, options);
  3069. break;
  3070. case _STARPU_FUT_WORKER_INIT_END:
  3071. handle_worker_init_end(&ev, options);
  3072. break;
  3073. case _STARPU_FUT_NEW_MEM_NODE:
  3074. handle_new_mem_node(&ev, options);
  3075. break;
  3076. /* detect when the workers were idling or not */
  3077. case _STARPU_FUT_START_CODELET_BODY:
  3078. handle_start_codelet_body(&ev, options);
  3079. break;
  3080. case _STARPU_FUT_MODEL_NAME:
  3081. handle_model_name(&ev, options);
  3082. break;
  3083. case _STARPU_FUT_CODELET_DATA:
  3084. handle_codelet_data(&ev, options);
  3085. break;
  3086. case _STARPU_FUT_CODELET_DATA_HANDLE:
  3087. handle_codelet_data_handle(&ev, options);
  3088. break;
  3089. case _STARPU_FUT_CODELET_DETAILS:
  3090. handle_codelet_details(&ev, options);
  3091. break;
  3092. case _STARPU_FUT_END_CODELET_BODY:
  3093. handle_end_codelet_body(&ev, options);
  3094. break;
  3095. case _STARPU_FUT_START_EXECUTING:
  3096. handle_start_executing(&ev, options);
  3097. break;
  3098. case _STARPU_FUT_END_EXECUTING:
  3099. handle_end_executing(&ev, options);
  3100. break;
  3101. case _STARPU_FUT_START_CALLBACK:
  3102. handle_start_callback(&ev, options);
  3103. break;
  3104. case _STARPU_FUT_END_CALLBACK:
  3105. handle_end_callback(&ev, options);
  3106. break;
  3107. case _STARPU_FUT_UPDATE_TASK_CNT:
  3108. handle_update_task_cnt(&ev, options);
  3109. break;
  3110. /* monitor stack size and generate sched_tasks.rec */
  3111. case _STARPU_FUT_JOB_PUSH:
  3112. handle_job_push(&ev, options);
  3113. break;
  3114. case _STARPU_FUT_JOB_POP:
  3115. handle_job_pop(&ev, options);
  3116. break;
  3117. case _STARPU_FUT_SCHED_COMPONENT_NEW:
  3118. handle_component_new(&ev, options);
  3119. break;
  3120. case _STARPU_FUT_SCHED_COMPONENT_CONNECT:
  3121. handle_component_connect(&ev, options);
  3122. break;
  3123. case _STARPU_FUT_SCHED_COMPONENT_PUSH:
  3124. handle_component_push(&ev, options);
  3125. break;
  3126. case _STARPU_FUT_SCHED_COMPONENT_PULL:
  3127. handle_component_pull(&ev, options);
  3128. break;
  3129. /* check the memory transfer overhead */
  3130. case _STARPU_FUT_START_FETCH_INPUT_ON_TID:
  3131. handle_worker_status_on_tid(&ev, options, "Fi");
  3132. break;
  3133. case _STARPU_FUT_START_PUSH_OUTPUT_ON_TID:
  3134. handle_worker_status_on_tid(&ev, options, "Po");
  3135. break;
  3136. case _STARPU_FUT_START_PROGRESS_ON_TID:
  3137. handle_worker_status_on_tid(&ev, options, "P");
  3138. break;
  3139. case _STARPU_FUT_START_UNPARTITION_ON_TID:
  3140. handle_worker_status_on_tid(&ev, options, "U");
  3141. break;
  3142. case _STARPU_FUT_END_FETCH_INPUT_ON_TID:
  3143. case _STARPU_FUT_END_PROGRESS_ON_TID:
  3144. case _STARPU_FUT_END_PUSH_OUTPUT_ON_TID:
  3145. case _STARPU_FUT_END_UNPARTITION_ON_TID:
  3146. handle_worker_status_on_tid(&ev, options, "B");
  3147. break;
  3148. case _STARPU_FUT_START_FETCH_INPUT:
  3149. handle_worker_status(&ev, options, "Fi");
  3150. break;
  3151. case _STARPU_FUT_END_FETCH_INPUT:
  3152. handle_worker_status(&ev, options, "B");
  3153. break;
  3154. case _STARPU_FUT_WORKER_SCHEDULING_START:
  3155. handle_worker_scheduling_start(&ev, options);
  3156. break;
  3157. case _STARPU_FUT_WORKER_SCHEDULING_END:
  3158. handle_worker_scheduling_end(&ev, options);
  3159. break;
  3160. case _STARPU_FUT_WORKER_SCHEDULING_PUSH:
  3161. handle_worker_scheduling_push(&ev, options);
  3162. break;
  3163. case _STARPU_FUT_WORKER_SCHEDULING_POP:
  3164. handle_worker_scheduling_pop(&ev, options);
  3165. break;
  3166. case _STARPU_FUT_WORKER_SLEEP_START:
  3167. handle_worker_sleep_start(&ev, options);
  3168. break;
  3169. case _STARPU_FUT_WORKER_SLEEP_END:
  3170. handle_worker_sleep_end(&ev, options);
  3171. break;
  3172. case _STARPU_FUT_TAG:
  3173. handle_tag(&ev, options);
  3174. break;
  3175. case _STARPU_FUT_TAG_DEPS:
  3176. handle_tag_deps(&ev, options);
  3177. break;
  3178. case _STARPU_FUT_TASK_DEPS:
  3179. handle_task_deps(&ev, options);
  3180. break;
  3181. case _STARPU_FUT_TASK_SUBMIT:
  3182. handle_task_submit(&ev, options);
  3183. break;
  3184. case _STARPU_FUT_TASK_BUILD_START:
  3185. handle_task_submit_event(&ev, options, ev.param[0], "Bu");
  3186. break;
  3187. case _STARPU_FUT_TASK_SUBMIT_START:
  3188. handle_task_submit_event(&ev, options, ev.param[0], "Su");
  3189. break;
  3190. case _STARPU_FUT_TASK_THROTTLE_START:
  3191. handle_task_submit_event(&ev, options, ev.param[0], "Th");
  3192. break;
  3193. case _STARPU_FUT_TASK_MPI_DECODE_START:
  3194. handle_task_submit_event(&ev, options, ev.param[0], "MD");
  3195. break;
  3196. case _STARPU_FUT_TASK_MPI_PRE_START:
  3197. handle_task_submit_event(&ev, options, ev.param[0], "MPr");
  3198. break;
  3199. case _STARPU_FUT_TASK_MPI_POST_START:
  3200. handle_task_submit_event(&ev, options, ev.param[0], "MPo");
  3201. break;
  3202. case _STARPU_FUT_TASK_WAIT_START:
  3203. handle_task_submit_event(&ev, options, ev.param[1], "W");
  3204. break;
  3205. case _STARPU_FUT_TASK_WAIT_FOR_ALL_START:
  3206. handle_task_submit_event(&ev, options, ev.param[0], "WA");
  3207. break;
  3208. case _STARPU_FUT_TASK_BUILD_END:
  3209. case _STARPU_FUT_TASK_SUBMIT_END:
  3210. case _STARPU_FUT_TASK_THROTTLE_END:
  3211. case _STARPU_FUT_TASK_MPI_DECODE_END:
  3212. case _STARPU_FUT_TASK_MPI_PRE_END:
  3213. case _STARPU_FUT_TASK_MPI_POST_END:
  3214. case _STARPU_FUT_TASK_WAIT_FOR_ALL_END:
  3215. handle_task_submit_event(&ev, options, ev.param[0], NULL);
  3216. break;
  3217. case _STARPU_FUT_TASK_WAIT_END:
  3218. handle_task_submit_event(&ev, options, ev.param[0], NULL);
  3219. break;
  3220. case _STARPU_FUT_TASK_EXCLUDE_FROM_DAG:
  3221. handle_task_exclude_from_dag(&ev, options);
  3222. break;
  3223. case _STARPU_FUT_TASK_NAME:
  3224. handle_task_name(&ev, options);
  3225. break;
  3226. case _STARPU_FUT_TASK_COLOR:
  3227. handle_task_color(&ev, options);
  3228. break;
  3229. case _STARPU_FUT_TASK_DONE:
  3230. handle_task_done(&ev, options);
  3231. break;
  3232. case _STARPU_FUT_TAG_DONE:
  3233. handle_tag_done(&ev, options);
  3234. break;
  3235. case _STARPU_FUT_HANDLE_DATA_REGISTER:
  3236. handle_data_register(&ev, options);
  3237. break;
  3238. case _STARPU_FUT_HANDLE_DATA_UNREGISTER:
  3239. handle_data_unregister(&ev, options);
  3240. break;
  3241. case _STARPU_FUT_DATA_STATE_INVALID:
  3242. if (options->memory_states)
  3243. handle_data_state(&ev, options, "SI");
  3244. break;
  3245. case _STARPU_FUT_DATA_STATE_OWNER:
  3246. if (options->memory_states)
  3247. handle_data_state(&ev, options, "SO");
  3248. break;
  3249. case _STARPU_FUT_DATA_STATE_SHARED:
  3250. if (options->memory_states)
  3251. handle_data_state(&ev, options, "SS");
  3252. break;
  3253. case _STARPU_FUT_DATA_REQUEST_CREATED:
  3254. if (!options->no_bus && options->memory_states)
  3255. {
  3256. handle_memnode_event_start_4(&ev, options, "rc");
  3257. }
  3258. break;
  3259. case _STARPU_FUT_PAPI_TASK_EVENT_VALUE:
  3260. handle_papi_event(&ev, options);
  3261. break;
  3262. case _STARPU_FUT_DATA_COPY:
  3263. if (!options->no_bus)
  3264. handle_data_copy();
  3265. break;
  3266. case _STARPU_FUT_DATA_LOAD:
  3267. break;
  3268. case _STARPU_FUT_DATA_NAME:
  3269. handle_data_name(&ev, options);
  3270. break;
  3271. case _STARPU_FUT_DATA_COORDINATES:
  3272. handle_data_coordinates(&ev, options);
  3273. break;
  3274. case _STARPU_FUT_DATA_WONT_USE:
  3275. handle_data_wont_use(&ev, options);
  3276. break;
  3277. case _STARPU_FUT_DATA_DOING_WONT_USE:
  3278. if (options->memory_states)
  3279. handle_data_doing_wont_use(&ev, options);
  3280. break;
  3281. case _STARPU_FUT_START_DRIVER_COPY:
  3282. if (!options->no_bus)
  3283. handle_start_driver_copy(&ev, options);
  3284. break;
  3285. case _STARPU_FUT_END_DRIVER_COPY:
  3286. if (!options->no_bus)
  3287. handle_end_driver_copy(&ev, options);
  3288. break;
  3289. case _STARPU_FUT_START_DRIVER_COPY_ASYNC:
  3290. if (!options->no_bus)
  3291. handle_start_driver_copy_async(&ev, options);
  3292. break;
  3293. case _STARPU_FUT_END_DRIVER_COPY_ASYNC:
  3294. if (!options->no_bus)
  3295. handle_end_driver_copy_async(&ev, options);
  3296. break;
  3297. case _STARPU_FUT_WORK_STEALING:
  3298. handle_work_stealing(&ev, options);
  3299. break;
  3300. case _STARPU_FUT_WORKER_DEINIT_START:
  3301. handle_worker_deinit_start(&ev, options);
  3302. break;
  3303. case _STARPU_FUT_WORKER_DEINIT_END:
  3304. handle_worker_deinit_end(&ev, options);
  3305. break;
  3306. case _STARPU_FUT_START_ALLOC:
  3307. if (!options->no_bus)
  3308. {
  3309. handle_push_memnode_event(&ev, options, "A");
  3310. handle_memnode_event_start_4(&ev, options, "Al");
  3311. }
  3312. break;
  3313. case _STARPU_FUT_START_ALLOC_REUSE:
  3314. if (!options->no_bus)
  3315. {
  3316. handle_push_memnode_event(&ev, options, "Ar");
  3317. handle_memnode_event_start_4(&ev, options, "Alr");
  3318. }
  3319. break;
  3320. case _STARPU_FUT_END_ALLOC:
  3321. if (!options->no_bus)
  3322. {
  3323. handle_pop_memnode_event(&ev, options);
  3324. handle_memnode_event_end_3(&ev, options, "AlE");
  3325. }
  3326. break;
  3327. case _STARPU_FUT_END_ALLOC_REUSE:
  3328. if (!options->no_bus)
  3329. {
  3330. handle_pop_memnode_event(&ev, options);
  3331. handle_memnode_event_end_3(&ev, options, "AlrE");
  3332. }
  3333. break;
  3334. case _STARPU_FUT_START_FREE:
  3335. if (!options->no_bus)
  3336. {
  3337. handle_push_memnode_event(&ev, options, "F");
  3338. handle_memnode_event_start_3(&ev, options, "Fe");
  3339. }
  3340. break;
  3341. case _STARPU_FUT_END_FREE:
  3342. if (!options->no_bus)
  3343. {
  3344. handle_pop_memnode_event(&ev, options);
  3345. handle_memnode_event_end_2(&ev, options, "FeE");
  3346. }
  3347. break;
  3348. case _STARPU_FUT_START_WRITEBACK:
  3349. if (!options->no_bus)
  3350. {
  3351. handle_push_memnode_event(&ev, options, "W");
  3352. handle_memnode_event_start_2(&ev, options, "Wb");
  3353. }
  3354. break;
  3355. case _STARPU_FUT_END_WRITEBACK:
  3356. if (!options->no_bus)
  3357. {
  3358. handle_pop_memnode_event(&ev, options);
  3359. handle_memnode_event_start_2(&ev, options, "WbE");
  3360. }
  3361. break;
  3362. case _STARPU_FUT_START_WRITEBACK_ASYNC:
  3363. if (!options->no_bus)
  3364. handle_push_memnode_event(&ev, options, "Wa");
  3365. break;
  3366. case _STARPU_FUT_END_WRITEBACK_ASYNC:
  3367. if (!options->no_bus)
  3368. handle_pop_memnode_event(&ev, options);
  3369. break;
  3370. case _STARPU_FUT_START_MEMRECLAIM:
  3371. if (!options->no_bus)
  3372. handle_push_memnode_event(&ev, options, "R");
  3373. break;
  3374. case _STARPU_FUT_END_MEMRECLAIM:
  3375. if (!options->no_bus)
  3376. handle_pop_memnode_event(&ev, options);
  3377. break;
  3378. case _STARPU_FUT_USED_MEM:
  3379. handle_used_mem(&ev, options);
  3380. break;
  3381. case _STARPU_FUT_USER_EVENT:
  3382. if (!options->no_events)
  3383. handle_user_event(&ev, options);
  3384. break;
  3385. case _STARPU_MPI_FUT_START:
  3386. handle_mpi_start(&ev, options);
  3387. break;
  3388. case _STARPU_MPI_FUT_STOP:
  3389. handle_mpi_stop(&ev, options);
  3390. break;
  3391. case _STARPU_MPI_FUT_BARRIER:
  3392. handle_mpi_barrier(&ev, options);
  3393. break;
  3394. case _STARPU_MPI_FUT_ISEND_SUBMIT_BEGIN:
  3395. handle_mpi_isend_submit_begin(&ev, options);
  3396. break;
  3397. case _STARPU_MPI_FUT_ISEND_SUBMIT_END:
  3398. handle_mpi_isend_submit_end(&ev, options);
  3399. break;
  3400. case _STARPU_MPI_FUT_IRECV_SUBMIT_BEGIN:
  3401. handle_mpi_irecv_submit_begin(&ev, options);
  3402. break;
  3403. case _STARPU_MPI_FUT_IRECV_SUBMIT_END:
  3404. handle_mpi_irecv_submit_end(&ev, options);
  3405. break;
  3406. case _STARPU_MPI_FUT_ISEND_COMPLETE_BEGIN:
  3407. handle_mpi_isend_complete_begin(&ev, options);
  3408. break;
  3409. case _STARPU_MPI_FUT_ISEND_COMPLETE_END:
  3410. handle_mpi_isend_complete_end(&ev, options);
  3411. break;
  3412. case _STARPU_MPI_FUT_IRECV_COMPLETE_BEGIN:
  3413. handle_mpi_irecv_complete_begin(&ev, options);
  3414. break;
  3415. case _STARPU_MPI_FUT_IRECV_COMPLETE_END:
  3416. handle_mpi_irecv_complete_end(&ev, options);
  3417. break;
  3418. case _STARPU_MPI_FUT_ISEND_TERMINATED:
  3419. break;
  3420. case _STARPU_MPI_FUT_IRECV_TERMINATED:
  3421. handle_mpi_irecv_terminated(&ev, options);
  3422. break;
  3423. case _STARPU_MPI_FUT_SLEEP_BEGIN:
  3424. handle_mpi_sleep_begin(&ev, options);
  3425. break;
  3426. case _STARPU_MPI_FUT_SLEEP_END:
  3427. handle_mpi_sleep_end(&ev, options);
  3428. break;
  3429. case _STARPU_MPI_FUT_DTESTING_BEGIN:
  3430. handle_mpi_dtesting_begin(&ev, options);
  3431. break;
  3432. case _STARPU_MPI_FUT_DTESTING_END:
  3433. handle_mpi_dtesting_end(&ev, options);
  3434. break;
  3435. case _STARPU_MPI_FUT_UTESTING_BEGIN:
  3436. handle_mpi_utesting_begin(&ev, options);
  3437. break;
  3438. case _STARPU_MPI_FUT_UTESTING_END:
  3439. handle_mpi_utesting_end(&ev, options);
  3440. break;
  3441. case _STARPU_MPI_FUT_UWAIT_BEGIN:
  3442. handle_mpi_uwait_begin(&ev, options);
  3443. break;
  3444. case _STARPU_MPI_FUT_UWAIT_END:
  3445. handle_mpi_uwait_end(&ev, options);
  3446. break;
  3447. case _STARPU_MPI_FUT_DATA_SET_RANK:
  3448. handle_mpi_data_set_rank(&ev, options);
  3449. break;
  3450. case _STARPU_MPI_FUT_DATA_SET_TAG:
  3451. handle_mpi_data_set_tag(&ev, options);
  3452. break;
  3453. case _STARPU_MPI_FUT_TESTING_DETACHED_BEGIN:
  3454. handle_mpi_testing_detached_begin(&ev, options);
  3455. break;
  3456. case _STARPU_MPI_FUT_TESTING_DETACHED_END:
  3457. handle_mpi_testing_detached_end(&ev, options);
  3458. break;
  3459. case _STARPU_MPI_FUT_TEST_BEGIN:
  3460. handle_mpi_test_begin(&ev, options);
  3461. break;
  3462. case _STARPU_MPI_FUT_TEST_END:
  3463. handle_mpi_test_end(&ev, options);
  3464. break;
  3465. case _STARPU_MPI_FUT_POLLING_BEGIN:
  3466. handle_mpi_polling_begin(&ev, options);
  3467. break;
  3468. case _STARPU_MPI_FUT_POLLING_END:
  3469. handle_mpi_polling_end(&ev, options);
  3470. break;
  3471. case _STARPU_MPI_FUT_DRIVER_RUN_BEGIN:
  3472. handle_mpi_driver_run_begin(&ev, options);
  3473. break;
  3474. case _STARPU_MPI_FUT_DRIVER_RUN_END:
  3475. handle_mpi_driver_run_end(&ev, options);
  3476. break;
  3477. case _STARPU_FUT_SET_PROFILING:
  3478. handle_set_profiling(&ev, options);
  3479. break;
  3480. case _STARPU_FUT_TASK_WAIT_FOR_ALL:
  3481. handle_task_wait_for_all();
  3482. break;
  3483. case _STARPU_FUT_EVENT:
  3484. if (!options->no_events)
  3485. handle_event(&ev, options);
  3486. break;
  3487. case _STARPU_FUT_THREAD_EVENT:
  3488. if (!options->no_events)
  3489. handle_thread_event(&ev, options);
  3490. break;
  3491. case _STARPU_FUT_LOCKING_MUTEX:
  3492. break;
  3493. case _STARPU_FUT_MUTEX_LOCKED:
  3494. break;
  3495. case _STARPU_FUT_UNLOCKING_MUTEX:
  3496. break;
  3497. case _STARPU_FUT_MUTEX_UNLOCKED:
  3498. break;
  3499. case _STARPU_FUT_TRYLOCK_MUTEX:
  3500. break;
  3501. case _STARPU_FUT_RDLOCKING_RWLOCK:
  3502. break;
  3503. case _STARPU_FUT_RWLOCK_RDLOCKED:
  3504. break;
  3505. case _STARPU_FUT_WRLOCKING_RWLOCK:
  3506. break;
  3507. case _STARPU_FUT_RWLOCK_WRLOCKED:
  3508. break;
  3509. case _STARPU_FUT_UNLOCKING_RWLOCK:
  3510. break;
  3511. case _STARPU_FUT_RWLOCK_UNLOCKED:
  3512. break;
  3513. case _STARPU_FUT_LOCKING_SPINLOCK:
  3514. break;
  3515. case _STARPU_FUT_SPINLOCK_LOCKED:
  3516. break;
  3517. case _STARPU_FUT_UNLOCKING_SPINLOCK:
  3518. break;
  3519. case _STARPU_FUT_SPINLOCK_UNLOCKED:
  3520. break;
  3521. case _STARPU_FUT_TRYLOCK_SPINLOCK:
  3522. break;
  3523. case _STARPU_FUT_COND_WAIT_BEGIN:
  3524. break;
  3525. case _STARPU_FUT_COND_WAIT_END:
  3526. break;
  3527. case _STARPU_FUT_BARRIER_WAIT_BEGIN:
  3528. break;
  3529. case _STARPU_FUT_BARRIER_WAIT_END:
  3530. break;
  3531. case _STARPU_FUT_MEMORY_FULL:
  3532. break;
  3533. case _STARPU_FUT_SCHED_COMPONENT_POP_PRIO:
  3534. break;
  3535. case _STARPU_FUT_SCHED_COMPONENT_PUSH_PRIO:
  3536. break;
  3537. case _STARPU_FUT_HYPERVISOR_BEGIN:
  3538. handle_hypervisor_begin(&ev, options);
  3539. break;
  3540. case _STARPU_FUT_HYPERVISOR_END:
  3541. handle_hypervisor_end(&ev, options);
  3542. break;
  3543. case FUT_SETUP_CODE:
  3544. fut_keymask = ev.param[0];
  3545. break;
  3546. case FUT_KEYCHANGE_CODE:
  3547. fut_keymask = ev.param[0];
  3548. break;
  3549. case FUT_START_FLUSH_CODE:
  3550. handle_string_event(&ev, "fxt_start_flush", options);
  3551. break;
  3552. case FUT_STOP_FLUSH_CODE:
  3553. handle_string_event(&ev, "fxt_stop_flush", options);
  3554. break;
  3555. /* We can safely ignore FUT internal events */
  3556. case FUT_CALIBRATE0_CODE:
  3557. case FUT_CALIBRATE1_CODE:
  3558. case FUT_CALIBRATE2_CODE:
  3559. case FUT_NEW_LWP_CODE:
  3560. case FUT_GCC_INSTRUMENT_ENTRY_CODE:
  3561. break;
  3562. default:
  3563. #ifdef STARPU_VERBOSE
  3564. _STARPU_MSG("unknown event.. %x at time %llx WITH OFFSET %llx\n",
  3565. (unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time-options->file_offset));
  3566. #endif
  3567. break;
  3568. }
  3569. _starpu_fxt_process_bandwidth(options);
  3570. if (!options->no_flops)
  3571. _starpu_fxt_process_computations(options);
  3572. }
  3573. if (!options->no_flops)
  3574. {
  3575. /* computations are supposed to be over, drop any pending comp */
  3576. unsigned i;
  3577. for (i = 0; i < STARPU_NMAXWORKERS; i++)
  3578. {
  3579. struct _starpu_computation *comp = ongoing_computation[i];
  3580. if (comp)
  3581. {
  3582. STARPU_ASSERT(!comp->peer);
  3583. _starpu_computation_list_erase(&computation_list, comp);
  3584. ongoing_computation[i] = 0;
  3585. }
  3586. }
  3587. /* And flush completed computations */
  3588. _starpu_fxt_process_computations(options);
  3589. }
  3590. if (out_paje_file && !options->no_bus)
  3591. {
  3592. while (!_starpu_communication_list_empty(&communication_list)) {
  3593. struct _starpu_communication*itor;
  3594. itor = _starpu_communication_list_pop_front(&communication_list);
  3595. /* Trace finished with this communication uncompleted, fake its termination */
  3596. unsigned comid = itor->comid;
  3597. unsigned long size = itor->size;
  3598. unsigned dst = itor->dst_node;
  3599. double time = current_computation_time;
  3600. const char *link_type = itor->type;
  3601. #ifdef STARPU_HAVE_POTI
  3602. char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN];
  3603. char dst_memnode_container[STARPU_POTI_STR_LEN], program_container[STARPU_POTI_STR_LEN];
  3604. snprintf(paje_value, sizeof(paje_value), "%lu", size);
  3605. snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
  3606. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  3607. memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, dst);
  3608. poti_EndLink(time, program_container, link_type, dst_memnode_container, paje_value, paje_key);
  3609. #else
  3610. fprintf(out_paje_file, "19 %.9f %s %sp %lu %smm%u com_%u\n", time, link_type, prefix, size, prefix, dst, comid);
  3611. #endif
  3612. _starpu_communication_delete(itor);
  3613. }
  3614. }
  3615. if (out_paje_file && !options->no_flops)
  3616. {
  3617. unsigned i;
  3618. for (i = 0; i < STARPU_NMAXWORKERS; i++)
  3619. {
  3620. if (last_codelet_end[i] != 0.0)
  3621. {
  3622. #ifdef STARPU_HAVE_POTI
  3623. char container[STARPU_POTI_STR_LEN];
  3624. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, i);
  3625. poti_SetVariable(last_codelet_end[i], container, "gf", 0.);
  3626. #else
  3627. fprintf(out_paje_file, "13 %.9f %sw%u gf %f\n",
  3628. last_codelet_end[i], prefix, i, 0.);
  3629. #endif
  3630. last_codelet_end[i] = 0.0;
  3631. }
  3632. }
  3633. /* flush last value */
  3634. #ifdef STARPU_HAVE_POTI
  3635. char container[STARPU_POTI_STR_LEN];
  3636. scheduler_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  3637. poti_SetVariable(current_computation_time, container, "gft", (double)current_computation);
  3638. #else
  3639. fprintf(out_paje_file, "13 %.9f %ssched gft %f\n", current_computation_time, prefix, (float)current_computation);
  3640. #endif
  3641. }
  3642. {
  3643. struct data_info *data=NULL, *tmp=NULL;
  3644. HASH_ITER(hh, data_info, data, tmp)
  3645. {
  3646. data_dump(data);
  3647. }
  3648. }
  3649. {
  3650. struct task_info *task=NULL, *tmp=NULL;
  3651. HASH_ITER(hh, tasks_info, task, tmp)
  3652. {
  3653. task_dump(task, options);
  3654. }
  3655. }
  3656. /* Close the trace file */
  3657. if (close(fd_in))
  3658. {
  3659. perror("close failed :");
  3660. exit(-1);
  3661. }
  3662. }
  3663. /* Initialize FxT options to default values */
  3664. void starpu_fxt_options_init(struct starpu_fxt_options *options)
  3665. {
  3666. options->per_task_colour = 0;
  3667. options->no_events = 0;
  3668. options->no_counter = 0;
  3669. options->no_bus = 0;
  3670. options->no_flops = 0;
  3671. options->no_smooth = 0;
  3672. options->no_acquire = 0;
  3673. options->memory_states = 0;
  3674. options->internal = 0;
  3675. options->label_deps = 0;
  3676. options->ninputfiles = 0;
  3677. options->out_paje_path = "paje.trace";
  3678. options->dag_path = "dag.dot";
  3679. options->tasks_path = "tasks.rec";
  3680. options->comms_path = "comms.rec";
  3681. options->number_events_path = NULL;
  3682. options->data_path = "data.rec";
  3683. options->papi_path = "papi.rec";
  3684. options->anim_path = "trace.html";
  3685. options->states_path = "trace.rec";
  3686. options->distrib_time_path = "distrib.data";
  3687. options->dumped_codelets = NULL;
  3688. options->activity_path = "activity.data";
  3689. options->sched_tasks_path = "sched_tasks.rec";
  3690. options->dir = NULL;
  3691. }
  3692. static
  3693. void _set_dir(char *dir, char **option)
  3694. {
  3695. if (*option)
  3696. {
  3697. char *tmp = strdup(*option);
  3698. _STARPU_MALLOC(*option, 256);
  3699. snprintf(*option, 256, "%s/%s", dir, tmp);
  3700. free(tmp);
  3701. }
  3702. }
  3703. static
  3704. void _starpu_fxt_options_set_dir(struct starpu_fxt_options *options)
  3705. {
  3706. if (!options->dir)
  3707. return;
  3708. _starpu_mkpath_and_check(options->dir, S_IRWXU);
  3709. _set_dir(options->dir, &options->out_paje_path);
  3710. _set_dir(options->dir, &options->dag_path);
  3711. _set_dir(options->dir, &options->tasks_path);
  3712. _set_dir(options->dir, &options->comms_path);
  3713. _set_dir(options->dir, &options->number_events_path);
  3714. _set_dir(options->dir, &options->data_path);
  3715. _set_dir(options->dir, &options->papi_path);
  3716. _set_dir(options->dir, &options->anim_path);
  3717. _set_dir(options->dir, &options->states_path);
  3718. _set_dir(options->dir, &options->distrib_time_path);
  3719. _set_dir(options->dir, &options->activity_path);
  3720. _set_dir(options->dir, &options->sched_tasks_path);
  3721. }
  3722. void starpu_fxt_options_shutdown(struct starpu_fxt_options *options)
  3723. {
  3724. if (options->dir)
  3725. {
  3726. free(options->out_paje_path);
  3727. free(options->dag_path);
  3728. free(options->tasks_path);
  3729. free(options->comms_path);
  3730. free(options->number_events_path);
  3731. free(options->data_path);
  3732. free(options->papi_path);
  3733. free(options->anim_path);
  3734. free(options->states_path);
  3735. free(options->distrib_time_path);
  3736. free(options->activity_path);
  3737. free(options->sched_tasks_path);
  3738. }
  3739. }
  3740. static
  3741. void _starpu_fxt_distrib_file_init(struct starpu_fxt_options *options)
  3742. {
  3743. dumped_codelets_count = 0;
  3744. dumped_codelets = NULL;
  3745. if (options->distrib_time_path)
  3746. {
  3747. distrib_time = fopen(options->distrib_time_path, "w+");
  3748. if (distrib_time == NULL)
  3749. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->distrib_time_path, strerror(errno));
  3750. }
  3751. else
  3752. {
  3753. distrib_time = NULL;
  3754. }
  3755. }
  3756. static
  3757. void _starpu_fxt_distrib_file_close(struct starpu_fxt_options *options)
  3758. {
  3759. if (distrib_time)
  3760. fclose(distrib_time);
  3761. if (options->dumped_codelets)
  3762. {
  3763. *options->dumped_codelets = dumped_codelets;
  3764. options->dumped_codelets_count = dumped_codelets_count;
  3765. }
  3766. }
  3767. static
  3768. void _starpu_fxt_activity_file_init(struct starpu_fxt_options *options)
  3769. {
  3770. if (options->activity_path)
  3771. {
  3772. activity_file = fopen(options->activity_path, "w+");
  3773. if (activity_file == NULL)
  3774. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->activity_path, strerror(errno));
  3775. }
  3776. else
  3777. activity_file = NULL;
  3778. }
  3779. static
  3780. void _starpu_fxt_sched_tasks_file_init(struct starpu_fxt_options *options)
  3781. {
  3782. if (options->sched_tasks_path)
  3783. {
  3784. sched_tasks_file = fopen(options->sched_tasks_path, "w+");
  3785. if (sched_tasks_file == NULL)
  3786. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->sched_tasks_path, strerror(errno));
  3787. }
  3788. else
  3789. sched_tasks_file = NULL;
  3790. }
  3791. static
  3792. void _starpu_fxt_anim_file_init(struct starpu_fxt_options *options)
  3793. {
  3794. if (options->anim_path)
  3795. {
  3796. anim_file = fopen(options->anim_path, "w+");
  3797. if (anim_file == NULL)
  3798. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->anim_path, strerror(errno));
  3799. _starpu_fxt_component_print_header(anim_file);
  3800. }
  3801. else
  3802. anim_file = NULL;
  3803. }
  3804. static
  3805. void _starpu_fxt_tasks_file_init(struct starpu_fxt_options *options)
  3806. {
  3807. if (options->tasks_path)
  3808. {
  3809. tasks_file = fopen(options->tasks_path, "w+");
  3810. if (tasks_file == NULL)
  3811. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->tasks_path, strerror(errno));
  3812. }
  3813. else
  3814. tasks_file = NULL;
  3815. }
  3816. static
  3817. void _starpu_fxt_data_file_init(struct starpu_fxt_options *options)
  3818. {
  3819. if (options->data_path)
  3820. {
  3821. data_file = fopen(options->data_path, "w+");
  3822. if (data_file == NULL)
  3823. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->data_path, strerror(errno));
  3824. }
  3825. else
  3826. data_file = NULL;
  3827. }
  3828. static
  3829. void _starpu_fxt_comms_file_init(struct starpu_fxt_options *options)
  3830. {
  3831. if (options->comms_path)
  3832. {
  3833. comms_file = fopen(options->comms_path, "w+");
  3834. if (comms_file == NULL)
  3835. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->comms_path, strerror(errno));
  3836. }
  3837. else
  3838. comms_file = NULL;
  3839. }
  3840. static
  3841. void _starpu_fxt_number_events_file_init(struct starpu_fxt_options *options)
  3842. {
  3843. if (options->number_events_path)
  3844. {
  3845. number_events_file = fopen(options->number_events_path, "w+");
  3846. if (number_events_file == NULL)
  3847. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->number_events_path, strerror(errno));
  3848. /* FUT_SETUP_CODE is the event with the maximal value */
  3849. number_events = calloc(FUT_SETUP_CODE+1, sizeof(uint64_t));
  3850. }
  3851. else
  3852. number_events_file = NULL;
  3853. }
  3854. static
  3855. void _starpu_fxt_papi_file_init(struct starpu_fxt_options *options)
  3856. {
  3857. #ifdef STARPU_PAPI
  3858. if (options->papi_path)
  3859. {
  3860. papi_file = fopen(options->papi_path, "w+");
  3861. if (papi_file == NULL)
  3862. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->papi_path, strerror(errno));
  3863. }
  3864. else
  3865. papi_file = NULL;
  3866. #endif
  3867. }
  3868. static
  3869. void _starpu_fxt_write_trace_header(FILE *f)
  3870. {
  3871. fprintf(f, "#\n");
  3872. fprintf(f, "# E: Event type\n");
  3873. fprintf(f, "# N: Event name\n");
  3874. fprintf(f, "# C: Event category\n");
  3875. fprintf(f, "# W: Worker ID\n");
  3876. fprintf(f, "# T: Thread ID\n");
  3877. fprintf(f, "# S: Start time\n");
  3878. fprintf(f, "#\n");
  3879. fprintf(f, "\n");
  3880. }
  3881. static
  3882. void _starpu_fxt_trace_file_init(struct starpu_fxt_options *options)
  3883. {
  3884. if (options->states_path)
  3885. {
  3886. trace_file = fopen(options->states_path, "w+");
  3887. if (trace_file == NULL)
  3888. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", options->states_path, strerror(errno));
  3889. }
  3890. else
  3891. trace_file = NULL;
  3892. if (trace_file)
  3893. _starpu_fxt_write_trace_header(trace_file);
  3894. }
  3895. static
  3896. void _starpu_fxt_activity_file_close(void)
  3897. {
  3898. if (activity_file)
  3899. fclose(activity_file);
  3900. }
  3901. static
  3902. void _starpu_fxt_sched_tasks_file_close(void)
  3903. {
  3904. if (sched_tasks_file)
  3905. fclose(sched_tasks_file);
  3906. }
  3907. static
  3908. void _starpu_fxt_anim_file_close(void)
  3909. {
  3910. //_starpu_fxt_component_dump(stderr);
  3911. if (anim_file)
  3912. {
  3913. _starpu_fxt_component_finish(anim_file);
  3914. fclose(anim_file);
  3915. }
  3916. }
  3917. static
  3918. void _starpu_fxt_tasks_file_close(void)
  3919. {
  3920. if (tasks_file)
  3921. fclose(tasks_file);
  3922. }
  3923. static
  3924. void _starpu_fxt_comms_file_close(void)
  3925. {
  3926. if (comms_file)
  3927. fclose(comms_file);
  3928. }
  3929. static
  3930. void _starpu_fxt_number_events_file_close(void)
  3931. {
  3932. if (number_events_file)
  3933. {
  3934. int i;
  3935. assert(number_events != NULL);
  3936. fprintf(number_events_file, "# Use starpu_fxt_number_events_to_names.py to convert event keys to event names.\n");
  3937. for (i = 0; i <= FUT_SETUP_CODE; i++)
  3938. {
  3939. if (number_events[i] > 0)
  3940. fprintf(number_events_file, "0x%x\t%"PRIu64"\n", i, number_events[i]);
  3941. }
  3942. free(number_events);
  3943. number_events = NULL;
  3944. fclose(number_events_file);
  3945. }
  3946. }
  3947. static
  3948. void _starpu_fxt_data_file_close(void)
  3949. {
  3950. if (data_file)
  3951. fclose(data_file);
  3952. }
  3953. static
  3954. void _starpu_fxt_papi_file_close(void)
  3955. {
  3956. #ifdef STARPU_PAPI
  3957. if (papi_file)
  3958. fclose(papi_file);
  3959. #endif
  3960. }
  3961. static
  3962. void _starpu_fxt_trace_file_close(void)
  3963. {
  3964. if (trace_file)
  3965. fclose(trace_file);
  3966. }
  3967. static
  3968. void _starpu_fxt_paje_file_init(struct starpu_fxt_options *options)
  3969. {
  3970. /* create a new file */
  3971. if (options->out_paje_path)
  3972. {
  3973. out_paje_file = fopen(options->out_paje_path, "w+");
  3974. if (!out_paje_file)
  3975. {
  3976. _STARPU_MSG("error while opening %s\n", options->out_paje_path);
  3977. perror("fopen");
  3978. exit(1);
  3979. }
  3980. #ifdef STARPU_HAVE_POTI
  3981. #ifdef HAVE_POTI_INIT_CUSTOM
  3982. fclose(out_paje_file);
  3983. poti_init_custom (options->out_paje_path,
  3984. 0, //if false, allow extended events
  3985. 1, //if true, an old header (pj_dump -n)
  3986. 0, //if false, the trace has no comments
  3987. 1, //if true, events have aliases
  3988. 1);//if true, relative timestamps
  3989. #else
  3990. poti_init (out_paje_file);
  3991. #endif
  3992. #endif
  3993. _starpu_fxt_write_paje_header(out_paje_file, options);
  3994. }
  3995. else
  3996. {
  3997. out_paje_file = NULL;
  3998. }
  3999. /* create lists for symbols (kernel states) and communications */
  4000. _starpu_symbol_name_list_init(&symbol_list);
  4001. _starpu_communication_list_init(&communication_list);
  4002. if (!options->no_flops)
  4003. _starpu_computation_list_init(&computation_list);
  4004. }
  4005. static
  4006. void _starpu_fxt_paje_file_close(void)
  4007. {
  4008. if (out_paje_file)
  4009. fclose(out_paje_file);
  4010. }
  4011. static
  4012. uint64_t _starpu_fxt_find_start_time(char *filename_in)
  4013. {
  4014. /* Open the trace file */
  4015. int fd_in;
  4016. fd_in = open(filename_in, O_RDONLY);
  4017. if (fd_in < 0)
  4018. {
  4019. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", filename_in, strerror(errno));
  4020. }
  4021. static fxt_t fut;
  4022. fut = fxt_fdopen(fd_in);
  4023. if (!fut)
  4024. {
  4025. perror("fxt_fdopen :");
  4026. exit(-1);
  4027. }
  4028. fxt_blockev_t block;
  4029. block = fxt_blockev_enter(fut);
  4030. struct fxt_ev_64 ev;
  4031. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  4032. STARPU_ASSERT (ret == FXT_EV_OK);
  4033. /* Close the trace file */
  4034. if (close(fd_in))
  4035. {
  4036. perror("close failed :");
  4037. exit(-1);
  4038. }
  4039. return (ev.time);
  4040. }
  4041. void starpu_fxt_generate_trace(struct starpu_fxt_options *options)
  4042. {
  4043. _starpu_fxt_options_set_dir(options);
  4044. _starpu_fxt_dag_init(options->dag_path);
  4045. _starpu_fxt_distrib_file_init(options);
  4046. _starpu_fxt_activity_file_init(options);
  4047. _starpu_fxt_sched_tasks_file_init(options);
  4048. _starpu_fxt_anim_file_init(options);
  4049. _starpu_fxt_tasks_file_init(options);
  4050. _starpu_fxt_data_file_init(options);
  4051. _starpu_fxt_papi_file_init(options);
  4052. _starpu_fxt_comms_file_init(options);
  4053. _starpu_fxt_number_events_file_init(options);
  4054. _starpu_fxt_trace_file_init(options);
  4055. _starpu_fxt_paje_file_init(options);
  4056. if (options->ninputfiles == 0)
  4057. {
  4058. return;
  4059. }
  4060. else if (options->ninputfiles == 1)
  4061. {
  4062. /* we usually only have a single trace */
  4063. uint64_t file_start_time = _starpu_fxt_find_start_time(options->filenames[0]);
  4064. options->file_prefix = strdup("");
  4065. options->file_offset = file_start_time;
  4066. options->file_rank = -1;
  4067. _starpu_fxt_parse_new_file(options->filenames[0], options);
  4068. }
  4069. else
  4070. {
  4071. unsigned inputfile;
  4072. uint64_t offsets[options->ninputfiles];
  4073. /*
  4074. * Find the trace offsets:
  4075. * - If there is no sync point
  4076. * psi_k(x) = x - start_k
  4077. * - If there is a sync point sync_k
  4078. * psi_k(x) = x - sync_k + M
  4079. * where M = max { sync_i - start_i | there exists sync_i}
  4080. * More generally:
  4081. * - psi_k(x) = x - offset_k
  4082. */
  4083. int unique_keys[options->ninputfiles];
  4084. int rank_k[options->ninputfiles];
  4085. uint64_t start_k[options->ninputfiles];
  4086. uint64_t sync_k[options->ninputfiles];
  4087. unsigned sync_k_exists[options->ninputfiles];
  4088. uint64_t M = 0;
  4089. unsigned found_one_sync_point = 0;
  4090. int key = 0;
  4091. unsigned display_mpi = 0;
  4092. /* Compute all start_k */
  4093. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4094. {
  4095. uint64_t file_start = _starpu_fxt_find_start_time(options->filenames[inputfile]);
  4096. start_k[inputfile] = file_start;
  4097. }
  4098. /* Compute all sync_k if they exist */
  4099. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4100. {
  4101. int ret = _starpu_fxt_mpi_find_sync_point(options->filenames[inputfile],
  4102. &sync_k[inputfile],
  4103. &unique_keys[inputfile],
  4104. &rank_k[inputfile]);
  4105. if (ret == -1)
  4106. {
  4107. /* There was no sync point, we assume there is no offset */
  4108. sync_k_exists[inputfile] = 0;
  4109. }
  4110. else
  4111. {
  4112. if (!found_one_sync_point)
  4113. {
  4114. key = unique_keys[inputfile];
  4115. display_mpi = 1;
  4116. found_one_sync_point = 1;
  4117. }
  4118. else
  4119. {
  4120. if (key != unique_keys[inputfile])
  4121. {
  4122. _STARPU_MSG("Warning: traces are coming from different run so we will not try to display MPI communications.\n");
  4123. display_mpi = 0;
  4124. }
  4125. }
  4126. STARPU_ASSERT(sync_k[inputfile] >= start_k[inputfile]);
  4127. sync_k_exists[inputfile] = 1;
  4128. uint64_t diff = sync_k[inputfile] - start_k[inputfile];
  4129. if (diff > M)
  4130. M = diff;
  4131. }
  4132. }
  4133. /* Compute the offset */
  4134. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4135. {
  4136. offsets[inputfile] = sync_k_exists[inputfile]?
  4137. (sync_k[inputfile]-M):start_k[inputfile];
  4138. }
  4139. /* generate the Paje trace for the different files */
  4140. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4141. {
  4142. int filerank = rank_k[inputfile];
  4143. _STARPU_DISP("Parsing file %s (rank %d)\n", options->filenames[inputfile], filerank);
  4144. char file_prefix[32];
  4145. snprintf(file_prefix, sizeof(file_prefix), "%d_", filerank);
  4146. free(options->file_prefix);
  4147. options->file_prefix = strdup(file_prefix);
  4148. options->file_offset = offsets[inputfile];
  4149. options->file_rank = filerank;
  4150. _starpu_fxt_parse_new_file(options->filenames[inputfile], options);
  4151. }
  4152. /* display the MPI transfers if possible */
  4153. if (display_mpi)
  4154. _starpu_fxt_display_mpi_transfers(options, rank_k, out_paje_file, comms_file);
  4155. }
  4156. /* close the different files */
  4157. _starpu_fxt_paje_file_close();
  4158. _starpu_fxt_activity_file_close();
  4159. _starpu_fxt_sched_tasks_file_close();
  4160. _starpu_fxt_distrib_file_close(options);
  4161. _starpu_fxt_anim_file_close();
  4162. _starpu_fxt_tasks_file_close();
  4163. _starpu_fxt_data_file_close();
  4164. _starpu_fxt_papi_file_close();
  4165. _starpu_fxt_comms_file_close();
  4166. _starpu_fxt_number_events_file_close();
  4167. _starpu_fxt_trace_file_close();
  4168. _starpu_fxt_dag_terminate();
  4169. options->nworkers = nworkers;
  4170. free(options->file_prefix);
  4171. }
  4172. #define DATA_STR_MAX_SIZE 15
  4173. struct parse_task
  4174. {
  4175. unsigned exec_time;
  4176. unsigned data_total;
  4177. unsigned workerid;
  4178. char *codelet_name;
  4179. };
  4180. static struct parse_task tasks[STARPU_NMAXWORKERS];
  4181. struct starpu_data_trace_kernel
  4182. {
  4183. UT_hash_handle hh;
  4184. char *name;
  4185. FILE *file;
  4186. } *kernels;
  4187. #define NANO_SEC_TO_MILI_SEC 0.000001
  4188. static FILE *codelet_list;
  4189. static void write_task(char *dir, struct parse_task pt)
  4190. {
  4191. struct starpu_data_trace_kernel *kernel;
  4192. char *codelet_name = pt.codelet_name;
  4193. HASH_FIND_STR(kernels, codelet_name, kernel);
  4194. //fprintf(stderr, "%p %p %s\n", kernel, kernels, codelet_name);
  4195. if(kernel == NULL)
  4196. {
  4197. _STARPU_MALLOC(kernel, sizeof(*kernel));
  4198. kernel->name = strdup(codelet_name);
  4199. char filename[256];
  4200. snprintf(filename, sizeof(filename), "%s/%s", dir, kernel->name);
  4201. //fprintf(stderr, "%s\n", kernel->name);
  4202. kernel->file = fopen(filename, "w+");
  4203. if(!kernel->file)
  4204. {
  4205. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", filename, strerror(errno));
  4206. }
  4207. HASH_ADD_STR(kernels, name, kernel);
  4208. fprintf(codelet_list, "%s\n", codelet_name);
  4209. }
  4210. double time = pt.exec_time * NANO_SEC_TO_MILI_SEC;
  4211. fprintf(kernel->file, "%lf %u %u\n", time, pt.data_total, pt.workerid);
  4212. }
  4213. void starpu_fxt_write_data_trace_in_dir(char *filename_in, char *dir)
  4214. {
  4215. int fd_in;
  4216. fd_in = open(filename_in, O_RDONLY);
  4217. if (fd_in < 0)
  4218. {
  4219. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", filename_in, strerror(errno));
  4220. }
  4221. static fxt_t fut;
  4222. fut = fxt_fdopen(fd_in);
  4223. if (!fut)
  4224. {
  4225. perror("fxt_fdopen :");
  4226. exit(-1);
  4227. }
  4228. char filename_out[512];
  4229. snprintf(filename_out, sizeof(filename_out), "%s/codelet_list", dir);
  4230. codelet_list = fopen(filename_out, "w+");
  4231. if(!codelet_list)
  4232. {
  4233. STARPU_ABORT_MSG("Failed to open '%s' (err %s)", filename_out, strerror(errno));
  4234. }
  4235. fxt_blockev_t block;
  4236. block = fxt_blockev_enter(fut);
  4237. struct fxt_ev_64 ev;
  4238. int workerid=-1;
  4239. unsigned long has_name = 0;
  4240. while(1)
  4241. {
  4242. unsigned i;
  4243. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  4244. for (i = ev.nb_params; i < FXT_MAX_PARAMS; i++)
  4245. ev.param[i] = 0;
  4246. if (ret != FXT_EV_OK)
  4247. {
  4248. break;
  4249. }
  4250. switch (ev.code)
  4251. {
  4252. case _STARPU_FUT_WORKER_INIT_START:
  4253. register_worker_id(0 /* TODO: Add nodeid here instead */, ev.param[6], ev.param[1], ev.param[5]);
  4254. break;
  4255. case _STARPU_FUT_START_CODELET_BODY:
  4256. workerid = ev.param[2];
  4257. tasks[workerid].workerid = (unsigned)workerid;
  4258. tasks[workerid].exec_time = ev.time;
  4259. has_name = ev.param[4];
  4260. tasks[workerid].codelet_name = strdup(has_name ? get_fxt_string(&ev, 5): "unknown");
  4261. //fprintf(stderr, "start codelet :[%d][%s]\n", workerid, tasks[workerid].codelet_name);
  4262. break;
  4263. case _STARPU_FUT_END_CODELET_BODY:
  4264. workerid = ev.param[3];
  4265. assert(workerid != -1);
  4266. tasks[workerid].exec_time = ev.time - tasks[workerid].exec_time;
  4267. write_task(dir, tasks[workerid]);
  4268. break;
  4269. case _STARPU_FUT_DATA_LOAD:
  4270. workerid = ev.param[0];
  4271. tasks[workerid].data_total = ev.param[1];
  4272. break;
  4273. default:
  4274. #ifdef STARPU_VERBOSE
  4275. _STARPU_MSG("unknown event.. %x at time %llx WITH OFFSET %llx\n",
  4276. (unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time));
  4277. #endif
  4278. break;
  4279. }
  4280. }
  4281. #ifdef HAVE_FXT_CLOSE
  4282. fxt_close(fut);
  4283. #endif
  4284. if (close(fd_in))
  4285. {
  4286. perror("close failed :");
  4287. exit(-1);
  4288. }
  4289. if(fclose(codelet_list))
  4290. {
  4291. perror("close failed :");
  4292. exit(-1);
  4293. }
  4294. struct starpu_data_trace_kernel *kernel=NULL, *tmp=NULL;
  4295. HASH_ITER(hh, kernels, kernel, tmp)
  4296. {
  4297. if(fclose(kernel->file))
  4298. {
  4299. perror("close failed :");
  4300. exit(-1);
  4301. }
  4302. HASH_DEL(kernels, kernel);
  4303. free(kernel->name);
  4304. free(kernel);
  4305. }
  4306. }
  4307. void starpu_fxt_write_data_trace(char *filename_in)
  4308. {
  4309. starpu_fxt_write_data_trace_in_dir(filename_in, ".");
  4310. }
  4311. #endif // STARPU_USE_FXT