starpu_fxt.c 148 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924
  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_checkpoint_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2021. {
  2022. /* Add an event in the trace */
  2023. if (out_paje_file) {
  2024. #ifdef STARPU_HAVE_POTI
  2025. char container[STARPU_POTI_STR_LEN];
  2026. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2027. poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", event);
  2028. #else
  2029. fprintf(out_paje_file, "25 %.9f checkpoint_begin %sp 0 %lu %lu\n", get_event_time_stamp(ev, options),
  2030. options->file_prefix, ev->param[0], ev->param[1]);
  2031. #endif
  2032. }
  2033. }
  2034. static void handle_checkpoint_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2035. {
  2036. /* Add an event in the trace */
  2037. if (out_paje_file) {
  2038. #ifdef STARPU_HAVE_POTI
  2039. char container[STARPU_POTI_STR_LEN];
  2040. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2041. poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", event);
  2042. #else
  2043. fprintf(out_paje_file, "25 %.9f checkpoint_end %sp 0 %lu %lu\n", get_event_time_stamp(ev, options),
  2044. options->file_prefix, ev->param[0], ev->param[1]);
  2045. #endif
  2046. }
  2047. }
  2048. static void handle_start_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2049. {
  2050. unsigned src = ev->param[0];
  2051. unsigned dst = ev->param[1];
  2052. unsigned size = ev->param[2];
  2053. unsigned comid = ev->param[3];
  2054. enum _starpu_is_prefetch prefetch = ev->param[4];
  2055. unsigned long handle = ev->param[5];
  2056. const char *link_type = copy_link_type(prefetch);
  2057. char *prefix = options->file_prefix;
  2058. if (!options->no_bus)
  2059. {
  2060. if (out_paje_file)
  2061. {
  2062. double time = get_event_time_stamp(ev, options);
  2063. memnode_push_state(time, prefix, dst, "Co");
  2064. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCo", handle, comid, size, src, options);
  2065. #ifdef STARPU_HAVE_POTI
  2066. char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN], src_memnode_container[STARPU_POTI_STR_LEN];
  2067. char program_container[STARPU_POTI_STR_LEN];
  2068. snprintf(paje_value, sizeof(paje_value), "%u", size);
  2069. snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
  2070. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2071. memmanager_container_alias(src_memnode_container, STARPU_POTI_STR_LEN, prefix, src);
  2072. char str_handle[STARPU_POTI_STR_LEN];
  2073. snprintf(str_handle, sizeof(str_handle), "%lx", handle);
  2074. poti_user_StartLink(_starpu_poti_CommLinkStart, time, program_container, link_type, src_memnode_container, paje_value, paje_key, 1, str_handle);
  2075. #else
  2076. fprintf(out_paje_file, "24 %.9f %s %sp %u %smm%u com_%u %lx\n", time, link_type, prefix, size, prefix, src, comid, handle);
  2077. #endif
  2078. }
  2079. /* create a structure to store the start of the communication, this will be matched later */
  2080. struct _starpu_communication *com = _starpu_communication_new();
  2081. com->comid = comid;
  2082. com->comm_start = get_event_time_stamp(ev, options);
  2083. com->size = size;
  2084. com->src_node = src;
  2085. com->dst_node = dst;
  2086. com->type = link_type;
  2087. com->peer = NULL;
  2088. com->handle = handle;
  2089. _starpu_communication_list_push_back(&communication_list, com);
  2090. }
  2091. }
  2092. static void handle_work_stealing(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2093. {
  2094. if (out_paje_file)
  2095. {
  2096. unsigned dst = ev->param[0];
  2097. unsigned src = ev->param[1];
  2098. char *prefix = options->file_prefix;
  2099. unsigned size = 0;
  2100. double time = get_event_time_stamp(ev, options);
  2101. #ifdef STARPU_HAVE_POTI
  2102. 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];
  2103. char program_container[STARPU_POTI_STR_LEN];
  2104. snprintf(paje_value, sizeof(paje_value), "%u", size);
  2105. snprintf(paje_key, sizeof(paje_key), "steal_%u", steal_number);
  2106. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2107. worker_container_alias(src_worker_container, STARPU_POTI_STR_LEN, prefix, src);
  2108. worker_container_alias(dst_worker_container, STARPU_POTI_STR_LEN, prefix, dst);
  2109. poti_StartLink(time, program_container, "WSL", src_worker_container, paje_value, paje_key);
  2110. poti_EndLink(time+0.000000001, program_container, "WSL", dst_worker_container, paje_value, paje_key);
  2111. #else
  2112. fprintf(out_paje_file, "18 %.9f WSL %sp %u %sw%u steal_%u\n", time, prefix, size, prefix, src, steal_number);
  2113. fprintf(out_paje_file, "19 %.9f WSL %sp %u %sw%u steal_%u\n", time+0.000000001, prefix, size, prefix, dst, steal_number);
  2114. #endif
  2115. }
  2116. steal_number++;
  2117. }
  2118. static void handle_end_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2119. {
  2120. int src = -1;
  2121. unsigned long handle = 0;
  2122. unsigned dst = ev->param[1];
  2123. unsigned long size = ev->param[2];
  2124. unsigned comid = ev->param[3];
  2125. enum _starpu_is_prefetch prefetch = ev->param[4];
  2126. const char *link_type = copy_link_type(prefetch);
  2127. char *prefix = options->file_prefix;
  2128. if (!options->no_bus)
  2129. {
  2130. /* look for a data transfer to match */
  2131. #ifdef STARPU_DEVEL
  2132. #warning FIXME: use hash table instead
  2133. #endif
  2134. struct _starpu_communication *itor;
  2135. for (itor = _starpu_communication_list_begin(&communication_list);
  2136. itor != _starpu_communication_list_end(&communication_list);
  2137. itor = _starpu_communication_list_next(itor))
  2138. {
  2139. if (itor->comid == comid)
  2140. {
  2141. double comm_end = get_event_time_stamp(ev, options);
  2142. double bandwidth = (double)((0.001*size)/(comm_end - itor->comm_start));
  2143. itor->bandwidth = bandwidth;
  2144. struct _starpu_communication *com = _starpu_communication_new();
  2145. com->comid = comid;
  2146. com->comm_start = get_event_time_stamp(ev, options);
  2147. com->bandwidth = -bandwidth;
  2148. com->size = size;
  2149. src = com->src_node = itor->src_node;
  2150. com->dst_node = itor->dst_node;
  2151. com->type = itor->type;
  2152. link_type = itor->type;
  2153. handle = itor->handle;
  2154. com->peer = itor;
  2155. itor->peer = com;
  2156. _starpu_communication_list_push_back(&communication_list, com);
  2157. break;
  2158. }
  2159. }
  2160. if (out_paje_file)
  2161. {
  2162. double time = get_event_time_stamp(ev, options);
  2163. memnode_pop_state(time, prefix, dst);
  2164. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCoE", handle, comid, size, src, options);
  2165. #ifdef STARPU_HAVE_POTI
  2166. char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN];
  2167. char dst_memnode_container[STARPU_POTI_STR_LEN], program_container[STARPU_POTI_STR_LEN];
  2168. snprintf(paje_value, sizeof(paje_value), "%lu", size);
  2169. snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
  2170. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2171. memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, dst);
  2172. poti_EndLink(time, program_container, link_type, dst_memnode_container, paje_value, paje_key);
  2173. #else
  2174. fprintf(out_paje_file, "19 %.9f %s %sp %lu %smm%u com_%u\n", time, link_type, prefix, size, prefix, dst, comid);
  2175. #endif
  2176. }
  2177. }
  2178. }
  2179. static void handle_start_driver_copy_async(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2180. {
  2181. unsigned src = ev->param[0];
  2182. unsigned dst = ev->param[1];
  2183. char *prefix = options->file_prefix;
  2184. if (!options->no_bus)
  2185. if (out_paje_file)
  2186. {
  2187. memnode_push_state(get_event_time_stamp(ev, options), prefix, dst, "CoA");
  2188. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCoA", 0, 0, 0, src, options);
  2189. }
  2190. }
  2191. static void handle_end_driver_copy_async(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2192. {
  2193. unsigned src = ev->param[0];
  2194. unsigned dst = ev->param[1];
  2195. char *prefix = options->file_prefix;
  2196. if (!options->no_bus)
  2197. if (out_paje_file)
  2198. {
  2199. memnode_pop_state(get_event_time_stamp(ev, options), prefix, dst);
  2200. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCoAE", 0, 0, 0, src, options);
  2201. }
  2202. }
  2203. /* Currently unused */
  2204. STARPU_ATTRIBUTE_UNUSED
  2205. static void handle_memnode_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2206. {
  2207. unsigned memnode = ev->param[0];
  2208. if (out_paje_file)
  2209. memnode_set_state(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr);
  2210. }
  2211. static void handle_memnode_event_start_3(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2212. {
  2213. unsigned memnode = ev->param[0];
  2214. unsigned size = ev->param[2];
  2215. unsigned long handle = ev->param[3];
  2216. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, 0, size, memnode, options);
  2217. }
  2218. static void handle_memnode_event_start_4(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2219. {
  2220. unsigned memnode = ev->param[0];
  2221. unsigned dest = ev->param[1];
  2222. if(strcmp(eventstr, "rc")==0)
  2223. {
  2224. //If it is a Request Create, use dest normally
  2225. }
  2226. else
  2227. {
  2228. dest = memnode;
  2229. }
  2230. unsigned size = ev->param[2];
  2231. unsigned long handle = ev->param[3];
  2232. unsigned prefe = ev->param[4];
  2233. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, prefe, size, dest, options);
  2234. }
  2235. static void handle_memnode_event_end_3(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2236. {
  2237. unsigned memnode = ev->param[0];
  2238. unsigned long handle = ev->param[2];
  2239. unsigned info = ev->param[3];
  2240. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, info, 0, memnode, options);
  2241. }
  2242. static void handle_memnode_event_start_2(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2243. {
  2244. unsigned memnode = ev->param[0];
  2245. unsigned long handle = ev->param[2];
  2246. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, 0, 0, memnode, options);
  2247. }
  2248. static void handle_memnode_event_end_2(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2249. {
  2250. unsigned memnode = ev->param[0];
  2251. unsigned long handle = ev->param[2];
  2252. memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, 0, 0, memnode, options);
  2253. }
  2254. static void handle_push_memnode_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
  2255. {
  2256. unsigned memnode = ev->param[0];
  2257. if (out_paje_file)
  2258. memnode_push_state(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr);
  2259. }
  2260. static void handle_pop_memnode_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2261. {
  2262. unsigned memnode = ev->param[0];
  2263. if (out_paje_file)
  2264. memnode_pop_state(get_event_time_stamp(ev, options), options->file_prefix, memnode);
  2265. }
  2266. static void handle_used_mem(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2267. {
  2268. unsigned memnode = ev->param[0];
  2269. if (out_paje_file)
  2270. {
  2271. #ifdef STARPU_HAVE_POTI
  2272. char memnode_container[STARPU_POTI_STR_LEN];
  2273. memmanager_container_alias(memnode_container, STARPU_POTI_STR_LEN, options->file_prefix, memnode);
  2274. poti_SetVariable(get_event_time_stamp(ev, options), memnode_container, "use", (double)ev->param[1] / (1<<20));
  2275. #else
  2276. fprintf(out_paje_file, "13 %.9f %smm%u use %f\n",
  2277. get_event_time_stamp(ev, options), options->file_prefix, memnode, (double)ev->param[1] / (1<<20));
  2278. #endif
  2279. }
  2280. }
  2281. static void handle_task_submit_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, unsigned long tid, const char *eventstr)
  2282. {
  2283. char *prefix = options->file_prefix;
  2284. int workerid = find_worker_id(prefixTOnodeid(prefix), tid);
  2285. double timestamp = get_event_time_stamp(ev, options);
  2286. if (workerid >= 0)
  2287. {
  2288. /* Normal worker */
  2289. if (eventstr)
  2290. {
  2291. thread_push_state(timestamp, prefix, tid, eventstr);
  2292. recfmt_thread_push_state(timestamp, prefixTOnodeid(prefix), tid, eventstr, "Runtime");
  2293. }
  2294. else
  2295. {
  2296. thread_pop_state(timestamp, prefix, tid);
  2297. recfmt_thread_pop_state(timestamp, prefixTOnodeid(prefix), tid);
  2298. }
  2299. }
  2300. else if (workerid == -2)
  2301. {
  2302. /* MPI thread */
  2303. if (eventstr)
  2304. {
  2305. mpicommthread_push_state(timestamp, prefix, eventstr);
  2306. recfmt_mpicommthread_push_state(get_event_time_stamp(ev, options), eventstr);
  2307. }
  2308. else
  2309. {
  2310. mpicommthread_pop_state(timestamp, prefix);
  2311. recfmt_mpicommthread_pop_state(get_event_time_stamp(ev, options));
  2312. }
  2313. }
  2314. else
  2315. {
  2316. if (eventstr)
  2317. {
  2318. user_thread_push_state(timestamp, prefix, tid, eventstr);
  2319. recfmt_user_thread_push_state(timestamp, tid, eventstr, "User");
  2320. }
  2321. else
  2322. {
  2323. user_thread_pop_state(timestamp, prefix, tid);
  2324. recfmt_user_thread_pop_state(timestamp, tid);
  2325. }
  2326. }
  2327. }
  2328. /*
  2329. * Number of task submitted to the scheduler
  2330. */
  2331. static int curq_size = 0;
  2332. static int nsubmitted = 0;
  2333. static void handle_job_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2334. {
  2335. double current_timestamp = get_event_time_stamp(ev, options);
  2336. unsigned task = ev->param[0];
  2337. int priority = ev->param[1];
  2338. curq_size++;
  2339. _starpu_fxt_component_update_ntasks(nsubmitted, curq_size);
  2340. if (!options->no_counter && out_paje_file)
  2341. {
  2342. #ifdef STARPU_HAVE_POTI
  2343. char container[STARPU_POTI_STR_LEN];
  2344. scheduler_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix);
  2345. poti_SetVariable(current_timestamp, container, "nready", (double)curq_size);
  2346. char paje_value[STARPU_POTI_STR_LEN];
  2347. snprintf(paje_value, sizeof(paje_value), "%u", task);
  2348. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2349. poti_NewEvent(get_event_time_stamp(ev, options), container, "pu", paje_value);
  2350. #else
  2351. fprintf(out_paje_file, "13 %.9f %ssched nready %f\n", current_timestamp, options->file_prefix, (float)curq_size);
  2352. if (!options->no_events)
  2353. fprintf(out_paje_file, "9 %.9f %s %sp %u\n", get_event_time_stamp(ev, options), "pu", options->file_prefix, task);
  2354. #endif
  2355. }
  2356. if (activity_file)
  2357. fprintf(activity_file, "cnt_ready\t%.9f\t%d\n", current_timestamp, curq_size);
  2358. if (sched_tasks_file)
  2359. {
  2360. fprintf(sched_tasks_file, "Type: push\n");
  2361. fprintf(sched_tasks_file, "Time: %.9f\n", current_timestamp);
  2362. fprintf(sched_tasks_file, "Priority: %d\n", priority);
  2363. if (options->file_rank < 0)
  2364. fprintf(sched_tasks_file, "JobId: %u\n", task);
  2365. else
  2366. fprintf(sched_tasks_file, "JobId: %d_%u\n", options->file_rank, task);
  2367. fprintf(sched_tasks_file, "\n");
  2368. }
  2369. }
  2370. static void handle_job_pop(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2371. {
  2372. double current_timestamp = get_event_time_stamp(ev, options);
  2373. unsigned task = ev->param[0];
  2374. int priority = ev->param[1];
  2375. curq_size--;
  2376. nsubmitted--;
  2377. _starpu_fxt_component_update_ntasks(nsubmitted, curq_size);
  2378. if (!options->no_counter && out_paje_file)
  2379. {
  2380. #ifdef STARPU_HAVE_POTI
  2381. char container[STARPU_POTI_STR_LEN];
  2382. scheduler_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix);
  2383. poti_SetVariable(current_timestamp, container, "nready", (double)curq_size);
  2384. poti_SetVariable(current_timestamp, container, "nsubmitted", (double)nsubmitted);
  2385. char paje_value[STARPU_POTI_STR_LEN];
  2386. snprintf(paje_value, sizeof(paje_value), "%u", task);
  2387. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2388. poti_NewEvent(get_event_time_stamp(ev, options), container, "po", paje_value);
  2389. #else
  2390. fprintf(out_paje_file, "13 %.9f %ssched nready %f\n", current_timestamp, options->file_prefix, (float)curq_size);
  2391. fprintf(out_paje_file, "13 %.9f %ssched nsubmitted %f\n", current_timestamp, options->file_prefix, (float)nsubmitted);
  2392. if (!options->no_events)
  2393. fprintf(out_paje_file, "9 %.9f %s %sp %u\n", get_event_time_stamp(ev, options), "po", options->file_prefix, task);
  2394. #endif
  2395. }
  2396. if (activity_file)
  2397. {
  2398. fprintf(activity_file, "cnt_ready\t%.9f\t%d\n", current_timestamp, curq_size);
  2399. fprintf(activity_file, "cnt_submitted\t%.9f\t%d\n", current_timestamp, nsubmitted);
  2400. }
  2401. if (sched_tasks_file)
  2402. {
  2403. fprintf(sched_tasks_file, "Type: pop\n");
  2404. fprintf(sched_tasks_file, "Time: %.9f\n", current_timestamp);
  2405. fprintf(sched_tasks_file, "Priority: %d\n", priority);
  2406. if (options->file_rank < 0)
  2407. fprintf(sched_tasks_file, "JobId: %u\n", task);
  2408. else
  2409. fprintf(sched_tasks_file, "JobId: %d_%u\n", options->file_rank, task);
  2410. fprintf(sched_tasks_file, "\n");
  2411. }
  2412. }
  2413. static void handle_component_new(struct fxt_ev_64 *ev, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
  2414. {
  2415. _starpu_fxt_component_new(ev->param[0], get_fxt_string(ev, 1));
  2416. }
  2417. static void handle_component_connect(struct fxt_ev_64 *ev, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
  2418. {
  2419. _starpu_fxt_component_connect(ev->param[0], ev->param[1]);
  2420. }
  2421. static void handle_component_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2422. {
  2423. char *prefix = options->file_prefix;
  2424. double current_timestamp = get_event_time_stamp(ev, options);
  2425. int workerid = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  2426. _starpu_fxt_component_push(anim_file, options, current_timestamp, workerid, ev->param[1], ev->param[2], ev->param[3], ev->param[4]);
  2427. }
  2428. static void handle_component_pull(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2429. {
  2430. char *prefix = options->file_prefix;
  2431. double current_timestamp = get_event_time_stamp(ev, options);
  2432. int workerid = find_worker_id(prefixTOnodeid(prefix), ev->param[0]);
  2433. _starpu_fxt_component_pull(anim_file, options, current_timestamp, workerid, ev->param[1], ev->param[2], ev->param[3], ev->param[4]);
  2434. }
  2435. static
  2436. void handle_update_task_cnt(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2437. {
  2438. double current_timestamp = get_event_time_stamp(ev, options);
  2439. nsubmitted++;
  2440. _starpu_fxt_component_update_ntasks(nsubmitted, curq_size);
  2441. if (!options->no_counter && out_paje_file)
  2442. {
  2443. #ifdef STARPU_HAVE_POTI
  2444. char container[STARPU_POTI_STR_LEN];
  2445. scheduler_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix);
  2446. poti_SetVariable(current_timestamp, container, "nsubmitted", (double)nsubmitted);
  2447. #else
  2448. fprintf(out_paje_file, "13 %.9f %ssched nsubmitted %f\n", current_timestamp, options->file_prefix, (float)nsubmitted);
  2449. #endif
  2450. }
  2451. if (activity_file)
  2452. fprintf(activity_file, "cnt_submitted\t%.9f\t%d\n", current_timestamp, nsubmitted);
  2453. }
  2454. static void handle_tag(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2455. {
  2456. uint64_t tag;
  2457. unsigned long job;
  2458. tag = ev->param[0];
  2459. job = ev->param[1];
  2460. if (options->label_deps)
  2461. _starpu_fxt_dag_add_tag(options->file_prefix, tag, job, "tag");
  2462. else
  2463. _starpu_fxt_dag_add_tag(options->file_prefix, tag, job, NULL);
  2464. }
  2465. static void handle_tag_deps(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2466. {
  2467. uint64_t child;
  2468. uint64_t father;
  2469. child = ev->param[0];
  2470. father = ev->param[1];
  2471. if (options->label_deps)
  2472. _starpu_fxt_dag_add_tag_deps(options->file_prefix, child, father, "tag");
  2473. else
  2474. _starpu_fxt_dag_add_tag_deps(options->file_prefix, child, father, NULL);
  2475. }
  2476. static void handle_task_deps(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2477. {
  2478. unsigned long dep_prev = ev->param[0];
  2479. unsigned long dep_succ = ev->param[1];
  2480. unsigned dep_succ_type = ev->param[2];
  2481. char *name = get_fxt_string(ev,4);
  2482. struct task_info *task = get_task(dep_succ, options->file_rank);
  2483. struct task_info *prev_task = get_task(dep_prev, options->file_rank);
  2484. unsigned alloc = 0;
  2485. task->type = dep_succ_type;
  2486. if (task->ndeps == 0)
  2487. /* Start with 8=2^3, should be plenty in most cases */
  2488. alloc = 8;
  2489. else if (task->ndeps >= 8)
  2490. {
  2491. /* Allocate dependencies array by powers of two */
  2492. if (! ((task->ndeps - 1) & task->ndeps)) /* Is task->ndeps a power of two? */
  2493. {
  2494. /* We have filled the previous power of two, get another one */
  2495. alloc = task->ndeps * 2;
  2496. }
  2497. }
  2498. if (alloc)
  2499. {
  2500. _STARPU_REALLOC(task->dependencies, sizeof(*task->dependencies) * alloc);
  2501. _STARPU_REALLOC(task->dep_labels, sizeof(*task->dep_labels) * alloc);
  2502. }
  2503. task->dependencies[task->ndeps] = dep_prev;
  2504. task->dep_labels[task->ndeps] = strdup(name);
  2505. task->ndeps++;
  2506. /* There is a dependency between both job id : dep_prev -> dep_succ */
  2507. if (show_task(task, options))
  2508. {
  2509. if (!options->label_deps) name = NULL;
  2510. /* We should show the name of the predecessor, then. */
  2511. prev_task->show = 1;
  2512. _starpu_fxt_dag_add_task_deps(options->file_prefix, dep_prev, dep_succ, name);
  2513. }
  2514. }
  2515. static void handle_task_submit(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2516. {
  2517. unsigned long job_id = ev->param[0];
  2518. unsigned long iteration = ev->param[1];
  2519. unsigned long subiteration = ev->param[2];
  2520. unsigned long submit_order = ev->param[3];
  2521. long priority = (long) ev->param[4];
  2522. unsigned type = ev->param[5];
  2523. struct task_info *task = get_task(job_id, options->file_rank);
  2524. task->submit_time = get_event_time_stamp(ev, options);
  2525. task->submit_order = submit_order;
  2526. task->priority = priority;
  2527. task->iterations[0] = iteration;
  2528. task->iterations[1] = subiteration;
  2529. task->type = type;
  2530. }
  2531. static void handle_task_color(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2532. {
  2533. unsigned long job_id = ev->param[0];
  2534. struct task_info *task = get_task(job_id, options->file_rank);
  2535. int color = (long) ev->param[1];
  2536. task->color = color;
  2537. }
  2538. static void handle_task_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2539. {
  2540. char *prefix = options->file_prefix;
  2541. unsigned long job_id = ev->param[0];
  2542. struct task_info *task = get_task(job_id, options->file_rank);
  2543. unsigned long has_name = ev->param[3];
  2544. char *name = has_name?get_fxt_string(ev,4):"unknown";
  2545. int worker;
  2546. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  2547. const char *colour;
  2548. char buffer[32];
  2549. if (task->color != 0)
  2550. {
  2551. snprintf(buffer, sizeof(buffer), "#%06x", task->color);
  2552. colour = &buffer[0];
  2553. }
  2554. else if (options->per_task_colour)
  2555. {
  2556. snprintf(buffer, sizeof(buffer), "#%x%x%x",
  2557. get_colour_symbol_red(name)/4,
  2558. get_colour_symbol_green(name)/4,
  2559. get_colour_symbol_blue(name)/4);
  2560. colour = &buffer[0];
  2561. }
  2562. else
  2563. {
  2564. colour= (worker < 0)?"#aaaaaa":get_worker_color(worker);
  2565. }
  2566. if (!task->name)
  2567. task->name = strdup(name);
  2568. unsigned exclude_from_dag = ev->param[2];
  2569. task->exclude_from_dag = exclude_from_dag;
  2570. if (!exclude_from_dag && show_task(task, options))
  2571. _starpu_fxt_dag_set_task_name(options->file_prefix, job_id, name, colour);
  2572. }
  2573. static void handle_task_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2574. {
  2575. /* Ideally, we would be able to dump tasks as they terminate, to save
  2576. * memory.
  2577. * We however may have to change their state later, e.g. the show field,
  2578. * due to dependencies added way later. */
  2579. #if 0
  2580. unsigned long job_id;
  2581. job_id = ev->param[0];
  2582. struct task_info *task = get_task(job_id, options->file_rank);
  2583. task_dump(task, options);
  2584. #else
  2585. (void) ev;
  2586. (void) options;
  2587. #endif
  2588. }
  2589. static void handle_tag_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2590. {
  2591. char *prefix = options->file_prefix;
  2592. uint64_t tag_id;
  2593. tag_id = ev->param[0];
  2594. unsigned long has_name = ev->param[2];
  2595. char *name = has_name?get_fxt_string(ev,3):"unknown";
  2596. int worker;
  2597. worker = find_worker_id(prefixTOnodeid(prefix), ev->param[1]);
  2598. const char *colour;
  2599. char buffer[32];
  2600. if (options->per_task_colour)
  2601. {
  2602. snprintf(buffer, sizeof(buffer), "%.4f,%.4f,%.4f",
  2603. get_colour_symbol_red(name)/1024.0,
  2604. get_colour_symbol_green(name)/1024.0,
  2605. get_colour_symbol_blue(name)/1024.0);
  2606. colour = &buffer[0];
  2607. }
  2608. else
  2609. {
  2610. colour= (worker < 0)?"white":get_worker_color(worker);
  2611. }
  2612. _starpu_fxt_dag_set_tag_done(options->file_prefix, tag_id, colour);
  2613. }
  2614. static void handle_mpi_barrier(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2615. {
  2616. int rank = ev->param[0];
  2617. STARPU_ASSERT(rank == options->file_rank || options->file_rank == -1);
  2618. /* Add an event in the trace */
  2619. if (out_paje_file)
  2620. {
  2621. #ifdef STARPU_HAVE_POTI
  2622. char container[STARPU_POTI_STR_LEN], paje_value[STARPU_POTI_STR_LEN];
  2623. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2624. snprintf(paje_value, sizeof(paje_value), "%d", rank);
  2625. poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", paje_value);
  2626. #else
  2627. fprintf(out_paje_file, "9 %.9f prog_event %sp %d\n", get_event_time_stamp(ev, options), options->file_prefix, rank);
  2628. #endif
  2629. }
  2630. }
  2631. static void handle_mpi_start(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2632. {
  2633. double date = get_event_time_stamp(ev, options);
  2634. char *prefix = options->file_prefix;
  2635. register_mpi_thread(prefixTOnodeid(prefix), ev->param[2]);
  2636. if (out_paje_file)
  2637. {
  2638. #ifdef STARPU_HAVE_POTI
  2639. char program_container[STARPU_POTI_STR_LEN];
  2640. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  2641. char new_mpicommthread_container_alias[STARPU_POTI_STR_LEN];
  2642. mpicommthread_container_alias(new_mpicommthread_container_alias, STARPU_POTI_STR_LEN, prefix);
  2643. snprintf(new_mpicommthread_container_alias, STARPU_POTI_STR_LEN, "%smpict", prefix);
  2644. poti_CreateContainer(date, new_mpicommthread_container_alias, "MPICt", program_container, new_mpicommthread_container_alias);
  2645. //set bandwidth variables to zero when they start
  2646. poti_SetVariable(date, new_mpicommthread_container_alias, "bwi_mpi", 0.);
  2647. poti_SetVariable(date, new_mpicommthread_container_alias, "bwo_mpi", 0.);
  2648. #else
  2649. fprintf(out_paje_file, "7 %.9f %smpict MPICt %sp %smpict\n", date, prefix, prefix, prefix);
  2650. //set bandwidth variables to zero when they start
  2651. fprintf(out_paje_file, "13 %.9f %smpict bwi_mpi 0.0\n", date, prefix);
  2652. fprintf(out_paje_file, "13 %.9f %smpict bwo_mpi 0.0\n", date, prefix);
  2653. #endif
  2654. mpicommthread_set_state(date, prefix, "Sl");
  2655. }
  2656. if (trace_file)
  2657. recfmt_mpicommthread_set_state(date, "Sl");
  2658. }
  2659. static void handle_mpi_stop(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2660. {
  2661. double date = get_event_time_stamp(ev, options);
  2662. char *prefix = options->file_prefix;
  2663. if (out_paje_file)
  2664. {
  2665. #ifdef STARPU_HAVE_POTI
  2666. char mpicommthread_container[STARPU_POTI_STR_LEN];
  2667. mpicommthread_container_alias(mpicommthread_container, STARPU_POTI_STR_LEN, prefix);
  2668. poti_DestroyContainer(date, "MPICt", mpicommthread_container);
  2669. #else
  2670. fprintf(out_paje_file, "8 %.9f %smpict MPICt\n",
  2671. date, prefix);
  2672. #endif
  2673. }
  2674. }
  2675. static void handle_mpi_isend_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, "SdS");
  2680. if (trace_file)
  2681. recfmt_mpicommthread_set_state(date, "SdS");
  2682. }
  2683. static int mpi_warned;
  2684. static void handle_mpi_isend_submit_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2685. {
  2686. int dest = ev->param[0];
  2687. int mpi_tag = ev->param[1];
  2688. size_t size = ev->param[2];
  2689. long jobid = ev->param[3];
  2690. unsigned long handle = ev->param[4];
  2691. double date = get_event_time_stamp(ev, options);
  2692. if (out_paje_file)
  2693. mpicommthread_set_state(date, options->file_prefix, "P");
  2694. if (trace_file)
  2695. recfmt_mpicommthread_set_state(date, "P");
  2696. if (options->file_rank < 0)
  2697. {
  2698. if (!mpi_warned)
  2699. {
  2700. _STARPU_MSG("Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
  2701. mpi_warned = 1;
  2702. }
  2703. }
  2704. else
  2705. _starpu_fxt_mpi_add_send_transfer(options->file_rank, dest, mpi_tag, size, date, jobid, handle);
  2706. }
  2707. static void handle_mpi_irecv_submit_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, "RvS");
  2712. if (trace_file)
  2713. recfmt_mpicommthread_set_state(date, "RvS");
  2714. }
  2715. static void handle_mpi_irecv_submit_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_isend_complete_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2724. {
  2725. double date = get_event_time_stamp(ev, options);
  2726. if (out_paje_file)
  2727. mpicommthread_set_state(date, options->file_prefix, "SdC");
  2728. if (trace_file)
  2729. recfmt_mpicommthread_set_state(date, "SdC");
  2730. }
  2731. static void handle_mpi_isend_complete_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2732. {
  2733. double date = get_event_time_stamp(ev, options);
  2734. if (out_paje_file)
  2735. mpicommthread_set_state(date, options->file_prefix, "P");
  2736. if (trace_file)
  2737. recfmt_mpicommthread_set_state(date, "P");
  2738. }
  2739. static void handle_mpi_irecv_complete_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2740. {
  2741. double date = get_event_time_stamp(ev, options);
  2742. if (out_paje_file)
  2743. mpicommthread_set_state(date, options->file_prefix, "RvC");
  2744. if (trace_file)
  2745. recfmt_mpicommthread_set_state(date, "RvC");
  2746. }
  2747. static void handle_mpi_irecv_complete_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2748. {
  2749. double date = get_event_time_stamp(ev, options);
  2750. if (out_paje_file)
  2751. mpicommthread_set_state(date, options->file_prefix, "P");
  2752. if (trace_file)
  2753. recfmt_mpicommthread_set_state(date, "P");
  2754. }
  2755. static void handle_mpi_irecv_terminated(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2756. {
  2757. int src = ev->param[0];
  2758. int mpi_tag = ev->param[1];
  2759. long jobid = ev->param[2];
  2760. unsigned long handle = ev->param[4];
  2761. double date = get_event_time_stamp(ev, options);
  2762. if (options->file_rank < 0)
  2763. {
  2764. if (!mpi_warned)
  2765. {
  2766. _STARPU_MSG("Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
  2767. mpi_warned = 1;
  2768. }
  2769. }
  2770. else
  2771. _starpu_fxt_mpi_add_recv_transfer(src, options->file_rank, mpi_tag, date, jobid, handle);
  2772. }
  2773. static void handle_mpi_sleep_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, "Sl");
  2778. if (trace_file)
  2779. recfmt_mpicommthread_set_state(date, "Sl");
  2780. }
  2781. static void handle_mpi_sleep_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, "Pl");
  2786. if (trace_file)
  2787. recfmt_mpicommthread_set_state(date, "Pl");
  2788. }
  2789. static void handle_mpi_dtesting_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, "DT");
  2794. if (trace_file)
  2795. recfmt_mpicommthread_set_state(date, "DT");
  2796. }
  2797. static void handle_mpi_dtesting_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_utesting_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_set_state(date, options->file_prefix, "UT");
  2810. if (trace_file)
  2811. recfmt_mpicommthread_set_state(date, "UT");
  2812. }
  2813. static void handle_mpi_utesting_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_set_state(date, options->file_prefix, "P");
  2818. if (trace_file)
  2819. recfmt_mpicommthread_set_state(date, "P");
  2820. }
  2821. static void handle_mpi_uwait_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_set_state(date, options->file_prefix, "UW");
  2826. if (trace_file)
  2827. recfmt_mpicommthread_set_state(date, "UW");
  2828. }
  2829. static void handle_mpi_uwait_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_set_state(date, options->file_prefix, "P");
  2834. if (trace_file)
  2835. recfmt_mpicommthread_set_state(date, "P");
  2836. }
  2837. static void handle_mpi_testing_detached_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_push_state(date, options->file_prefix, "TD");
  2842. if (trace_file)
  2843. recfmt_mpicommthread_push_state(date, "TD");
  2844. }
  2845. static void handle_mpi_testing_detached_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2846. {
  2847. double date = get_event_time_stamp(ev, options);
  2848. if (out_paje_file)
  2849. mpicommthread_pop_state(date, options->file_prefix);
  2850. if (trace_file)
  2851. recfmt_mpicommthread_pop_state(date);
  2852. }
  2853. static void handle_mpi_test_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2854. {
  2855. double date = get_event_time_stamp(ev, options);
  2856. if (out_paje_file)
  2857. mpicommthread_push_state(date, options->file_prefix, "MT");
  2858. if (trace_file)
  2859. recfmt_mpicommthread_push_state(date, "MT");
  2860. }
  2861. static void handle_mpi_test_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2862. {
  2863. double date = get_event_time_stamp(ev, options);
  2864. if (out_paje_file)
  2865. mpicommthread_pop_state(date, options->file_prefix);
  2866. if (trace_file)
  2867. recfmt_mpicommthread_pop_state(date);
  2868. }
  2869. static void handle_mpi_polling_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2870. {
  2871. double date = get_event_time_stamp(ev, options);
  2872. if (out_paje_file)
  2873. mpicommthread_set_state(date, options->file_prefix, "Pl");
  2874. }
  2875. static void handle_mpi_polling_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2876. {
  2877. double date = get_event_time_stamp(ev, options);
  2878. if (out_paje_file)
  2879. mpicommthread_set_state(date, options->file_prefix, "P");
  2880. }
  2881. static void handle_mpi_driver_run_begin(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2882. {
  2883. double date = get_event_time_stamp(ev, options);
  2884. if (out_paje_file)
  2885. mpicommthread_set_state(date, options->file_prefix, "Dr");
  2886. }
  2887. static void handle_mpi_driver_run_end(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2888. {
  2889. double date = get_event_time_stamp(ev, options);
  2890. if (out_paje_file)
  2891. mpicommthread_set_state(date, options->file_prefix, "Pl");
  2892. }
  2893. static void handle_set_profiling(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2894. {
  2895. int status = ev->param[0];
  2896. if (activity_file)
  2897. fprintf(activity_file, "set_profiling\t%.9f\t%d\n", get_event_time_stamp(ev, options), status);
  2898. }
  2899. static void handle_task_wait_for_all(void)
  2900. {
  2901. _starpu_fxt_dag_add_sync_point();
  2902. }
  2903. static void handle_string_event(struct fxt_ev_64 *ev, const char *event, struct starpu_fxt_options *options)
  2904. {
  2905. /* Add an event in the trace */
  2906. if (out_paje_file)
  2907. {
  2908. #ifdef STARPU_HAVE_POTI
  2909. char container[STARPU_POTI_STR_LEN];
  2910. snprintf(container, sizeof(container), "%sp", options->file_prefix);
  2911. poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", event);
  2912. #else
  2913. fprintf(out_paje_file, "9 %.9f prog_event %sp \"%s\"\n", get_event_time_stamp(ev, options), options->file_prefix, event);
  2914. #endif
  2915. }
  2916. if (trace_file)
  2917. recfmt_dump_state(get_event_time_stamp(ev, options), "ProgEvent", -1, 0, event, "Program");
  2918. }
  2919. static void handle_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2920. {
  2921. char *event = get_fxt_string(ev, 0);
  2922. handle_string_event(ev, event, options);
  2923. }
  2924. static void handle_thread_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
  2925. {
  2926. /* Add an event in the trace */
  2927. if (out_paje_file)
  2928. {
  2929. char *event = get_fxt_string(ev, 1);
  2930. #ifdef STARPU_HAVE_POTI
  2931. char container[STARPU_POTI_STR_LEN];
  2932. thread_container_alias(container, STARPU_POTI_STR_LEN, options->file_prefix, ev->param[0]);
  2933. poti_NewEvent(get_event_time_stamp(ev, options), container, "thread_event", event);
  2934. #else
  2935. 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);
  2936. #endif
  2937. }
  2938. }
  2939. static
  2940. void _starpu_fxt_process_bandwidth(struct starpu_fxt_options *options)
  2941. {
  2942. char *prefix = options->file_prefix;
  2943. /* Loop through completed communications */
  2944. while (!_starpu_communication_list_empty(&communication_list)
  2945. && _starpu_communication_list_begin(&communication_list)->peer)
  2946. {
  2947. struct _starpu_communication*itor;
  2948. /* This communication is complete */
  2949. itor = _starpu_communication_list_pop_front(&communication_list);
  2950. current_bandwidth_out_per_node[itor->src_node] += itor->bandwidth;
  2951. if (out_paje_file)
  2952. {
  2953. #ifdef STARPU_HAVE_POTI
  2954. char src_memnode_container[STARPU_POTI_STR_LEN];
  2955. memmanager_container_alias(src_memnode_container, STARPU_POTI_STR_LEN, prefix, itor->src_node);
  2956. poti_SetVariable(itor->comm_start, src_memnode_container, "bwo_mm", current_bandwidth_out_per_node[itor->src_node]);
  2957. #else
  2958. fprintf(out_paje_file, "13 %.9f %smm%u bwo_mm %f\n",
  2959. itor->comm_start, prefix, itor->src_node, current_bandwidth_out_per_node[itor->src_node]);
  2960. #endif
  2961. }
  2962. current_bandwidth_in_per_node[itor->dst_node] += itor->bandwidth;
  2963. if (out_paje_file)
  2964. {
  2965. #ifdef STARPU_HAVE_POTI
  2966. char dst_memnode_container[STARPU_POTI_STR_LEN];
  2967. memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, itor->dst_node);
  2968. poti_SetVariable(itor->comm_start, dst_memnode_container, "bwi_mm", current_bandwidth_in_per_node[itor->dst_node]);
  2969. #else
  2970. fprintf(out_paje_file, "13 %.9f %smm%u bwi_mm %f\n",
  2971. itor->comm_start, prefix, itor->dst_node, current_bandwidth_in_per_node[itor->dst_node]);
  2972. #endif
  2973. }
  2974. _starpu_communication_delete(itor);
  2975. }
  2976. }
  2977. static
  2978. void _starpu_fxt_process_computations(struct starpu_fxt_options *options)
  2979. {
  2980. char *prefix = options->file_prefix;
  2981. /* Loop through completed computations */
  2982. struct _starpu_computation*itor;
  2983. while (!_starpu_computation_list_empty(&computation_list)
  2984. && _starpu_computation_list_begin(&computation_list)->peer)
  2985. {
  2986. /* This computation is complete */
  2987. itor = _starpu_computation_list_pop_front(&computation_list);
  2988. if (out_paje_file && itor->comp_start != current_computation_time)
  2989. {
  2990. /* flush last value */
  2991. #ifdef STARPU_HAVE_POTI
  2992. char container[STARPU_POTI_STR_LEN];
  2993. scheduler_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  2994. poti_SetVariable(current_computation_time, container, "gft", (double)current_computation);
  2995. #else
  2996. fprintf(out_paje_file, "13 %.9f %ssched gft %f\n", current_computation_time, prefix, (float)current_computation);
  2997. #endif
  2998. }
  2999. current_computation += itor->gflops;
  3000. current_computation_time = itor->comp_start;
  3001. _starpu_computation_delete(itor);
  3002. }
  3003. }
  3004. static
  3005. void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *options)
  3006. {
  3007. /* Open the trace file */
  3008. int fd_in;
  3009. fd_in = open(filename_in, O_RDONLY);
  3010. if (fd_in < 0)
  3011. {
  3012. perror("open failed :");
  3013. exit(-1);
  3014. }
  3015. static fxt_t fut;
  3016. fut = fxt_fdopen(fd_in);
  3017. if (!fut)
  3018. {
  3019. perror("fxt_fdopen :");
  3020. exit(-1);
  3021. }
  3022. fxt_blockev_t block;
  3023. block = fxt_blockev_enter(fut);
  3024. char *prefix = options->file_prefix;
  3025. /* TODO starttime ...*/
  3026. /* create the "program" container */
  3027. current_computation = 0.0;
  3028. current_computation_time = 0.0;
  3029. if (out_paje_file)
  3030. {
  3031. #ifdef STARPU_HAVE_POTI
  3032. char new_program_container_alias[STARPU_POTI_STR_LEN], new_program_container_name[STARPU_POTI_STR_LEN];
  3033. program_container_alias(new_program_container_alias, STARPU_POTI_STR_LEN, prefix);
  3034. snprintf(new_program_container_name, sizeof(new_program_container_name), "program %s", prefix);
  3035. poti_CreateContainer (0, new_program_container_alias, "P", "MPIroot", new_program_container_name);
  3036. char new_scheduler_container_alias[STARPU_POTI_STR_LEN], new_scheduler_container_name[STARPU_POTI_STR_LEN];
  3037. scheduler_container_alias(new_scheduler_container_alias, STARPU_POTI_STR_LEN, prefix);
  3038. snprintf(new_scheduler_container_name, sizeof(new_scheduler_container_name), "%sscheduler", prefix);
  3039. if (!options->no_counter || !options->no_flops)
  3040. {
  3041. poti_CreateContainer(0.0, new_scheduler_container_alias, "Sc", new_program_container_alias, new_scheduler_container_name);
  3042. }
  3043. if (!options->no_counter)
  3044. {
  3045. poti_SetVariable(0.0, new_scheduler_container_alias, "nsubmitted", 0.0);
  3046. poti_SetVariable(0.0, new_scheduler_container_alias, "nready", 0.0);
  3047. }
  3048. if (!options->no_flops)
  3049. {
  3050. poti_SetVariable(0.0, new_scheduler_container_alias, "gft", 0.0);
  3051. }
  3052. #else
  3053. fprintf(out_paje_file, "7 0.0 %sp P MPIroot %sprogram \n", prefix, prefix);
  3054. if (!options->no_counter || !options->no_flops)
  3055. {
  3056. fprintf(out_paje_file, "7 0.0 %ssched Sc %sp %sscheduler\n", prefix, prefix, prefix);
  3057. }
  3058. if (!options->no_counter)
  3059. {
  3060. /* create a variable with the number of tasks */
  3061. fprintf(out_paje_file, "13 0.0 %ssched nsubmitted 0.0\n", prefix);
  3062. fprintf(out_paje_file, "13 0.0 %ssched nready 0.0\n", prefix);
  3063. }
  3064. if (!options->no_flops)
  3065. {
  3066. fprintf(out_paje_file, "13 0.0 %ssched gft 0.0\n", prefix);
  3067. }
  3068. #endif
  3069. }
  3070. struct fxt_ev_64 ev;
  3071. while(1)
  3072. {
  3073. unsigned i;
  3074. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  3075. for (i = ev.nb_params; i < FXT_MAX_PARAMS; i++)
  3076. ev.param[i] = 0;
  3077. if (ret != FXT_EV_OK)
  3078. {
  3079. break;
  3080. }
  3081. if (number_events_file != NULL)
  3082. {
  3083. assert(number_events != NULL);
  3084. assert(ev.code <= FUT_SETUP_CODE);
  3085. number_events[ev.code]++;
  3086. }
  3087. switch (ev.code)
  3088. {
  3089. case _STARPU_FUT_WORKER_INIT_START:
  3090. handle_worker_init_start(&ev, options);
  3091. break;
  3092. case _STARPU_FUT_WORKER_INIT_END:
  3093. handle_worker_init_end(&ev, options);
  3094. break;
  3095. case _STARPU_FUT_NEW_MEM_NODE:
  3096. handle_new_mem_node(&ev, options);
  3097. break;
  3098. /* detect when the workers were idling or not */
  3099. case _STARPU_FUT_START_CODELET_BODY:
  3100. handle_start_codelet_body(&ev, options);
  3101. break;
  3102. case _STARPU_FUT_MODEL_NAME:
  3103. handle_model_name(&ev, options);
  3104. break;
  3105. case _STARPU_FUT_CODELET_DATA:
  3106. handle_codelet_data(&ev, options);
  3107. break;
  3108. case _STARPU_FUT_CODELET_DATA_HANDLE:
  3109. handle_codelet_data_handle(&ev, options);
  3110. break;
  3111. case _STARPU_FUT_CODELET_DETAILS:
  3112. handle_codelet_details(&ev, options);
  3113. break;
  3114. case _STARPU_FUT_END_CODELET_BODY:
  3115. handle_end_codelet_body(&ev, options);
  3116. break;
  3117. case _STARPU_FUT_START_EXECUTING:
  3118. handle_start_executing(&ev, options);
  3119. break;
  3120. case _STARPU_FUT_END_EXECUTING:
  3121. handle_end_executing(&ev, options);
  3122. break;
  3123. case _STARPU_FUT_START_CALLBACK:
  3124. handle_start_callback(&ev, options);
  3125. break;
  3126. case _STARPU_FUT_END_CALLBACK:
  3127. handle_end_callback(&ev, options);
  3128. break;
  3129. case _STARPU_FUT_UPDATE_TASK_CNT:
  3130. handle_update_task_cnt(&ev, options);
  3131. break;
  3132. /* monitor stack size and generate sched_tasks.rec */
  3133. case _STARPU_FUT_JOB_PUSH:
  3134. handle_job_push(&ev, options);
  3135. break;
  3136. case _STARPU_FUT_JOB_POP:
  3137. handle_job_pop(&ev, options);
  3138. break;
  3139. case _STARPU_FUT_SCHED_COMPONENT_NEW:
  3140. handle_component_new(&ev, options);
  3141. break;
  3142. case _STARPU_FUT_SCHED_COMPONENT_CONNECT:
  3143. handle_component_connect(&ev, options);
  3144. break;
  3145. case _STARPU_FUT_SCHED_COMPONENT_PUSH:
  3146. handle_component_push(&ev, options);
  3147. break;
  3148. case _STARPU_FUT_SCHED_COMPONENT_PULL:
  3149. handle_component_pull(&ev, options);
  3150. break;
  3151. /* check the memory transfer overhead */
  3152. case _STARPU_FUT_START_FETCH_INPUT_ON_TID:
  3153. handle_worker_status_on_tid(&ev, options, "Fi");
  3154. break;
  3155. case _STARPU_FUT_START_PUSH_OUTPUT_ON_TID:
  3156. handle_worker_status_on_tid(&ev, options, "Po");
  3157. break;
  3158. case _STARPU_FUT_START_PROGRESS_ON_TID:
  3159. handle_worker_status_on_tid(&ev, options, "P");
  3160. break;
  3161. case _STARPU_FUT_START_UNPARTITION_ON_TID:
  3162. handle_worker_status_on_tid(&ev, options, "U");
  3163. break;
  3164. case _STARPU_FUT_END_FETCH_INPUT_ON_TID:
  3165. case _STARPU_FUT_END_PROGRESS_ON_TID:
  3166. case _STARPU_FUT_END_PUSH_OUTPUT_ON_TID:
  3167. case _STARPU_FUT_END_UNPARTITION_ON_TID:
  3168. handle_worker_status_on_tid(&ev, options, "B");
  3169. break;
  3170. case _STARPU_FUT_START_FETCH_INPUT:
  3171. handle_worker_status(&ev, options, "Fi");
  3172. break;
  3173. case _STARPU_FUT_END_FETCH_INPUT:
  3174. handle_worker_status(&ev, options, "B");
  3175. break;
  3176. case _STARPU_FUT_WORKER_SCHEDULING_START:
  3177. handle_worker_scheduling_start(&ev, options);
  3178. break;
  3179. case _STARPU_FUT_WORKER_SCHEDULING_END:
  3180. handle_worker_scheduling_end(&ev, options);
  3181. break;
  3182. case _STARPU_FUT_WORKER_SCHEDULING_PUSH:
  3183. handle_worker_scheduling_push(&ev, options);
  3184. break;
  3185. case _STARPU_FUT_WORKER_SCHEDULING_POP:
  3186. handle_worker_scheduling_pop(&ev, options);
  3187. break;
  3188. case _STARPU_FUT_WORKER_SLEEP_START:
  3189. handle_worker_sleep_start(&ev, options);
  3190. break;
  3191. case _STARPU_FUT_WORKER_SLEEP_END:
  3192. handle_worker_sleep_end(&ev, options);
  3193. break;
  3194. case _STARPU_FUT_TAG:
  3195. handle_tag(&ev, options);
  3196. break;
  3197. case _STARPU_FUT_TAG_DEPS:
  3198. handle_tag_deps(&ev, options);
  3199. break;
  3200. case _STARPU_FUT_TASK_DEPS:
  3201. handle_task_deps(&ev, options);
  3202. break;
  3203. case _STARPU_FUT_TASK_SUBMIT:
  3204. handle_task_submit(&ev, options);
  3205. break;
  3206. case _STARPU_FUT_TASK_BUILD_START:
  3207. handle_task_submit_event(&ev, options, ev.param[0], "Bu");
  3208. break;
  3209. case _STARPU_FUT_TASK_SUBMIT_START:
  3210. handle_task_submit_event(&ev, options, ev.param[0], "Su");
  3211. break;
  3212. case _STARPU_FUT_TASK_THROTTLE_START:
  3213. handle_task_submit_event(&ev, options, ev.param[0], "Th");
  3214. break;
  3215. case _STARPU_FUT_TASK_MPI_DECODE_START:
  3216. handle_task_submit_event(&ev, options, ev.param[0], "MD");
  3217. break;
  3218. case _STARPU_FUT_TASK_MPI_PRE_START:
  3219. handle_task_submit_event(&ev, options, ev.param[0], "MPr");
  3220. break;
  3221. case _STARPU_FUT_TASK_MPI_POST_START:
  3222. handle_task_submit_event(&ev, options, ev.param[0], "MPo");
  3223. break;
  3224. case _STARPU_FUT_TASK_WAIT_START:
  3225. handle_task_submit_event(&ev, options, ev.param[1], "W");
  3226. break;
  3227. case _STARPU_FUT_TASK_WAIT_FOR_ALL_START:
  3228. handle_task_submit_event(&ev, options, ev.param[0], "WA");
  3229. break;
  3230. case _STARPU_FUT_TASK_BUILD_END:
  3231. case _STARPU_FUT_TASK_SUBMIT_END:
  3232. case _STARPU_FUT_TASK_THROTTLE_END:
  3233. case _STARPU_FUT_TASK_MPI_DECODE_END:
  3234. case _STARPU_FUT_TASK_MPI_PRE_END:
  3235. case _STARPU_FUT_TASK_MPI_POST_END:
  3236. case _STARPU_FUT_TASK_WAIT_FOR_ALL_END:
  3237. handle_task_submit_event(&ev, options, ev.param[0], NULL);
  3238. break;
  3239. case _STARPU_FUT_TASK_WAIT_END:
  3240. handle_task_submit_event(&ev, options, ev.param[0], NULL);
  3241. break;
  3242. case _STARPU_FUT_TASK_NAME:
  3243. handle_task_name(&ev, options);
  3244. break;
  3245. case _STARPU_FUT_TASK_COLOR:
  3246. handle_task_color(&ev, options);
  3247. break;
  3248. case _STARPU_FUT_TASK_DONE:
  3249. handle_task_done(&ev, options);
  3250. break;
  3251. case _STARPU_FUT_TAG_DONE:
  3252. handle_tag_done(&ev, options);
  3253. break;
  3254. case _STARPU_FUT_HANDLE_DATA_REGISTER:
  3255. handle_data_register(&ev, options);
  3256. break;
  3257. case _STARPU_FUT_HANDLE_DATA_UNREGISTER:
  3258. handle_data_unregister(&ev, options);
  3259. break;
  3260. case _STARPU_FUT_DATA_STATE_INVALID:
  3261. if (options->memory_states)
  3262. handle_data_state(&ev, options, "SI");
  3263. break;
  3264. case _STARPU_FUT_DATA_STATE_OWNER:
  3265. if (options->memory_states)
  3266. handle_data_state(&ev, options, "SO");
  3267. break;
  3268. case _STARPU_FUT_DATA_STATE_SHARED:
  3269. if (options->memory_states)
  3270. handle_data_state(&ev, options, "SS");
  3271. break;
  3272. case _STARPU_FUT_DATA_REQUEST_CREATED:
  3273. if (!options->no_bus && options->memory_states)
  3274. {
  3275. handle_memnode_event_start_4(&ev, options, "rc");
  3276. }
  3277. break;
  3278. case _STARPU_FUT_PAPI_TASK_EVENT_VALUE:
  3279. handle_papi_event(&ev, options);
  3280. break;
  3281. case _STARPU_FUT_DATA_COPY:
  3282. if (!options->no_bus)
  3283. handle_data_copy();
  3284. break;
  3285. case _STARPU_FUT_DATA_LOAD:
  3286. break;
  3287. case _STARPU_FUT_DATA_NAME:
  3288. handle_data_name(&ev, options);
  3289. break;
  3290. case _STARPU_FUT_DATA_COORDINATES:
  3291. handle_data_coordinates(&ev, options);
  3292. break;
  3293. case _STARPU_FUT_DATA_WONT_USE:
  3294. handle_data_wont_use(&ev, options);
  3295. break;
  3296. case _STARPU_FUT_DATA_DOING_WONT_USE:
  3297. if (options->memory_states)
  3298. handle_data_doing_wont_use(&ev, options);
  3299. break;
  3300. case _STARPU_FUT_START_DRIVER_COPY:
  3301. if (!options->no_bus)
  3302. handle_start_driver_copy(&ev, options);
  3303. break;
  3304. case _STARPU_FUT_END_DRIVER_COPY:
  3305. if (!options->no_bus)
  3306. handle_end_driver_copy(&ev, options);
  3307. break;
  3308. case _STARPU_FUT_START_DRIVER_COPY_ASYNC:
  3309. if (!options->no_bus)
  3310. handle_start_driver_copy_async(&ev, options);
  3311. break;
  3312. case _STARPU_FUT_END_DRIVER_COPY_ASYNC:
  3313. if (!options->no_bus)
  3314. handle_end_driver_copy_async(&ev, options);
  3315. break;
  3316. case _STARPU_FUT_WORK_STEALING:
  3317. handle_work_stealing(&ev, options);
  3318. break;
  3319. case _STARPU_FUT_WORKER_DEINIT_START:
  3320. handle_worker_deinit_start(&ev, options);
  3321. break;
  3322. case _STARPU_FUT_WORKER_DEINIT_END:
  3323. handle_worker_deinit_end(&ev, options);
  3324. break;
  3325. case _STARPU_FUT_START_ALLOC:
  3326. if (!options->no_bus)
  3327. {
  3328. handle_push_memnode_event(&ev, options, "A");
  3329. handle_memnode_event_start_4(&ev, options, "Al");
  3330. }
  3331. break;
  3332. case _STARPU_FUT_START_ALLOC_REUSE:
  3333. if (!options->no_bus)
  3334. {
  3335. handle_push_memnode_event(&ev, options, "Ar");
  3336. handle_memnode_event_start_4(&ev, options, "Alr");
  3337. }
  3338. break;
  3339. case _STARPU_FUT_END_ALLOC:
  3340. if (!options->no_bus)
  3341. {
  3342. handle_pop_memnode_event(&ev, options);
  3343. handle_memnode_event_end_3(&ev, options, "AlE");
  3344. }
  3345. break;
  3346. case _STARPU_FUT_END_ALLOC_REUSE:
  3347. if (!options->no_bus)
  3348. {
  3349. handle_pop_memnode_event(&ev, options);
  3350. handle_memnode_event_end_3(&ev, options, "AlrE");
  3351. }
  3352. break;
  3353. case _STARPU_FUT_START_FREE:
  3354. if (!options->no_bus)
  3355. {
  3356. handle_push_memnode_event(&ev, options, "F");
  3357. handle_memnode_event_start_3(&ev, options, "Fe");
  3358. }
  3359. break;
  3360. case _STARPU_FUT_END_FREE:
  3361. if (!options->no_bus)
  3362. {
  3363. handle_pop_memnode_event(&ev, options);
  3364. handle_memnode_event_end_2(&ev, options, "FeE");
  3365. }
  3366. break;
  3367. case _STARPU_FUT_START_WRITEBACK:
  3368. if (!options->no_bus)
  3369. {
  3370. handle_push_memnode_event(&ev, options, "W");
  3371. handle_memnode_event_start_2(&ev, options, "Wb");
  3372. }
  3373. break;
  3374. case _STARPU_FUT_END_WRITEBACK:
  3375. if (!options->no_bus)
  3376. {
  3377. handle_pop_memnode_event(&ev, options);
  3378. handle_memnode_event_start_2(&ev, options, "WbE");
  3379. }
  3380. break;
  3381. case _STARPU_FUT_START_WRITEBACK_ASYNC:
  3382. if (!options->no_bus)
  3383. handle_push_memnode_event(&ev, options, "Wa");
  3384. break;
  3385. case _STARPU_FUT_END_WRITEBACK_ASYNC:
  3386. if (!options->no_bus)
  3387. handle_pop_memnode_event(&ev, options);
  3388. break;
  3389. case _STARPU_FUT_START_MEMRECLAIM:
  3390. if (!options->no_bus)
  3391. handle_push_memnode_event(&ev, options, "R");
  3392. break;
  3393. case _STARPU_FUT_END_MEMRECLAIM:
  3394. if (!options->no_bus)
  3395. handle_pop_memnode_event(&ev, options);
  3396. break;
  3397. case _STARPU_FUT_USED_MEM:
  3398. handle_used_mem(&ev, options);
  3399. break;
  3400. case _STARPU_FUT_USER_EVENT:
  3401. if (!options->no_events)
  3402. handle_user_event(&ev, options);
  3403. break;
  3404. case _STARPU_MPI_FUT_START:
  3405. handle_mpi_start(&ev, options);
  3406. break;
  3407. case _STARPU_MPI_FUT_STOP:
  3408. handle_mpi_stop(&ev, options);
  3409. break;
  3410. case _STARPU_MPI_FUT_BARRIER:
  3411. handle_mpi_barrier(&ev, options);
  3412. break;
  3413. case _STARPU_MPI_FUT_ISEND_SUBMIT_BEGIN:
  3414. handle_mpi_isend_submit_begin(&ev, options);
  3415. break;
  3416. case _STARPU_MPI_FUT_ISEND_SUBMIT_END:
  3417. handle_mpi_isend_submit_end(&ev, options);
  3418. break;
  3419. case _STARPU_MPI_FUT_IRECV_SUBMIT_BEGIN:
  3420. handle_mpi_irecv_submit_begin(&ev, options);
  3421. break;
  3422. case _STARPU_MPI_FUT_IRECV_SUBMIT_END:
  3423. handle_mpi_irecv_submit_end(&ev, options);
  3424. break;
  3425. case _STARPU_MPI_FUT_ISEND_COMPLETE_BEGIN:
  3426. handle_mpi_isend_complete_begin(&ev, options);
  3427. break;
  3428. case _STARPU_MPI_FUT_ISEND_COMPLETE_END:
  3429. handle_mpi_isend_complete_end(&ev, options);
  3430. break;
  3431. case _STARPU_MPI_FUT_IRECV_COMPLETE_BEGIN:
  3432. handle_mpi_irecv_complete_begin(&ev, options);
  3433. break;
  3434. case _STARPU_MPI_FUT_IRECV_COMPLETE_END:
  3435. handle_mpi_irecv_complete_end(&ev, options);
  3436. break;
  3437. case _STARPU_MPI_FUT_ISEND_TERMINATED:
  3438. break;
  3439. case _STARPU_MPI_FUT_IRECV_TERMINATED:
  3440. handle_mpi_irecv_terminated(&ev, options);
  3441. break;
  3442. case _STARPU_MPI_FUT_SLEEP_BEGIN:
  3443. handle_mpi_sleep_begin(&ev, options);
  3444. break;
  3445. case _STARPU_MPI_FUT_SLEEP_END:
  3446. handle_mpi_sleep_end(&ev, options);
  3447. break;
  3448. case _STARPU_MPI_FUT_DTESTING_BEGIN:
  3449. handle_mpi_dtesting_begin(&ev, options);
  3450. break;
  3451. case _STARPU_MPI_FUT_DTESTING_END:
  3452. handle_mpi_dtesting_end(&ev, options);
  3453. break;
  3454. case _STARPU_MPI_FUT_UTESTING_BEGIN:
  3455. handle_mpi_utesting_begin(&ev, options);
  3456. break;
  3457. case _STARPU_MPI_FUT_UTESTING_END:
  3458. handle_mpi_utesting_end(&ev, options);
  3459. break;
  3460. case _STARPU_MPI_FUT_UWAIT_BEGIN:
  3461. handle_mpi_uwait_begin(&ev, options);
  3462. break;
  3463. case _STARPU_MPI_FUT_UWAIT_END:
  3464. handle_mpi_uwait_end(&ev, options);
  3465. break;
  3466. case _STARPU_MPI_FUT_DATA_SET_RANK:
  3467. handle_mpi_data_set_rank(&ev, options);
  3468. break;
  3469. case _STARPU_MPI_FUT_DATA_SET_TAG:
  3470. handle_mpi_data_set_tag(&ev, options);
  3471. break;
  3472. case _STARPU_MPI_FUT_TESTING_DETACHED_BEGIN:
  3473. handle_mpi_testing_detached_begin(&ev, options);
  3474. break;
  3475. case _STARPU_MPI_FUT_TESTING_DETACHED_END:
  3476. handle_mpi_testing_detached_end(&ev, options);
  3477. break;
  3478. case _STARPU_MPI_FUT_TEST_BEGIN:
  3479. handle_mpi_test_begin(&ev, options);
  3480. break;
  3481. case _STARPU_MPI_FUT_TEST_END:
  3482. handle_mpi_test_end(&ev, options);
  3483. break;
  3484. case _STARPU_MPI_FUT_POLLING_BEGIN:
  3485. handle_mpi_polling_begin(&ev, options);
  3486. break;
  3487. case _STARPU_MPI_FUT_POLLING_END:
  3488. handle_mpi_polling_end(&ev, options);
  3489. break;
  3490. case _STARPU_MPI_FUT_DRIVER_RUN_BEGIN:
  3491. handle_mpi_driver_run_begin(&ev, options);
  3492. break;
  3493. case _STARPU_MPI_FUT_DRIVER_RUN_END:
  3494. handle_mpi_driver_run_end(&ev, options);
  3495. break;
  3496. case _STARPU_MPI_FUT_CHECKPOINT_BEGIN:
  3497. handle_checkpoint_begin(&ev, options);
  3498. break;
  3499. case _STARPU_MPI_FUT_CHECKPOINT_END:
  3500. handle_checkpoint_end(&ev, options);
  3501. break;
  3502. case _STARPU_FUT_SET_PROFILING:
  3503. handle_set_profiling(&ev, options);
  3504. break;
  3505. case _STARPU_FUT_TASK_WAIT_FOR_ALL:
  3506. handle_task_wait_for_all();
  3507. break;
  3508. case _STARPU_FUT_EVENT:
  3509. if (!options->no_events)
  3510. handle_event(&ev, options);
  3511. break;
  3512. case _STARPU_FUT_THREAD_EVENT:
  3513. if (!options->no_events)
  3514. handle_thread_event(&ev, options);
  3515. break;
  3516. case _STARPU_FUT_LOCKING_MUTEX:
  3517. break;
  3518. case _STARPU_FUT_MUTEX_LOCKED:
  3519. break;
  3520. case _STARPU_FUT_UNLOCKING_MUTEX:
  3521. break;
  3522. case _STARPU_FUT_MUTEX_UNLOCKED:
  3523. break;
  3524. case _STARPU_FUT_TRYLOCK_MUTEX:
  3525. break;
  3526. case _STARPU_FUT_RDLOCKING_RWLOCK:
  3527. break;
  3528. case _STARPU_FUT_RWLOCK_RDLOCKED:
  3529. break;
  3530. case _STARPU_FUT_WRLOCKING_RWLOCK:
  3531. break;
  3532. case _STARPU_FUT_RWLOCK_WRLOCKED:
  3533. break;
  3534. case _STARPU_FUT_UNLOCKING_RWLOCK:
  3535. break;
  3536. case _STARPU_FUT_RWLOCK_UNLOCKED:
  3537. break;
  3538. case _STARPU_FUT_LOCKING_SPINLOCK:
  3539. break;
  3540. case _STARPU_FUT_SPINLOCK_LOCKED:
  3541. break;
  3542. case _STARPU_FUT_UNLOCKING_SPINLOCK:
  3543. break;
  3544. case _STARPU_FUT_SPINLOCK_UNLOCKED:
  3545. break;
  3546. case _STARPU_FUT_TRYLOCK_SPINLOCK:
  3547. break;
  3548. case _STARPU_FUT_COND_WAIT_BEGIN:
  3549. break;
  3550. case _STARPU_FUT_COND_WAIT_END:
  3551. break;
  3552. case _STARPU_FUT_BARRIER_WAIT_BEGIN:
  3553. break;
  3554. case _STARPU_FUT_BARRIER_WAIT_END:
  3555. break;
  3556. case _STARPU_FUT_MEMORY_FULL:
  3557. break;
  3558. case _STARPU_FUT_SCHED_COMPONENT_POP_PRIO:
  3559. break;
  3560. case _STARPU_FUT_SCHED_COMPONENT_PUSH_PRIO:
  3561. break;
  3562. case _STARPU_FUT_HYPERVISOR_BEGIN:
  3563. handle_hypervisor_begin(&ev, options);
  3564. break;
  3565. case _STARPU_FUT_HYPERVISOR_END:
  3566. handle_hypervisor_end(&ev, options);
  3567. break;
  3568. case FUT_SETUP_CODE:
  3569. fut_keymask = ev.param[0];
  3570. break;
  3571. case FUT_KEYCHANGE_CODE:
  3572. fut_keymask = ev.param[0];
  3573. break;
  3574. case FUT_START_FLUSH_CODE:
  3575. handle_string_event(&ev, "fxt_start_flush", options);
  3576. break;
  3577. case FUT_STOP_FLUSH_CODE:
  3578. handle_string_event(&ev, "fxt_stop_flush", options);
  3579. break;
  3580. /* We can safely ignore FUT internal events */
  3581. case FUT_CALIBRATE0_CODE:
  3582. case FUT_CALIBRATE1_CODE:
  3583. case FUT_CALIBRATE2_CODE:
  3584. case FUT_NEW_LWP_CODE:
  3585. case FUT_GCC_INSTRUMENT_ENTRY_CODE:
  3586. break;
  3587. default:
  3588. #ifdef STARPU_VERBOSE
  3589. _STARPU_MSG("unknown event.. %x at time %llx WITH OFFSET %llx\n",
  3590. (unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time-options->file_offset));
  3591. #endif
  3592. break;
  3593. }
  3594. _starpu_fxt_process_bandwidth(options);
  3595. if (!options->no_flops)
  3596. _starpu_fxt_process_computations(options);
  3597. }
  3598. if (!options->no_flops)
  3599. {
  3600. /* computations are supposed to be over, drop any pending comp */
  3601. unsigned i;
  3602. for (i = 0; i < STARPU_NMAXWORKERS; i++)
  3603. {
  3604. struct _starpu_computation *comp = ongoing_computation[i];
  3605. if (comp)
  3606. {
  3607. STARPU_ASSERT(!comp->peer);
  3608. _starpu_computation_list_erase(&computation_list, comp);
  3609. ongoing_computation[i] = 0;
  3610. }
  3611. }
  3612. /* And flush completed computations */
  3613. _starpu_fxt_process_computations(options);
  3614. }
  3615. if (out_paje_file && !options->no_bus)
  3616. {
  3617. while (!_starpu_communication_list_empty(&communication_list)) {
  3618. struct _starpu_communication*itor;
  3619. itor = _starpu_communication_list_pop_front(&communication_list);
  3620. /* Trace finished with this communication uncompleted, fake its termination */
  3621. unsigned comid = itor->comid;
  3622. unsigned long size = itor->size;
  3623. unsigned dst = itor->dst_node;
  3624. double time = current_computation_time;
  3625. const char *link_type = itor->type;
  3626. #ifdef STARPU_HAVE_POTI
  3627. char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN];
  3628. char dst_memnode_container[STARPU_POTI_STR_LEN], program_container[STARPU_POTI_STR_LEN];
  3629. snprintf(paje_value, sizeof(paje_value), "%lu", size);
  3630. snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
  3631. program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
  3632. memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, dst);
  3633. poti_EndLink(time, program_container, link_type, dst_memnode_container, paje_value, paje_key);
  3634. #else
  3635. fprintf(out_paje_file, "19 %.9f %s %sp %lu %smm%u com_%u\n", time, link_type, prefix, size, prefix, dst, comid);
  3636. #endif
  3637. _starpu_communication_delete(itor);
  3638. }
  3639. }
  3640. if (out_paje_file && !options->no_flops)
  3641. {
  3642. unsigned i;
  3643. for (i = 0; i < STARPU_NMAXWORKERS; i++)
  3644. {
  3645. if (last_codelet_end[i] != 0.0)
  3646. {
  3647. #ifdef STARPU_HAVE_POTI
  3648. char container[STARPU_POTI_STR_LEN];
  3649. worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, i);
  3650. poti_SetVariable(last_codelet_end[i], container, "gf", 0.);
  3651. #else
  3652. fprintf(out_paje_file, "13 %.9f %sw%u gf %f\n",
  3653. last_codelet_end[i], prefix, i, 0.);
  3654. #endif
  3655. last_codelet_end[i] = 0.0;
  3656. }
  3657. }
  3658. /* flush last value */
  3659. #ifdef STARPU_HAVE_POTI
  3660. char container[STARPU_POTI_STR_LEN];
  3661. scheduler_container_alias(container, STARPU_POTI_STR_LEN, prefix);
  3662. poti_SetVariable(current_computation_time, container, "gft", (double)current_computation);
  3663. #else
  3664. fprintf(out_paje_file, "13 %.9f %ssched gft %f\n", current_computation_time, prefix, (float)current_computation);
  3665. #endif
  3666. }
  3667. {
  3668. struct data_info *data=NULL, *tmp=NULL;
  3669. HASH_ITER(hh, data_info, data, tmp)
  3670. {
  3671. data_dump(data);
  3672. }
  3673. }
  3674. {
  3675. struct task_info *task=NULL, *tmp=NULL;
  3676. HASH_ITER(hh, tasks_info, task, tmp)
  3677. {
  3678. task_dump(task, options);
  3679. }
  3680. }
  3681. /* Close the trace file */
  3682. if (close(fd_in))
  3683. {
  3684. perror("close failed :");
  3685. exit(-1);
  3686. }
  3687. }
  3688. /* Initialize FxT options to default values */
  3689. void starpu_fxt_options_init(struct starpu_fxt_options *options)
  3690. {
  3691. options->per_task_colour = 0;
  3692. options->no_events = 0;
  3693. options->no_counter = 0;
  3694. options->no_bus = 0;
  3695. options->no_flops = 0;
  3696. options->no_smooth = 0;
  3697. options->no_acquire = 0;
  3698. options->memory_states = 0;
  3699. options->internal = 0;
  3700. options->label_deps = 0;
  3701. options->ninputfiles = 0;
  3702. options->out_paje_path = "paje.trace";
  3703. options->dag_path = "dag.dot";
  3704. options->tasks_path = "tasks.rec";
  3705. options->comms_path = "comms.rec";
  3706. options->number_events_path = NULL;
  3707. options->data_path = "data.rec";
  3708. options->papi_path = "papi.rec";
  3709. options->anim_path = "trace.html";
  3710. options->states_path = "trace.rec";
  3711. options->distrib_time_path = "distrib.data";
  3712. options->dumped_codelets = NULL;
  3713. options->activity_path = "activity.data";
  3714. options->sched_tasks_path = "sched_tasks.rec";
  3715. }
  3716. static
  3717. void _starpu_fxt_distrib_file_init(struct starpu_fxt_options *options)
  3718. {
  3719. dumped_codelets_count = 0;
  3720. dumped_codelets = NULL;
  3721. if (options->distrib_time_path)
  3722. {
  3723. distrib_time = fopen(options->distrib_time_path, "w+");
  3724. }
  3725. else
  3726. {
  3727. distrib_time = NULL;
  3728. }
  3729. }
  3730. static
  3731. void _starpu_fxt_distrib_file_close(struct starpu_fxt_options *options)
  3732. {
  3733. if (distrib_time)
  3734. fclose(distrib_time);
  3735. if (options->dumped_codelets)
  3736. {
  3737. *options->dumped_codelets = dumped_codelets;
  3738. options->dumped_codelets_count = dumped_codelets_count;
  3739. }
  3740. }
  3741. static
  3742. void _starpu_fxt_activity_file_init(struct starpu_fxt_options *options)
  3743. {
  3744. if (options->activity_path)
  3745. activity_file = fopen(options->activity_path, "w+");
  3746. else
  3747. activity_file = NULL;
  3748. }
  3749. static
  3750. void _starpu_fxt_sched_tasks_file_init(struct starpu_fxt_options *options)
  3751. {
  3752. if (options->sched_tasks_path)
  3753. sched_tasks_file = fopen(options->sched_tasks_path, "w+");
  3754. else
  3755. sched_tasks_file = NULL;
  3756. }
  3757. static
  3758. void _starpu_fxt_anim_file_init(struct starpu_fxt_options *options)
  3759. {
  3760. if (options->anim_path)
  3761. {
  3762. anim_file = fopen(options->anim_path, "w+");
  3763. _starpu_fxt_component_print_header(anim_file);
  3764. }
  3765. else
  3766. anim_file = NULL;
  3767. }
  3768. static
  3769. void _starpu_fxt_tasks_file_init(struct starpu_fxt_options *options)
  3770. {
  3771. if (options->tasks_path)
  3772. tasks_file = fopen(options->tasks_path, "w+");
  3773. else
  3774. tasks_file = NULL;
  3775. }
  3776. static
  3777. void _starpu_fxt_data_file_init(struct starpu_fxt_options *options)
  3778. {
  3779. if (options->data_path)
  3780. data_file = fopen(options->data_path, "w+");
  3781. else
  3782. data_file = NULL;
  3783. }
  3784. static
  3785. void _starpu_fxt_comms_file_init(struct starpu_fxt_options *options)
  3786. {
  3787. if (options->comms_path)
  3788. comms_file = fopen(options->comms_path, "w+");
  3789. else
  3790. comms_file = NULL;
  3791. }
  3792. static
  3793. void _starpu_fxt_number_events_file_init(struct starpu_fxt_options *options)
  3794. {
  3795. if (options->number_events_path)
  3796. {
  3797. number_events_file = fopen(options->number_events_path, "w+");
  3798. /* FUT_SETUP_CODE is the event with the maximal value */
  3799. number_events = calloc(FUT_SETUP_CODE+1, sizeof(uint64_t));
  3800. }
  3801. else
  3802. number_events_file = NULL;
  3803. }
  3804. static
  3805. void _starpu_fxt_papi_file_init(struct starpu_fxt_options *options)
  3806. {
  3807. #ifdef STARPU_PAPI
  3808. if (options->papi_path)
  3809. papi_file = fopen(options->papi_path, "w+");
  3810. else
  3811. papi_file = NULL;
  3812. #endif
  3813. }
  3814. static
  3815. void _starpu_fxt_write_trace_header(FILE *f)
  3816. {
  3817. fprintf(f, "#\n");
  3818. fprintf(f, "# E: Event type\n");
  3819. fprintf(f, "# N: Event name\n");
  3820. fprintf(f, "# C: Event category\n");
  3821. fprintf(f, "# W: Worker ID\n");
  3822. fprintf(f, "# T: Thread ID\n");
  3823. fprintf(f, "# S: Start time\n");
  3824. fprintf(f, "#\n");
  3825. fprintf(f, "\n");
  3826. }
  3827. static
  3828. void _starpu_fxt_trace_file_init(struct starpu_fxt_options *options)
  3829. {
  3830. if (options->states_path)
  3831. trace_file = fopen(options->states_path, "w+");
  3832. else
  3833. trace_file = NULL;
  3834. if (trace_file)
  3835. _starpu_fxt_write_trace_header(trace_file);
  3836. }
  3837. static
  3838. void _starpu_fxt_activity_file_close(void)
  3839. {
  3840. if (activity_file)
  3841. fclose(activity_file);
  3842. }
  3843. static
  3844. void _starpu_fxt_sched_tasks_file_close(void)
  3845. {
  3846. if (sched_tasks_file)
  3847. fclose(sched_tasks_file);
  3848. }
  3849. static
  3850. void _starpu_fxt_anim_file_close(void)
  3851. {
  3852. //_starpu_fxt_component_dump(stderr);
  3853. if (anim_file)
  3854. {
  3855. _starpu_fxt_component_finish(anim_file);
  3856. fclose(anim_file);
  3857. }
  3858. }
  3859. static
  3860. void _starpu_fxt_tasks_file_close(void)
  3861. {
  3862. if (tasks_file)
  3863. fclose(tasks_file);
  3864. }
  3865. static
  3866. void _starpu_fxt_comms_file_close(void)
  3867. {
  3868. if (comms_file)
  3869. fclose(comms_file);
  3870. }
  3871. static
  3872. void _starpu_fxt_number_events_file_close(void)
  3873. {
  3874. if (number_events_file)
  3875. {
  3876. int i;
  3877. assert(number_events != NULL);
  3878. fprintf(number_events_file, "# Use starpu_fxt_number_events_to_names.py to convert event keys to event names.\n");
  3879. for (i = 0; i <= FUT_SETUP_CODE; i++)
  3880. {
  3881. if (number_events[i] > 0)
  3882. fprintf(number_events_file, "0x%x\t%"PRIu64"\n", i, number_events[i]);
  3883. }
  3884. free(number_events);
  3885. number_events = NULL;
  3886. fclose(number_events_file);
  3887. }
  3888. }
  3889. static
  3890. void _starpu_fxt_data_file_close(void)
  3891. {
  3892. if (data_file)
  3893. fclose(data_file);
  3894. }
  3895. static
  3896. void _starpu_fxt_papi_file_close(void)
  3897. {
  3898. #ifdef STARPU_PAPI
  3899. if (papi_file)
  3900. fclose(papi_file);
  3901. #endif
  3902. }
  3903. static
  3904. void _starpu_fxt_trace_file_close(void)
  3905. {
  3906. if (trace_file)
  3907. fclose(trace_file);
  3908. }
  3909. static
  3910. void _starpu_fxt_paje_file_init(struct starpu_fxt_options *options)
  3911. {
  3912. /* create a new file */
  3913. if (options->out_paje_path)
  3914. {
  3915. out_paje_file = fopen(options->out_paje_path, "w+");
  3916. if (!out_paje_file)
  3917. {
  3918. _STARPU_MSG("error while opening %s\n", options->out_paje_path);
  3919. perror("fopen");
  3920. exit(1);
  3921. }
  3922. #ifdef STARPU_HAVE_POTI
  3923. #ifdef HAVE_POTI_INIT_CUSTOM
  3924. fclose(out_paje_file);
  3925. poti_init_custom (options->out_paje_path,
  3926. 0, //if false, allow extended events
  3927. 1, //if true, an old header (pj_dump -n)
  3928. 0, //if false, the trace has no comments
  3929. 1, //if true, events have aliases
  3930. 1);//if true, relative timestamps
  3931. #else
  3932. poti_init (out_paje_file);
  3933. #endif
  3934. #endif
  3935. _starpu_fxt_write_paje_header(out_paje_file, options);
  3936. }
  3937. else
  3938. {
  3939. out_paje_file = NULL;
  3940. }
  3941. /* create lists for symbols (kernel states) and communications */
  3942. _starpu_symbol_name_list_init(&symbol_list);
  3943. _starpu_communication_list_init(&communication_list);
  3944. if (!options->no_flops)
  3945. _starpu_computation_list_init(&computation_list);
  3946. }
  3947. static
  3948. void _starpu_fxt_paje_file_close(void)
  3949. {
  3950. if (out_paje_file)
  3951. fclose(out_paje_file);
  3952. }
  3953. static
  3954. uint64_t _starpu_fxt_find_start_time(char *filename_in)
  3955. {
  3956. /* Open the trace file */
  3957. int fd_in;
  3958. fd_in = open(filename_in, O_RDONLY);
  3959. if (fd_in < 0)
  3960. {
  3961. perror("open failed :");
  3962. exit(-1);
  3963. }
  3964. static fxt_t fut;
  3965. fut = fxt_fdopen(fd_in);
  3966. if (!fut)
  3967. {
  3968. perror("fxt_fdopen :");
  3969. exit(-1);
  3970. }
  3971. fxt_blockev_t block;
  3972. block = fxt_blockev_enter(fut);
  3973. struct fxt_ev_64 ev;
  3974. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  3975. STARPU_ASSERT (ret == FXT_EV_OK);
  3976. /* Close the trace file */
  3977. if (close(fd_in))
  3978. {
  3979. perror("close failed :");
  3980. exit(-1);
  3981. }
  3982. return (ev.time);
  3983. }
  3984. void starpu_fxt_generate_trace(struct starpu_fxt_options *options)
  3985. {
  3986. _starpu_fxt_dag_init(options->dag_path);
  3987. _starpu_fxt_distrib_file_init(options);
  3988. _starpu_fxt_activity_file_init(options);
  3989. _starpu_fxt_sched_tasks_file_init(options);
  3990. _starpu_fxt_anim_file_init(options);
  3991. _starpu_fxt_tasks_file_init(options);
  3992. _starpu_fxt_data_file_init(options);
  3993. _starpu_fxt_papi_file_init(options);
  3994. _starpu_fxt_comms_file_init(options);
  3995. _starpu_fxt_number_events_file_init(options);
  3996. _starpu_fxt_trace_file_init(options);
  3997. _starpu_fxt_paje_file_init(options);
  3998. if (options->ninputfiles == 0)
  3999. {
  4000. return;
  4001. }
  4002. else if (options->ninputfiles == 1)
  4003. {
  4004. /* we usually only have a single trace */
  4005. uint64_t file_start_time = _starpu_fxt_find_start_time(options->filenames[0]);
  4006. options->file_prefix = strdup("");
  4007. options->file_offset = file_start_time;
  4008. options->file_rank = -1;
  4009. _starpu_fxt_parse_new_file(options->filenames[0], options);
  4010. }
  4011. else
  4012. {
  4013. unsigned inputfile;
  4014. uint64_t offsets[options->ninputfiles];
  4015. /*
  4016. * Find the trace offsets:
  4017. * - If there is no sync point
  4018. * psi_k(x) = x - start_k
  4019. * - If there is a sync point sync_k
  4020. * psi_k(x) = x - sync_k + M
  4021. * where M = max { sync_i - start_i | there exists sync_i}
  4022. * More generally:
  4023. * - psi_k(x) = x - offset_k
  4024. */
  4025. int unique_keys[options->ninputfiles];
  4026. int rank_k[options->ninputfiles];
  4027. uint64_t start_k[options->ninputfiles];
  4028. uint64_t sync_k[options->ninputfiles];
  4029. unsigned sync_k_exists[options->ninputfiles];
  4030. uint64_t M = 0;
  4031. unsigned found_one_sync_point = 0;
  4032. int key = 0;
  4033. unsigned display_mpi = 0;
  4034. /* Compute all start_k */
  4035. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4036. {
  4037. uint64_t file_start = _starpu_fxt_find_start_time(options->filenames[inputfile]);
  4038. start_k[inputfile] = file_start;
  4039. }
  4040. /* Compute all sync_k if they exist */
  4041. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4042. {
  4043. int ret = _starpu_fxt_mpi_find_sync_point(options->filenames[inputfile],
  4044. &sync_k[inputfile],
  4045. &unique_keys[inputfile],
  4046. &rank_k[inputfile]);
  4047. if (ret == -1)
  4048. {
  4049. /* There was no sync point, we assume there is no offset */
  4050. sync_k_exists[inputfile] = 0;
  4051. }
  4052. else
  4053. {
  4054. if (!found_one_sync_point)
  4055. {
  4056. key = unique_keys[inputfile];
  4057. display_mpi = 1;
  4058. found_one_sync_point = 1;
  4059. }
  4060. else
  4061. {
  4062. if (key != unique_keys[inputfile])
  4063. {
  4064. _STARPU_MSG("Warning: traces are coming from different run so we will not try to display MPI communications.\n");
  4065. display_mpi = 0;
  4066. }
  4067. }
  4068. STARPU_ASSERT(sync_k[inputfile] >= start_k[inputfile]);
  4069. sync_k_exists[inputfile] = 1;
  4070. uint64_t diff = sync_k[inputfile] - start_k[inputfile];
  4071. if (diff > M)
  4072. M = diff;
  4073. }
  4074. }
  4075. /* Compute the offset */
  4076. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4077. {
  4078. offsets[inputfile] = sync_k_exists[inputfile]?
  4079. (sync_k[inputfile]-M):start_k[inputfile];
  4080. }
  4081. /* generate the Paje trace for the different files */
  4082. for (inputfile = 0; inputfile < options->ninputfiles; inputfile++)
  4083. {
  4084. int filerank = rank_k[inputfile];
  4085. _STARPU_DISP("Parsing file %s (rank %d)\n", options->filenames[inputfile], filerank);
  4086. char file_prefix[32];
  4087. snprintf(file_prefix, sizeof(file_prefix), "%d_", filerank);
  4088. free(options->file_prefix);
  4089. options->file_prefix = strdup(file_prefix);
  4090. options->file_offset = offsets[inputfile];
  4091. options->file_rank = filerank;
  4092. _starpu_fxt_parse_new_file(options->filenames[inputfile], options);
  4093. }
  4094. /* display the MPI transfers if possible */
  4095. if (display_mpi)
  4096. _starpu_fxt_display_mpi_transfers(options, rank_k, out_paje_file, comms_file);
  4097. }
  4098. /* close the different files */
  4099. _starpu_fxt_paje_file_close();
  4100. _starpu_fxt_activity_file_close();
  4101. _starpu_fxt_sched_tasks_file_close();
  4102. _starpu_fxt_distrib_file_close(options);
  4103. _starpu_fxt_anim_file_close();
  4104. _starpu_fxt_tasks_file_close();
  4105. _starpu_fxt_data_file_close();
  4106. _starpu_fxt_papi_file_close();
  4107. _starpu_fxt_comms_file_close();
  4108. _starpu_fxt_number_events_file_close();
  4109. _starpu_fxt_trace_file_close();
  4110. _starpu_fxt_dag_terminate();
  4111. options->nworkers = nworkers;
  4112. free(options->file_prefix);
  4113. }
  4114. #define DATA_STR_MAX_SIZE 15
  4115. struct parse_task
  4116. {
  4117. unsigned exec_time;
  4118. unsigned data_total;
  4119. unsigned workerid;
  4120. char *codelet_name;
  4121. };
  4122. static struct parse_task tasks[STARPU_NMAXWORKERS];
  4123. struct starpu_data_trace_kernel
  4124. {
  4125. UT_hash_handle hh;
  4126. char *name;
  4127. FILE *file;
  4128. } *kernels;
  4129. #define NANO_SEC_TO_MILI_SEC 0.000001
  4130. static FILE *codelet_list;
  4131. static void write_task(struct parse_task pt)
  4132. {
  4133. struct starpu_data_trace_kernel *kernel;
  4134. char *codelet_name = pt.codelet_name;
  4135. HASH_FIND_STR(kernels, codelet_name, kernel);
  4136. //fprintf(stderr, "%p %p %s\n", kernel, kernels, codelet_name);
  4137. if(kernel == NULL)
  4138. {
  4139. _STARPU_MALLOC(kernel, sizeof(*kernel));
  4140. kernel->name = strdup(codelet_name);
  4141. //fprintf(stderr, "%s\n", kernel->name);
  4142. kernel->file = fopen(codelet_name, "w+");
  4143. if(!kernel->file)
  4144. {
  4145. perror("open failed :");
  4146. exit(-1);
  4147. }
  4148. HASH_ADD_STR(kernels, name, kernel);
  4149. fprintf(codelet_list, "%s\n", codelet_name);
  4150. }
  4151. double time = pt.exec_time * NANO_SEC_TO_MILI_SEC;
  4152. fprintf(kernel->file, "%lf %u %u\n", time, pt.data_total, pt.workerid);
  4153. }
  4154. void starpu_fxt_write_data_trace(char *filename_in)
  4155. {
  4156. int fd_in;
  4157. fd_in = open(filename_in, O_RDONLY);
  4158. if (fd_in < 0)
  4159. {
  4160. perror("open failed :");
  4161. exit(-1);
  4162. }
  4163. static fxt_t fut;
  4164. fut = fxt_fdopen(fd_in);
  4165. if (!fut)
  4166. {
  4167. perror("fxt_fdopen :");
  4168. exit(-1);
  4169. }
  4170. codelet_list = fopen("codelet_list", "w+");
  4171. if(!codelet_list)
  4172. {
  4173. perror("open failed :");
  4174. exit(-1);
  4175. }
  4176. fxt_blockev_t block;
  4177. block = fxt_blockev_enter(fut);
  4178. struct fxt_ev_64 ev;
  4179. int workerid=-1;
  4180. unsigned long has_name = 0;
  4181. while(1)
  4182. {
  4183. unsigned i;
  4184. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  4185. for (i = ev.nb_params; i < FXT_MAX_PARAMS; i++)
  4186. ev.param[i] = 0;
  4187. if (ret != FXT_EV_OK)
  4188. {
  4189. break;
  4190. }
  4191. switch (ev.code)
  4192. {
  4193. case _STARPU_FUT_WORKER_INIT_START:
  4194. register_worker_id(0 /* TODO: Add nodeid here instead */, ev.param[6], ev.param[1], ev.param[5]);
  4195. break;
  4196. case _STARPU_FUT_START_CODELET_BODY:
  4197. workerid = ev.param[2];
  4198. tasks[workerid].workerid = (unsigned)workerid;
  4199. tasks[workerid].exec_time = ev.time;
  4200. has_name = ev.param[4];
  4201. tasks[workerid].codelet_name = strdup(has_name ? get_fxt_string(&ev, 5): "unknown");
  4202. //fprintf(stderr, "start codelet :[%d][%s]\n", workerid, tasks[workerid].codelet_name);
  4203. break;
  4204. case _STARPU_FUT_END_CODELET_BODY:
  4205. workerid = ev.param[3];
  4206. assert(workerid != -1);
  4207. tasks[workerid].exec_time = ev.time - tasks[workerid].exec_time;
  4208. write_task(tasks[workerid]);
  4209. break;
  4210. case _STARPU_FUT_DATA_LOAD:
  4211. workerid = ev.param[0];
  4212. tasks[workerid].data_total = ev.param[1];
  4213. break;
  4214. default:
  4215. #ifdef STARPU_VERBOSE
  4216. _STARPU_MSG("unknown event.. %x at time %llx WITH OFFSET %llx\n",
  4217. (unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time));
  4218. #endif
  4219. break;
  4220. }
  4221. }
  4222. if (close(fd_in))
  4223. {
  4224. perror("close failed :");
  4225. exit(-1);
  4226. }
  4227. if(fclose(codelet_list))
  4228. {
  4229. perror("close failed :");
  4230. exit(-1);
  4231. }
  4232. struct starpu_data_trace_kernel *kernel=NULL, *tmp=NULL;
  4233. HASH_ITER(hh, kernels, kernel, tmp)
  4234. {
  4235. if(fclose(kernel->file))
  4236. {
  4237. perror("close failed :");
  4238. exit(-1);
  4239. }
  4240. HASH_DEL(kernels, kernel);
  4241. free(kernel->name);
  4242. free(kernel);
  4243. }
  4244. }
  4245. #endif // STARPU_USE_FXT