starpu_fxt.c 146 KB

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