cuda.h 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280
  1. /*
  2. * Copyright 1993-2023 NVIDIA Corporation. All rights reserved.
  3. *
  4. * NOTICE TO LICENSEE:
  5. *
  6. * This source code and/or documentation ("Licensed Deliverables") are
  7. * subject to NVIDIA intellectual property rights under U.S. and
  8. * international Copyright laws.
  9. *
  10. * These Licensed Deliverables contained herein is PROPRIETARY and
  11. * CONFIDENTIAL to NVIDIA and is being provided under the terms and
  12. * conditions of a form of NVIDIA software license agreement by and
  13. * between NVIDIA and Licensee ("License Agreement") or electronically
  14. * accepted by Licensee. Notwithstanding any terms or conditions to
  15. * the contrary in the License Agreement, reproduction or disclosure
  16. * of the Licensed Deliverables to any third party without the express
  17. * written consent of NVIDIA is prohibited.
  18. *
  19. * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
  20. * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
  21. * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
  22. * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
  23. * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
  24. * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
  25. * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
  26. * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
  27. * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
  28. * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
  29. * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  30. * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  31. * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  32. * OF THESE LICENSED DELIVERABLES.
  33. *
  34. * U.S. Government End Users. These Licensed Deliverables are a
  35. * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
  36. * 1995), consisting of "commercial computer software" and "commercial
  37. * computer software documentation" as such terms are used in 48
  38. * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
  39. * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
  40. * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
  41. * U.S. Government End Users acquire the Licensed Deliverables with
  42. * only those rights set forth herein.
  43. *
  44. * Any use of the Licensed Deliverables in individual and commercial
  45. * software must include, in the user documentation and internal
  46. * comments to the code, the above Disclaimer and U.S. Government End
  47. * Users Notice.
  48. */
  49. #ifndef __cuda_cuda_h__
  50. #define __cuda_cuda_h__
  51. #include <stdlib.h>
  52. #ifdef _MSC_VER
  53. typedef unsigned __int32 cuuint32_t;
  54. typedef unsigned __int64 cuuint64_t;
  55. #else
  56. #include <stdint.h>
  57. typedef uint32_t cuuint32_t;
  58. typedef uint64_t cuuint64_t;
  59. #endif
  60. #if defined(__CUDA_API_VERSION_INTERNAL) || defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
  61. #define __CUDA_DEPRECATED
  62. #elif defined(_MSC_VER)
  63. #define __CUDA_DEPRECATED __declspec(deprecated)
  64. #elif defined(__GNUC__)
  65. #define __CUDA_DEPRECATED __attribute__((deprecated))
  66. #else
  67. #define __CUDA_DEPRECATED
  68. #endif
  69. #if defined(CUDA_FORCE_API_VERSION)
  70. #error "CUDA_FORCE_API_VERSION is no longer supported."
  71. #endif
  72. #if defined(__CUDA_API_VERSION_INTERNAL) || defined(CUDA_API_PER_THREAD_DEFAULT_STREAM)
  73. #define __CUDA_API_PER_THREAD_DEFAULT_STREAM
  74. #define __CUDA_API_PTDS(api) api ## _ptds
  75. #define __CUDA_API_PTSZ(api) api ## _ptsz
  76. #else
  77. #define __CUDA_API_PTDS(api) api
  78. #define __CUDA_API_PTSZ(api) api
  79. #endif
  80. #define cuDeviceTotalMem cuDeviceTotalMem_v2
  81. #define cuCtxCreate cuCtxCreate_v2
  82. #define cuCtxCreate_v3 cuCtxCreate_v3
  83. #define cuCtxCreate_v4 cuCtxCreate_v4
  84. #define cuModuleGetGlobal cuModuleGetGlobal_v2
  85. #define cuMemGetInfo cuMemGetInfo_v2
  86. #define cuMemAlloc cuMemAlloc_v2
  87. #define cuMemAllocPitch cuMemAllocPitch_v2
  88. #define cuMemFree cuMemFree_v2
  89. #define cuMemGetAddressRange cuMemGetAddressRange_v2
  90. #define cuMemAllocHost cuMemAllocHost_v2
  91. #define cuMemHostGetDevicePointer cuMemHostGetDevicePointer_v2
  92. #define cuMemcpyHtoD __CUDA_API_PTDS(cuMemcpyHtoD_v2)
  93. #define cuMemcpyDtoH __CUDA_API_PTDS(cuMemcpyDtoH_v2)
  94. #define cuMemcpyDtoD __CUDA_API_PTDS(cuMemcpyDtoD_v2)
  95. #define cuMemcpyDtoA __CUDA_API_PTDS(cuMemcpyDtoA_v2)
  96. #define cuMemcpyAtoD __CUDA_API_PTDS(cuMemcpyAtoD_v2)
  97. #define cuMemcpyHtoA __CUDA_API_PTDS(cuMemcpyHtoA_v2)
  98. #define cuMemcpyAtoH __CUDA_API_PTDS(cuMemcpyAtoH_v2)
  99. #define cuMemcpyAtoA __CUDA_API_PTDS(cuMemcpyAtoA_v2)
  100. #define cuMemcpyHtoAAsync __CUDA_API_PTSZ(cuMemcpyHtoAAsync_v2)
  101. #define cuMemcpyAtoHAsync __CUDA_API_PTSZ(cuMemcpyAtoHAsync_v2)
  102. #define cuMemcpy2D __CUDA_API_PTDS(cuMemcpy2D_v2)
  103. #define cuMemcpy2DUnaligned __CUDA_API_PTDS(cuMemcpy2DUnaligned_v2)
  104. #define cuMemcpy3D __CUDA_API_PTDS(cuMemcpy3D_v2)
  105. #define cuMemcpyHtoDAsync __CUDA_API_PTSZ(cuMemcpyHtoDAsync_v2)
  106. #define cuMemcpyDtoHAsync __CUDA_API_PTSZ(cuMemcpyDtoHAsync_v2)
  107. #define cuMemcpyDtoDAsync __CUDA_API_PTSZ(cuMemcpyDtoDAsync_v2)
  108. #define cuMemcpy2DAsync __CUDA_API_PTSZ(cuMemcpy2DAsync_v2)
  109. #define cuMemcpy3DAsync __CUDA_API_PTSZ(cuMemcpy3DAsync_v2)
  110. #define cuMemcpyBatchAsync __CUDA_API_PTSZ(cuMemcpyBatchAsync)
  111. #define cuMemcpy3DBatchAsync __CUDA_API_PTSZ(cuMemcpy3DBatchAsync)
  112. #define cuMemsetD8 __CUDA_API_PTDS(cuMemsetD8_v2)
  113. #define cuMemsetD16 __CUDA_API_PTDS(cuMemsetD16_v2)
  114. #define cuMemsetD32 __CUDA_API_PTDS(cuMemsetD32_v2)
  115. #define cuMemsetD2D8 __CUDA_API_PTDS(cuMemsetD2D8_v2)
  116. #define cuMemsetD2D16 __CUDA_API_PTDS(cuMemsetD2D16_v2)
  117. #define cuMemsetD2D32 __CUDA_API_PTDS(cuMemsetD2D32_v2)
  118. #define cuArrayCreate cuArrayCreate_v2
  119. #define cuArrayGetDescriptor cuArrayGetDescriptor_v2
  120. #define cuArray3DCreate cuArray3DCreate_v2
  121. #define cuArray3DGetDescriptor cuArray3DGetDescriptor_v2
  122. #define cuTexRefSetAddress cuTexRefSetAddress_v2
  123. #define cuTexRefGetAddress cuTexRefGetAddress_v2
  124. #define cuGraphicsResourceGetMappedPointer cuGraphicsResourceGetMappedPointer_v2
  125. #define cuCtxDestroy cuCtxDestroy_v2
  126. #define cuCtxPopCurrent cuCtxPopCurrent_v2
  127. #define cuCtxPushCurrent cuCtxPushCurrent_v2
  128. #define cuStreamDestroy cuStreamDestroy_v2
  129. #define cuEventDestroy cuEventDestroy_v2
  130. #define cuTexRefSetAddress2D cuTexRefSetAddress2D_v3
  131. #define cuLinkCreate cuLinkCreate_v2
  132. #define cuLinkAddData cuLinkAddData_v2
  133. #define cuLinkAddFile cuLinkAddFile_v2
  134. #define cuMemHostRegister cuMemHostRegister_v2
  135. #define cuGraphicsResourceSetMapFlags cuGraphicsResourceSetMapFlags_v2
  136. #define cuStreamBeginCapture __CUDA_API_PTSZ(cuStreamBeginCapture_v2)
  137. #define cuDevicePrimaryCtxRelease cuDevicePrimaryCtxRelease_v2
  138. #define cuDevicePrimaryCtxReset cuDevicePrimaryCtxReset_v2
  139. #define cuDevicePrimaryCtxSetFlags cuDevicePrimaryCtxSetFlags_v2
  140. #define cuDeviceGetUuid_v2 cuDeviceGetUuid_v2
  141. #define cuIpcOpenMemHandle cuIpcOpenMemHandle_v2
  142. #define cuGraphInstantiate cuGraphInstantiateWithFlags
  143. #define cuGraphExecUpdate cuGraphExecUpdate_v2
  144. #define cuGetProcAddress cuGetProcAddress_v2
  145. #define cuGraphAddKernelNode cuGraphAddKernelNode_v2
  146. #define cuGraphKernelNodeGetParams cuGraphKernelNodeGetParams_v2
  147. #define cuGraphKernelNodeSetParams cuGraphKernelNodeSetParams_v2
  148. #define cuGraphExecKernelNodeSetParams cuGraphExecKernelNodeSetParams_v2
  149. #define cuStreamWriteValue32 __CUDA_API_PTSZ(cuStreamWriteValue32_v2)
  150. #define cuStreamWaitValue32 __CUDA_API_PTSZ(cuStreamWaitValue32_v2)
  151. #define cuStreamWriteValue64 __CUDA_API_PTSZ(cuStreamWriteValue64_v2)
  152. #define cuStreamWaitValue64 __CUDA_API_PTSZ(cuStreamWaitValue64_v2)
  153. #define cuStreamBatchMemOp __CUDA_API_PTSZ(cuStreamBatchMemOp_v2)
  154. #define cuStreamGetCaptureInfo __CUDA_API_PTSZ(cuStreamGetCaptureInfo_v2)
  155. #define cuStreamGetCaptureInfo_v2 __CUDA_API_PTSZ(cuStreamGetCaptureInfo_v2)
  156. #if defined(__CUDA_API_PER_THREAD_DEFAULT_STREAM)
  157. #define cuMemcpy __CUDA_API_PTDS(cuMemcpy)
  158. #define cuMemcpyAsync __CUDA_API_PTSZ(cuMemcpyAsync)
  159. #define cuMemcpyPeer __CUDA_API_PTDS(cuMemcpyPeer)
  160. #define cuMemcpyPeerAsync __CUDA_API_PTSZ(cuMemcpyPeerAsync)
  161. #define cuMemcpy3DPeer __CUDA_API_PTDS(cuMemcpy3DPeer)
  162. #define cuMemcpy3DPeerAsync __CUDA_API_PTSZ(cuMemcpy3DPeerAsync)
  163. #define cuMemPrefetchAsync __CUDA_API_PTSZ(cuMemPrefetchAsync)
  164. #define cuMemPrefetchAsync_v2 __CUDA_API_PTSZ(cuMemPrefetchAsync_v2)
  165. #define cuMemsetD8Async __CUDA_API_PTSZ(cuMemsetD8Async)
  166. #define cuMemsetD16Async __CUDA_API_PTSZ(cuMemsetD16Async)
  167. #define cuMemsetD32Async __CUDA_API_PTSZ(cuMemsetD32Async)
  168. #define cuMemsetD2D8Async __CUDA_API_PTSZ(cuMemsetD2D8Async)
  169. #define cuMemsetD2D16Async __CUDA_API_PTSZ(cuMemsetD2D16Async)
  170. #define cuMemsetD2D32Async __CUDA_API_PTSZ(cuMemsetD2D32Async)
  171. #define cuStreamGetPriority __CUDA_API_PTSZ(cuStreamGetPriority)
  172. #define cuStreamGetId __CUDA_API_PTSZ(cuStreamGetId)
  173. #define cuStreamGetFlags __CUDA_API_PTSZ(cuStreamGetFlags)
  174. #define cuStreamGetDevice __CUDA_API_PTSZ(cuStreamGetDevice)
  175. #define cuStreamGetCtx __CUDA_API_PTSZ(cuStreamGetCtx)
  176. #define cuStreamGetCtx_v2 __CUDA_API_PTSZ(cuStreamGetCtx_v2)
  177. #define cuStreamWaitEvent __CUDA_API_PTSZ(cuStreamWaitEvent)
  178. #define cuStreamEndCapture __CUDA_API_PTSZ(cuStreamEndCapture)
  179. #define cuStreamIsCapturing __CUDA_API_PTSZ(cuStreamIsCapturing)
  180. #define cuStreamGetCaptureInfo_v3 __CUDA_API_PTSZ(cuStreamGetCaptureInfo_v3)
  181. #define cuStreamUpdateCaptureDependencies __CUDA_API_PTSZ(cuStreamUpdateCaptureDependencies)
  182. #define cuStreamUpdateCaptureDependencies_v2 __CUDA_API_PTSZ(cuStreamUpdateCaptureDependencies_v2)
  183. #define cuStreamAddCallback __CUDA_API_PTSZ(cuStreamAddCallback)
  184. #define cuStreamAttachMemAsync __CUDA_API_PTSZ(cuStreamAttachMemAsync)
  185. #define cuStreamQuery __CUDA_API_PTSZ(cuStreamQuery)
  186. #define cuStreamSynchronize __CUDA_API_PTSZ(cuStreamSynchronize)
  187. #define cuEventRecord __CUDA_API_PTSZ(cuEventRecord)
  188. #define cuEventRecordWithFlags __CUDA_API_PTSZ(cuEventRecordWithFlags)
  189. #define cuLaunchKernel __CUDA_API_PTSZ(cuLaunchKernel)
  190. #define cuLaunchKernelEx __CUDA_API_PTSZ(cuLaunchKernelEx)
  191. #define cuLaunchHostFunc __CUDA_API_PTSZ(cuLaunchHostFunc)
  192. #define cuGraphicsMapResources __CUDA_API_PTSZ(cuGraphicsMapResources)
  193. #define cuGraphicsUnmapResources __CUDA_API_PTSZ(cuGraphicsUnmapResources)
  194. #define cuLaunchCooperativeKernel __CUDA_API_PTSZ(cuLaunchCooperativeKernel)
  195. #define cuSignalExternalSemaphoresAsync __CUDA_API_PTSZ(cuSignalExternalSemaphoresAsync)
  196. #define cuWaitExternalSemaphoresAsync __CUDA_API_PTSZ(cuWaitExternalSemaphoresAsync)
  197. #define cuGraphInstantiateWithParams __CUDA_API_PTSZ(cuGraphInstantiateWithParams)
  198. #define cuGraphUpload __CUDA_API_PTSZ(cuGraphUpload)
  199. #define cuGraphLaunch __CUDA_API_PTSZ(cuGraphLaunch)
  200. #define cuStreamCopyAttributes __CUDA_API_PTSZ(cuStreamCopyAttributes)
  201. #define cuStreamGetAttribute __CUDA_API_PTSZ(cuStreamGetAttribute)
  202. #define cuStreamSetAttribute __CUDA_API_PTSZ(cuStreamSetAttribute)
  203. #define cuMemMapArrayAsync __CUDA_API_PTSZ(cuMemMapArrayAsync)
  204. #define cuMemFreeAsync __CUDA_API_PTSZ(cuMemFreeAsync)
  205. #define cuMemAllocAsync __CUDA_API_PTSZ(cuMemAllocAsync)
  206. #define cuMemAllocFromPoolAsync __CUDA_API_PTSZ(cuMemAllocFromPoolAsync)
  207. #define cuStreamBeginCaptureToGraph __CUDA_API_PTSZ(cuStreamBeginCaptureToGraph)
  208. #endif
  209. #define cuMemBatchDecompressAsync __CUDA_API_PTSZ(cuMemBatchDecompressAsync)
  210. /**
  211. * \file cuda.h
  212. * \brief Header file for the CUDA Toolkit application programming interface.
  213. *
  214. * \file cudaGL.h
  215. * \brief Header file for the OpenGL interoperability functions of the
  216. * low-level CUDA driver application programming interface.
  217. *
  218. * \file cudaD3D9.h
  219. * \brief Header file for the Direct3D 9 interoperability functions of the
  220. * low-level CUDA driver application programming interface.
  221. */
  222. /**
  223. * \defgroup CUDA_TYPES Data types used by CUDA driver
  224. * @{
  225. */
  226. /**
  227. * CUDA API version number
  228. */
  229. #define CUDA_VERSION 12080
  230. #ifdef __cplusplus
  231. extern "C" {
  232. #endif
  233. /**
  234. * CUDA device pointer
  235. * CUdeviceptr is defined as an unsigned integer type whose size matches the size of a pointer on the target platform.
  236. */
  237. #if defined(_WIN64) || defined(__LP64__)
  238. typedef unsigned long long CUdeviceptr_v2;
  239. #else
  240. typedef unsigned int CUdeviceptr_v2;
  241. #endif
  242. typedef CUdeviceptr_v2 CUdeviceptr; /**< CUDA device pointer */
  243. typedef int CUdevice_v1; /**< CUDA device */
  244. typedef CUdevice_v1 CUdevice; /**< CUDA device */
  245. typedef struct CUctx_st *CUcontext; /**< A regular context handle */
  246. typedef struct CUmod_st *CUmodule; /**< CUDA module */
  247. typedef struct CUfunc_st *CUfunction; /**< CUDA function */
  248. typedef struct CUlib_st *CUlibrary; /**< CUDA library */
  249. typedef struct CUkern_st *CUkernel; /**< CUDA kernel */
  250. typedef struct CUarray_st *CUarray; /**< CUDA array */
  251. typedef struct CUmipmappedArray_st *CUmipmappedArray; /**< CUDA mipmapped array */
  252. typedef struct CUtexref_st *CUtexref; /**< CUDA texture reference */
  253. typedef struct CUsurfref_st *CUsurfref; /**< CUDA surface reference */
  254. typedef struct CUevent_st *CUevent; /**< CUDA event */
  255. typedef struct CUstream_st *CUstream; /**< CUDA stream */
  256. typedef struct CUgraphicsResource_st *CUgraphicsResource; /**< CUDA graphics interop resource */
  257. typedef unsigned long long CUtexObject_v1; /**< An opaque value that represents a CUDA texture object */
  258. typedef CUtexObject_v1 CUtexObject; /**< An opaque value that represents a CUDA texture object */
  259. typedef unsigned long long CUsurfObject_v1; /**< An opaque value that represents a CUDA surface object */
  260. typedef CUsurfObject_v1 CUsurfObject; /**< An opaque value that represents a CUDA surface object */
  261. typedef struct CUextMemory_st *CUexternalMemory; /**< CUDA external memory */
  262. typedef struct CUextSemaphore_st *CUexternalSemaphore; /**< CUDA external semaphore */
  263. typedef struct CUgraph_st *CUgraph; /**< CUDA graph */
  264. typedef struct CUgraphNode_st *CUgraphNode; /**< CUDA graph node */
  265. typedef struct CUgraphExec_st *CUgraphExec; /**< CUDA executable graph */
  266. typedef struct CUmemPoolHandle_st *CUmemoryPool; /**< CUDA memory pool */
  267. typedef struct CUuserObject_st *CUuserObject; /**< CUDA user object for graphs */
  268. typedef cuuint64_t CUgraphConditionalHandle; /**< CUDA graph conditional handle */
  269. typedef struct CUgraphDeviceUpdatableNode_st *CUgraphDeviceNode; /**< CUDA graph device node handle */
  270. typedef struct CUasyncCallbackEntry_st *CUasyncCallbackHandle; /**< CUDA async notification callback handle */
  271. /*!
  272. * \typedef typedef struct CUgreenCtx_st* CUgreenCtx
  273. * A green context handle. This handle can be used safely from only one CPU thread at a time.
  274. * Created via ::cuGreenCtxCreate
  275. */
  276. typedef struct CUgreenCtx_st *CUgreenCtx;
  277. #ifndef CU_UUID_HAS_BEEN_DEFINED
  278. #define CU_UUID_HAS_BEEN_DEFINED
  279. typedef struct CUuuid_st { /**< CUDA definition of UUID */
  280. char bytes[16];
  281. } CUuuid;
  282. #endif
  283. /**
  284. * CUDA IPC handle size
  285. */
  286. #define CU_IPC_HANDLE_SIZE 64
  287. /**
  288. * Fabric handle - An opaque handle representing a memory allocation
  289. * that can be exported to processes in same or different nodes. For IPC
  290. * between processes on different nodes they must be connected via the
  291. * NVSwitch fabric.
  292. */
  293. typedef struct CUmemFabricHandle_st {
  294. unsigned char data[CU_IPC_HANDLE_SIZE];
  295. } CUmemFabricHandle_v1;
  296. typedef CUmemFabricHandle_v1 CUmemFabricHandle;
  297. /**
  298. * CUDA IPC event handle
  299. */
  300. typedef struct CUipcEventHandle_st {
  301. char reserved[CU_IPC_HANDLE_SIZE];
  302. } CUipcEventHandle_v1;
  303. typedef CUipcEventHandle_v1 CUipcEventHandle;
  304. /**
  305. * CUDA IPC mem handle
  306. */
  307. typedef struct CUipcMemHandle_st {
  308. char reserved[CU_IPC_HANDLE_SIZE];
  309. } CUipcMemHandle_v1;
  310. typedef CUipcMemHandle_v1 CUipcMemHandle;
  311. /**
  312. * CUDA Ipc Mem Flags
  313. */
  314. typedef enum CUipcMem_flags_enum {
  315. CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS = 0x1 /**< Automatically enable peer access between remote devices as needed */
  316. } CUipcMem_flags;
  317. /**
  318. * CUDA Mem Attach Flags
  319. */
  320. typedef enum CUmemAttach_flags_enum {
  321. CU_MEM_ATTACH_GLOBAL = 0x1, /**< Memory can be accessed by any stream on any device */
  322. CU_MEM_ATTACH_HOST = 0x2, /**< Memory cannot be accessed by any stream on any device */
  323. CU_MEM_ATTACH_SINGLE = 0x4 /**< Memory can only be accessed by a single stream on the associated device */
  324. } CUmemAttach_flags;
  325. /**
  326. * Context creation flags
  327. */
  328. typedef enum CUctx_flags_enum {
  329. CU_CTX_SCHED_AUTO = 0x00, /**< Automatic scheduling */
  330. CU_CTX_SCHED_SPIN = 0x01, /**< Set spin as default scheduling */
  331. CU_CTX_SCHED_YIELD = 0x02, /**< Set yield as default scheduling */
  332. CU_CTX_SCHED_BLOCKING_SYNC = 0x04, /**< Set blocking synchronization as default scheduling */
  333. CU_CTX_BLOCKING_SYNC = 0x04, /**< Set blocking synchronization as default scheduling
  334. * \deprecated This flag was deprecated as of CUDA 4.0
  335. * and was replaced with ::CU_CTX_SCHED_BLOCKING_SYNC. */
  336. CU_CTX_SCHED_MASK = 0x07,
  337. CU_CTX_MAP_HOST = 0x08, /**< \deprecated This flag was deprecated as of CUDA 11.0
  338. * and it no longer has any effect. All contexts
  339. * as of CUDA 3.2 behave as though the flag is enabled. */
  340. CU_CTX_LMEM_RESIZE_TO_MAX = 0x10, /**< Keep local memory allocation after launch */
  341. CU_CTX_COREDUMP_ENABLE = 0x20, /**< Trigger coredumps from exceptions in this context */
  342. CU_CTX_USER_COREDUMP_ENABLE= 0x40, /**< Enable user pipe to trigger coredumps in this context */
  343. CU_CTX_SYNC_MEMOPS = 0x80, /**< Ensure synchronous memory operations on this context will synchronize */
  344. CU_CTX_FLAGS_MASK = 0xFF
  345. } CUctx_flags;
  346. /**
  347. * Event sched flags
  348. */
  349. typedef enum CUevent_sched_flags_enum {
  350. CU_EVENT_SCHED_AUTO = 0x00, /**< Automatic scheduling */
  351. CU_EVENT_SCHED_SPIN = 0x01, /**< Set spin as default scheduling */
  352. CU_EVENT_SCHED_YIELD = 0x02, /**< Set yield as default scheduling */
  353. CU_EVENT_SCHED_BLOCKING_SYNC = 0x04, /**< Set blocking synchronization as default scheduling */
  354. } CUevent_sched_flags;
  355. /**
  356. * NVCL event scheduling flags
  357. */
  358. typedef enum cl_event_flags_enum {
  359. NVCL_EVENT_SCHED_AUTO = 0x00, /**< Automatic scheduling */
  360. NVCL_EVENT_SCHED_SPIN = 0x01, /**< Set spin as default scheduling */
  361. NVCL_EVENT_SCHED_YIELD = 0x02, /**< Set yield as default scheduling */
  362. NVCL_EVENT_SCHED_BLOCKING_SYNC = 0x04, /**< Set blocking synchronization as default scheduling */
  363. } cl_event_flags;
  364. /**
  365. * NVCL context scheduling flags
  366. */
  367. typedef enum cl_context_flags_enum {
  368. NVCL_CTX_SCHED_AUTO = 0x00, /**< Automatic scheduling */
  369. NVCL_CTX_SCHED_SPIN = 0x01, /**< Set spin as default scheduling */
  370. NVCL_CTX_SCHED_YIELD = 0x02, /**< Set yield as default scheduling */
  371. NVCL_CTX_SCHED_BLOCKING_SYNC = 0x04, /**< Set blocking synchronization as default scheduling */
  372. } cl_context_flags;
  373. /**
  374. * Stream creation flags
  375. */
  376. typedef enum CUstream_flags_enum {
  377. CU_STREAM_DEFAULT = 0x0, /**< Default stream flag */
  378. CU_STREAM_NON_BLOCKING = 0x1 /**< Stream does not synchronize with stream 0 (the NULL stream) */
  379. } CUstream_flags;
  380. /**
  381. * Legacy stream handle
  382. *
  383. * Stream handle that can be passed as a CUstream to use an implicit stream
  384. * with legacy synchronization behavior.
  385. *
  386. * See details of the \link_sync_behavior
  387. */
  388. #define CU_STREAM_LEGACY ((CUstream)0x1)
  389. /**
  390. * Per-thread stream handle
  391. *
  392. * Stream handle that can be passed as a CUstream to use an implicit stream
  393. * with per-thread synchronization behavior.
  394. *
  395. * See details of the \link_sync_behavior
  396. */
  397. #define CU_STREAM_PER_THREAD ((CUstream)0x2)
  398. /**
  399. * Event creation flags
  400. */
  401. typedef enum CUevent_flags_enum {
  402. CU_EVENT_DEFAULT = 0x0, /**< Default event flag */
  403. CU_EVENT_BLOCKING_SYNC = 0x1, /**< Event uses blocking synchronization */
  404. CU_EVENT_DISABLE_TIMING = 0x2, /**< Event will not record timing data */
  405. CU_EVENT_INTERPROCESS = 0x4 /**< Event is suitable for interprocess use. CU_EVENT_DISABLE_TIMING must be set */
  406. } CUevent_flags;
  407. /**
  408. * Event record flags
  409. */
  410. typedef enum CUevent_record_flags_enum {
  411. CU_EVENT_RECORD_DEFAULT = 0x0, /**< Default event record flag */
  412. CU_EVENT_RECORD_EXTERNAL = 0x1 /**< When using stream capture, create an event record node
  413. * instead of the default behavior. This flag is invalid
  414. * when used outside of capture. */
  415. } CUevent_record_flags;
  416. /**
  417. * Event wait flags
  418. */
  419. typedef enum CUevent_wait_flags_enum {
  420. CU_EVENT_WAIT_DEFAULT = 0x0, /**< Default event wait flag */
  421. CU_EVENT_WAIT_EXTERNAL = 0x1 /**< When using stream capture, create an event wait node
  422. * instead of the default behavior. This flag is invalid
  423. * when used outside of capture.*/
  424. } CUevent_wait_flags;
  425. /**
  426. * Flags for ::cuStreamWaitValue32 and ::cuStreamWaitValue64
  427. */
  428. typedef enum CUstreamWaitValue_flags_enum {
  429. CU_STREAM_WAIT_VALUE_GEQ = 0x0, /**< Wait until (int32_t)(*addr - value) >= 0 (or int64_t for 64 bit
  430. values). Note this is a cyclic comparison which ignores wraparound.
  431. (Default behavior.) */
  432. CU_STREAM_WAIT_VALUE_EQ = 0x1, /**< Wait until *addr == value. */
  433. CU_STREAM_WAIT_VALUE_AND = 0x2, /**< Wait until (*addr & value) != 0. */
  434. CU_STREAM_WAIT_VALUE_NOR = 0x3, /**< Wait until ~(*addr | value) != 0. Support for this operation can be
  435. queried with ::cuDeviceGetAttribute() and
  436. ::CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_WAIT_VALUE_NOR.*/
  437. CU_STREAM_WAIT_VALUE_FLUSH = 1<<30 /**< Follow the wait operation with a flush of outstanding remote writes. This
  438. means that, if a remote write operation is guaranteed to have reached the
  439. device before the wait can be satisfied, that write is guaranteed to be
  440. visible to downstream device work. The device is permitted to reorder
  441. remote writes internally. For example, this flag would be required if
  442. two remote writes arrive in a defined order, the wait is satisfied by the
  443. second write, and downstream work needs to observe the first write.
  444. Support for this operation is restricted to selected platforms and can be
  445. queried with ::CU_DEVICE_ATTRIBUTE_CAN_FLUSH_REMOTE_WRITES.*/
  446. } CUstreamWaitValue_flags;
  447. /**
  448. * Flags for ::cuStreamWriteValue32
  449. */
  450. typedef enum CUstreamWriteValue_flags_enum {
  451. CU_STREAM_WRITE_VALUE_DEFAULT = 0x0, /**< Default behavior */
  452. CU_STREAM_WRITE_VALUE_NO_MEMORY_BARRIER = 0x1 /**< Permits the write to be reordered with writes which were issued
  453. before it, as a performance optimization. Normally,
  454. ::cuStreamWriteValue32 will provide a memory fence before the
  455. write, which has similar semantics to
  456. __threadfence_system() but is scoped to the stream
  457. rather than a CUDA thread.
  458. This flag is not supported in the v2 API. */
  459. } CUstreamWriteValue_flags;
  460. /**
  461. * Operations for ::cuStreamBatchMemOp
  462. */
  463. typedef enum CUstreamBatchMemOpType_enum {
  464. CU_STREAM_MEM_OP_WAIT_VALUE_32 = 1, /**< Represents a ::cuStreamWaitValue32 operation */
  465. CU_STREAM_MEM_OP_WRITE_VALUE_32 = 2, /**< Represents a ::cuStreamWriteValue32 operation */
  466. CU_STREAM_MEM_OP_WAIT_VALUE_64 = 4, /**< Represents a ::cuStreamWaitValue64 operation */
  467. CU_STREAM_MEM_OP_WRITE_VALUE_64 = 5, /**< Represents a ::cuStreamWriteValue64 operation */
  468. CU_STREAM_MEM_OP_BARRIER = 6, /**< Insert a memory barrier of the specified type */
  469. CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES = 3 /**< This has the same effect as ::CU_STREAM_WAIT_VALUE_FLUSH, but as a
  470. standalone operation. */
  471. } CUstreamBatchMemOpType;
  472. /**
  473. * Flags for ::cuStreamMemoryBarrier
  474. */
  475. typedef enum CUstreamMemoryBarrier_flags_enum {
  476. CU_STREAM_MEMORY_BARRIER_TYPE_SYS = 0x0, /**< System-wide memory barrier. */
  477. CU_STREAM_MEMORY_BARRIER_TYPE_GPU = 0x1 /**< Limit memory barrier scope to the GPU. */
  478. } CUstreamMemoryBarrier_flags;
  479. /**
  480. * Per-operation parameters for ::cuStreamBatchMemOp
  481. */
  482. typedef union CUstreamBatchMemOpParams_union {
  483. CUstreamBatchMemOpType operation;
  484. struct CUstreamMemOpWaitValueParams_st {
  485. CUstreamBatchMemOpType operation;
  486. CUdeviceptr address;
  487. union {
  488. cuuint32_t value;
  489. cuuint64_t value64;
  490. };
  491. unsigned int flags;
  492. CUdeviceptr alias; /**< For driver internal use. Initial value is unimportant. */
  493. } waitValue;
  494. struct CUstreamMemOpWriteValueParams_st {
  495. CUstreamBatchMemOpType operation;
  496. CUdeviceptr address;
  497. union {
  498. cuuint32_t value;
  499. cuuint64_t value64;
  500. };
  501. unsigned int flags;
  502. CUdeviceptr alias; /**< For driver internal use. Initial value is unimportant. */
  503. } writeValue;
  504. struct CUstreamMemOpFlushRemoteWritesParams_st {
  505. CUstreamBatchMemOpType operation;
  506. unsigned int flags;
  507. } flushRemoteWrites;
  508. struct CUstreamMemOpMemoryBarrierParams_st { /**< Only supported in the _v2 API */
  509. CUstreamBatchMemOpType operation;
  510. unsigned int flags;
  511. } memoryBarrier;
  512. cuuint64_t pad[6];
  513. } CUstreamBatchMemOpParams_v1;
  514. typedef CUstreamBatchMemOpParams_v1 CUstreamBatchMemOpParams;
  515. typedef struct CUDA_BATCH_MEM_OP_NODE_PARAMS_v1_st {
  516. CUcontext ctx;
  517. unsigned int count;
  518. CUstreamBatchMemOpParams *paramArray;
  519. unsigned int flags;
  520. } CUDA_BATCH_MEM_OP_NODE_PARAMS_v1;
  521. typedef CUDA_BATCH_MEM_OP_NODE_PARAMS_v1 CUDA_BATCH_MEM_OP_NODE_PARAMS;
  522. /**
  523. * Batch memory operation node parameters
  524. */
  525. typedef struct CUDA_BATCH_MEM_OP_NODE_PARAMS_v2_st {
  526. CUcontext ctx; /**< Context to use for the operations. */
  527. unsigned int count; /**< Number of operations in paramArray. */
  528. CUstreamBatchMemOpParams *paramArray; /**< Array of batch memory operations. */
  529. unsigned int flags; /**< Flags to control the node. */
  530. } CUDA_BATCH_MEM_OP_NODE_PARAMS_v2;
  531. /**
  532. * Occupancy calculator flag
  533. */
  534. typedef enum CUoccupancy_flags_enum {
  535. CU_OCCUPANCY_DEFAULT = 0x0, /**< Default behavior */
  536. CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE = 0x1 /**< Assume global caching is enabled and cannot be automatically turned off */
  537. } CUoccupancy_flags;
  538. /**
  539. * Flags for ::cuStreamUpdateCaptureDependencies
  540. */
  541. typedef enum CUstreamUpdateCaptureDependencies_flags_enum {
  542. CU_STREAM_ADD_CAPTURE_DEPENDENCIES = 0x0, /**< Add new nodes to the dependency set */
  543. CU_STREAM_SET_CAPTURE_DEPENDENCIES = 0x1 /**< Replace the dependency set with the new nodes */
  544. } CUstreamUpdateCaptureDependencies_flags;
  545. /**
  546. * Types of async notification that can be sent
  547. */
  548. typedef enum CUasyncNotificationType_enum {
  549. CU_ASYNC_NOTIFICATION_TYPE_OVER_BUDGET = 0x1
  550. } CUasyncNotificationType;
  551. /**
  552. * Information passed to the user via the async notification callback
  553. */
  554. typedef struct CUasyncNotificationInfo_st {
  555. CUasyncNotificationType type;
  556. union {
  557. struct {
  558. unsigned long long bytesOverBudget;
  559. } overBudget;
  560. } info;
  561. } CUasyncNotificationInfo;
  562. /**
  563. * CUDA async notification callback
  564. * \param info Information describing what actions to take as a result of this trim notification.
  565. * \param userData Pointer to user defined data provided at registration.
  566. * \param callback The callback handle associated with this specific callback.
  567. */
  568. typedef void (*CUasyncCallback)(CUasyncNotificationInfo *info, void *userData, CUasyncCallbackHandle callback);
  569. /**
  570. * Array formats
  571. */
  572. typedef enum CUarray_format_enum {
  573. CU_AD_FORMAT_UNSIGNED_INT8 = 0x01, /**< Unsigned 8-bit integers */
  574. CU_AD_FORMAT_UNSIGNED_INT16 = 0x02, /**< Unsigned 16-bit integers */
  575. CU_AD_FORMAT_UNSIGNED_INT32 = 0x03, /**< Unsigned 32-bit integers */
  576. CU_AD_FORMAT_SIGNED_INT8 = 0x08, /**< Signed 8-bit integers */
  577. CU_AD_FORMAT_SIGNED_INT16 = 0x09, /**< Signed 16-bit integers */
  578. CU_AD_FORMAT_SIGNED_INT32 = 0x0a, /**< Signed 32-bit integers */
  579. CU_AD_FORMAT_HALF = 0x10, /**< 16-bit floating point */
  580. CU_AD_FORMAT_FLOAT = 0x20, /**< 32-bit floating point */
  581. CU_AD_FORMAT_NV12 = 0xb0, /**< 8-bit YUV planar format, with 4:2:0 sampling */
  582. CU_AD_FORMAT_UNORM_INT8X1 = 0xc0, /**< 1 channel unsigned 8-bit normalized integer */
  583. CU_AD_FORMAT_UNORM_INT8X2 = 0xc1, /**< 2 channel unsigned 8-bit normalized integer */
  584. CU_AD_FORMAT_UNORM_INT8X4 = 0xc2, /**< 4 channel unsigned 8-bit normalized integer */
  585. CU_AD_FORMAT_UNORM_INT16X1 = 0xc3, /**< 1 channel unsigned 16-bit normalized integer */
  586. CU_AD_FORMAT_UNORM_INT16X2 = 0xc4, /**< 2 channel unsigned 16-bit normalized integer */
  587. CU_AD_FORMAT_UNORM_INT16X4 = 0xc5, /**< 4 channel unsigned 16-bit normalized integer */
  588. CU_AD_FORMAT_SNORM_INT8X1 = 0xc6, /**< 1 channel signed 8-bit normalized integer */
  589. CU_AD_FORMAT_SNORM_INT8X2 = 0xc7, /**< 2 channel signed 8-bit normalized integer */
  590. CU_AD_FORMAT_SNORM_INT8X4 = 0xc8, /**< 4 channel signed 8-bit normalized integer */
  591. CU_AD_FORMAT_SNORM_INT16X1 = 0xc9, /**< 1 channel signed 16-bit normalized integer */
  592. CU_AD_FORMAT_SNORM_INT16X2 = 0xca, /**< 2 channel signed 16-bit normalized integer */
  593. CU_AD_FORMAT_SNORM_INT16X4 = 0xcb, /**< 4 channel signed 16-bit normalized integer */
  594. CU_AD_FORMAT_BC1_UNORM = 0x91, /**< 4 channel unsigned normalized block-compressed (BC1 compression) format */
  595. CU_AD_FORMAT_BC1_UNORM_SRGB = 0x92, /**< 4 channel unsigned normalized block-compressed (BC1 compression) format with sRGB encoding*/
  596. CU_AD_FORMAT_BC2_UNORM = 0x93, /**< 4 channel unsigned normalized block-compressed (BC2 compression) format */
  597. CU_AD_FORMAT_BC2_UNORM_SRGB = 0x94, /**< 4 channel unsigned normalized block-compressed (BC2 compression) format with sRGB encoding*/
  598. CU_AD_FORMAT_BC3_UNORM = 0x95, /**< 4 channel unsigned normalized block-compressed (BC3 compression) format */
  599. CU_AD_FORMAT_BC3_UNORM_SRGB = 0x96, /**< 4 channel unsigned normalized block-compressed (BC3 compression) format with sRGB encoding*/
  600. CU_AD_FORMAT_BC4_UNORM = 0x97, /**< 1 channel unsigned normalized block-compressed (BC4 compression) format */
  601. CU_AD_FORMAT_BC4_SNORM = 0x98, /**< 1 channel signed normalized block-compressed (BC4 compression) format */
  602. CU_AD_FORMAT_BC5_UNORM = 0x99, /**< 2 channel unsigned normalized block-compressed (BC5 compression) format */
  603. CU_AD_FORMAT_BC5_SNORM = 0x9a, /**< 2 channel signed normalized block-compressed (BC5 compression) format */
  604. CU_AD_FORMAT_BC6H_UF16 = 0x9b, /**< 3 channel unsigned half-float block-compressed (BC6H compression) format */
  605. CU_AD_FORMAT_BC6H_SF16 = 0x9c, /**< 3 channel signed half-float block-compressed (BC6H compression) format */
  606. CU_AD_FORMAT_BC7_UNORM = 0x9d, /**< 4 channel unsigned normalized block-compressed (BC7 compression) format */
  607. CU_AD_FORMAT_BC7_UNORM_SRGB = 0x9e, /**< 4 channel unsigned normalized block-compressed (BC7 compression) format with sRGB encoding */
  608. CU_AD_FORMAT_P010 = 0x9f, /**< 10-bit YUV planar format, with 4:2:0 sampling */
  609. CU_AD_FORMAT_P016 = 0xa1, /**< 16-bit YUV planar format, with 4:2:0 sampling */
  610. CU_AD_FORMAT_NV16 = 0xa2, /**< 8-bit YUV planar format, with 4:2:2 sampling */
  611. CU_AD_FORMAT_P210 = 0xa3, /**< 10-bit YUV planar format, with 4:2:2 sampling */
  612. CU_AD_FORMAT_P216 = 0xa4, /**< 16-bit YUV planar format, with 4:2:2 sampling */
  613. CU_AD_FORMAT_YUY2 = 0xa5, /**< 2 channel, 8-bit YUV packed planar format, with 4:2:2 sampling */
  614. CU_AD_FORMAT_Y210 = 0xa6, /**< 2 channel, 10-bit YUV packed planar format, with 4:2:2 sampling */
  615. CU_AD_FORMAT_Y216 = 0xa7, /**< 2 channel, 16-bit YUV packed planar format, with 4:2:2 sampling */
  616. CU_AD_FORMAT_AYUV = 0xa8, /**< 4 channel, 8-bit YUV packed planar format, with 4:4:4 sampling */
  617. CU_AD_FORMAT_Y410 = 0xa9, /**< 10-bit YUV packed planar format, with 4:4:4 sampling */
  618. CU_AD_FORMAT_Y416 = 0xb1, /**< 4 channel, 12-bit YUV packed planar format, with 4:4:4 sampling */
  619. CU_AD_FORMAT_Y444_PLANAR8 = 0xb2, /**< 3 channel 8-bit YUV planar format, with 4:4:4 sampling */
  620. CU_AD_FORMAT_Y444_PLANAR10 = 0xb3, /**< 3 channel 10-bit YUV planar format, with 4:4:4 sampling */
  621. CU_AD_FORMAT_YUV444_8bit_SemiPlanar = 0xb4, /**< 3 channel 8-bit YUV semi-planar format, with 4:4:4 sampling */
  622. CU_AD_FORMAT_YUV444_16bit_SemiPlanar = 0xb5, /**< 3 channel 16-bit YUV semi-planar format, with 4:4:4 sampling */
  623. CU_AD_FORMAT_UNORM_INT_101010_2 = 0x50, /**< 4 channel unorm R10G10B10A2 RGB format */
  624. CU_AD_FORMAT_MAX = 0x7FFFFFFF
  625. } CUarray_format;
  626. /**
  627. * Texture reference addressing modes
  628. */
  629. typedef enum CUaddress_mode_enum {
  630. CU_TR_ADDRESS_MODE_WRAP = 0, /**< Wrapping address mode */
  631. CU_TR_ADDRESS_MODE_CLAMP = 1, /**< Clamp to edge address mode */
  632. CU_TR_ADDRESS_MODE_MIRROR = 2, /**< Mirror address mode */
  633. CU_TR_ADDRESS_MODE_BORDER = 3 /**< Border address mode */
  634. } CUaddress_mode;
  635. /**
  636. * Texture reference filtering modes
  637. */
  638. typedef enum CUfilter_mode_enum {
  639. CU_TR_FILTER_MODE_POINT = 0, /**< Point filter mode */
  640. CU_TR_FILTER_MODE_LINEAR = 1 /**< Linear filter mode */
  641. } CUfilter_mode;
  642. /**
  643. * Device properties
  644. */
  645. typedef enum CUdevice_attribute_enum {
  646. CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 1, /**< Maximum number of threads per block */
  647. CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X = 2, /**< Maximum block dimension X */
  648. CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y = 3, /**< Maximum block dimension Y */
  649. CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z = 4, /**< Maximum block dimension Z */
  650. CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 5, /**< Maximum grid dimension X */
  651. CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y = 6, /**< Maximum grid dimension Y */
  652. CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z = 7, /**< Maximum grid dimension Z */
  653. CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK = 8, /**< Maximum shared memory available per block in bytes */
  654. CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK = 8, /**< Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK */
  655. CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY = 9, /**< Memory available on device for __constant__ variables in a CUDA C kernel in bytes */
  656. CU_DEVICE_ATTRIBUTE_WARP_SIZE = 10, /**< Warp size in threads */
  657. CU_DEVICE_ATTRIBUTE_MAX_PITCH = 11, /**< Maximum pitch in bytes allowed by memory copies */
  658. CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK = 12, /**< Maximum number of 32-bit registers available per block */
  659. CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK = 12, /**< Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK */
  660. CU_DEVICE_ATTRIBUTE_CLOCK_RATE = 13, /**< Typical clock frequency in kilohertz */
  661. CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT = 14, /**< Alignment requirement for textures */
  662. CU_DEVICE_ATTRIBUTE_GPU_OVERLAP = 15, /**< Device can possibly copy memory and execute a kernel concurrently. Deprecated. Use instead CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT. */
  663. CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT = 16, /**< Number of multiprocessors on device */
  664. CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT = 17, /**< Specifies whether there is a run time limit on kernels */
  665. CU_DEVICE_ATTRIBUTE_INTEGRATED = 18, /**< Device is integrated with host memory */
  666. CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY = 19, /**< Device can map host memory into CUDA address space */
  667. CU_DEVICE_ATTRIBUTE_COMPUTE_MODE = 20, /**< Compute mode (See ::CUcomputemode for details) */
  668. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH = 21, /**< Maximum 1D texture width */
  669. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH = 22, /**< Maximum 2D texture width */
  670. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT = 23, /**< Maximum 2D texture height */
  671. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH = 24, /**< Maximum 3D texture width */
  672. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT = 25, /**< Maximum 3D texture height */
  673. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH = 26, /**< Maximum 3D texture depth */
  674. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH = 27, /**< Maximum 2D layered texture width */
  675. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT = 28, /**< Maximum 2D layered texture height */
  676. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS = 29, /**< Maximum layers in a 2D layered texture */
  677. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH = 27, /**< Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH */
  678. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT = 28, /**< Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT */
  679. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES = 29, /**< Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS */
  680. CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT = 30, /**< Alignment requirement for surfaces */
  681. CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS = 31, /**< Device can possibly execute multiple kernels concurrently */
  682. CU_DEVICE_ATTRIBUTE_ECC_ENABLED = 32, /**< Device has ECC support enabled */
  683. CU_DEVICE_ATTRIBUTE_PCI_BUS_ID = 33, /**< PCI bus ID of the device */
  684. CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID = 34, /**< PCI device ID of the device */
  685. CU_DEVICE_ATTRIBUTE_TCC_DRIVER = 35, /**< Device is using TCC driver model */
  686. CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE = 36, /**< Peak memory clock frequency in kilohertz */
  687. CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH = 37, /**< Global memory bus width in bits */
  688. CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE = 38, /**< Size of L2 cache in bytes */
  689. CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR = 39, /**< Maximum resident threads per multiprocessor */
  690. CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT = 40, /**< Number of asynchronous engines */
  691. CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING = 41, /**< Device shares a unified address space with the host */
  692. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH = 42, /**< Maximum 1D layered texture width */
  693. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS = 43, /**< Maximum layers in a 1D layered texture */
  694. CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER = 44, /**< Deprecated, do not use. */
  695. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH = 45, /**< Maximum 2D texture width if CUDA_ARRAY3D_TEXTURE_GATHER is set */
  696. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT = 46, /**< Maximum 2D texture height if CUDA_ARRAY3D_TEXTURE_GATHER is set */
  697. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE = 47, /**< Alternate maximum 3D texture width */
  698. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE = 48, /**< Alternate maximum 3D texture height */
  699. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE = 49, /**< Alternate maximum 3D texture depth */
  700. CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID = 50, /**< PCI domain ID of the device */
  701. CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT = 51, /**< Pitch alignment requirement for textures */
  702. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH = 52, /**< Maximum cubemap texture width/height */
  703. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH = 53, /**< Maximum cubemap layered texture width/height */
  704. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS = 54, /**< Maximum layers in a cubemap layered texture */
  705. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH = 55, /**< Maximum 1D surface width */
  706. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH = 56, /**< Maximum 2D surface width */
  707. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT = 57, /**< Maximum 2D surface height */
  708. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH = 58, /**< Maximum 3D surface width */
  709. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT = 59, /**< Maximum 3D surface height */
  710. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH = 60, /**< Maximum 3D surface depth */
  711. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH = 61, /**< Maximum 1D layered surface width */
  712. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS = 62, /**< Maximum layers in a 1D layered surface */
  713. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH = 63, /**< Maximum 2D layered surface width */
  714. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT = 64, /**< Maximum 2D layered surface height */
  715. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS = 65, /**< Maximum layers in a 2D layered surface */
  716. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH = 66, /**< Maximum cubemap surface width */
  717. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH = 67, /**< Maximum cubemap layered surface width */
  718. CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS = 68, /**< Maximum layers in a cubemap layered surface */
  719. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH = 69, /**< Deprecated, do not use. Use cudaDeviceGetTexture1DLinearMaxWidth() or cuDeviceGetTexture1DLinearMaxWidth() instead. */
  720. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH = 70, /**< Maximum 2D linear texture width */
  721. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT = 71, /**< Maximum 2D linear texture height */
  722. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH = 72, /**< Maximum 2D linear texture pitch in bytes */
  723. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH = 73, /**< Maximum mipmapped 2D texture width */
  724. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT = 74, /**< Maximum mipmapped 2D texture height */
  725. CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75, /**< Major compute capability version number */
  726. CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76, /**< Minor compute capability version number */
  727. CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH = 77, /**< Maximum mipmapped 1D texture width */
  728. CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED = 78, /**< Device supports stream priorities */
  729. CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED = 79, /**< Device supports caching globals in L1 */
  730. CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED = 80, /**< Device supports caching locals in L1 */
  731. CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR = 81, /**< Maximum shared memory available per multiprocessor in bytes */
  732. CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR = 82, /**< Maximum number of 32-bit registers available per multiprocessor */
  733. CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY = 83, /**< Device can allocate managed memory on this system */
  734. CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD = 84, /**< Device is on a multi-GPU board */
  735. CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID = 85, /**< Unique id for a group of devices on the same multi-GPU board */
  736. CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED = 86, /**< Link between the device and the host supports native atomic operations (this is a placeholder attribute, and is not supported on any current hardware)*/
  737. CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO = 87, /**< Ratio of single precision performance (in floating-point operations per second) to double precision performance */
  738. CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS = 88, /**< Device supports coherently accessing pageable memory without calling cudaHostRegister on it */
  739. CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS = 89, /**< Device can coherently access managed memory concurrently with the CPU */
  740. CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED = 90, /**< Device supports compute preemption. */
  741. CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM = 91, /**< Device can access host registered memory at the same virtual address as the CPU */
  742. CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_MEM_OPS_V1 = 92, /**< Deprecated, along with v1 MemOps API, ::cuStreamBatchMemOp and related APIs are supported. */
  743. CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS_V1 = 93, /**< Deprecated, along with v1 MemOps API, 64-bit operations are supported in ::cuStreamBatchMemOp and related APIs. */
  744. CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_WAIT_VALUE_NOR_V1 = 94, /**< Deprecated, along with v1 MemOps API, ::CU_STREAM_WAIT_VALUE_NOR is supported. */
  745. CU_DEVICE_ATTRIBUTE_COOPERATIVE_LAUNCH = 95, /**< Device supports launching cooperative kernels via ::cuLaunchCooperativeKernel */
  746. CU_DEVICE_ATTRIBUTE_COOPERATIVE_MULTI_DEVICE_LAUNCH = 96, /**< Deprecated, ::cuLaunchCooperativeKernelMultiDevice is deprecated. */
  747. CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN = 97, /**< Maximum optin shared memory per block */
  748. CU_DEVICE_ATTRIBUTE_CAN_FLUSH_REMOTE_WRITES = 98, /**< The ::CU_STREAM_WAIT_VALUE_FLUSH flag and the ::CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES MemOp are supported on the device. See \ref CUDA_MEMOP for additional details. */
  749. CU_DEVICE_ATTRIBUTE_HOST_REGISTER_SUPPORTED = 99, /**< Device supports host memory registration via ::cudaHostRegister. */
  750. CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES = 100, /**< Device accesses pageable memory via the host's page tables. */
  751. CU_DEVICE_ATTRIBUTE_DIRECT_MANAGED_MEM_ACCESS_FROM_HOST = 101, /**< The host can directly access managed memory on the device without migration. */
  752. CU_DEVICE_ATTRIBUTE_VIRTUAL_ADDRESS_MANAGEMENT_SUPPORTED = 102, /**< Deprecated, Use CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED*/
  753. CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED = 102, /**< Device supports virtual memory management APIs like ::cuMemAddressReserve, ::cuMemCreate, ::cuMemMap and related APIs */
  754. CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR_SUPPORTED = 103, /**< Device supports exporting memory to a posix file descriptor with ::cuMemExportToShareableHandle, if requested via ::cuMemCreate */
  755. CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_HANDLE_SUPPORTED = 104, /**< Device supports exporting memory to a Win32 NT handle with ::cuMemExportToShareableHandle, if requested via ::cuMemCreate */
  756. CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_KMT_HANDLE_SUPPORTED = 105, /**< Device supports exporting memory to a Win32 KMT handle with ::cuMemExportToShareableHandle, if requested via ::cuMemCreate */
  757. CU_DEVICE_ATTRIBUTE_MAX_BLOCKS_PER_MULTIPROCESSOR = 106, /**< Maximum number of blocks per multiprocessor */
  758. CU_DEVICE_ATTRIBUTE_GENERIC_COMPRESSION_SUPPORTED = 107, /**< Device supports compression of memory */
  759. CU_DEVICE_ATTRIBUTE_MAX_PERSISTING_L2_CACHE_SIZE = 108, /**< Maximum L2 persisting lines capacity setting in bytes. */
  760. CU_DEVICE_ATTRIBUTE_MAX_ACCESS_POLICY_WINDOW_SIZE = 109, /**< Maximum value of CUaccessPolicyWindow::num_bytes. */
  761. CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED = 110, /**< Device supports specifying the GPUDirect RDMA flag with ::cuMemCreate */
  762. CU_DEVICE_ATTRIBUTE_RESERVED_SHARED_MEMORY_PER_BLOCK = 111, /**< Shared memory reserved by CUDA driver per block in bytes */
  763. CU_DEVICE_ATTRIBUTE_SPARSE_CUDA_ARRAY_SUPPORTED = 112, /**< Device supports sparse CUDA arrays and sparse CUDA mipmapped arrays */
  764. CU_DEVICE_ATTRIBUTE_READ_ONLY_HOST_REGISTER_SUPPORTED = 113, /**< Device supports using the ::cuMemHostRegister flag ::CU_MEMHOSTERGISTER_READ_ONLY to register memory that must be mapped as read-only to the GPU */
  765. CU_DEVICE_ATTRIBUTE_TIMELINE_SEMAPHORE_INTEROP_SUPPORTED = 114, /**< External timeline semaphore interop is supported on the device */
  766. CU_DEVICE_ATTRIBUTE_MEMORY_POOLS_SUPPORTED = 115, /**< Device supports using the ::cuMemAllocAsync and ::cuMemPool family of APIs */
  767. CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_SUPPORTED = 116, /**< Device supports GPUDirect RDMA APIs, like nvidia_p2p_get_pages (see https://docs.nvidia.com/cuda/gpudirect-rdma for more information) */
  768. CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_FLUSH_WRITES_OPTIONS = 117, /**< The returned attribute shall be interpreted as a bitmask, where the individual bits are described by the ::CUflushGPUDirectRDMAWritesOptions enum */
  769. CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WRITES_ORDERING = 118, /**< GPUDirect RDMA writes to the device do not need to be flushed for consumers within the scope indicated by the returned attribute. See ::CUGPUDirectRDMAWritesOrdering for the numerical values returned here. */
  770. CU_DEVICE_ATTRIBUTE_MEMPOOL_SUPPORTED_HANDLE_TYPES = 119, /**< Handle types supported with mempool based IPC */
  771. CU_DEVICE_ATTRIBUTE_CLUSTER_LAUNCH = 120, /**< Indicates device supports cluster launch */
  772. CU_DEVICE_ATTRIBUTE_DEFERRED_MAPPING_CUDA_ARRAY_SUPPORTED = 121, /**< Device supports deferred mapping CUDA arrays and CUDA mipmapped arrays */
  773. CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS = 122, /**< 64-bit operations are supported in ::cuStreamBatchMemOp and related MemOp APIs. */
  774. CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_WAIT_VALUE_NOR = 123, /**< ::CU_STREAM_WAIT_VALUE_NOR is supported by MemOp APIs. */
  775. CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED = 124, /**< Device supports buffer sharing with dma_buf mechanism. */
  776. CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED = 125, /**< Device supports IPC Events. */
  777. CU_DEVICE_ATTRIBUTE_MEM_SYNC_DOMAIN_COUNT = 126, /**< Number of memory domains the device supports. */
  778. CU_DEVICE_ATTRIBUTE_TENSOR_MAP_ACCESS_SUPPORTED = 127, /**< Device supports accessing memory using Tensor Map. */
  779. CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_FABRIC_SUPPORTED = 128, /**< Device supports exporting memory to a fabric handle with cuMemExportToShareableHandle() or requested with cuMemCreate() */
  780. CU_DEVICE_ATTRIBUTE_UNIFIED_FUNCTION_POINTERS = 129, /**< Device supports unified function pointers. */
  781. CU_DEVICE_ATTRIBUTE_NUMA_CONFIG = 130, /**< NUMA configuration of a device: value is of type ::CUdeviceNumaConfig enum */
  782. CU_DEVICE_ATTRIBUTE_NUMA_ID = 131, /**< NUMA node ID of the GPU memory */
  783. CU_DEVICE_ATTRIBUTE_MULTICAST_SUPPORTED = 132, /**< Device supports switch multicast and reduction operations. */
  784. CU_DEVICE_ATTRIBUTE_MPS_ENABLED = 133, /**< Indicates if contexts created on this device will be shared via MPS */
  785. CU_DEVICE_ATTRIBUTE_HOST_NUMA_ID = 134, /**< NUMA ID of the host node closest to the device. Returns -1 when system does not support NUMA. */
  786. CU_DEVICE_ATTRIBUTE_D3D12_CIG_SUPPORTED = 135, /**< Device supports CIG with D3D12. */
  787. CU_DEVICE_ATTRIBUTE_MEM_DECOMPRESS_ALGORITHM_MASK = 136, /**< The returned valued shall be interpreted as a bitmask, where the individual bits are described by the ::CUmemDecompressAlgorithm enum. */
  788. CU_DEVICE_ATTRIBUTE_MEM_DECOMPRESS_MAXIMUM_LENGTH = 137, /**< The returned valued is the maximum length in bytes of a single decompress operation that is allowed. */
  789. CU_DEVICE_ATTRIBUTE_GPU_PCI_DEVICE_ID = 139, /**< The combined 16-bit PCI device ID and 16-bit PCI vendor ID. */
  790. CU_DEVICE_ATTRIBUTE_GPU_PCI_SUBSYSTEM_ID = 140, /**< The combined 16-bit PCI subsystem ID and 16-bit PCI subsystem vendor ID. */
  791. CU_DEVICE_ATTRIBUTE_HOST_NUMA_MULTINODE_IPC_SUPPORTED = 143, /**< Device supports HOST_NUMA location IPC between nodes in a multi-node system. */
  792. CU_DEVICE_ATTRIBUTE_MAX
  793. } CUdevice_attribute;
  794. /**
  795. * Legacy device properties
  796. */
  797. typedef struct CUdevprop_st {
  798. int maxThreadsPerBlock; /**< Maximum number of threads per block */
  799. int maxThreadsDim[3]; /**< Maximum size of each dimension of a block */
  800. int maxGridSize[3]; /**< Maximum size of each dimension of a grid */
  801. int sharedMemPerBlock; /**< Shared memory available per block in bytes */
  802. int totalConstantMemory; /**< Constant memory available on device in bytes */
  803. int SIMDWidth; /**< Warp size in threads */
  804. int memPitch; /**< Maximum pitch in bytes allowed by memory copies */
  805. int regsPerBlock; /**< 32-bit registers available per block */
  806. int clockRate; /**< Clock frequency in kilohertz */
  807. int textureAlign; /**< Alignment requirement for textures */
  808. } CUdevprop_v1;
  809. typedef CUdevprop_v1 CUdevprop;
  810. /**
  811. * Pointer information
  812. */
  813. typedef enum CUpointer_attribute_enum {
  814. CU_POINTER_ATTRIBUTE_CONTEXT = 1, /**< The ::CUcontext on which a pointer was allocated or registered */
  815. CU_POINTER_ATTRIBUTE_MEMORY_TYPE = 2, /**< The ::CUmemorytype describing the physical location of a pointer */
  816. CU_POINTER_ATTRIBUTE_DEVICE_POINTER = 3, /**< The address at which a pointer's memory may be accessed on the device */
  817. CU_POINTER_ATTRIBUTE_HOST_POINTER = 4, /**< The address at which a pointer's memory may be accessed on the host */
  818. CU_POINTER_ATTRIBUTE_P2P_TOKENS = 5, /**< A pair of tokens for use with the nv-p2p.h Linux kernel interface */
  819. CU_POINTER_ATTRIBUTE_SYNC_MEMOPS = 6, /**< Synchronize every synchronous memory operation initiated on this region */
  820. CU_POINTER_ATTRIBUTE_BUFFER_ID = 7, /**< A process-wide unique ID for an allocated memory region*/
  821. CU_POINTER_ATTRIBUTE_IS_MANAGED = 8, /**< Indicates if the pointer points to managed memory */
  822. CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL = 9, /**< A device ordinal of a device on which a pointer was allocated or registered */
  823. CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE = 10, /**< 1 if this pointer maps to an allocation that is suitable for ::cudaIpcGetMemHandle, 0 otherwise **/
  824. CU_POINTER_ATTRIBUTE_RANGE_START_ADDR = 11, /**< Starting address for this requested pointer */
  825. CU_POINTER_ATTRIBUTE_RANGE_SIZE = 12, /**< Size of the address range for this requested pointer */
  826. CU_POINTER_ATTRIBUTE_MAPPED = 13, /**< 1 if this pointer is in a valid address range that is mapped to a backing allocation, 0 otherwise **/
  827. CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES = 14, /**< Bitmask of allowed ::CUmemAllocationHandleType for this allocation **/
  828. CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE = 15, /**< 1 if the memory this pointer is referencing can be used with the GPUDirect RDMA API **/
  829. CU_POINTER_ATTRIBUTE_ACCESS_FLAGS = 16, /**< Returns the access flags the device associated with the current context has on the corresponding memory referenced by the pointer given */
  830. CU_POINTER_ATTRIBUTE_MEMPOOL_HANDLE = 17, /**< Returns the mempool handle for the allocation if it was allocated from a mempool. Otherwise returns NULL. **/
  831. CU_POINTER_ATTRIBUTE_MAPPING_SIZE = 18, /**< Size of the actual underlying mapping that the pointer belongs to **/
  832. CU_POINTER_ATTRIBUTE_MAPPING_BASE_ADDR = 19, /**< The start address of the mapping that the pointer belongs to **/
  833. CU_POINTER_ATTRIBUTE_MEMORY_BLOCK_ID = 20 /**< A process-wide unique id corresponding to the physical allocation the pointer belongs to **/
  834. , CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE = 21 /**< Returns in \p *data a boolean that indicates whether the pointer points to memory that is capable to be used for hardware accelerated decompression. */
  835. } CUpointer_attribute;
  836. /**
  837. * Function properties
  838. */
  839. typedef enum CUfunction_attribute_enum {
  840. /**
  841. * The maximum number of threads per block, beyond which a launch of the
  842. * function would fail. This number depends on both the function and the
  843. * device on which the function is currently loaded.
  844. */
  845. CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 0,
  846. /**
  847. * The size in bytes of statically-allocated shared memory required by
  848. * this function. This does not include dynamically-allocated shared
  849. * memory requested by the user at runtime.
  850. */
  851. CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES = 1,
  852. /**
  853. * The size in bytes of user-allocated constant memory required by this
  854. * function.
  855. */
  856. CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES = 2,
  857. /**
  858. * The size in bytes of local memory used by each thread of this function.
  859. */
  860. CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES = 3,
  861. /**
  862. * The number of registers used by each thread of this function.
  863. */
  864. CU_FUNC_ATTRIBUTE_NUM_REGS = 4,
  865. /**
  866. * The PTX virtual architecture version for which the function was
  867. * compiled. This value is the major PTX version * 10 + the minor PTX
  868. * version, so a PTX version 1.3 function would return the value 13.
  869. * Note that this may return the undefined value of 0 for cubins
  870. * compiled prior to CUDA 3.0.
  871. */
  872. CU_FUNC_ATTRIBUTE_PTX_VERSION = 5,
  873. /**
  874. * The binary architecture version for which the function was compiled.
  875. * This value is the major binary version * 10 + the minor binary version,
  876. * so a binary version 1.3 function would return the value 13. Note that
  877. * this will return a value of 10 for legacy cubins that do not have a
  878. * properly-encoded binary architecture version.
  879. */
  880. CU_FUNC_ATTRIBUTE_BINARY_VERSION = 6,
  881. /**
  882. * The attribute to indicate whether the function has been compiled with
  883. * user specified option "-Xptxas --dlcm=ca" set .
  884. */
  885. CU_FUNC_ATTRIBUTE_CACHE_MODE_CA = 7,
  886. /**
  887. * The maximum size in bytes of dynamically-allocated shared memory that can be used by
  888. * this function. If the user-specified dynamic shared memory size is larger than this
  889. * value, the launch will fail.
  890. * See ::cuFuncSetAttribute, ::cuKernelSetAttribute
  891. */
  892. CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES = 8,
  893. /**
  894. * On devices where the L1 cache and shared memory use the same hardware resources,
  895. * this sets the shared memory carveout preference, in percent of the total shared memory.
  896. * Refer to ::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR.
  897. * This is only a hint, and the driver can choose a different ratio if required to execute the function.
  898. * See ::cuFuncSetAttribute, ::cuKernelSetAttribute
  899. */
  900. CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT = 9,
  901. /**
  902. * If this attribute is set, the kernel must launch with a valid cluster
  903. * size specified.
  904. * See ::cuFuncSetAttribute, ::cuKernelSetAttribute
  905. */
  906. CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET = 10,
  907. /**
  908. * The required cluster width in blocks. The values must either all be 0 or
  909. * all be positive. The validity of the cluster dimensions is otherwise
  910. * checked at launch time.
  911. *
  912. * If the value is set during compile time, it cannot be set at runtime.
  913. * Setting it at runtime will return CUDA_ERROR_NOT_PERMITTED.
  914. * See ::cuFuncSetAttribute, ::cuKernelSetAttribute
  915. */
  916. CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH = 11,
  917. /**
  918. * The required cluster height in blocks. The values must either all be 0 or
  919. * all be positive. The validity of the cluster dimensions is otherwise
  920. * checked at launch time.
  921. *
  922. * If the value is set during compile time, it cannot be set at runtime.
  923. * Setting it at runtime should return CUDA_ERROR_NOT_PERMITTED.
  924. * See ::cuFuncSetAttribute, ::cuKernelSetAttribute
  925. */
  926. CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT = 12,
  927. /**
  928. * The required cluster depth in blocks. The values must either all be 0 or
  929. * all be positive. The validity of the cluster dimensions is otherwise
  930. * checked at launch time.
  931. *
  932. * If the value is set during compile time, it cannot be set at runtime.
  933. * Setting it at runtime should return CUDA_ERROR_NOT_PERMITTED.
  934. * See ::cuFuncSetAttribute, ::cuKernelSetAttribute
  935. */
  936. CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH = 13,
  937. /**
  938. * Whether the function can be launched with non-portable cluster size. 1 is
  939. * allowed, 0 is disallowed. A non-portable cluster size may only function
  940. * on the specific SKUs the program is tested on. The launch might fail if
  941. * the program is run on a different hardware platform.
  942. *
  943. * CUDA API provides cudaOccupancyMaxActiveClusters to assist with checking
  944. * whether the desired size can be launched on the current device.
  945. *
  946. * Portable Cluster Size
  947. *
  948. * A portable cluster size is guaranteed to be functional on all compute
  949. * capabilities higher than the target compute capability. The portable
  950. * cluster size for sm_90 is 8 blocks per cluster. This value may increase
  951. * for future compute capabilities.
  952. *
  953. * The specific hardware unit may support higher cluster sizes that’s not
  954. * guaranteed to be portable.
  955. * See ::cuFuncSetAttribute, ::cuKernelSetAttribute
  956. */
  957. CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED = 14,
  958. /**
  959. * The block scheduling policy of a function. The value type is
  960. * CUclusterSchedulingPolicy / cudaClusterSchedulingPolicy.
  961. * See ::cuFuncSetAttribute, ::cuKernelSetAttribute
  962. */
  963. CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE = 15,
  964. CU_FUNC_ATTRIBUTE_MAX
  965. } CUfunction_attribute;
  966. /**
  967. * Function cache configurations
  968. */
  969. typedef enum CUfunc_cache_enum {
  970. CU_FUNC_CACHE_PREFER_NONE = 0x00, /**< no preference for shared memory or L1 (default) */
  971. CU_FUNC_CACHE_PREFER_SHARED = 0x01, /**< prefer larger shared memory and smaller L1 cache */
  972. CU_FUNC_CACHE_PREFER_L1 = 0x02, /**< prefer larger L1 cache and smaller shared memory */
  973. CU_FUNC_CACHE_PREFER_EQUAL = 0x03 /**< prefer equal sized L1 cache and shared memory */
  974. } CUfunc_cache;
  975. /**
  976. * \deprecated
  977. *
  978. * Shared memory configurations
  979. */
  980. typedef enum CUsharedconfig_enum {
  981. CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE = 0x00, /**< set default shared memory bank size */
  982. CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE = 0x01, /**< set shared memory bank width to four bytes */
  983. CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE = 0x02 /**< set shared memory bank width to eight bytes */
  984. } CUsharedconfig;
  985. /**
  986. * Shared memory carveout configurations. These may be passed to ::cuFuncSetAttribute or ::cuKernelSetAttribute
  987. */
  988. typedef enum CUshared_carveout_enum {
  989. CU_SHAREDMEM_CARVEOUT_DEFAULT = -1, /**< No preference for shared memory or L1 (default) */
  990. CU_SHAREDMEM_CARVEOUT_MAX_SHARED = 100, /**< Prefer maximum available shared memory, minimum L1 cache */
  991. CU_SHAREDMEM_CARVEOUT_MAX_L1 = 0 /**< Prefer maximum available L1 cache, minimum shared memory */
  992. } CUshared_carveout;
  993. /**
  994. * Memory types
  995. */
  996. typedef enum CUmemorytype_enum {
  997. CU_MEMORYTYPE_HOST = 0x01, /**< Host memory */
  998. CU_MEMORYTYPE_DEVICE = 0x02, /**< Device memory */
  999. CU_MEMORYTYPE_ARRAY = 0x03, /**< Array memory */
  1000. CU_MEMORYTYPE_UNIFIED = 0x04 /**< Unified device or host memory */
  1001. } CUmemorytype;
  1002. /**
  1003. * Compute Modes
  1004. */
  1005. typedef enum CUcomputemode_enum {
  1006. CU_COMPUTEMODE_DEFAULT = 0, /**< Default compute mode (Multiple contexts allowed per device) */
  1007. CU_COMPUTEMODE_PROHIBITED = 2, /**< Compute-prohibited mode (No contexts can be created on this device at this time) */
  1008. CU_COMPUTEMODE_EXCLUSIVE_PROCESS = 3 /**< Compute-exclusive-process mode (Only one context used by a single process can be present on this device at a time) */
  1009. } CUcomputemode;
  1010. /**
  1011. * Memory advise values
  1012. */
  1013. typedef enum CUmem_advise_enum {
  1014. CU_MEM_ADVISE_SET_READ_MOSTLY = 1, /**< Data will mostly be read and only occasionally be written to */
  1015. CU_MEM_ADVISE_UNSET_READ_MOSTLY = 2, /**< Undo the effect of ::CU_MEM_ADVISE_SET_READ_MOSTLY */
  1016. CU_MEM_ADVISE_SET_PREFERRED_LOCATION = 3, /**< Set the preferred location for the data as the specified device */
  1017. CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION = 4, /**< Clear the preferred location for the data */
  1018. CU_MEM_ADVISE_SET_ACCESSED_BY = 5, /**< Data will be accessed by the specified device, so prevent page faults as much as possible */
  1019. CU_MEM_ADVISE_UNSET_ACCESSED_BY = 6 /**< Let the Unified Memory subsystem decide on the page faulting policy for the specified device */
  1020. } CUmem_advise;
  1021. typedef enum CUmem_range_attribute_enum {
  1022. CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY = 1, /**< Whether the range will mostly be read and only occasionally be written to */
  1023. CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION = 2, /**< The preferred location of the range */
  1024. CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY = 3, /**< Memory range has ::CU_MEM_ADVISE_SET_ACCESSED_BY set for specified device */
  1025. CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION = 4 /**< The last location to which the range was prefetched */
  1026. , CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE = 5 /**< The preferred location type of the range */
  1027. , CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_ID = 6 /**< The preferred location id of the range */
  1028. , CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE = 7 /**< The last location type to which the range was prefetched */
  1029. , CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_ID = 8 /**< The last location id to which the range was prefetched */
  1030. } CUmem_range_attribute;
  1031. /**
  1032. * Online compiler and linker options
  1033. */
  1034. typedef enum CUjit_option_enum
  1035. {
  1036. /**
  1037. * Max number of registers that a thread may use.\n
  1038. * Option type: unsigned int\n
  1039. * Applies to: compiler only
  1040. */
  1041. CU_JIT_MAX_REGISTERS = 0,
  1042. /**
  1043. * IN: Specifies minimum number of threads per block to target compilation
  1044. * for\n
  1045. * OUT: Returns the number of threads the compiler actually targeted.
  1046. * This restricts the resource utilization of the compiler (e.g. max
  1047. * registers) such that a block with the given number of threads should be
  1048. * able to launch based on register limitations. Note, this option does not
  1049. * currently take into account any other resource limitations, such as
  1050. * shared memory utilization.\n
  1051. * Cannot be combined with ::CU_JIT_TARGET.\n
  1052. * Option type: unsigned int\n
  1053. * Applies to: compiler only
  1054. */
  1055. CU_JIT_THREADS_PER_BLOCK = 1,
  1056. /**
  1057. * Overwrites the option value with the total wall clock time, in
  1058. * milliseconds, spent in the compiler and linker\n
  1059. * Option type: float\n
  1060. * Applies to: compiler and linker
  1061. */
  1062. CU_JIT_WALL_TIME = 2,
  1063. /**
  1064. * Pointer to a buffer in which to print any log messages
  1065. * that are informational in nature (the buffer size is specified via
  1066. * option ::CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES)\n
  1067. * Option type: char *\n
  1068. * Applies to: compiler and linker
  1069. */
  1070. CU_JIT_INFO_LOG_BUFFER = 3,
  1071. /**
  1072. * IN: Log buffer size in bytes. Log messages will be capped at this size
  1073. * (including null terminator)\n
  1074. * OUT: Amount of log buffer filled with messages\n
  1075. * Option type: unsigned int\n
  1076. * Applies to: compiler and linker
  1077. */
  1078. CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES = 4,
  1079. /**
  1080. * Pointer to a buffer in which to print any log messages that
  1081. * reflect errors (the buffer size is specified via option
  1082. * ::CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES)\n
  1083. * Option type: char *\n
  1084. * Applies to: compiler and linker
  1085. */
  1086. CU_JIT_ERROR_LOG_BUFFER = 5,
  1087. /**
  1088. * IN: Log buffer size in bytes. Log messages will be capped at this size
  1089. * (including null terminator)\n
  1090. * OUT: Amount of log buffer filled with messages\n
  1091. * Option type: unsigned int\n
  1092. * Applies to: compiler and linker
  1093. */
  1094. CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES = 6,
  1095. /**
  1096. * Level of optimizations to apply to generated code (0 - 4), with 4
  1097. * being the default and highest level of optimizations.\n
  1098. * Option type: unsigned int\n
  1099. * Applies to: compiler only
  1100. */
  1101. CU_JIT_OPTIMIZATION_LEVEL = 7,
  1102. /**
  1103. * No option value required. Determines the target based on the current
  1104. * attached context (default)\n
  1105. * Option type: No option value needed\n
  1106. * Applies to: compiler and linker
  1107. */
  1108. CU_JIT_TARGET_FROM_CUCONTEXT = 8,
  1109. /**
  1110. * Target is chosen based on supplied ::CUjit_target. Cannot be
  1111. * combined with ::CU_JIT_THREADS_PER_BLOCK.\n
  1112. * Option type: unsigned int for enumerated type ::CUjit_target\n
  1113. * Applies to: compiler and linker
  1114. */
  1115. CU_JIT_TARGET = 9,
  1116. /**
  1117. * Specifies choice of fallback strategy if matching cubin is not found.
  1118. * Choice is based on supplied ::CUjit_fallback. This option cannot be
  1119. * used with cuLink* APIs as the linker requires exact matches.\n
  1120. * Option type: unsigned int for enumerated type ::CUjit_fallback\n
  1121. * Applies to: compiler only
  1122. */
  1123. CU_JIT_FALLBACK_STRATEGY = 10,
  1124. /**
  1125. * Specifies whether to create debug information in output (-g)
  1126. * (0: false, default)\n
  1127. * Option type: int\n
  1128. * Applies to: compiler and linker
  1129. */
  1130. CU_JIT_GENERATE_DEBUG_INFO = 11,
  1131. /**
  1132. * Generate verbose log messages (0: false, default)\n
  1133. * Option type: int\n
  1134. * Applies to: compiler and linker
  1135. */
  1136. CU_JIT_LOG_VERBOSE = 12,
  1137. /**
  1138. * Generate line number information (-lineinfo) (0: false, default)\n
  1139. * Option type: int\n
  1140. * Applies to: compiler only
  1141. */
  1142. CU_JIT_GENERATE_LINE_INFO = 13,
  1143. /**
  1144. * Specifies whether to enable caching explicitly (-dlcm) \n
  1145. * Choice is based on supplied ::CUjit_cacheMode_enum.\n
  1146. * Option type: unsigned int for enumerated type ::CUjit_cacheMode_enum\n
  1147. * Applies to: compiler only
  1148. */
  1149. CU_JIT_CACHE_MODE = 14,
  1150. /**
  1151. * \deprecated
  1152. * This jit option is deprecated and should not be used.
  1153. */
  1154. CU_JIT_NEW_SM3X_OPT = 15,
  1155. /**
  1156. * This jit option is used for internal purpose only.
  1157. */
  1158. CU_JIT_FAST_COMPILE = 16,
  1159. /**
  1160. * Array of device symbol names that will be relocated to the corresponding
  1161. * host addresses stored in ::CU_JIT_GLOBAL_SYMBOL_ADDRESSES.\n
  1162. * Must contain ::CU_JIT_GLOBAL_SYMBOL_COUNT entries.\n
  1163. * When loading a device module, driver will relocate all encountered
  1164. * unresolved symbols to the host addresses.\n
  1165. * It is only allowed to register symbols that correspond to unresolved
  1166. * global variables.\n
  1167. * It is illegal to register the same device symbol at multiple addresses.\n
  1168. * Option type: const char **\n
  1169. * Applies to: dynamic linker only
  1170. */
  1171. CU_JIT_GLOBAL_SYMBOL_NAMES = 17,
  1172. /**
  1173. * Array of host addresses that will be used to relocate corresponding
  1174. * device symbols stored in ::CU_JIT_GLOBAL_SYMBOL_NAMES.\n
  1175. * Must contain ::CU_JIT_GLOBAL_SYMBOL_COUNT entries.\n
  1176. * Option type: void **\n
  1177. * Applies to: dynamic linker only
  1178. */
  1179. CU_JIT_GLOBAL_SYMBOL_ADDRESSES = 18,
  1180. /**
  1181. * Number of entries in ::CU_JIT_GLOBAL_SYMBOL_NAMES and
  1182. * ::CU_JIT_GLOBAL_SYMBOL_ADDRESSES arrays.\n
  1183. * Option type: unsigned int\n
  1184. * Applies to: dynamic linker only
  1185. */
  1186. CU_JIT_GLOBAL_SYMBOL_COUNT = 19,
  1187. /**
  1188. * \deprecated
  1189. * Enable link-time optimization (-dlto) for device code (Disabled by default).\n
  1190. * This option is not supported on 32-bit platforms.\n
  1191. * Option type: int\n
  1192. * Applies to: compiler and linker
  1193. *
  1194. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1195. */
  1196. CU_JIT_LTO = 20,
  1197. /**
  1198. * \deprecated
  1199. * Control single-precision denormals (-ftz) support (0: false, default).
  1200. * 1 : flushes denormal values to zero
  1201. * 0 : preserves denormal values
  1202. * Option type: int\n
  1203. * Applies to: link-time optimization specified with CU_JIT_LTO
  1204. *
  1205. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1206. */
  1207. CU_JIT_FTZ = 21,
  1208. /**
  1209. * \deprecated
  1210. * Control single-precision floating-point division and reciprocals
  1211. * (-prec-div) support (1: true, default).
  1212. * 1 : Enables the IEEE round-to-nearest mode
  1213. * 0 : Enables the fast approximation mode
  1214. * Option type: int\n
  1215. * Applies to: link-time optimization specified with CU_JIT_LTO
  1216. *
  1217. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1218. */
  1219. CU_JIT_PREC_DIV = 22,
  1220. /**
  1221. * \deprecated
  1222. * Control single-precision floating-point square root
  1223. * (-prec-sqrt) support (1: true, default).
  1224. * 1 : Enables the IEEE round-to-nearest mode
  1225. * 0 : Enables the fast approximation mode
  1226. * Option type: int\n
  1227. * Applies to: link-time optimization specified with CU_JIT_LTO
  1228. *
  1229. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1230. */
  1231. CU_JIT_PREC_SQRT = 23,
  1232. /**
  1233. * \deprecated
  1234. * Enable/Disable the contraction of floating-point multiplies
  1235. * and adds/subtracts into floating-point multiply-add (-fma)
  1236. * operations (1: Enable, default; 0: Disable).
  1237. * Option type: int\n
  1238. * Applies to: link-time optimization specified with CU_JIT_LTO
  1239. *
  1240. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1241. */
  1242. CU_JIT_FMA = 24,
  1243. /**
  1244. * \deprecated
  1245. * Array of kernel names that should be preserved at link time while others
  1246. * can be removed.\n
  1247. * Must contain ::CU_JIT_REFERENCED_KERNEL_COUNT entries.\n
  1248. * Note that kernel names can be mangled by the compiler in which case the
  1249. * mangled name needs to be specified.\n
  1250. * Wildcard "*" can be used to represent zero or more characters instead of
  1251. * specifying the full or mangled name.\n
  1252. * It is important to note that the wildcard "*" is also added implicitly.
  1253. * For example, specifying "foo" will match "foobaz", "barfoo", "barfoobaz" and
  1254. * thus preserve all kernels with those names. This can be avoided by providing
  1255. * a more specific name like "barfoobaz".\n
  1256. * Option type: const char **\n
  1257. * Applies to: dynamic linker only
  1258. *
  1259. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1260. */
  1261. CU_JIT_REFERENCED_KERNEL_NAMES = 25,
  1262. /**
  1263. * \deprecated
  1264. * Number of entries in ::CU_JIT_REFERENCED_KERNEL_NAMES array.\n
  1265. * Option type: unsigned int\n
  1266. * Applies to: dynamic linker only
  1267. *
  1268. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1269. */
  1270. CU_JIT_REFERENCED_KERNEL_COUNT = 26,
  1271. /**
  1272. * \deprecated
  1273. * Array of variable names (__device__ and/or __constant__) that should be
  1274. * preserved at link time while others can be removed.\n
  1275. * Must contain ::CU_JIT_REFERENCED_VARIABLE_COUNT entries.\n
  1276. * Note that variable names can be mangled by the compiler in which case the
  1277. * mangled name needs to be specified.\n
  1278. * Wildcard "*" can be used to represent zero or more characters instead of
  1279. * specifying the full or mangled name.\n
  1280. * It is important to note that the wildcard "*" is also added implicitly.
  1281. * For example, specifying "foo" will match "foobaz", "barfoo", "barfoobaz" and
  1282. * thus preserve all variables with those names. This can be avoided by providing
  1283. * a more specific name like "barfoobaz".\n
  1284. * Option type: const char **\n
  1285. * Applies to: link-time optimization specified with CU_JIT_LTO
  1286. *
  1287. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1288. */
  1289. CU_JIT_REFERENCED_VARIABLE_NAMES = 27,
  1290. /**
  1291. * \deprecated
  1292. * Number of entries in ::CU_JIT_REFERENCED_VARIABLE_NAMES array.\n
  1293. * Option type: unsigned int\n
  1294. * Applies to: link-time optimization specified with CU_JIT_LTO
  1295. *
  1296. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1297. */
  1298. CU_JIT_REFERENCED_VARIABLE_COUNT = 28,
  1299. /**
  1300. * \deprecated
  1301. * This option serves as a hint to enable the JIT compiler/linker
  1302. * to remove constant (__constant__) and device (__device__) variables
  1303. * unreferenced in device code (Disabled by default).\n
  1304. * Note that host references to constant and device variables using APIs like
  1305. * ::cuModuleGetGlobal() with this option specified may result in undefined behavior unless
  1306. * the variables are explicitly specified using ::CU_JIT_REFERENCED_VARIABLE_NAMES.\n
  1307. * Option type: int\n
  1308. * Applies to: link-time optimization specified with CU_JIT_LTO
  1309. *
  1310. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1311. */
  1312. CU_JIT_OPTIMIZE_UNUSED_DEVICE_VARIABLES = 29,
  1313. /**
  1314. * Generate position independent code (0: false)\n
  1315. * Option type: int\n
  1316. * Applies to: compiler only
  1317. */
  1318. CU_JIT_POSITION_INDEPENDENT_CODE = 30,
  1319. /**
  1320. * This option hints to the JIT compiler the minimum number of CTAs from the
  1321. * kernel’s grid to be mapped to a SM. This option is ignored when used together
  1322. * with ::CU_JIT_MAX_REGISTERS or ::CU_JIT_THREADS_PER_BLOCK.
  1323. * Optimizations based on this option need ::CU_JIT_MAX_THREADS_PER_BLOCK to
  1324. * be specified as well. For kernels already using PTX directive .minnctapersm,
  1325. * this option will be ignored by default. Use ::CU_JIT_OVERRIDE_DIRECTIVE_VALUES
  1326. * to let this option take precedence over the PTX directive.
  1327. * Option type: unsigned int\n
  1328. * Applies to: compiler only
  1329. */
  1330. CU_JIT_MIN_CTA_PER_SM = 31,
  1331. /**
  1332. * Maximum number threads in a thread block, computed as the product of
  1333. * the maximum extent specifed for each dimension of the block. This limit
  1334. * is guaranteed not to be exeeded in any invocation of the kernel. Exceeding
  1335. * the the maximum number of threads results in runtime error or kernel launch
  1336. * failure. For kernels already using PTX directive .maxntid, this option will
  1337. * be ignored by default. Use ::CU_JIT_OVERRIDE_DIRECTIVE_VALUES to let this
  1338. * option take precedence over the PTX directive.
  1339. * Option type: int\n
  1340. * Applies to: compiler only
  1341. */
  1342. CU_JIT_MAX_THREADS_PER_BLOCK = 32,
  1343. /**
  1344. * This option lets the values specified using ::CU_JIT_MAX_REGISTERS,
  1345. * ::CU_JIT_THREADS_PER_BLOCK, ::CU_JIT_MAX_THREADS_PER_BLOCK and
  1346. * ::CU_JIT_MIN_CTA_PER_SM take precedence over any PTX directives.
  1347. * (0: Disable, default; 1: Enable)
  1348. * Option type: int\n
  1349. * Applies to: compiler only
  1350. */
  1351. CU_JIT_OVERRIDE_DIRECTIVE_VALUES = 33,
  1352. CU_JIT_NUM_OPTIONS
  1353. } CUjit_option;
  1354. /*
  1355. * Indicates that compute device class supports accelerated features.
  1356. */
  1357. #define CU_COMPUTE_ACCELERATED_TARGET_BASE 0x10000
  1358. /**
  1359. * Online compilation targets
  1360. */
  1361. typedef enum CUjit_target_enum
  1362. {
  1363. CU_TARGET_COMPUTE_30 = 30, /**< Compute device class 3.0 */
  1364. CU_TARGET_COMPUTE_32 = 32, /**< Compute device class 3.2 */
  1365. CU_TARGET_COMPUTE_35 = 35, /**< Compute device class 3.5 */
  1366. CU_TARGET_COMPUTE_37 = 37, /**< Compute device class 3.7 */
  1367. CU_TARGET_COMPUTE_50 = 50, /**< Compute device class 5.0 */
  1368. CU_TARGET_COMPUTE_52 = 52, /**< Compute device class 5.2 */
  1369. CU_TARGET_COMPUTE_53 = 53, /**< Compute device class 5.3 */
  1370. CU_TARGET_COMPUTE_60 = 60, /**< Compute device class 6.0.*/
  1371. CU_TARGET_COMPUTE_61 = 61, /**< Compute device class 6.1.*/
  1372. CU_TARGET_COMPUTE_62 = 62, /**< Compute device class 6.2.*/
  1373. CU_TARGET_COMPUTE_70 = 70, /**< Compute device class 7.0.*/
  1374. CU_TARGET_COMPUTE_72 = 72, /**< Compute device class 7.2.*/
  1375. CU_TARGET_COMPUTE_75 = 75, /**< Compute device class 7.5.*/
  1376. CU_TARGET_COMPUTE_80 = 80, /**< Compute device class 8.0.*/
  1377. CU_TARGET_COMPUTE_86 = 86, /**< Compute device class 8.6.*/
  1378. CU_TARGET_COMPUTE_87 = 87, /**< Compute device class 8.7.*/
  1379. CU_TARGET_COMPUTE_89 = 89, /**< Compute device class 8.9.*/
  1380. CU_TARGET_COMPUTE_90 = 90, /**< Compute device class 9.0.*/
  1381. CU_TARGET_COMPUTE_100 = 100, /**< Compute device class 10.0.*/
  1382. CU_TARGET_COMPUTE_101 = 101, /**< Compute device class 10.1.*/
  1383. CU_TARGET_COMPUTE_120 = 120, /**< Compute device class 12.0.*/
  1384. /**< Compute device class 9.0. with accelerated features.*/
  1385. CU_TARGET_COMPUTE_90A = CU_COMPUTE_ACCELERATED_TARGET_BASE + CU_TARGET_COMPUTE_90,
  1386. /**< Compute device class 10.0. with accelerated features.*/
  1387. CU_TARGET_COMPUTE_100A = CU_COMPUTE_ACCELERATED_TARGET_BASE + CU_TARGET_COMPUTE_100,
  1388. /**< Compute device class 10.1 with accelerated features.*/
  1389. CU_TARGET_COMPUTE_101A = CU_COMPUTE_ACCELERATED_TARGET_BASE + CU_TARGET_COMPUTE_101,
  1390. /**< Compute device class 12.0. with accelerated features.*/
  1391. CU_TARGET_COMPUTE_120A = CU_COMPUTE_ACCELERATED_TARGET_BASE + CU_TARGET_COMPUTE_120,
  1392. } CUjit_target;
  1393. /**
  1394. * Cubin matching fallback strategies
  1395. */
  1396. typedef enum CUjit_fallback_enum
  1397. {
  1398. CU_PREFER_PTX = 0, /**< Prefer to compile ptx if exact binary match not found */
  1399. CU_PREFER_BINARY /**< Prefer to fall back to compatible binary code if exact match not found */
  1400. } CUjit_fallback;
  1401. /**
  1402. * Caching modes for dlcm
  1403. */
  1404. typedef enum CUjit_cacheMode_enum
  1405. {
  1406. CU_JIT_CACHE_OPTION_NONE = 0, /**< Compile with no -dlcm flag specified */
  1407. CU_JIT_CACHE_OPTION_CG, /**< Compile with L1 cache disabled */
  1408. CU_JIT_CACHE_OPTION_CA /**< Compile with L1 cache enabled */
  1409. } CUjit_cacheMode;
  1410. /**
  1411. * Device code formats
  1412. */
  1413. typedef enum CUjitInputType_enum
  1414. {
  1415. /**
  1416. * Compiled device-class-specific device code\n
  1417. * Applicable options: none
  1418. */
  1419. CU_JIT_INPUT_CUBIN = 0,
  1420. /**
  1421. * PTX source code\n
  1422. * Applicable options: PTX compiler options
  1423. */
  1424. CU_JIT_INPUT_PTX = 1,
  1425. /**
  1426. * Bundle of multiple cubins and/or PTX of some device code\n
  1427. * Applicable options: PTX compiler options, ::CU_JIT_FALLBACK_STRATEGY
  1428. */
  1429. CU_JIT_INPUT_FATBINARY = 2,
  1430. /**
  1431. * Host object with embedded device code\n
  1432. * Applicable options: PTX compiler options, ::CU_JIT_FALLBACK_STRATEGY
  1433. */
  1434. CU_JIT_INPUT_OBJECT = 3,
  1435. /**
  1436. * Archive of host objects with embedded device code\n
  1437. * Applicable options: PTX compiler options, ::CU_JIT_FALLBACK_STRATEGY
  1438. */
  1439. CU_JIT_INPUT_LIBRARY = 4,
  1440. /**
  1441. * \deprecated
  1442. * High-level intermediate code for link-time optimization\n
  1443. * Applicable options: NVVM compiler options, PTX compiler options
  1444. *
  1445. * Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
  1446. */
  1447. CU_JIT_INPUT_NVVM = 5,
  1448. CU_JIT_NUM_INPUT_TYPES = 6
  1449. } CUjitInputType;
  1450. typedef struct CUlinkState_st *CUlinkState;
  1451. /**
  1452. * Flags to register a graphics resource
  1453. */
  1454. typedef enum CUgraphicsRegisterFlags_enum {
  1455. CU_GRAPHICS_REGISTER_FLAGS_NONE = 0x00,
  1456. CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY = 0x01,
  1457. CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD = 0x02,
  1458. CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST = 0x04,
  1459. CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER = 0x08
  1460. } CUgraphicsRegisterFlags;
  1461. /**
  1462. * Flags for mapping and unmapping interop resources
  1463. */
  1464. typedef enum CUgraphicsMapResourceFlags_enum {
  1465. CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = 0x00,
  1466. CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01,
  1467. CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 0x02
  1468. } CUgraphicsMapResourceFlags;
  1469. /**
  1470. * Array indices for cube faces
  1471. */
  1472. typedef enum CUarray_cubemap_face_enum {
  1473. CU_CUBEMAP_FACE_POSITIVE_X = 0x00, /**< Positive X face of cubemap */
  1474. CU_CUBEMAP_FACE_NEGATIVE_X = 0x01, /**< Negative X face of cubemap */
  1475. CU_CUBEMAP_FACE_POSITIVE_Y = 0x02, /**< Positive Y face of cubemap */
  1476. CU_CUBEMAP_FACE_NEGATIVE_Y = 0x03, /**< Negative Y face of cubemap */
  1477. CU_CUBEMAP_FACE_POSITIVE_Z = 0x04, /**< Positive Z face of cubemap */
  1478. CU_CUBEMAP_FACE_NEGATIVE_Z = 0x05 /**< Negative Z face of cubemap */
  1479. } CUarray_cubemap_face;
  1480. /**
  1481. * Limits
  1482. */
  1483. typedef enum CUlimit_enum {
  1484. CU_LIMIT_STACK_SIZE = 0x00, /**< GPU thread stack size */
  1485. CU_LIMIT_PRINTF_FIFO_SIZE = 0x01, /**< GPU printf FIFO size */
  1486. CU_LIMIT_MALLOC_HEAP_SIZE = 0x02, /**< GPU malloc heap size */
  1487. CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH = 0x03, /**< GPU device runtime launch synchronize depth */
  1488. CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT = 0x04, /**< GPU device runtime pending launch count */
  1489. CU_LIMIT_MAX_L2_FETCH_GRANULARITY = 0x05, /**< A value between 0 and 128 that indicates the maximum fetch granularity of L2 (in Bytes). This is a hint */
  1490. CU_LIMIT_PERSISTING_L2_CACHE_SIZE = 0x06, /**< A size in bytes for L2 persisting lines cache size */
  1491. CU_LIMIT_SHMEM_SIZE = 0x07, /**< A maximum size in bytes of shared memory available to CUDA kernels on a CIG context. Can only be queried, cannot be set */
  1492. CU_LIMIT_CIG_ENABLED = 0x08, /**< A non-zero value indicates this CUDA context is a CIG-enabled context. Can only be queried, cannot be set */
  1493. CU_LIMIT_CIG_SHMEM_FALLBACK_ENABLED = 0x09, /**< When set to zero, CUDA will fail to launch a kernel on a CIG context, instead of using the fallback path, if the kernel uses more shared memory than available */
  1494. CU_LIMIT_MAX
  1495. } CUlimit;
  1496. /**
  1497. * Resource types
  1498. */
  1499. typedef enum CUresourcetype_enum {
  1500. CU_RESOURCE_TYPE_ARRAY = 0x00, /**< Array resource */
  1501. CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01, /**< Mipmapped array resource */
  1502. CU_RESOURCE_TYPE_LINEAR = 0x02, /**< Linear resource */
  1503. CU_RESOURCE_TYPE_PITCH2D = 0x03 /**< Pitch 2D resource */
  1504. } CUresourcetype;
  1505. #ifdef _WIN32
  1506. #define CUDA_CB __stdcall
  1507. #else
  1508. #define CUDA_CB
  1509. #endif
  1510. /**
  1511. * CUDA host function
  1512. * \param userData Argument value passed to the function
  1513. */
  1514. typedef void (CUDA_CB *CUhostFn)(void *userData);
  1515. /**
  1516. * Specifies performance hint with ::CUaccessPolicyWindow for hitProp and missProp members.
  1517. */
  1518. typedef enum CUaccessProperty_enum {
  1519. CU_ACCESS_PROPERTY_NORMAL = 0, /**< Normal cache persistence. */
  1520. CU_ACCESS_PROPERTY_STREAMING = 1, /**< Streaming access is less likely to persit from cache. */
  1521. CU_ACCESS_PROPERTY_PERSISTING = 2 /**< Persisting access is more likely to persist in cache.*/
  1522. } CUaccessProperty;
  1523. /**
  1524. * Specifies an access policy for a window, a contiguous extent of memory
  1525. * beginning at base_ptr and ending at base_ptr + num_bytes.
  1526. * num_bytes is limited by CU_DEVICE_ATTRIBUTE_MAX_ACCESS_POLICY_WINDOW_SIZE.
  1527. * Partition into many segments and assign segments such that:
  1528. * sum of "hit segments" / window == approx. ratio.
  1529. * sum of "miss segments" / window == approx 1-ratio.
  1530. * Segments and ratio specifications are fitted to the capabilities of
  1531. * the architecture.
  1532. * Accesses in a hit segment apply the hitProp access policy.
  1533. * Accesses in a miss segment apply the missProp access policy.
  1534. */
  1535. typedef struct CUaccessPolicyWindow_st {
  1536. void *base_ptr; /**< Starting address of the access policy window. CUDA driver may align it. */
  1537. size_t num_bytes; /**< Size in bytes of the window policy. CUDA driver may restrict the maximum size and alignment. */
  1538. float hitRatio; /**< hitRatio specifies percentage of lines assigned hitProp, rest are assigned missProp. */
  1539. CUaccessProperty hitProp; /**< ::CUaccessProperty set for hit. */
  1540. CUaccessProperty missProp; /**< ::CUaccessProperty set for miss. Must be either NORMAL or STREAMING */
  1541. } CUaccessPolicyWindow_v1;
  1542. /**
  1543. * Access policy window
  1544. */
  1545. typedef CUaccessPolicyWindow_v1 CUaccessPolicyWindow;
  1546. /**
  1547. * GPU kernel node parameters
  1548. */
  1549. typedef struct CUDA_KERNEL_NODE_PARAMS_st {
  1550. CUfunction func; /**< Kernel to launch */
  1551. unsigned int gridDimX; /**< Width of grid in blocks */
  1552. unsigned int gridDimY; /**< Height of grid in blocks */
  1553. unsigned int gridDimZ; /**< Depth of grid in blocks */
  1554. unsigned int blockDimX; /**< X dimension of each thread block */
  1555. unsigned int blockDimY; /**< Y dimension of each thread block */
  1556. unsigned int blockDimZ; /**< Z dimension of each thread block */
  1557. unsigned int sharedMemBytes; /**< Dynamic shared-memory size per thread block in bytes */
  1558. void **kernelParams; /**< Array of pointers to kernel parameters */
  1559. void **extra; /**< Extra options */
  1560. } CUDA_KERNEL_NODE_PARAMS_v1;
  1561. /**
  1562. * GPU kernel node parameters
  1563. */
  1564. typedef struct CUDA_KERNEL_NODE_PARAMS_v2_st {
  1565. CUfunction func; /**< Kernel to launch */
  1566. unsigned int gridDimX; /**< Width of grid in blocks */
  1567. unsigned int gridDimY; /**< Height of grid in blocks */
  1568. unsigned int gridDimZ; /**< Depth of grid in blocks */
  1569. unsigned int blockDimX; /**< X dimension of each thread block */
  1570. unsigned int blockDimY; /**< Y dimension of each thread block */
  1571. unsigned int blockDimZ; /**< Z dimension of each thread block */
  1572. unsigned int sharedMemBytes; /**< Dynamic shared-memory size per thread block in bytes */
  1573. void **kernelParams; /**< Array of pointers to kernel parameters */
  1574. void **extra; /**< Extra options */
  1575. CUkernel kern; /**< Kernel to launch, will only be referenced if func is NULL */
  1576. CUcontext ctx; /**< Context for the kernel task to run in. The value NULL will indicate the current context should be used by the api. This field is ignored if func is set. */
  1577. } CUDA_KERNEL_NODE_PARAMS_v2;
  1578. typedef CUDA_KERNEL_NODE_PARAMS_v2 CUDA_KERNEL_NODE_PARAMS;
  1579. /**
  1580. * GPU kernel node parameters
  1581. */
  1582. typedef struct CUDA_KERNEL_NODE_PARAMS_v3_st {
  1583. CUfunction func; /**< Kernel to launch */
  1584. unsigned int gridDimX; /**< Width of grid in blocks */
  1585. unsigned int gridDimY; /**< Height of grid in blocks */
  1586. unsigned int gridDimZ; /**< Depth of grid in blocks */
  1587. unsigned int blockDimX; /**< X dimension of each thread block */
  1588. unsigned int blockDimY; /**< Y dimension of each thread block */
  1589. unsigned int blockDimZ; /**< Z dimension of each thread block */
  1590. unsigned int sharedMemBytes; /**< Dynamic shared-memory size per thread block in bytes */
  1591. void **kernelParams; /**< Array of pointers to kernel parameters */
  1592. void **extra; /**< Extra options */
  1593. CUkernel kern; /**< Kernel to launch, will only be referenced if func is NULL */
  1594. CUcontext ctx; /**< Context for the kernel task to run in. The value NULL will indicate the current context should be used by the api. This field is ignored if func is set. */
  1595. } CUDA_KERNEL_NODE_PARAMS_v3;
  1596. /**
  1597. * Memset node parameters
  1598. */
  1599. typedef struct CUDA_MEMSET_NODE_PARAMS_st {
  1600. CUdeviceptr dst; /**< Destination device pointer */
  1601. size_t pitch; /**< Pitch of destination device pointer. Unused if height is 1 */
  1602. unsigned int value; /**< Value to be set */
  1603. unsigned int elementSize; /**< Size of each element in bytes. Must be 1, 2, or 4. */
  1604. size_t width; /**< Width of the row in elements */
  1605. size_t height; /**< Number of rows */
  1606. } CUDA_MEMSET_NODE_PARAMS_v1;
  1607. typedef CUDA_MEMSET_NODE_PARAMS_v1 CUDA_MEMSET_NODE_PARAMS;
  1608. /**
  1609. * Memset node parameters
  1610. */
  1611. typedef struct CUDA_MEMSET_NODE_PARAMS_v2_st {
  1612. CUdeviceptr dst; /**< Destination device pointer */
  1613. size_t pitch; /**< Pitch of destination device pointer. Unused if height is 1 */
  1614. unsigned int value; /**< Value to be set */
  1615. unsigned int elementSize; /**< Size of each element in bytes. Must be 1, 2, or 4. */
  1616. size_t width; /**< Width of the row in elements */
  1617. size_t height; /**< Number of rows */
  1618. CUcontext ctx; /**< Context on which to run the node */
  1619. } CUDA_MEMSET_NODE_PARAMS_v2;
  1620. /**
  1621. * Host node parameters
  1622. */
  1623. typedef struct CUDA_HOST_NODE_PARAMS_st {
  1624. CUhostFn fn; /**< The function to call when the node executes */
  1625. void* userData; /**< Argument to pass to the function */
  1626. } CUDA_HOST_NODE_PARAMS_v1;
  1627. typedef CUDA_HOST_NODE_PARAMS_v1 CUDA_HOST_NODE_PARAMS;
  1628. /**
  1629. * Host node parameters
  1630. */
  1631. typedef struct CUDA_HOST_NODE_PARAMS_v2_st {
  1632. CUhostFn fn; /**< The function to call when the node executes */
  1633. void* userData; /**< Argument to pass to the function */
  1634. } CUDA_HOST_NODE_PARAMS_v2;
  1635. /**
  1636. * Conditional node handle flags
  1637. */
  1638. #define CU_GRAPH_COND_ASSIGN_DEFAULT 0x1 /**< Default value is applied when graph is launched. */
  1639. /**
  1640. * Conditional node types
  1641. */
  1642. typedef enum CUgraphConditionalNodeType_enum {
  1643. CU_GRAPH_COND_TYPE_IF = 0, /**< Conditional 'if/else' Node. Body[0] executed if condition is non-zero. If \p size == 2, an optional ELSE graph is created and this is executed if the condition is zero. */
  1644. CU_GRAPH_COND_TYPE_WHILE = 1, /**< Conditional 'while' Node. Body executed repeatedly while condition value is non-zero. */
  1645. CU_GRAPH_COND_TYPE_SWITCH = 2, /**< Conditional 'switch' Node. Body[n] is executed once, where 'n' is the value of the condition. If the condition does not match a body index, no body is launched. */
  1646. } CUgraphConditionalNodeType;
  1647. /**
  1648. * Conditional node parameters
  1649. */
  1650. typedef struct CUDA_CONDITIONAL_NODE_PARAMS {
  1651. CUgraphConditionalHandle handle; /**< Conditional node handle.
  1652. Handles must be created in advance of creating the node
  1653. using ::cuGraphConditionalHandleCreate. */
  1654. CUgraphConditionalNodeType type; /**< Type of conditional node. */
  1655. unsigned int size; /**< Size of graph output array. Allowed values are 1 for CU_GRAPH_COND_TYPE_WHILE, 1 or 2
  1656. for CU_GRAPH_COND_TYPE_IF, or any value greater than zero for CU_GRAPH_COND_TYPE_SWITCH. */
  1657. CUgraph *phGraph_out; /**< CUDA-owned array populated with conditional node child graphs during creation of the node.
  1658. Valid for the lifetime of the conditional node.
  1659. The contents of the graph(s) are subject to the following constraints:
  1660. - Allowed node types are kernel nodes, empty nodes, child graphs, memsets,
  1661. memcopies, and conditionals. This applies recursively to child graphs and conditional bodies.
  1662. - All kernels, including kernels in nested conditionals or child graphs at any level,
  1663. must belong to the same CUDA context.
  1664. These graphs may be populated using graph node creation APIs or ::cuStreamBeginCaptureToGraph.
  1665. CU_GRAPH_COND_TYPE_IF:
  1666. phGraph_out[0] is executed when the condition is non-zero. If \p size == 2, phGraph_out[1] will
  1667. be executed when the condition is zero.
  1668. CU_GRAPH_COND_TYPE_WHILE:
  1669. phGraph_out[0] is executed as long as the condition is non-zero.
  1670. CU_GRAPH_COND_TYPE_SWITCH:
  1671. phGraph_out[n] is executed when the condition is equal to n. If the condition >= \p size,
  1672. no body graph is executed.
  1673. */
  1674. CUcontext ctx; /**< Context on which to run the node. Must match context used to create the handle and all body nodes. */
  1675. } CUDA_CONDITIONAL_NODE_PARAMS;
  1676. /**
  1677. * Graph node types
  1678. */
  1679. typedef enum CUgraphNodeType_enum {
  1680. CU_GRAPH_NODE_TYPE_KERNEL = 0, /**< GPU kernel node */
  1681. CU_GRAPH_NODE_TYPE_MEMCPY = 1, /**< Memcpy node */
  1682. CU_GRAPH_NODE_TYPE_MEMSET = 2, /**< Memset node */
  1683. CU_GRAPH_NODE_TYPE_HOST = 3, /**< Host (executable) node */
  1684. CU_GRAPH_NODE_TYPE_GRAPH = 4, /**< Node which executes an embedded graph */
  1685. CU_GRAPH_NODE_TYPE_EMPTY = 5, /**< Empty (no-op) node */
  1686. CU_GRAPH_NODE_TYPE_WAIT_EVENT = 6, /**< External event wait node */
  1687. CU_GRAPH_NODE_TYPE_EVENT_RECORD = 7, /**< External event record node */
  1688. CU_GRAPH_NODE_TYPE_EXT_SEMAS_SIGNAL = 8, /**< External semaphore signal node */
  1689. CU_GRAPH_NODE_TYPE_EXT_SEMAS_WAIT = 9, /**< External semaphore wait node */
  1690. CU_GRAPH_NODE_TYPE_MEM_ALLOC = 10,/**< Memory Allocation Node */
  1691. CU_GRAPH_NODE_TYPE_MEM_FREE = 11,/**< Memory Free Node */
  1692. CU_GRAPH_NODE_TYPE_BATCH_MEM_OP = 12,/**< Batch MemOp Node */
  1693. CU_GRAPH_NODE_TYPE_CONDITIONAL = 13 /**< Conditional Node
  1694. May be used to implement a conditional execution path or loop
  1695. inside of a graph. The graph(s) contained within the body of the conditional node
  1696. can be selectively executed or iterated upon based on the value of a conditional
  1697. variable.
  1698. Handles must be created in advance of creating the node
  1699. using ::cuGraphConditionalHandleCreate.
  1700. The following restrictions apply to graphs which contain conditional nodes:
  1701. The graph cannot be used in a child node.
  1702. Only one instantiation of the graph may exist at any point in time.
  1703. The graph cannot be cloned.
  1704. To set the control value, supply a default value when creating the handle and/or
  1705. call ::cudaGraphSetConditional from device code.*/
  1706. } CUgraphNodeType;
  1707. /**
  1708. * Type annotations that can be applied to graph edges as part of ::CUgraphEdgeData.
  1709. */
  1710. typedef enum CUgraphDependencyType_enum {
  1711. CU_GRAPH_DEPENDENCY_TYPE_DEFAULT = 0, /**< This is an ordinary dependency. */
  1712. CU_GRAPH_DEPENDENCY_TYPE_PROGRAMMATIC = 1 /**< This dependency type allows the downstream node to
  1713. use \c cudaGridDependencySynchronize(). It may only be used
  1714. between kernel nodes, and must be used with either the
  1715. ::CU_GRAPH_KERNEL_NODE_PORT_PROGRAMMATIC or
  1716. ::CU_GRAPH_KERNEL_NODE_PORT_LAUNCH_ORDER outgoing port. */
  1717. } CUgraphDependencyType;
  1718. /**
  1719. * This port activates when the kernel has finished executing.
  1720. */
  1721. #define CU_GRAPH_KERNEL_NODE_PORT_DEFAULT 0
  1722. /**
  1723. * This port activates when all blocks of the kernel have performed cudaTriggerProgrammaticLaunchCompletion()
  1724. * or have terminated. It must be used with edge type ::CU_GRAPH_DEPENDENCY_TYPE_PROGRAMMATIC. See also
  1725. * ::CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT.
  1726. */
  1727. #define CU_GRAPH_KERNEL_NODE_PORT_PROGRAMMATIC 1
  1728. /**
  1729. * This port activates when all blocks of the kernel have begun execution. See also
  1730. * ::CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT.
  1731. */
  1732. #define CU_GRAPH_KERNEL_NODE_PORT_LAUNCH_ORDER 2
  1733. /**
  1734. * Optional annotation for edges in a CUDA graph. Note, all edges implicitly have annotations and
  1735. * default to a zero-initialized value if not specified. A zero-initialized struct indicates a
  1736. * standard full serialization of two nodes with memory visibility.
  1737. */
  1738. typedef struct CUgraphEdgeData_st {
  1739. unsigned char from_port; /**< This indicates when the dependency is triggered from the upstream
  1740. node on the edge. The meaning is specfic to the node type. A value
  1741. of 0 in all cases means full completion of the upstream node, with
  1742. memory visibility to the downstream node or portion thereof
  1743. (indicated by \c to_port).
  1744. <br>
  1745. Only kernel nodes define non-zero ports. A kernel node
  1746. can use the following output port types:
  1747. ::CU_GRAPH_KERNEL_NODE_PORT_DEFAULT, ::CU_GRAPH_KERNEL_NODE_PORT_PROGRAMMATIC,
  1748. or ::CU_GRAPH_KERNEL_NODE_PORT_LAUNCH_ORDER. */
  1749. unsigned char to_port; /**< This indicates what portion of the downstream node is dependent on
  1750. the upstream node or portion thereof (indicated by \c from_port). The
  1751. meaning is specific to the node type. A value of 0 in all cases means
  1752. the entirety of the downstream node is dependent on the upstream work.
  1753. <br>
  1754. Currently no node types define non-zero ports. Accordingly, this field
  1755. must be set to zero. */
  1756. unsigned char type; /**< This should be populated with a value from ::CUgraphDependencyType. (It
  1757. is typed as char due to compiler-specific layout of bitfields.) See
  1758. ::CUgraphDependencyType. */
  1759. unsigned char reserved[5]; /**< These bytes are unused and must be zeroed. This ensures
  1760. compatibility if additional fields are added in the future. */
  1761. } CUgraphEdgeData;
  1762. /**
  1763. * Graph instantiation results
  1764. */
  1765. typedef enum CUgraphInstantiateResult_enum
  1766. {
  1767. CUDA_GRAPH_INSTANTIATE_SUCCESS = 0, /**< Instantiation succeeded */
  1768. CUDA_GRAPH_INSTANTIATE_ERROR = 1, /**< Instantiation failed for an unexpected reason which is described in the return value of the function */
  1769. CUDA_GRAPH_INSTANTIATE_INVALID_STRUCTURE = 2, /**< Instantiation failed due to invalid structure, such as cycles */
  1770. CUDA_GRAPH_INSTANTIATE_NODE_OPERATION_NOT_SUPPORTED = 3, /**< Instantiation for device launch failed because the graph contained an unsupported operation */
  1771. CUDA_GRAPH_INSTANTIATE_MULTIPLE_CTXS_NOT_SUPPORTED = 4, /**< Instantiation for device launch failed due to the nodes belonging to different contexts */
  1772. CUDA_GRAPH_INSTANTIATE_CONDITIONAL_HANDLE_UNUSED = 5, /**< One or more conditional handles are not associated with conditional nodes */
  1773. } CUgraphInstantiateResult;
  1774. /**
  1775. * Graph instantiation parameters
  1776. */
  1777. typedef struct CUDA_GRAPH_INSTANTIATE_PARAMS_st
  1778. {
  1779. cuuint64_t flags; /**< Instantiation flags */
  1780. CUstream hUploadStream; /**< Upload stream */
  1781. CUgraphNode hErrNode_out; /**< The node which caused instantiation to fail, if any */
  1782. CUgraphInstantiateResult result_out; /**< Whether instantiation was successful. If it failed, the reason why */
  1783. } CUDA_GRAPH_INSTANTIATE_PARAMS;
  1784. typedef enum CUsynchronizationPolicy_enum {
  1785. CU_SYNC_POLICY_AUTO = 1,
  1786. CU_SYNC_POLICY_SPIN = 2,
  1787. CU_SYNC_POLICY_YIELD = 3,
  1788. CU_SYNC_POLICY_BLOCKING_SYNC = 4
  1789. } CUsynchronizationPolicy;
  1790. /**
  1791. * Cluster scheduling policies. These may be passed to ::cuFuncSetAttribute or ::cuKernelSetAttribute
  1792. */
  1793. typedef enum CUclusterSchedulingPolicy_enum {
  1794. CU_CLUSTER_SCHEDULING_POLICY_DEFAULT = 0, /**< the default policy */
  1795. CU_CLUSTER_SCHEDULING_POLICY_SPREAD = 1, /**< spread the blocks within a cluster to the SMs */
  1796. CU_CLUSTER_SCHEDULING_POLICY_LOAD_BALANCING = 2 /**< allow the hardware to load-balance the blocks in a cluster to the SMs */
  1797. } CUclusterSchedulingPolicy;
  1798. /**
  1799. * Memory Synchronization Domain
  1800. *
  1801. * A kernel can be launched in a specified memory synchronization domain that affects all memory operations issued by
  1802. * that kernel. A memory barrier issued in one domain will only order memory operations in that domain, thus eliminating
  1803. * latency increase from memory barriers ordering unrelated traffic.
  1804. *
  1805. * By default, kernels are launched in domain 0. Kernel launched with ::CU_LAUNCH_MEM_SYNC_DOMAIN_REMOTE will have a
  1806. * different domain ID. User may also alter the domain ID with ::CUlaunchMemSyncDomainMap for a specific stream /
  1807. * graph node / kernel launch. See ::CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN, ::cuStreamSetAttribute, ::cuLaunchKernelEx,
  1808. * ::cuGraphKernelNodeSetAttribute.
  1809. *
  1810. * Memory operations done in kernels launched in different domains are considered system-scope distanced. In other
  1811. * words, a GPU scoped memory synchronization is not sufficient for memory order to be observed by kernels in another
  1812. * memory synchronization domain even if they are on the same GPU.
  1813. */
  1814. typedef enum CUlaunchMemSyncDomain_enum {
  1815. CU_LAUNCH_MEM_SYNC_DOMAIN_DEFAULT = 0, /**< Launch kernels in the default domain */
  1816. CU_LAUNCH_MEM_SYNC_DOMAIN_REMOTE = 1 /**< Launch kernels in the remote domain */
  1817. } CUlaunchMemSyncDomain;
  1818. /**
  1819. * Memory Synchronization Domain map
  1820. *
  1821. * See ::cudaLaunchMemSyncDomain.
  1822. *
  1823. * By default, kernels are launched in domain 0. Kernel launched with ::CU_LAUNCH_MEM_SYNC_DOMAIN_REMOTE will have a
  1824. * different domain ID. User may also alter the domain ID with ::CUlaunchMemSyncDomainMap for a specific stream /
  1825. * graph node / kernel launch. See ::CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP.
  1826. *
  1827. * Domain ID range is available through ::CU_DEVICE_ATTRIBUTE_MEM_SYNC_DOMAIN_COUNT.
  1828. */
  1829. typedef struct CUlaunchMemSyncDomainMap_st {
  1830. unsigned char default_; /**< The default domain ID to use for designated kernels */
  1831. unsigned char remote; /**< The remote domain ID to use for designated kernels */
  1832. } CUlaunchMemSyncDomainMap;
  1833. /**
  1834. * Launch attributes enum; used as id field of ::CUlaunchAttribute
  1835. */
  1836. typedef enum CUlaunchAttributeID_enum {
  1837. CU_LAUNCH_ATTRIBUTE_IGNORE = 0 /**< Ignored entry, for convenient composition */
  1838. , CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW = 1 /**< Valid for streams, graph nodes, launches. See
  1839. ::CUlaunchAttributeValue::accessPolicyWindow. */
  1840. , CU_LAUNCH_ATTRIBUTE_COOPERATIVE = 2 /**< Valid for graph nodes, launches. See
  1841. ::CUlaunchAttributeValue::cooperative. */
  1842. , CU_LAUNCH_ATTRIBUTE_SYNCHRONIZATION_POLICY = 3 /**< Valid for streams. See
  1843. ::CUlaunchAttributeValue::syncPolicy. */
  1844. , CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION = 4 /**< Valid for graph nodes, launches. See ::CUlaunchAttributeValue::clusterDim. */
  1845. , CU_LAUNCH_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE = 5 /**< Valid for graph nodes, launches. See ::CUlaunchAttributeValue::clusterSchedulingPolicyPreference. */
  1846. , CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION = 6 /**< Valid for launches. Setting
  1847. ::CUlaunchAttributeValue::programmaticStreamSerializationAllowed
  1848. to non-0 signals that the kernel will use programmatic
  1849. means to resolve its stream dependency, so that the
  1850. CUDA runtime should opportunistically allow the grid's
  1851. execution to overlap with the previous kernel in the
  1852. stream, if that kernel requests the overlap. The
  1853. dependent launches can choose to wait on the
  1854. dependency using the programmatic sync
  1855. (cudaGridDependencySynchronize() or equivalent PTX
  1856. instructions). */
  1857. , CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT = 7 /**< Valid for launches. Set
  1858. ::CUlaunchAttributeValue::programmaticEvent to
  1859. record the event. Event recorded through this
  1860. launch attribute is guaranteed to only trigger
  1861. after all block in the associated kernel trigger
  1862. the event. A block can trigger the event through
  1863. PTX launchdep.release or CUDA builtin function
  1864. cudaTriggerProgrammaticLaunchCompletion(). A
  1865. trigger can also be inserted at the beginning of
  1866. each block's execution if triggerAtBlockStart is
  1867. set to non-0. The dependent launches can choose to
  1868. wait on the dependency using the programmatic sync
  1869. (cudaGridDependencySynchronize() or equivalent PTX
  1870. instructions). Note that dependents (including the
  1871. CPU thread calling cuEventSynchronize()) are not
  1872. guaranteed to observe the release precisely when
  1873. it is released. For example, cuEventSynchronize()
  1874. may only observe the event trigger long after the
  1875. associated kernel has completed. This recording
  1876. type is primarily meant for establishing
  1877. programmatic dependency between device tasks. Note
  1878. also this type of dependency allows, but does not
  1879. guarantee, concurrent execution of tasks.
  1880. <br>
  1881. The event supplied must not be an interprocess or
  1882. interop event. The event must disable timing (i.e.
  1883. must be created with the ::CU_EVENT_DISABLE_TIMING
  1884. flag set).
  1885. */
  1886. , CU_LAUNCH_ATTRIBUTE_PRIORITY = 8 /**< Valid for streams, graph nodes, launches. See
  1887. ::CUlaunchAttributeValue::priority. */
  1888. , CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP = 9 /**< Valid for streams, graph nodes, launches. See
  1889. ::CUlaunchAttributeValue::memSyncDomainMap. */
  1890. , CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN = 10 /**< Valid for streams, graph nodes, launches. See
  1891. ::CUlaunchAttributeValue::memSyncDomain. */
  1892. , CU_LAUNCH_ATTRIBUTE_PREFERRED_CLUSTER_DIMENSION = 11 /**< Valid for graph nodes, launches. Set
  1893. ::CUlaunchAttributeValue::preferredClusterDim
  1894. to allow the kernel launch to specify a preferred substitute
  1895. cluster dimension. Blocks may be grouped according to either
  1896. the dimensions specified with this attribute (grouped into a
  1897. "preferred substitute cluster"), or the one specified with
  1898. ::CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION attribute (grouped
  1899. into a "regular cluster"). The cluster dimensions of a
  1900. "preferred substitute cluster" shall be an integer multiple
  1901. greater than zero of the regular cluster dimensions. The
  1902. device will attempt - on a best-effort basis - to group
  1903. thread blocks into preferred clusters over grouping them
  1904. into regular clusters. When it deems necessary (primarily
  1905. when the device temporarily runs out of physical resources
  1906. to launch the larger preferred clusters), the device may
  1907. switch to launch the regular clusters instead to attempt to
  1908. utilize as much of the physical device resources as possible.
  1909. <br>
  1910. Each type of cluster will have its enumeration / coordinate
  1911. setup as if the grid consists solely of its type of cluster.
  1912. For example, if the preferred substitute cluster dimensions
  1913. double the regular cluster dimensions, there might be
  1914. simultaneously a regular cluster indexed at (1,0,0), and a
  1915. preferred cluster indexed at (1,0,0). In this example, the
  1916. preferred substitute cluster (1,0,0) replaces regular
  1917. clusters (2,0,0) and (3,0,0) and groups their blocks.
  1918. <br>
  1919. This attribute will only take effect when a regular cluster
  1920. dimension has been specified. The preferred substitute
  1921. cluster dimension must be an integer multiple greater than
  1922. zero of the regular cluster dimension and must divide the
  1923. grid. It must also be no more than `maxBlocksPerCluster`, if
  1924. it is set in the kernel's `__launch_bounds__`. Otherwise it
  1925. must be less than the maximum value the driver can support.
  1926. Otherwise, setting this attribute to a value physically
  1927. unable to fit on any particular device is permitted. */
  1928. , CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT = 12 /**< Valid for launches. Set
  1929. ::CUlaunchAttributeValue::launchCompletionEvent to record the
  1930. event.
  1931. <br>
  1932. Nominally, the event is triggered once all blocks of the kernel
  1933. have begun execution. Currently this is a best effort. If a kernel
  1934. B has a launch completion dependency on a kernel A, B may wait
  1935. until A is complete. Alternatively, blocks of B may begin before
  1936. all blocks of A have begun, for example if B can claim execution
  1937. resources unavailable to A (e.g. they run on different GPUs) or
  1938. if B is a higher priority than A.
  1939. Exercise caution if such an ordering inversion could lead
  1940. to deadlock.
  1941. <br>
  1942. A launch completion event is nominally similar to a programmatic
  1943. event with \c triggerAtBlockStart set except that it is not
  1944. visible to \c cudaGridDependencySynchronize() and can be used with
  1945. compute capability less than 9.0.
  1946. <br>
  1947. The event supplied must not be an interprocess or interop
  1948. event. The event must disable timing (i.e. must be created
  1949. with the ::CU_EVENT_DISABLE_TIMING flag set). */
  1950. , CU_LAUNCH_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE = 13 /**< Valid for graph nodes, launches. This attribute is graphs-only,
  1951. and passing it to a launch in a non-capturing stream will result
  1952. in an error.
  1953. <br>
  1954. ::CUlaunchAttributeValue::deviceUpdatableKernelNode::deviceUpdatable can
  1955. only be set to 0 or 1. Setting the field to 1 indicates that the
  1956. corresponding kernel node should be device-updatable. On success, a handle
  1957. will be returned via
  1958. ::CUlaunchAttributeValue::deviceUpdatableKernelNode::devNode which can be
  1959. passed to the various device-side update functions to update the node's
  1960. kernel parameters from within another kernel. For more information on the
  1961. types of device updates that can be made, as well as the relevant limitations
  1962. thereof, see ::cudaGraphKernelNodeUpdatesApply.
  1963. <br>
  1964. Nodes which are device-updatable have additional restrictions compared to
  1965. regular kernel nodes. Firstly, device-updatable nodes cannot be removed
  1966. from their graph via ::cuGraphDestroyNode. Additionally, once opted-in
  1967. to this functionality, a node cannot opt out, and any attempt to set the
  1968. deviceUpdatable attribute to 0 will result in an error. Device-updatable
  1969. kernel nodes also cannot have their attributes copied to/from another kernel
  1970. node via ::cuGraphKernelNodeCopyAttributes. Graphs containing one or more
  1971. device-updatable nodes also do not allow multiple instantiation, and neither
  1972. the graph nor its instantiated version can be passed to ::cuGraphExecUpdate.
  1973. <br>
  1974. If a graph contains device-updatable nodes and updates those nodes from the device
  1975. from within the graph, the graph must be uploaded with ::cuGraphUpload before it
  1976. is launched. For such a graph, if host-side executable graph updates are made to the
  1977. device-updatable nodes, the graph must be uploaded before it is launched again. */
  1978. , CU_LAUNCH_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT = 14 /**< Valid for launches. On devices where the L1 cache and shared memory use the
  1979. same hardware resources, setting ::CUlaunchAttributeValue::sharedMemCarveout to a
  1980. percentage between 0-100 signals the CUDA driver to set the shared memory carveout
  1981. preference, in percent of the total shared memory for that kernel launch.
  1982. This attribute takes precedence over ::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT.
  1983. This is only a hint, and the CUDA driver can choose a different configuration if
  1984. required for the launch. */
  1985. #if defined(__CUDA_API_VERSION_INTERNAL) && !defined(__CUDA_API_VERSION_INTERNAL_ODR)
  1986. , CU_LAUNCH_ATTRIBUTE_MAX
  1987. #endif
  1988. } CUlaunchAttributeID;
  1989. /**
  1990. * Launch attributes union; used as value field of ::CUlaunchAttribute
  1991. */
  1992. typedef union CUlaunchAttributeValue_union {
  1993. char pad[64]; /* Pad to 64 bytes */
  1994. CUaccessPolicyWindow accessPolicyWindow; /**< Value of launch attribute ::CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW. */
  1995. int cooperative; /**< Value of launch attribute ::CU_LAUNCH_ATTRIBUTE_COOPERATIVE. Nonzero indicates a cooperative
  1996. kernel (see ::cuLaunchCooperativeKernel). */
  1997. CUsynchronizationPolicy syncPolicy; /**< Value of launch attribute
  1998. ::CU_LAUNCH_ATTRIBUTE_SYNCHRONIZATION_POLICY. ::CUsynchronizationPolicy for
  1999. work queued up in this stream */
  2000. /**
  2001. * Value of launch attribute ::CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION that
  2002. * represents the desired cluster dimensions for the kernel. Opaque type
  2003. * with the following fields:
  2004. * - \p x - The X dimension of the cluster, in blocks. Must be a divisor
  2005. * of the grid X dimension.
  2006. * - \p y - The Y dimension of the cluster, in blocks. Must be a divisor
  2007. * of the grid Y dimension.
  2008. * - \p z - The Z dimension of the cluster, in blocks. Must be a divisor
  2009. * of the grid Z dimension.
  2010. */
  2011. struct {
  2012. unsigned int x;
  2013. unsigned int y;
  2014. unsigned int z;
  2015. } clusterDim;
  2016. CUclusterSchedulingPolicy clusterSchedulingPolicyPreference; /**< Value of launch attribute
  2017. ::CU_LAUNCH_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE. Cluster
  2018. scheduling policy preference for the kernel. */
  2019. int programmaticStreamSerializationAllowed; /**< Value of launch attribute
  2020. ::CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION. */
  2021. /**
  2022. * Value of launch attribute ::CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT
  2023. * with the following fields:
  2024. * - \p CUevent event - Event to fire when all blocks trigger it.
  2025. * - \p Event record flags, see ::cuEventRecordWithFlags. Does not accept :CU_EVENT_RECORD_EXTERNAL.
  2026. * - \p triggerAtBlockStart - If this is set to non-0, each block launch will automatically trigger the event.
  2027. */
  2028. struct {
  2029. CUevent event;
  2030. int flags;
  2031. int triggerAtBlockStart;
  2032. } programmaticEvent;
  2033. /**
  2034. * Value of launch attribute ::CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT
  2035. * with the following fields:
  2036. * - \p CUevent event - Event to fire when the last block launches
  2037. * - \p int flags; - Event record flags, see ::cuEventRecordWithFlags. Does not accept ::CU_EVENT_RECORD_EXTERNAL.
  2038. */
  2039. struct {
  2040. CUevent event;
  2041. int flags;
  2042. } launchCompletionEvent;
  2043. int priority; /**< Value of launch attribute ::CU_LAUNCH_ATTRIBUTE_PRIORITY. Execution priority of the kernel. */
  2044. CUlaunchMemSyncDomainMap memSyncDomainMap; /**< Value of launch attribute
  2045. ::CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP. See
  2046. ::CUlaunchMemSyncDomainMap. */
  2047. CUlaunchMemSyncDomain memSyncDomain; /**< Value of launch attribute
  2048. ::CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN. See::CUlaunchMemSyncDomain */
  2049. /**
  2050. * Value of launch attribute ::CU_LAUNCH_ATTRIBUTE_PREFERRED_CLUSTER_DIMENSION
  2051. * that represents the desired preferred cluster dimensions for the kernel.
  2052. * Opaque type with the following fields:
  2053. * - \p x - The X dimension of the preferred cluster, in blocks. Must
  2054. * be a divisor of the grid X dimension, and must be a
  2055. * multiple of the \p x field of ::CUlaunchAttributeValue::clusterDim.
  2056. * - \p y - The Y dimension of the preferred cluster, in blocks. Must
  2057. * be a divisor of the grid Y dimension, and must be a
  2058. * multiple of the \p y field of ::CUlaunchAttributeValue::clusterDim.
  2059. * - \p z - The Z dimension of the preferred cluster, in blocks. Must be
  2060. * equal to the \p z field of ::CUlaunchAttributeValue::clusterDim.
  2061. */
  2062. struct {
  2063. unsigned int x;
  2064. unsigned int y;
  2065. unsigned int z;
  2066. } preferredClusterDim;
  2067. /**
  2068. * Value of launch attribute ::CU_LAUNCH_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE.
  2069. * with the following fields:
  2070. * - \p int deviceUpdatable - Whether or not the resulting kernel node should be device-updatable.
  2071. * - \p CUgraphDeviceNode devNode - Returns a handle to pass to the various device-side update functions.
  2072. */
  2073. struct {
  2074. int deviceUpdatable;
  2075. CUgraphDeviceNode devNode;
  2076. } deviceUpdatableKernelNode;
  2077. unsigned int sharedMemCarveout; /**< Value of launch attribute ::CU_LAUNCH_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT. */
  2078. } CUlaunchAttributeValue;
  2079. /**
  2080. * Launch attribute
  2081. */
  2082. typedef struct CUlaunchAttribute_st {
  2083. CUlaunchAttributeID id; /**< Attribute to set */
  2084. char pad[8 - sizeof(CUlaunchAttributeID)];
  2085. CUlaunchAttributeValue value; /**< Value of the attribute */
  2086. } CUlaunchAttribute;
  2087. /**
  2088. * CUDA extensible launch configuration
  2089. */
  2090. typedef struct CUlaunchConfig_st {
  2091. unsigned int gridDimX; /**< Width of grid in blocks */
  2092. unsigned int gridDimY; /**< Height of grid in blocks */
  2093. unsigned int gridDimZ; /**< Depth of grid in blocks */
  2094. unsigned int blockDimX; /**< X dimension of each thread block */
  2095. unsigned int blockDimY; /**< Y dimension of each thread block */
  2096. unsigned int blockDimZ; /**< Z dimension of each thread block */
  2097. unsigned int sharedMemBytes; /**< Dynamic shared-memory size per thread block in bytes */
  2098. CUstream hStream; /**< Stream identifier */
  2099. CUlaunchAttribute *attrs; /**< List of attributes; nullable if ::CUlaunchConfig::numAttrs == 0 */
  2100. unsigned int numAttrs; /**< Number of attributes populated in ::CUlaunchConfig::attrs */
  2101. } CUlaunchConfig;
  2102. typedef CUlaunchAttributeID CUkernelNodeAttrID;
  2103. #define CU_KERNEL_NODE_ATTRIBUTE_ACCESS_POLICY_WINDOW CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW
  2104. #define CU_KERNEL_NODE_ATTRIBUTE_COOPERATIVE CU_LAUNCH_ATTRIBUTE_COOPERATIVE
  2105. #define CU_KERNEL_NODE_ATTRIBUTE_CLUSTER_DIMENSION CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION
  2106. #define CU_KERNEL_NODE_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE CU_LAUNCH_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE
  2107. #define CU_KERNEL_NODE_ATTRIBUTE_PRIORITY CU_LAUNCH_ATTRIBUTE_PRIORITY
  2108. #define CU_KERNEL_NODE_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP
  2109. #define CU_KERNEL_NODE_ATTRIBUTE_MEM_SYNC_DOMAIN CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN
  2110. #define CU_KERNEL_NODE_ATTRIBUTE_PREFERRED_CLUSTER_DIMENSION CU_LAUNCH_ATTRIBUTE_PREFERRED_CLUSTER_DIMENSION
  2111. #define CU_KERNEL_NODE_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE CU_LAUNCH_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE
  2112. #define CU_KERNEL_NODE_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT CU_LAUNCH_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT
  2113. typedef CUlaunchAttributeValue CUkernelNodeAttrValue_v1;
  2114. typedef CUkernelNodeAttrValue_v1 CUkernelNodeAttrValue;
  2115. /**
  2116. * Possible stream capture statuses returned by ::cuStreamIsCapturing
  2117. */
  2118. typedef enum CUstreamCaptureStatus_enum {
  2119. CU_STREAM_CAPTURE_STATUS_NONE = 0, /**< Stream is not capturing */
  2120. CU_STREAM_CAPTURE_STATUS_ACTIVE = 1, /**< Stream is actively capturing */
  2121. CU_STREAM_CAPTURE_STATUS_INVALIDATED = 2 /**< Stream is part of a capture sequence that
  2122. has been invalidated, but not terminated */
  2123. } CUstreamCaptureStatus;
  2124. /**
  2125. * Possible modes for stream capture thread interactions. For more details see
  2126. * ::cuStreamBeginCapture and ::cuThreadExchangeStreamCaptureMode
  2127. */
  2128. typedef enum CUstreamCaptureMode_enum {
  2129. CU_STREAM_CAPTURE_MODE_GLOBAL = 0,
  2130. CU_STREAM_CAPTURE_MODE_THREAD_LOCAL = 1,
  2131. CU_STREAM_CAPTURE_MODE_RELAXED = 2
  2132. } CUstreamCaptureMode;
  2133. typedef CUlaunchAttributeID CUstreamAttrID;
  2134. #define CU_STREAM_ATTRIBUTE_ACCESS_POLICY_WINDOW CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW
  2135. #define CU_STREAM_ATTRIBUTE_SYNCHRONIZATION_POLICY CU_LAUNCH_ATTRIBUTE_SYNCHRONIZATION_POLICY
  2136. #define CU_STREAM_ATTRIBUTE_PRIORITY CU_LAUNCH_ATTRIBUTE_PRIORITY
  2137. #define CU_STREAM_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP
  2138. #define CU_STREAM_ATTRIBUTE_MEM_SYNC_DOMAIN CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN
  2139. typedef CUlaunchAttributeValue CUstreamAttrValue_v1;
  2140. typedef CUstreamAttrValue_v1 CUstreamAttrValue;
  2141. /**
  2142. * Flags to specify search options. For more details see ::cuGetProcAddress
  2143. */
  2144. typedef enum CUdriverProcAddress_flags_enum {
  2145. CU_GET_PROC_ADDRESS_DEFAULT = 0, /**< Default search mode for driver symbols. */
  2146. CU_GET_PROC_ADDRESS_LEGACY_STREAM = 1 << 0, /**< Search for legacy versions of driver symbols. */
  2147. CU_GET_PROC_ADDRESS_PER_THREAD_DEFAULT_STREAM = 1 << 1 /**< Search for per-thread versions of driver symbols. */
  2148. } CUdriverProcAddress_flags;
  2149. /**
  2150. * Flags to indicate search status. For more details see ::cuGetProcAddress
  2151. */
  2152. typedef enum CUdriverProcAddressQueryResult_enum {
  2153. CU_GET_PROC_ADDRESS_SUCCESS = 0, /**< Symbol was succesfully found */
  2154. CU_GET_PROC_ADDRESS_SYMBOL_NOT_FOUND = 1, /**< Symbol was not found in search */
  2155. CU_GET_PROC_ADDRESS_VERSION_NOT_SUFFICIENT = 2 /**< Symbol was found but version supplied was not sufficient */
  2156. } CUdriverProcAddressQueryResult;
  2157. /**
  2158. * Execution Affinity Types
  2159. */
  2160. typedef enum CUexecAffinityType_enum {
  2161. CU_EXEC_AFFINITY_TYPE_SM_COUNT = 0, /**< Create a context with limited SMs. */
  2162. CU_EXEC_AFFINITY_TYPE_MAX
  2163. } CUexecAffinityType;
  2164. /**
  2165. * Value for ::CU_EXEC_AFFINITY_TYPE_SM_COUNT
  2166. */
  2167. typedef struct CUexecAffinitySmCount_st {
  2168. unsigned int val; /**< The number of SMs the context is limited to use. */
  2169. } CUexecAffinitySmCount_v1;
  2170. typedef CUexecAffinitySmCount_v1 CUexecAffinitySmCount;
  2171. /**
  2172. * Execution Affinity Parameters
  2173. */
  2174. typedef struct CUexecAffinityParam_st {
  2175. CUexecAffinityType type;
  2176. union {
  2177. CUexecAffinitySmCount smCount; /** Value for ::CU_EXEC_AFFINITY_TYPE_SM_COUNT */
  2178. } param;
  2179. } CUexecAffinityParam_v1;
  2180. /**
  2181. * Execution Affinity Parameters
  2182. */
  2183. typedef CUexecAffinityParam_v1 CUexecAffinityParam;
  2184. typedef enum CUcigDataType_enum {
  2185. CIG_DATA_TYPE_D3D12_COMMAND_QUEUE = 0x1, /** D3D12 Command Queue Handle */
  2186. } CUcigDataType;
  2187. /**
  2188. * CIG Context Create Params
  2189. */
  2190. typedef struct CUctxCigParam_st {
  2191. CUcigDataType sharedDataType;
  2192. void* sharedData;
  2193. } CUctxCigParam;
  2194. /**
  2195. * Params for creating CUDA context
  2196. * Exactly one of execAffinityParams and cigParams
  2197. * must be non-NULL.
  2198. */
  2199. typedef struct CUctxCreateParams_st {
  2200. CUexecAffinityParam *execAffinityParams;
  2201. int numExecAffinityParams;
  2202. CUctxCigParam *cigParams;
  2203. } CUctxCreateParams;
  2204. /**
  2205. * Library options to be specified with ::cuLibraryLoadData() or ::cuLibraryLoadFromFile()
  2206. */
  2207. typedef enum CUlibraryOption_enum
  2208. {
  2209. CU_LIBRARY_HOST_UNIVERSAL_FUNCTION_AND_DATA_TABLE = 0,
  2210. /**
  2211. * Specifes that the argument \p code passed to ::cuLibraryLoadData() will be preserved.
  2212. * Specifying this option will let the driver know that \p code can be accessed at any point
  2213. * until ::cuLibraryUnload(). The default behavior is for the driver to allocate and
  2214. * maintain its own copy of \p code. Note that this is only a memory usage optimization
  2215. * hint and the driver can choose to ignore it if required.
  2216. * Specifying this option with ::cuLibraryLoadFromFile() is invalid and
  2217. * will return ::CUDA_ERROR_INVALID_VALUE.
  2218. */
  2219. CU_LIBRARY_BINARY_IS_PRESERVED = 1,
  2220. CU_LIBRARY_NUM_OPTIONS
  2221. } CUlibraryOption;
  2222. typedef struct CUlibraryHostUniversalFunctionAndDataTable_st
  2223. {
  2224. void *functionTable;
  2225. size_t functionWindowSize;
  2226. void *dataTable;
  2227. size_t dataWindowSize;
  2228. } CUlibraryHostUniversalFunctionAndDataTable;
  2229. /**
  2230. * Error codes
  2231. */
  2232. typedef enum cudaError_enum {
  2233. /**
  2234. * The API call returned with no errors. In the case of query calls, this
  2235. * also means that the operation being queried is complete (see
  2236. * ::cuEventQuery() and ::cuStreamQuery()).
  2237. */
  2238. CUDA_SUCCESS = 0,
  2239. /**
  2240. * This indicates that one or more of the parameters passed to the API call
  2241. * is not within an acceptable range of values.
  2242. */
  2243. CUDA_ERROR_INVALID_VALUE = 1,
  2244. /**
  2245. * The API call failed because it was unable to allocate enough memory or
  2246. * other resources to perform the requested operation.
  2247. */
  2248. CUDA_ERROR_OUT_OF_MEMORY = 2,
  2249. /**
  2250. * This indicates that the CUDA driver has not been initialized with
  2251. * ::cuInit() or that initialization has failed.
  2252. */
  2253. CUDA_ERROR_NOT_INITIALIZED = 3,
  2254. /**
  2255. * This indicates that the CUDA driver is in the process of shutting down.
  2256. */
  2257. CUDA_ERROR_DEINITIALIZED = 4,
  2258. /**
  2259. * This indicates profiler is not initialized for this run. This can
  2260. * happen when the application is running with external profiling tools
  2261. * like visual profiler.
  2262. */
  2263. CUDA_ERROR_PROFILER_DISABLED = 5,
  2264. /**
  2265. * \deprecated
  2266. * This error return is deprecated as of CUDA 5.0. It is no longer an error
  2267. * to attempt to enable/disable the profiling via ::cuProfilerStart or
  2268. * ::cuProfilerStop without initialization.
  2269. */
  2270. CUDA_ERROR_PROFILER_NOT_INITIALIZED = 6,
  2271. /**
  2272. * \deprecated
  2273. * This error return is deprecated as of CUDA 5.0. It is no longer an error
  2274. * to call cuProfilerStart() when profiling is already enabled.
  2275. */
  2276. CUDA_ERROR_PROFILER_ALREADY_STARTED = 7,
  2277. /**
  2278. * \deprecated
  2279. * This error return is deprecated as of CUDA 5.0. It is no longer an error
  2280. * to call cuProfilerStop() when profiling is already disabled.
  2281. */
  2282. CUDA_ERROR_PROFILER_ALREADY_STOPPED = 8,
  2283. /**
  2284. * This indicates that the CUDA driver that the application has loaded is a
  2285. * stub library. Applications that run with the stub rather than a real
  2286. * driver loaded will result in CUDA API returning this error.
  2287. */
  2288. CUDA_ERROR_STUB_LIBRARY = 34,
  2289. /**
  2290. * This indicates that requested CUDA device is unavailable at the current
  2291. * time. Devices are often unavailable due to use of
  2292. * ::CU_COMPUTEMODE_EXCLUSIVE_PROCESS or ::CU_COMPUTEMODE_PROHIBITED.
  2293. */
  2294. CUDA_ERROR_DEVICE_UNAVAILABLE = 46,
  2295. /**
  2296. * This indicates that no CUDA-capable devices were detected by the installed
  2297. * CUDA driver.
  2298. */
  2299. CUDA_ERROR_NO_DEVICE = 100,
  2300. /**
  2301. * This indicates that the device ordinal supplied by the user does not
  2302. * correspond to a valid CUDA device or that the action requested is
  2303. * invalid for the specified device.
  2304. */
  2305. CUDA_ERROR_INVALID_DEVICE = 101,
  2306. /**
  2307. * This error indicates that the Grid license is not applied.
  2308. */
  2309. CUDA_ERROR_DEVICE_NOT_LICENSED = 102,
  2310. /**
  2311. * This indicates that the device kernel image is invalid. This can also
  2312. * indicate an invalid CUDA module.
  2313. */
  2314. CUDA_ERROR_INVALID_IMAGE = 200,
  2315. /**
  2316. * This most frequently indicates that there is no context bound to the
  2317. * current thread. This can also be returned if the context passed to an
  2318. * API call is not a valid handle (such as a context that has had
  2319. * ::cuCtxDestroy() invoked on it). This can also be returned if a user
  2320. * mixes different API versions (i.e. 3010 context with 3020 API calls).
  2321. * See ::cuCtxGetApiVersion() for more details.
  2322. * This can also be returned if the green context passed to an API call
  2323. * was not converted to a ::CUcontext using ::cuCtxFromGreenCtx API.
  2324. */
  2325. CUDA_ERROR_INVALID_CONTEXT = 201,
  2326. /**
  2327. * This indicated that the context being supplied as a parameter to the
  2328. * API call was already the active context.
  2329. * \deprecated
  2330. * This error return is deprecated as of CUDA 3.2. It is no longer an
  2331. * error to attempt to push the active context via ::cuCtxPushCurrent().
  2332. */
  2333. CUDA_ERROR_CONTEXT_ALREADY_CURRENT = 202,
  2334. /**
  2335. * This indicates that a map or register operation has failed.
  2336. */
  2337. CUDA_ERROR_MAP_FAILED = 205,
  2338. /**
  2339. * This indicates that an unmap or unregister operation has failed.
  2340. */
  2341. CUDA_ERROR_UNMAP_FAILED = 206,
  2342. /**
  2343. * This indicates that the specified array is currently mapped and thus
  2344. * cannot be destroyed.
  2345. */
  2346. CUDA_ERROR_ARRAY_IS_MAPPED = 207,
  2347. /**
  2348. * This indicates that the resource is already mapped.
  2349. */
  2350. CUDA_ERROR_ALREADY_MAPPED = 208,
  2351. /**
  2352. * This indicates that there is no kernel image available that is suitable
  2353. * for the device. This can occur when a user specifies code generation
  2354. * options for a particular CUDA source file that do not include the
  2355. * corresponding device configuration.
  2356. */
  2357. CUDA_ERROR_NO_BINARY_FOR_GPU = 209,
  2358. /**
  2359. * This indicates that a resource has already been acquired.
  2360. */
  2361. CUDA_ERROR_ALREADY_ACQUIRED = 210,
  2362. /**
  2363. * This indicates that a resource is not mapped.
  2364. */
  2365. CUDA_ERROR_NOT_MAPPED = 211,
  2366. /**
  2367. * This indicates that a mapped resource is not available for access as an
  2368. * array.
  2369. */
  2370. CUDA_ERROR_NOT_MAPPED_AS_ARRAY = 212,
  2371. /**
  2372. * This indicates that a mapped resource is not available for access as a
  2373. * pointer.
  2374. */
  2375. CUDA_ERROR_NOT_MAPPED_AS_POINTER = 213,
  2376. /**
  2377. * This indicates that an uncorrectable ECC error was detected during
  2378. * execution.
  2379. */
  2380. CUDA_ERROR_ECC_UNCORRECTABLE = 214,
  2381. /**
  2382. * This indicates that the ::CUlimit passed to the API call is not
  2383. * supported by the active device.
  2384. */
  2385. CUDA_ERROR_UNSUPPORTED_LIMIT = 215,
  2386. /**
  2387. * This indicates that the ::CUcontext passed to the API call can
  2388. * only be bound to a single CPU thread at a time but is already
  2389. * bound to a CPU thread.
  2390. */
  2391. CUDA_ERROR_CONTEXT_ALREADY_IN_USE = 216,
  2392. /**
  2393. * This indicates that peer access is not supported across the given
  2394. * devices.
  2395. */
  2396. CUDA_ERROR_PEER_ACCESS_UNSUPPORTED = 217,
  2397. /**
  2398. * This indicates that a PTX JIT compilation failed.
  2399. */
  2400. CUDA_ERROR_INVALID_PTX = 218,
  2401. /**
  2402. * This indicates an error with OpenGL or DirectX context.
  2403. */
  2404. CUDA_ERROR_INVALID_GRAPHICS_CONTEXT = 219,
  2405. /**
  2406. * This indicates that an uncorrectable NVLink error was detected during the
  2407. * execution.
  2408. */
  2409. CUDA_ERROR_NVLINK_UNCORRECTABLE = 220,
  2410. /**
  2411. * This indicates that the PTX JIT compiler library was not found.
  2412. */
  2413. CUDA_ERROR_JIT_COMPILER_NOT_FOUND = 221,
  2414. /**
  2415. * This indicates that the provided PTX was compiled with an unsupported toolchain.
  2416. */
  2417. CUDA_ERROR_UNSUPPORTED_PTX_VERSION = 222,
  2418. /**
  2419. * This indicates that the PTX JIT compilation was disabled.
  2420. */
  2421. CUDA_ERROR_JIT_COMPILATION_DISABLED = 223,
  2422. /**
  2423. * This indicates that the ::CUexecAffinityType passed to the API call is not
  2424. * supported by the active device.
  2425. */
  2426. CUDA_ERROR_UNSUPPORTED_EXEC_AFFINITY = 224,
  2427. /**
  2428. * This indicates that the code to be compiled by the PTX JIT contains
  2429. * unsupported call to cudaDeviceSynchronize.
  2430. */
  2431. CUDA_ERROR_UNSUPPORTED_DEVSIDE_SYNC = 225,
  2432. /**
  2433. * This indicates that an exception occurred on the device that is now
  2434. * contained by the GPU's error containment capability. Common causes are -
  2435. * a. Certain types of invalid accesses of peer GPU memory over nvlink
  2436. * b. Certain classes of hardware errors
  2437. * This leaves the process in an inconsistent state and any further CUDA
  2438. * work will return the same error. To continue using CUDA, the process must
  2439. * be terminated and relaunched.
  2440. */
  2441. CUDA_ERROR_CONTAINED = 226,
  2442. /**
  2443. * This indicates that the device kernel source is invalid. This includes
  2444. * compilation/linker errors encountered in device code or user error.
  2445. */
  2446. CUDA_ERROR_INVALID_SOURCE = 300,
  2447. /**
  2448. * This indicates that the file specified was not found.
  2449. */
  2450. CUDA_ERROR_FILE_NOT_FOUND = 301,
  2451. /**
  2452. * This indicates that a link to a shared object failed to resolve.
  2453. */
  2454. CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = 302,
  2455. /**
  2456. * This indicates that initialization of a shared object failed.
  2457. */
  2458. CUDA_ERROR_SHARED_OBJECT_INIT_FAILED = 303,
  2459. /**
  2460. * This indicates that an OS call failed.
  2461. */
  2462. CUDA_ERROR_OPERATING_SYSTEM = 304,
  2463. /**
  2464. * This indicates that a resource handle passed to the API call was not
  2465. * valid. Resource handles are opaque types like ::CUstream and ::CUevent.
  2466. */
  2467. CUDA_ERROR_INVALID_HANDLE = 400,
  2468. /**
  2469. * This indicates that a resource required by the API call is not in a
  2470. * valid state to perform the requested operation.
  2471. */
  2472. CUDA_ERROR_ILLEGAL_STATE = 401,
  2473. /**
  2474. * This indicates an attempt was made to introspect an object in a way that
  2475. * would discard semantically important information. This is either due to
  2476. * the object using funtionality newer than the API version used to
  2477. * introspect it or omission of optional return arguments.
  2478. */
  2479. CUDA_ERROR_LOSSY_QUERY = 402,
  2480. /**
  2481. * This indicates that a named symbol was not found. Examples of symbols
  2482. * are global/constant variable names, driver function names, texture names,
  2483. * and surface names.
  2484. */
  2485. CUDA_ERROR_NOT_FOUND = 500,
  2486. /**
  2487. * This indicates that asynchronous operations issued previously have not
  2488. * completed yet. This result is not actually an error, but must be indicated
  2489. * differently than ::CUDA_SUCCESS (which indicates completion). Calls that
  2490. * may return this value include ::cuEventQuery() and ::cuStreamQuery().
  2491. */
  2492. CUDA_ERROR_NOT_READY = 600,
  2493. /**
  2494. * While executing a kernel, the device encountered a
  2495. * load or store instruction on an invalid memory address.
  2496. * This leaves the process in an inconsistent state and any further CUDA work
  2497. * will return the same error. To continue using CUDA, the process must be terminated
  2498. * and relaunched.
  2499. */
  2500. CUDA_ERROR_ILLEGAL_ADDRESS = 700,
  2501. /**
  2502. * This indicates that a launch did not occur because it did not have
  2503. * appropriate resources. This error usually indicates that the user has
  2504. * attempted to pass too many arguments to the device kernel, or the
  2505. * kernel launch specifies too many threads for the kernel's register
  2506. * count. Passing arguments of the wrong size (i.e. a 64-bit pointer
  2507. * when a 32-bit int is expected) is equivalent to passing too many
  2508. * arguments and can also result in this error.
  2509. */
  2510. CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES = 701,
  2511. /**
  2512. * This indicates that the device kernel took too long to execute. This can
  2513. * only occur if timeouts are enabled - see the device attribute
  2514. * ::CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT for more information.
  2515. * This leaves the process in an inconsistent state and any further CUDA work
  2516. * will return the same error. To continue using CUDA, the process must be terminated
  2517. * and relaunched.
  2518. */
  2519. CUDA_ERROR_LAUNCH_TIMEOUT = 702,
  2520. /**
  2521. * This error indicates a kernel launch that uses an incompatible texturing
  2522. * mode.
  2523. */
  2524. CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING = 703,
  2525. /**
  2526. * This error indicates that a call to ::cuCtxEnablePeerAccess() is
  2527. * trying to re-enable peer access to a context which has already
  2528. * had peer access to it enabled.
  2529. */
  2530. CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED = 704,
  2531. /**
  2532. * This error indicates that ::cuCtxDisablePeerAccess() is
  2533. * trying to disable peer access which has not been enabled yet
  2534. * via ::cuCtxEnablePeerAccess().
  2535. */
  2536. CUDA_ERROR_PEER_ACCESS_NOT_ENABLED = 705,
  2537. /**
  2538. * This error indicates that the primary context for the specified device
  2539. * has already been initialized.
  2540. */
  2541. CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE = 708,
  2542. /**
  2543. * This error indicates that the context current to the calling thread
  2544. * has been destroyed using ::cuCtxDestroy, or is a primary context which
  2545. * has not yet been initialized.
  2546. */
  2547. CUDA_ERROR_CONTEXT_IS_DESTROYED = 709,
  2548. /**
  2549. * A device-side assert triggered during kernel execution. The context
  2550. * cannot be used anymore, and must be destroyed. All existing device
  2551. * memory allocations from this context are invalid and must be
  2552. * reconstructed if the program is to continue using CUDA.
  2553. */
  2554. CUDA_ERROR_ASSERT = 710,
  2555. /**
  2556. * This error indicates that the hardware resources required to enable
  2557. * peer access have been exhausted for one or more of the devices
  2558. * passed to ::cuCtxEnablePeerAccess().
  2559. */
  2560. CUDA_ERROR_TOO_MANY_PEERS = 711,
  2561. /**
  2562. * This error indicates that the memory range passed to ::cuMemHostRegister()
  2563. * has already been registered.
  2564. */
  2565. CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED = 712,
  2566. /**
  2567. * This error indicates that the pointer passed to ::cuMemHostUnregister()
  2568. * does not correspond to any currently registered memory region.
  2569. */
  2570. CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED = 713,
  2571. /**
  2572. * While executing a kernel, the device encountered a stack error.
  2573. * This can be due to stack corruption or exceeding the stack size limit.
  2574. * This leaves the process in an inconsistent state and any further CUDA work
  2575. * will return the same error. To continue using CUDA, the process must be terminated
  2576. * and relaunched.
  2577. */
  2578. CUDA_ERROR_HARDWARE_STACK_ERROR = 714,
  2579. /**
  2580. * While executing a kernel, the device encountered an illegal instruction.
  2581. * This leaves the process in an inconsistent state and any further CUDA work
  2582. * will return the same error. To continue using CUDA, the process must be terminated
  2583. * and relaunched.
  2584. */
  2585. CUDA_ERROR_ILLEGAL_INSTRUCTION = 715,
  2586. /**
  2587. * While executing a kernel, the device encountered a load or store instruction
  2588. * on a memory address which is not aligned.
  2589. * This leaves the process in an inconsistent state and any further CUDA work
  2590. * will return the same error. To continue using CUDA, the process must be terminated
  2591. * and relaunched.
  2592. */
  2593. CUDA_ERROR_MISALIGNED_ADDRESS = 716,
  2594. /**
  2595. * While executing a kernel, the device encountered an instruction
  2596. * which can only operate on memory locations in certain address spaces
  2597. * (global, shared, or local), but was supplied a memory address not
  2598. * belonging to an allowed address space.
  2599. * This leaves the process in an inconsistent state and any further CUDA work
  2600. * will return the same error. To continue using CUDA, the process must be terminated
  2601. * and relaunched.
  2602. */
  2603. CUDA_ERROR_INVALID_ADDRESS_SPACE = 717,
  2604. /**
  2605. * While executing a kernel, the device program counter wrapped its address space.
  2606. * This leaves the process in an inconsistent state and any further CUDA work
  2607. * will return the same error. To continue using CUDA, the process must be terminated
  2608. * and relaunched.
  2609. */
  2610. CUDA_ERROR_INVALID_PC = 718,
  2611. /**
  2612. * An exception occurred on the device while executing a kernel. Common
  2613. * causes include dereferencing an invalid device pointer and accessing
  2614. * out of bounds shared memory. Less common cases can be system specific - more
  2615. * information about these cases can be found in the system specific user guide.
  2616. * This leaves the process in an inconsistent state and any further CUDA work
  2617. * will return the same error. To continue using CUDA, the process must be terminated
  2618. * and relaunched.
  2619. */
  2620. CUDA_ERROR_LAUNCH_FAILED = 719,
  2621. /**
  2622. * This error indicates that the number of blocks launched per grid for a kernel that was
  2623. * launched via either ::cuLaunchCooperativeKernel or ::cuLaunchCooperativeKernelMultiDevice
  2624. * exceeds the maximum number of blocks as allowed by ::cuOccupancyMaxActiveBlocksPerMultiprocessor
  2625. * or ::cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags times the number of multiprocessors
  2626. * as specified by the device attribute ::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT.
  2627. */
  2628. CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE = 720,
  2629. /**
  2630. * An exception occurred on the device while exiting a kernel using tensor memory: the
  2631. * tensor memory was not completely deallocated. This leaves the process in an inconsistent
  2632. * state and any further CUDA work will return the same error. To continue using CUDA, the
  2633. * process must be terminated and relaunched.
  2634. */
  2635. CUDA_ERROR_TENSOR_MEMORY_LEAK = 721,
  2636. /**
  2637. * This error indicates that the attempted operation is not permitted.
  2638. */
  2639. CUDA_ERROR_NOT_PERMITTED = 800,
  2640. /**
  2641. * This error indicates that the attempted operation is not supported
  2642. * on the current system or device.
  2643. */
  2644. CUDA_ERROR_NOT_SUPPORTED = 801,
  2645. /**
  2646. * This error indicates that the system is not yet ready to start any CUDA
  2647. * work. To continue using CUDA, verify the system configuration is in a
  2648. * valid state and all required driver daemons are actively running.
  2649. * More information about this error can be found in the system specific
  2650. * user guide.
  2651. */
  2652. CUDA_ERROR_SYSTEM_NOT_READY = 802,
  2653. /**
  2654. * This error indicates that there is a mismatch between the versions of
  2655. * the display driver and the CUDA driver. Refer to the compatibility documentation
  2656. * for supported versions.
  2657. */
  2658. CUDA_ERROR_SYSTEM_DRIVER_MISMATCH = 803,
  2659. /**
  2660. * This error indicates that the system was upgraded to run with forward compatibility
  2661. * but the visible hardware detected by CUDA does not support this configuration.
  2662. * Refer to the compatibility documentation for the supported hardware matrix or ensure
  2663. * that only supported hardware is visible during initialization via the CUDA_VISIBLE_DEVICES
  2664. * environment variable.
  2665. */
  2666. CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE = 804,
  2667. /**
  2668. * This error indicates that the MPS client failed to connect to the MPS control daemon or the MPS server.
  2669. */
  2670. CUDA_ERROR_MPS_CONNECTION_FAILED = 805,
  2671. /**
  2672. * This error indicates that the remote procedural call between the MPS server and the MPS client failed.
  2673. */
  2674. CUDA_ERROR_MPS_RPC_FAILURE = 806,
  2675. /**
  2676. * This error indicates that the MPS server is not ready to accept new MPS client requests.
  2677. * This error can be returned when the MPS server is in the process of recovering from a fatal failure.
  2678. */
  2679. CUDA_ERROR_MPS_SERVER_NOT_READY = 807,
  2680. /**
  2681. * This error indicates that the hardware resources required to create MPS client have been exhausted.
  2682. */
  2683. CUDA_ERROR_MPS_MAX_CLIENTS_REACHED = 808,
  2684. /**
  2685. * This error indicates the the hardware resources required to support device connections have been exhausted.
  2686. */
  2687. CUDA_ERROR_MPS_MAX_CONNECTIONS_REACHED = 809,
  2688. /**
  2689. * This error indicates that the MPS client has been terminated by the server. To continue using CUDA, the process must be terminated and relaunched.
  2690. */
  2691. CUDA_ERROR_MPS_CLIENT_TERMINATED = 810,
  2692. /**
  2693. * This error indicates that the module is using CUDA Dynamic Parallelism, but the current configuration, like MPS, does not support it.
  2694. */
  2695. CUDA_ERROR_CDP_NOT_SUPPORTED = 811,
  2696. /**
  2697. * This error indicates that a module contains an unsupported interaction between different versions of CUDA Dynamic Parallelism.
  2698. */
  2699. CUDA_ERROR_CDP_VERSION_MISMATCH = 812,
  2700. /**
  2701. * This error indicates that the operation is not permitted when
  2702. * the stream is capturing.
  2703. */
  2704. CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED = 900,
  2705. /**
  2706. * This error indicates that the current capture sequence on the stream
  2707. * has been invalidated due to a previous error.
  2708. */
  2709. CUDA_ERROR_STREAM_CAPTURE_INVALIDATED = 901,
  2710. /**
  2711. * This error indicates that the operation would have resulted in a merge
  2712. * of two independent capture sequences.
  2713. */
  2714. CUDA_ERROR_STREAM_CAPTURE_MERGE = 902,
  2715. /**
  2716. * This error indicates that the capture was not initiated in this stream.
  2717. */
  2718. CUDA_ERROR_STREAM_CAPTURE_UNMATCHED = 903,
  2719. /**
  2720. * This error indicates that the capture sequence contains a fork that was
  2721. * not joined to the primary stream.
  2722. */
  2723. CUDA_ERROR_STREAM_CAPTURE_UNJOINED = 904,
  2724. /**
  2725. * This error indicates that a dependency would have been created which
  2726. * crosses the capture sequence boundary. Only implicit in-stream ordering
  2727. * dependencies are allowed to cross the boundary.
  2728. */
  2729. CUDA_ERROR_STREAM_CAPTURE_ISOLATION = 905,
  2730. /**
  2731. * This error indicates a disallowed implicit dependency on a current capture
  2732. * sequence from cudaStreamLegacy.
  2733. */
  2734. CUDA_ERROR_STREAM_CAPTURE_IMPLICIT = 906,
  2735. /**
  2736. * This error indicates that the operation is not permitted on an event which
  2737. * was last recorded in a capturing stream.
  2738. */
  2739. CUDA_ERROR_CAPTURED_EVENT = 907,
  2740. /**
  2741. * A stream capture sequence not initiated with the ::CU_STREAM_CAPTURE_MODE_RELAXED
  2742. * argument to ::cuStreamBeginCapture was passed to ::cuStreamEndCapture in a
  2743. * different thread.
  2744. */
  2745. CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD = 908,
  2746. /**
  2747. * This error indicates that the timeout specified for the wait operation has lapsed.
  2748. */
  2749. CUDA_ERROR_TIMEOUT = 909,
  2750. /**
  2751. * This error indicates that the graph update was not performed because it included
  2752. * changes which violated constraints specific to instantiated graph update.
  2753. */
  2754. CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE = 910,
  2755. /**
  2756. * This indicates that an async error has occurred in a device outside of CUDA.
  2757. * If CUDA was waiting for an external device's signal before consuming shared data,
  2758. * the external device signaled an error indicating that the data is not valid for
  2759. * consumption. This leaves the process in an inconsistent state and any further CUDA
  2760. * work will return the same error. To continue using CUDA, the process must be
  2761. * terminated and relaunched.
  2762. */
  2763. CUDA_ERROR_EXTERNAL_DEVICE = 911,
  2764. /**
  2765. * Indicates a kernel launch error due to cluster misconfiguration.
  2766. */
  2767. CUDA_ERROR_INVALID_CLUSTER_SIZE = 912,
  2768. /**
  2769. * Indiciates a function handle is not loaded when calling an API that requires
  2770. * a loaded function.
  2771. */
  2772. CUDA_ERROR_FUNCTION_NOT_LOADED = 913,
  2773. /**
  2774. * This error indicates one or more resources passed in are not valid resource
  2775. * types for the operation.
  2776. */
  2777. CUDA_ERROR_INVALID_RESOURCE_TYPE = 914,
  2778. /**
  2779. * This error indicates one or more resources are insufficient or non-applicable for
  2780. * the operation.
  2781. */
  2782. CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION = 915,
  2783. /**
  2784. * This error indicates that an error happened during the key rotation
  2785. * sequence.
  2786. */
  2787. CUDA_ERROR_KEY_ROTATION = 916,
  2788. /**
  2789. * This indicates that an unknown internal error has occurred.
  2790. */
  2791. CUDA_ERROR_UNKNOWN = 999
  2792. } CUresult;
  2793. /**
  2794. * P2P Attributes
  2795. */
  2796. typedef enum CUdevice_P2PAttribute_enum {
  2797. CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK = 0x01, /**< A relative value indicating the performance of the link between two devices */
  2798. CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED = 0x02, /**< P2P Access is enable */
  2799. CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED = 0x03, /**< Atomic operation over the link supported */
  2800. CU_DEVICE_P2P_ATTRIBUTE_ACCESS_ACCESS_SUPPORTED = 0x04, /**< \deprecated use CU_DEVICE_P2P_ATTRIBUTE_CUDA_ARRAY_ACCESS_SUPPORTED instead */
  2801. CU_DEVICE_P2P_ATTRIBUTE_CUDA_ARRAY_ACCESS_SUPPORTED = 0x04 /**< Accessing CUDA arrays over the link supported */
  2802. } CUdevice_P2PAttribute;
  2803. /**
  2804. * CUDA stream callback
  2805. * \param hStream The stream the callback was added to, as passed to ::cuStreamAddCallback. May be NULL.
  2806. * \param status ::CUDA_SUCCESS or any persistent error on the stream.
  2807. * \param userData User parameter provided at registration.
  2808. */
  2809. typedef void (CUDA_CB *CUstreamCallback)(CUstream hStream, CUresult status, void *userData);
  2810. /**
  2811. * Block size to per-block dynamic shared memory mapping for a certain
  2812. * kernel \param blockSize Block size of the kernel.
  2813. *
  2814. * \return The dynamic shared memory needed by a block.
  2815. */
  2816. typedef size_t (CUDA_CB *CUoccupancyB2DSize)(int blockSize);
  2817. /**
  2818. * If set, host memory is portable between CUDA contexts.
  2819. * Flag for ::cuMemHostAlloc()
  2820. */
  2821. #define CU_MEMHOSTALLOC_PORTABLE 0x01
  2822. /**
  2823. * If set, host memory is mapped into CUDA address space and
  2824. * ::cuMemHostGetDevicePointer() may be called on the host pointer.
  2825. * Flag for ::cuMemHostAlloc()
  2826. */
  2827. #define CU_MEMHOSTALLOC_DEVICEMAP 0x02
  2828. /**
  2829. * If set, host memory is allocated as write-combined - fast to write,
  2830. * faster to DMA, slow to read except via SSE4 streaming load instruction
  2831. * (MOVNTDQA).
  2832. * Flag for ::cuMemHostAlloc()
  2833. */
  2834. #define CU_MEMHOSTALLOC_WRITECOMBINED 0x04
  2835. /**
  2836. * If set, host memory is portable between CUDA contexts.
  2837. * Flag for ::cuMemHostRegister()
  2838. */
  2839. #define CU_MEMHOSTREGISTER_PORTABLE 0x01
  2840. /**
  2841. * If set, host memory is mapped into CUDA address space and
  2842. * ::cuMemHostGetDevicePointer() may be called on the host pointer.
  2843. * Flag for ::cuMemHostRegister()
  2844. */
  2845. #define CU_MEMHOSTREGISTER_DEVICEMAP 0x02
  2846. /**
  2847. * If set, the passed memory pointer is treated as pointing to some
  2848. * memory-mapped I/O space, e.g. belonging to a third-party PCIe device.
  2849. * On Windows the flag is a no-op.
  2850. * On Linux that memory is marked as non cache-coherent for the GPU and
  2851. * is expected to be physically contiguous. It may return
  2852. * ::CUDA_ERROR_NOT_PERMITTED if run as an unprivileged user,
  2853. * ::CUDA_ERROR_NOT_SUPPORTED on older Linux kernel versions.
  2854. * On all other platforms, it is not supported and ::CUDA_ERROR_NOT_SUPPORTED
  2855. * is returned.
  2856. * Flag for ::cuMemHostRegister()
  2857. */
  2858. #define CU_MEMHOSTREGISTER_IOMEMORY 0x04
  2859. /**
  2860. * If set, the passed memory pointer is treated as pointing to memory that is
  2861. * considered read-only by the device. On platforms without
  2862. * ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES, this flag is
  2863. * required in order to register memory mapped to the CPU as read-only. Support
  2864. * for the use of this flag can be queried from the device attribute
  2865. * ::CU_DEVICE_ATTRIBUTE_READ_ONLY_HOST_REGISTER_SUPPORTED. Using this flag with
  2866. * a current context associated with a device that does not have this attribute
  2867. * set will cause ::cuMemHostRegister to error with ::CUDA_ERROR_NOT_SUPPORTED.
  2868. */
  2869. #define CU_MEMHOSTREGISTER_READ_ONLY 0x08
  2870. /**
  2871. * 2D memory copy parameters
  2872. */
  2873. typedef struct CUDA_MEMCPY2D_st {
  2874. size_t srcXInBytes; /**< Source X in bytes */
  2875. size_t srcY; /**< Source Y */
  2876. CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */
  2877. const void *srcHost; /**< Source host pointer */
  2878. CUdeviceptr srcDevice; /**< Source device pointer */
  2879. CUarray srcArray; /**< Source array reference */
  2880. size_t srcPitch; /**< Source pitch (ignored when src is array) */
  2881. size_t dstXInBytes; /**< Destination X in bytes */
  2882. size_t dstY; /**< Destination Y */
  2883. CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */
  2884. void *dstHost; /**< Destination host pointer */
  2885. CUdeviceptr dstDevice; /**< Destination device pointer */
  2886. CUarray dstArray; /**< Destination array reference */
  2887. size_t dstPitch; /**< Destination pitch (ignored when dst is array) */
  2888. size_t WidthInBytes; /**< Width of 2D memory copy in bytes */
  2889. size_t Height; /**< Height of 2D memory copy */
  2890. } CUDA_MEMCPY2D_v2;
  2891. typedef CUDA_MEMCPY2D_v2 CUDA_MEMCPY2D;
  2892. /**
  2893. * 3D memory copy parameters
  2894. */
  2895. typedef struct CUDA_MEMCPY3D_st {
  2896. size_t srcXInBytes; /**< Source X in bytes */
  2897. size_t srcY; /**< Source Y */
  2898. size_t srcZ; /**< Source Z */
  2899. size_t srcLOD; /**< Source LOD */
  2900. CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */
  2901. const void *srcHost; /**< Source host pointer */
  2902. CUdeviceptr srcDevice; /**< Source device pointer */
  2903. CUarray srcArray; /**< Source array reference */
  2904. void *reserved0; /**< Must be NULL */
  2905. size_t srcPitch; /**< Source pitch (ignored when src is array) */
  2906. size_t srcHeight; /**< Source height (ignored when src is array; may be 0 if Depth==1) */
  2907. size_t dstXInBytes; /**< Destination X in bytes */
  2908. size_t dstY; /**< Destination Y */
  2909. size_t dstZ; /**< Destination Z */
  2910. size_t dstLOD; /**< Destination LOD */
  2911. CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */
  2912. void *dstHost; /**< Destination host pointer */
  2913. CUdeviceptr dstDevice; /**< Destination device pointer */
  2914. CUarray dstArray; /**< Destination array reference */
  2915. void *reserved1; /**< Must be NULL */
  2916. size_t dstPitch; /**< Destination pitch (ignored when dst is array) */
  2917. size_t dstHeight; /**< Destination height (ignored when dst is array; may be 0 if Depth==1) */
  2918. size_t WidthInBytes; /**< Width of 3D memory copy in bytes */
  2919. size_t Height; /**< Height of 3D memory copy */
  2920. size_t Depth; /**< Depth of 3D memory copy */
  2921. } CUDA_MEMCPY3D_v2;
  2922. typedef CUDA_MEMCPY3D_v2 CUDA_MEMCPY3D;
  2923. /**
  2924. * 3D memory cross-context copy parameters
  2925. */
  2926. typedef struct CUDA_MEMCPY3D_PEER_st {
  2927. size_t srcXInBytes; /**< Source X in bytes */
  2928. size_t srcY; /**< Source Y */
  2929. size_t srcZ; /**< Source Z */
  2930. size_t srcLOD; /**< Source LOD */
  2931. CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */
  2932. const void *srcHost; /**< Source host pointer */
  2933. CUdeviceptr srcDevice; /**< Source device pointer */
  2934. CUarray srcArray; /**< Source array reference */
  2935. CUcontext srcContext; /**< Source context (ignored with srcMemoryType is ::CU_MEMORYTYPE_ARRAY) */
  2936. size_t srcPitch; /**< Source pitch (ignored when src is array) */
  2937. size_t srcHeight; /**< Source height (ignored when src is array; may be 0 if Depth==1) */
  2938. size_t dstXInBytes; /**< Destination X in bytes */
  2939. size_t dstY; /**< Destination Y */
  2940. size_t dstZ; /**< Destination Z */
  2941. size_t dstLOD; /**< Destination LOD */
  2942. CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */
  2943. void *dstHost; /**< Destination host pointer */
  2944. CUdeviceptr dstDevice; /**< Destination device pointer */
  2945. CUarray dstArray; /**< Destination array reference */
  2946. CUcontext dstContext; /**< Destination context (ignored with dstMemoryType is ::CU_MEMORYTYPE_ARRAY) */
  2947. size_t dstPitch; /**< Destination pitch (ignored when dst is array) */
  2948. size_t dstHeight; /**< Destination height (ignored when dst is array; may be 0 if Depth==1) */
  2949. size_t WidthInBytes; /**< Width of 3D memory copy in bytes */
  2950. size_t Height; /**< Height of 3D memory copy */
  2951. size_t Depth; /**< Depth of 3D memory copy */
  2952. } CUDA_MEMCPY3D_PEER_v1;
  2953. typedef CUDA_MEMCPY3D_PEER_v1 CUDA_MEMCPY3D_PEER;
  2954. /**
  2955. * Memcpy node parameters
  2956. */
  2957. typedef struct CUDA_MEMCPY_NODE_PARAMS_st {
  2958. int flags; /**< Must be zero */
  2959. int reserved; /**< Must be zero */
  2960. CUcontext copyCtx; /**< Context on which to run the node */
  2961. CUDA_MEMCPY3D copyParams; /**< Parameters for the memory copy */
  2962. } CUDA_MEMCPY_NODE_PARAMS;
  2963. /**
  2964. * Array descriptor
  2965. */
  2966. typedef struct CUDA_ARRAY_DESCRIPTOR_st
  2967. {
  2968. size_t Width; /**< Width of array */
  2969. size_t Height; /**< Height of array */
  2970. CUarray_format Format; /**< Array format */
  2971. unsigned int NumChannels; /**< Channels per array element */
  2972. } CUDA_ARRAY_DESCRIPTOR_v2;
  2973. typedef CUDA_ARRAY_DESCRIPTOR_v2 CUDA_ARRAY_DESCRIPTOR;
  2974. /**
  2975. * 3D array descriptor
  2976. */
  2977. typedef struct CUDA_ARRAY3D_DESCRIPTOR_st
  2978. {
  2979. size_t Width; /**< Width of 3D array */
  2980. size_t Height; /**< Height of 3D array */
  2981. size_t Depth; /**< Depth of 3D array */
  2982. CUarray_format Format; /**< Array format */
  2983. unsigned int NumChannels; /**< Channels per array element */
  2984. unsigned int Flags; /**< Flags */
  2985. } CUDA_ARRAY3D_DESCRIPTOR_v2;
  2986. typedef CUDA_ARRAY3D_DESCRIPTOR_v2 CUDA_ARRAY3D_DESCRIPTOR;
  2987. /**
  2988. * Indicates that the layered sparse CUDA array or CUDA mipmapped array has a single mip tail region for all layers
  2989. */
  2990. #define CU_ARRAY_SPARSE_PROPERTIES_SINGLE_MIPTAIL 0x1
  2991. /**
  2992. * CUDA array sparse properties
  2993. */
  2994. typedef struct CUDA_ARRAY_SPARSE_PROPERTIES_st {
  2995. struct {
  2996. unsigned int width; /**< Width of sparse tile in elements */
  2997. unsigned int height; /**< Height of sparse tile in elements */
  2998. unsigned int depth; /**< Depth of sparse tile in elements */
  2999. } tileExtent;
  3000. /**
  3001. * First mip level at which the mip tail begins.
  3002. */
  3003. unsigned int miptailFirstLevel;
  3004. /**
  3005. * Total size of the mip tail.
  3006. */
  3007. unsigned long long miptailSize;
  3008. /**
  3009. * Flags will either be zero or ::CU_ARRAY_SPARSE_PROPERTIES_SINGLE_MIPTAIL
  3010. */
  3011. unsigned int flags;
  3012. unsigned int reserved[4];
  3013. } CUDA_ARRAY_SPARSE_PROPERTIES_v1;
  3014. typedef CUDA_ARRAY_SPARSE_PROPERTIES_v1 CUDA_ARRAY_SPARSE_PROPERTIES;
  3015. /**
  3016. * CUDA array memory requirements
  3017. */
  3018. typedef struct CUDA_ARRAY_MEMORY_REQUIREMENTS_st {
  3019. size_t size; /**< Total required memory size */
  3020. size_t alignment; /**< alignment requirement */
  3021. unsigned int reserved[4];
  3022. } CUDA_ARRAY_MEMORY_REQUIREMENTS_v1;
  3023. typedef CUDA_ARRAY_MEMORY_REQUIREMENTS_v1 CUDA_ARRAY_MEMORY_REQUIREMENTS;
  3024. /**
  3025. * CUDA Resource descriptor
  3026. */
  3027. typedef struct CUDA_RESOURCE_DESC_st
  3028. {
  3029. CUresourcetype resType; /**< Resource type */
  3030. union {
  3031. struct {
  3032. CUarray hArray; /**< CUDA array */
  3033. } array;
  3034. struct {
  3035. CUmipmappedArray hMipmappedArray; /**< CUDA mipmapped array */
  3036. } mipmap;
  3037. struct {
  3038. CUdeviceptr devPtr; /**< Device pointer */
  3039. CUarray_format format; /**< Array format */
  3040. unsigned int numChannels; /**< Channels per array element */
  3041. size_t sizeInBytes; /**< Size in bytes */
  3042. } linear;
  3043. struct {
  3044. CUdeviceptr devPtr; /**< Device pointer */
  3045. CUarray_format format; /**< Array format */
  3046. unsigned int numChannels; /**< Channels per array element */
  3047. size_t width; /**< Width of the array in elements */
  3048. size_t height; /**< Height of the array in elements */
  3049. size_t pitchInBytes; /**< Pitch between two rows in bytes */
  3050. } pitch2D;
  3051. struct {
  3052. int reserved[32];
  3053. } reserved;
  3054. } res;
  3055. unsigned int flags; /**< Flags (must be zero) */
  3056. } CUDA_RESOURCE_DESC_v1;
  3057. typedef CUDA_RESOURCE_DESC_v1 CUDA_RESOURCE_DESC;
  3058. /**
  3059. * Texture descriptor
  3060. */
  3061. typedef struct CUDA_TEXTURE_DESC_st {
  3062. CUaddress_mode addressMode[3]; /**< Address modes */
  3063. CUfilter_mode filterMode; /**< Filter mode */
  3064. unsigned int flags; /**< Flags */
  3065. unsigned int maxAnisotropy; /**< Maximum anisotropy ratio */
  3066. CUfilter_mode mipmapFilterMode; /**< Mipmap filter mode */
  3067. float mipmapLevelBias; /**< Mipmap level bias */
  3068. float minMipmapLevelClamp; /**< Mipmap minimum level clamp */
  3069. float maxMipmapLevelClamp; /**< Mipmap maximum level clamp */
  3070. float borderColor[4]; /**< Border Color */
  3071. int reserved[12];
  3072. } CUDA_TEXTURE_DESC_v1;
  3073. typedef CUDA_TEXTURE_DESC_v1 CUDA_TEXTURE_DESC;
  3074. /**
  3075. * Resource view format
  3076. */
  3077. typedef enum CUresourceViewFormat_enum
  3078. {
  3079. CU_RES_VIEW_FORMAT_NONE = 0x00, /**< No resource view format (use underlying resource format) */
  3080. CU_RES_VIEW_FORMAT_UINT_1X8 = 0x01, /**< 1 channel unsigned 8-bit integers */
  3081. CU_RES_VIEW_FORMAT_UINT_2X8 = 0x02, /**< 2 channel unsigned 8-bit integers */
  3082. CU_RES_VIEW_FORMAT_UINT_4X8 = 0x03, /**< 4 channel unsigned 8-bit integers */
  3083. CU_RES_VIEW_FORMAT_SINT_1X8 = 0x04, /**< 1 channel signed 8-bit integers */
  3084. CU_RES_VIEW_FORMAT_SINT_2X8 = 0x05, /**< 2 channel signed 8-bit integers */
  3085. CU_RES_VIEW_FORMAT_SINT_4X8 = 0x06, /**< 4 channel signed 8-bit integers */
  3086. CU_RES_VIEW_FORMAT_UINT_1X16 = 0x07, /**< 1 channel unsigned 16-bit integers */
  3087. CU_RES_VIEW_FORMAT_UINT_2X16 = 0x08, /**< 2 channel unsigned 16-bit integers */
  3088. CU_RES_VIEW_FORMAT_UINT_4X16 = 0x09, /**< 4 channel unsigned 16-bit integers */
  3089. CU_RES_VIEW_FORMAT_SINT_1X16 = 0x0a, /**< 1 channel signed 16-bit integers */
  3090. CU_RES_VIEW_FORMAT_SINT_2X16 = 0x0b, /**< 2 channel signed 16-bit integers */
  3091. CU_RES_VIEW_FORMAT_SINT_4X16 = 0x0c, /**< 4 channel signed 16-bit integers */
  3092. CU_RES_VIEW_FORMAT_UINT_1X32 = 0x0d, /**< 1 channel unsigned 32-bit integers */
  3093. CU_RES_VIEW_FORMAT_UINT_2X32 = 0x0e, /**< 2 channel unsigned 32-bit integers */
  3094. CU_RES_VIEW_FORMAT_UINT_4X32 = 0x0f, /**< 4 channel unsigned 32-bit integers */
  3095. CU_RES_VIEW_FORMAT_SINT_1X32 = 0x10, /**< 1 channel signed 32-bit integers */
  3096. CU_RES_VIEW_FORMAT_SINT_2X32 = 0x11, /**< 2 channel signed 32-bit integers */
  3097. CU_RES_VIEW_FORMAT_SINT_4X32 = 0x12, /**< 4 channel signed 32-bit integers */
  3098. CU_RES_VIEW_FORMAT_FLOAT_1X16 = 0x13, /**< 1 channel 16-bit floating point */
  3099. CU_RES_VIEW_FORMAT_FLOAT_2X16 = 0x14, /**< 2 channel 16-bit floating point */
  3100. CU_RES_VIEW_FORMAT_FLOAT_4X16 = 0x15, /**< 4 channel 16-bit floating point */
  3101. CU_RES_VIEW_FORMAT_FLOAT_1X32 = 0x16, /**< 1 channel 32-bit floating point */
  3102. CU_RES_VIEW_FORMAT_FLOAT_2X32 = 0x17, /**< 2 channel 32-bit floating point */
  3103. CU_RES_VIEW_FORMAT_FLOAT_4X32 = 0x18, /**< 4 channel 32-bit floating point */
  3104. CU_RES_VIEW_FORMAT_UNSIGNED_BC1 = 0x19, /**< Block compressed 1 */
  3105. CU_RES_VIEW_FORMAT_UNSIGNED_BC2 = 0x1a, /**< Block compressed 2 */
  3106. CU_RES_VIEW_FORMAT_UNSIGNED_BC3 = 0x1b, /**< Block compressed 3 */
  3107. CU_RES_VIEW_FORMAT_UNSIGNED_BC4 = 0x1c, /**< Block compressed 4 unsigned */
  3108. CU_RES_VIEW_FORMAT_SIGNED_BC4 = 0x1d, /**< Block compressed 4 signed */
  3109. CU_RES_VIEW_FORMAT_UNSIGNED_BC5 = 0x1e, /**< Block compressed 5 unsigned */
  3110. CU_RES_VIEW_FORMAT_SIGNED_BC5 = 0x1f, /**< Block compressed 5 signed */
  3111. CU_RES_VIEW_FORMAT_UNSIGNED_BC6H = 0x20, /**< Block compressed 6 unsigned half-float */
  3112. CU_RES_VIEW_FORMAT_SIGNED_BC6H = 0x21, /**< Block compressed 6 signed half-float */
  3113. CU_RES_VIEW_FORMAT_UNSIGNED_BC7 = 0x22 /**< Block compressed 7 */
  3114. } CUresourceViewFormat;
  3115. /**
  3116. * Resource view descriptor
  3117. */
  3118. typedef struct CUDA_RESOURCE_VIEW_DESC_st
  3119. {
  3120. CUresourceViewFormat format; /**< Resource view format */
  3121. size_t width; /**< Width of the resource view */
  3122. size_t height; /**< Height of the resource view */
  3123. size_t depth; /**< Depth of the resource view */
  3124. unsigned int firstMipmapLevel; /**< First defined mipmap level */
  3125. unsigned int lastMipmapLevel; /**< Last defined mipmap level */
  3126. unsigned int firstLayer; /**< First layer index */
  3127. unsigned int lastLayer; /**< Last layer index */
  3128. unsigned int reserved[16];
  3129. } CUDA_RESOURCE_VIEW_DESC_v1;
  3130. typedef CUDA_RESOURCE_VIEW_DESC_v1 CUDA_RESOURCE_VIEW_DESC;
  3131. /**
  3132. * Size of tensor map descriptor
  3133. */
  3134. #define CU_TENSOR_MAP_NUM_QWORDS 16
  3135. /**
  3136. * Tensor map descriptor. Requires compiler support for aligning to 64 bytes.
  3137. */
  3138. typedef struct CUtensorMap_st {
  3139. #if defined(__cplusplus) && (__cplusplus >= 201103L)
  3140. alignas(64)
  3141. #elif __STDC_VERSION__ >= 201112L
  3142. _Alignas(64)
  3143. #endif
  3144. cuuint64_t opaque[CU_TENSOR_MAP_NUM_QWORDS];
  3145. } CUtensorMap;
  3146. /**
  3147. * Tensor map data type
  3148. */
  3149. typedef enum CUtensorMapDataType_enum {
  3150. CU_TENSOR_MAP_DATA_TYPE_UINT8 = 0,
  3151. CU_TENSOR_MAP_DATA_TYPE_UINT16,
  3152. CU_TENSOR_MAP_DATA_TYPE_UINT32,
  3153. CU_TENSOR_MAP_DATA_TYPE_INT32,
  3154. CU_TENSOR_MAP_DATA_TYPE_UINT64,
  3155. CU_TENSOR_MAP_DATA_TYPE_INT64,
  3156. CU_TENSOR_MAP_DATA_TYPE_FLOAT16,
  3157. CU_TENSOR_MAP_DATA_TYPE_FLOAT32,
  3158. CU_TENSOR_MAP_DATA_TYPE_FLOAT64,
  3159. CU_TENSOR_MAP_DATA_TYPE_BFLOAT16,
  3160. CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ,
  3161. CU_TENSOR_MAP_DATA_TYPE_TFLOAT32,
  3162. CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ,
  3163. CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B,
  3164. CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B,
  3165. CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B
  3166. } CUtensorMapDataType;
  3167. /**
  3168. * Tensor map interleave layout type
  3169. */
  3170. typedef enum CUtensorMapInterleave_enum {
  3171. CU_TENSOR_MAP_INTERLEAVE_NONE = 0,
  3172. CU_TENSOR_MAP_INTERLEAVE_16B,
  3173. CU_TENSOR_MAP_INTERLEAVE_32B
  3174. } CUtensorMapInterleave;
  3175. /**
  3176. * Tensor map swizzling mode of shared memory banks
  3177. */
  3178. typedef enum CUtensorMapSwizzle_enum {
  3179. CU_TENSOR_MAP_SWIZZLE_NONE = 0,
  3180. CU_TENSOR_MAP_SWIZZLE_32B,
  3181. CU_TENSOR_MAP_SWIZZLE_64B,
  3182. CU_TENSOR_MAP_SWIZZLE_128B,
  3183. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B,
  3184. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B_FLIP_8B,
  3185. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B
  3186. } CUtensorMapSwizzle;
  3187. /**
  3188. * Tensor map L2 promotion type
  3189. */
  3190. typedef enum CUtensorMapL2promotion_enum {
  3191. CU_TENSOR_MAP_L2_PROMOTION_NONE = 0,
  3192. CU_TENSOR_MAP_L2_PROMOTION_L2_64B,
  3193. CU_TENSOR_MAP_L2_PROMOTION_L2_128B,
  3194. CU_TENSOR_MAP_L2_PROMOTION_L2_256B
  3195. } CUtensorMapL2promotion;
  3196. /**
  3197. * Tensor map out-of-bounds fill type
  3198. */
  3199. typedef enum CUtensorMapFloatOOBfill_enum {
  3200. CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE = 0,
  3201. CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA
  3202. } CUtensorMapFloatOOBfill;
  3203. /**
  3204. * Tensor map Im2Col wide mode
  3205. */
  3206. typedef enum CUtensorMapIm2ColWideMode_enum {
  3207. CU_TENSOR_MAP_IM2COL_WIDE_MODE_W = 0,
  3208. CU_TENSOR_MAP_IM2COL_WIDE_MODE_W128
  3209. } CUtensorMapIm2ColWideMode;
  3210. /**
  3211. * GPU Direct v3 tokens
  3212. */
  3213. typedef struct CUDA_POINTER_ATTRIBUTE_P2P_TOKENS_st {
  3214. unsigned long long p2pToken;
  3215. unsigned int vaSpaceToken;
  3216. } CUDA_POINTER_ATTRIBUTE_P2P_TOKENS_v1;
  3217. typedef CUDA_POINTER_ATTRIBUTE_P2P_TOKENS_v1 CUDA_POINTER_ATTRIBUTE_P2P_TOKENS;
  3218. /**
  3219. * Access flags that specify the level of access the current context's device has
  3220. * on the memory referenced.
  3221. */
  3222. typedef enum CUDA_POINTER_ATTRIBUTE_ACCESS_FLAGS_enum {
  3223. CU_POINTER_ATTRIBUTE_ACCESS_FLAG_NONE = 0x0, /**< No access, meaning the device cannot access this memory at all, thus must be staged through accessible memory in order to complete certain operations */
  3224. CU_POINTER_ATTRIBUTE_ACCESS_FLAG_READ = 0x1, /**< Read-only access, meaning writes to this memory are considered invalid accesses and thus return error in that case. */
  3225. CU_POINTER_ATTRIBUTE_ACCESS_FLAG_READWRITE = 0x3 /**< Read-write access, the device has full read-write access to the memory */
  3226. } CUDA_POINTER_ATTRIBUTE_ACCESS_FLAGS;
  3227. /**
  3228. * Kernel launch parameters
  3229. */
  3230. typedef struct CUDA_LAUNCH_PARAMS_st {
  3231. CUfunction function; /**< Kernel to launch */
  3232. unsigned int gridDimX; /**< Width of grid in blocks */
  3233. unsigned int gridDimY; /**< Height of grid in blocks */
  3234. unsigned int gridDimZ; /**< Depth of grid in blocks */
  3235. unsigned int blockDimX; /**< X dimension of each thread block */
  3236. unsigned int blockDimY; /**< Y dimension of each thread block */
  3237. unsigned int blockDimZ; /**< Z dimension of each thread block */
  3238. unsigned int sharedMemBytes; /**< Dynamic shared-memory size per thread block in bytes */
  3239. CUstream hStream; /**< Stream identifier */
  3240. void **kernelParams; /**< Array of pointers to kernel parameters */
  3241. } CUDA_LAUNCH_PARAMS_v1;
  3242. typedef CUDA_LAUNCH_PARAMS_v1 CUDA_LAUNCH_PARAMS;
  3243. /**
  3244. * External memory handle types
  3245. */
  3246. typedef enum CUexternalMemoryHandleType_enum {
  3247. /**
  3248. * Handle is an opaque file descriptor
  3249. */
  3250. CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD = 1,
  3251. /**
  3252. * Handle is an opaque shared NT handle
  3253. */
  3254. CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32 = 2,
  3255. /**
  3256. * Handle is an opaque, globally shared handle
  3257. */
  3258. CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
  3259. /**
  3260. * Handle is a D3D12 heap object
  3261. */
  3262. CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP = 4,
  3263. /**
  3264. * Handle is a D3D12 committed resource
  3265. */
  3266. CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE = 5,
  3267. /**
  3268. * Handle is a shared NT handle to a D3D11 resource
  3269. */
  3270. CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE = 6,
  3271. /**
  3272. * Handle is a globally shared handle to a D3D11 resource
  3273. */
  3274. CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT = 7,
  3275. /**
  3276. * Handle is an NvSciBuf object
  3277. */
  3278. CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF = 8,
  3279. } CUexternalMemoryHandleType;
  3280. /**
  3281. * Indicates that the external memory object is a dedicated resource
  3282. */
  3283. #define CUDA_EXTERNAL_MEMORY_DEDICATED 0x1
  3284. /** When the \p flags parameter of ::CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS
  3285. * contains this flag, it indicates that signaling an external semaphore object
  3286. * should skip performing appropriate memory synchronization operations over all
  3287. * the external memory objects that are imported as ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF,
  3288. * which otherwise are performed by default to ensure data coherency with other
  3289. * importers of the same NvSciBuf memory objects.
  3290. */
  3291. #define CUDA_EXTERNAL_SEMAPHORE_SIGNAL_SKIP_NVSCIBUF_MEMSYNC 0x01
  3292. /** When the \p flags parameter of ::CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS
  3293. * contains this flag, it indicates that waiting on an external semaphore object
  3294. * should skip performing appropriate memory synchronization operations over all
  3295. * the external memory objects that are imported as ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF,
  3296. * which otherwise are performed by default to ensure data coherency with other
  3297. * importers of the same NvSciBuf memory objects.
  3298. */
  3299. #define CUDA_EXTERNAL_SEMAPHORE_WAIT_SKIP_NVSCIBUF_MEMSYNC 0x02
  3300. /**
  3301. * When \p flags of ::cuDeviceGetNvSciSyncAttributes is set to this,
  3302. * it indicates that application needs signaler specific NvSciSyncAttr
  3303. * to be filled by ::cuDeviceGetNvSciSyncAttributes.
  3304. */
  3305. #define CUDA_NVSCISYNC_ATTR_SIGNAL 0x1
  3306. /**
  3307. * When \p flags of ::cuDeviceGetNvSciSyncAttributes is set to this,
  3308. * it indicates that application needs waiter specific NvSciSyncAttr
  3309. * to be filled by ::cuDeviceGetNvSciSyncAttributes.
  3310. */
  3311. #define CUDA_NVSCISYNC_ATTR_WAIT 0x2
  3312. /**
  3313. * External memory handle descriptor
  3314. */
  3315. typedef struct CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st {
  3316. /**
  3317. * Type of the handle
  3318. */
  3319. CUexternalMemoryHandleType type;
  3320. union {
  3321. /**
  3322. * File descriptor referencing the memory object. Valid
  3323. * when type is
  3324. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD
  3325. */
  3326. int fd;
  3327. /**
  3328. * Win32 handle referencing the semaphore object. Valid when
  3329. * type is one of the following:
  3330. * - ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32
  3331. * - ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT
  3332. * - ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP
  3333. * - ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE
  3334. * - ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE
  3335. * - ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT
  3336. * Exactly one of 'handle' and 'name' must be non-NULL. If
  3337. * type is one of the following:
  3338. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT
  3339. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT
  3340. * then 'name' must be NULL.
  3341. */
  3342. struct {
  3343. /**
  3344. * Valid NT handle. Must be NULL if 'name' is non-NULL
  3345. */
  3346. void *handle;
  3347. /**
  3348. * Name of a valid memory object.
  3349. * Must be NULL if 'handle' is non-NULL.
  3350. */
  3351. const void *name;
  3352. } win32;
  3353. /**
  3354. * A handle representing an NvSciBuf Object. Valid when type
  3355. * is ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF
  3356. */
  3357. const void *nvSciBufObject;
  3358. } handle;
  3359. /**
  3360. * Size of the memory allocation
  3361. */
  3362. unsigned long long size;
  3363. /**
  3364. * Flags must either be zero or ::CUDA_EXTERNAL_MEMORY_DEDICATED
  3365. */
  3366. unsigned int flags;
  3367. unsigned int reserved[16];
  3368. } CUDA_EXTERNAL_MEMORY_HANDLE_DESC_v1;
  3369. typedef CUDA_EXTERNAL_MEMORY_HANDLE_DESC_v1 CUDA_EXTERNAL_MEMORY_HANDLE_DESC;
  3370. /**
  3371. * External memory buffer descriptor
  3372. */
  3373. typedef struct CUDA_EXTERNAL_MEMORY_BUFFER_DESC_st {
  3374. /**
  3375. * Offset into the memory object where the buffer's base is
  3376. */
  3377. unsigned long long offset;
  3378. /**
  3379. * Size of the buffer
  3380. */
  3381. unsigned long long size;
  3382. /**
  3383. * Flags reserved for future use. Must be zero.
  3384. */
  3385. unsigned int flags;
  3386. unsigned int reserved[16];
  3387. } CUDA_EXTERNAL_MEMORY_BUFFER_DESC_v1;
  3388. typedef CUDA_EXTERNAL_MEMORY_BUFFER_DESC_v1 CUDA_EXTERNAL_MEMORY_BUFFER_DESC;
  3389. /**
  3390. * External memory mipmap descriptor
  3391. */
  3392. typedef struct CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_st {
  3393. /**
  3394. * Offset into the memory object where the base level of the
  3395. * mipmap chain is.
  3396. */
  3397. unsigned long long offset;
  3398. /**
  3399. * Format, dimension and type of base level of the mipmap chain
  3400. */
  3401. CUDA_ARRAY3D_DESCRIPTOR arrayDesc;
  3402. /**
  3403. * Total number of levels in the mipmap chain
  3404. */
  3405. unsigned int numLevels;
  3406. unsigned int reserved[16];
  3407. } CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_v1;
  3408. typedef CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_v1 CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC;
  3409. /**
  3410. * External semaphore handle types
  3411. */
  3412. typedef enum CUexternalSemaphoreHandleType_enum {
  3413. /**
  3414. * Handle is an opaque file descriptor
  3415. */
  3416. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD = 1,
  3417. /**
  3418. * Handle is an opaque shared NT handle
  3419. */
  3420. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32 = 2,
  3421. /**
  3422. * Handle is an opaque, globally shared handle
  3423. */
  3424. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
  3425. /**
  3426. * Handle is a shared NT handle referencing a D3D12 fence object
  3427. */
  3428. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE = 4,
  3429. /**
  3430. * Handle is a shared NT handle referencing a D3D11 fence object
  3431. */
  3432. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE = 5,
  3433. /**
  3434. * Opaque handle to NvSciSync Object
  3435. */
  3436. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC = 6,
  3437. /**
  3438. * Handle is a shared NT handle referencing a D3D11 keyed mutex object
  3439. */
  3440. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX = 7,
  3441. /**
  3442. * Handle is a globally shared handle referencing a D3D11 keyed mutex object
  3443. */
  3444. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT = 8,
  3445. /**
  3446. * Handle is an opaque file descriptor referencing a timeline semaphore
  3447. */
  3448. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD = 9,
  3449. /**
  3450. * Handle is an opaque shared NT handle referencing a timeline semaphore
  3451. */
  3452. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32 = 10
  3453. } CUexternalSemaphoreHandleType;
  3454. /**
  3455. * External semaphore handle descriptor
  3456. */
  3457. typedef struct CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st {
  3458. /**
  3459. * Type of the handle
  3460. */
  3461. CUexternalSemaphoreHandleType type;
  3462. union {
  3463. /**
  3464. * File descriptor referencing the semaphore object. Valid
  3465. * when type is one of the following:
  3466. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD
  3467. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD
  3468. */
  3469. int fd;
  3470. /**
  3471. * Win32 handle referencing the semaphore object. Valid when
  3472. * type is one of the following:
  3473. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32
  3474. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT
  3475. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE
  3476. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE
  3477. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX
  3478. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32
  3479. * Exactly one of 'handle' and 'name' must be non-NULL. If
  3480. * type is one of the following:
  3481. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT
  3482. * - ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT
  3483. * then 'name' must be NULL.
  3484. */
  3485. struct {
  3486. /**
  3487. * Valid NT handle. Must be NULL if 'name' is non-NULL
  3488. */
  3489. void *handle;
  3490. /**
  3491. * Name of a valid synchronization primitive.
  3492. * Must be NULL if 'handle' is non-NULL.
  3493. */
  3494. const void *name;
  3495. } win32;
  3496. /**
  3497. * Valid NvSciSyncObj. Must be non NULL
  3498. */
  3499. const void* nvSciSyncObj;
  3500. } handle;
  3501. /**
  3502. * Flags reserved for the future. Must be zero.
  3503. */
  3504. unsigned int flags;
  3505. unsigned int reserved[16];
  3506. } CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_v1;
  3507. typedef CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_v1 CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC;
  3508. /**
  3509. * External semaphore signal parameters
  3510. */
  3511. typedef struct CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st {
  3512. struct {
  3513. /**
  3514. * Parameters for fence objects
  3515. */
  3516. struct {
  3517. /**
  3518. * Value of fence to be signaled
  3519. */
  3520. unsigned long long value;
  3521. } fence;
  3522. union {
  3523. /**
  3524. * Pointer to NvSciSyncFence. Valid if ::CUexternalSemaphoreHandleType
  3525. * is of type ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC.
  3526. */
  3527. void *fence;
  3528. unsigned long long reserved;
  3529. } nvSciSync;
  3530. /**
  3531. * Parameters for keyed mutex objects
  3532. */
  3533. struct {
  3534. /**
  3535. * Value of key to release the mutex with
  3536. */
  3537. unsigned long long key;
  3538. } keyedMutex;
  3539. unsigned int reserved[12];
  3540. } params;
  3541. /**
  3542. * Only when ::CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS is used to
  3543. * signal a ::CUexternalSemaphore of type
  3544. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC, the valid flag is
  3545. * ::CUDA_EXTERNAL_SEMAPHORE_SIGNAL_SKIP_NVSCIBUF_MEMSYNC which indicates
  3546. * that while signaling the ::CUexternalSemaphore, no memory synchronization
  3547. * operations should be performed for any external memory object imported
  3548. * as ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF.
  3549. * For all other types of ::CUexternalSemaphore, flags must be zero.
  3550. */
  3551. unsigned int flags;
  3552. unsigned int reserved[16];
  3553. } CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_v1;
  3554. typedef CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_v1 CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS;
  3555. /**
  3556. * External semaphore wait parameters
  3557. */
  3558. typedef struct CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st {
  3559. struct {
  3560. /**
  3561. * Parameters for fence objects
  3562. */
  3563. struct {
  3564. /**
  3565. * Value of fence to be waited on
  3566. */
  3567. unsigned long long value;
  3568. } fence;
  3569. /**
  3570. * Pointer to NvSciSyncFence. Valid if CUexternalSemaphoreHandleType
  3571. * is of type CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC.
  3572. */
  3573. union {
  3574. void *fence;
  3575. unsigned long long reserved;
  3576. } nvSciSync;
  3577. /**
  3578. * Parameters for keyed mutex objects
  3579. */
  3580. struct {
  3581. /**
  3582. * Value of key to acquire the mutex with
  3583. */
  3584. unsigned long long key;
  3585. /**
  3586. * Timeout in milliseconds to wait to acquire the mutex
  3587. */
  3588. unsigned int timeoutMs;
  3589. } keyedMutex;
  3590. unsigned int reserved[10];
  3591. } params;
  3592. /**
  3593. * Only when ::CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS is used to wait on
  3594. * a ::CUexternalSemaphore of type ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC,
  3595. * the valid flag is ::CUDA_EXTERNAL_SEMAPHORE_WAIT_SKIP_NVSCIBUF_MEMSYNC
  3596. * which indicates that while waiting for the ::CUexternalSemaphore, no memory
  3597. * synchronization operations should be performed for any external memory
  3598. * object imported as ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF.
  3599. * For all other types of ::CUexternalSemaphore, flags must be zero.
  3600. */
  3601. unsigned int flags;
  3602. unsigned int reserved[16];
  3603. } CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_v1;
  3604. typedef CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_v1 CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS;
  3605. /**
  3606. * Semaphore signal node parameters
  3607. */
  3608. typedef struct CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_st {
  3609. CUexternalSemaphore* extSemArray; /**< Array of external semaphore handles. */
  3610. const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS* paramsArray; /**< Array of external semaphore signal parameters. */
  3611. unsigned int numExtSems; /**< Number of handles and parameters supplied in extSemArray and paramsArray. */
  3612. } CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v1;
  3613. typedef CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v1 CUDA_EXT_SEM_SIGNAL_NODE_PARAMS;
  3614. /**
  3615. * Semaphore signal node parameters
  3616. */
  3617. typedef struct CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v2_st {
  3618. CUexternalSemaphore* extSemArray; /**< Array of external semaphore handles. */
  3619. const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS* paramsArray; /**< Array of external semaphore signal parameters. */
  3620. unsigned int numExtSems; /**< Number of handles and parameters supplied in extSemArray and paramsArray. */
  3621. } CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v2;
  3622. /**
  3623. * Semaphore wait node parameters
  3624. */
  3625. typedef struct CUDA_EXT_SEM_WAIT_NODE_PARAMS_st {
  3626. CUexternalSemaphore* extSemArray; /**< Array of external semaphore handles. */
  3627. const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS* paramsArray; /**< Array of external semaphore wait parameters. */
  3628. unsigned int numExtSems; /**< Number of handles and parameters supplied in extSemArray and paramsArray. */
  3629. } CUDA_EXT_SEM_WAIT_NODE_PARAMS_v1;
  3630. typedef CUDA_EXT_SEM_WAIT_NODE_PARAMS_v1 CUDA_EXT_SEM_WAIT_NODE_PARAMS;
  3631. /**
  3632. * Semaphore wait node parameters
  3633. */
  3634. typedef struct CUDA_EXT_SEM_WAIT_NODE_PARAMS_v2_st {
  3635. CUexternalSemaphore* extSemArray; /**< Array of external semaphore handles. */
  3636. const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS* paramsArray; /**< Array of external semaphore wait parameters. */
  3637. unsigned int numExtSems; /**< Number of handles and parameters supplied in extSemArray and paramsArray. */
  3638. } CUDA_EXT_SEM_WAIT_NODE_PARAMS_v2;
  3639. typedef unsigned long long CUmemGenericAllocationHandle_v1;
  3640. typedef CUmemGenericAllocationHandle_v1 CUmemGenericAllocationHandle;
  3641. /**
  3642. * Flags for specifying particular handle types
  3643. */
  3644. typedef enum CUmemAllocationHandleType_enum {
  3645. CU_MEM_HANDLE_TYPE_NONE = 0x0, /**< Does not allow any export mechanism. > */
  3646. CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR = 0x1, /**< Allows a file descriptor to be used for exporting. Permitted only on POSIX systems. (int) */
  3647. CU_MEM_HANDLE_TYPE_WIN32 = 0x2, /**< Allows a Win32 NT handle to be used for exporting. (HANDLE) */
  3648. CU_MEM_HANDLE_TYPE_WIN32_KMT = 0x4, /**< Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) */
  3649. CU_MEM_HANDLE_TYPE_FABRIC = 0x8, /**< Allows a fabric handle to be used for exporting. (CUmemFabricHandle)*/
  3650. CU_MEM_HANDLE_TYPE_MAX = 0x7FFFFFFF
  3651. } CUmemAllocationHandleType;
  3652. /**
  3653. * Specifies the memory protection flags for mapping.
  3654. */
  3655. typedef enum CUmemAccess_flags_enum {
  3656. CU_MEM_ACCESS_FLAGS_PROT_NONE = 0x0, /**< Default, make the address range not accessible */
  3657. CU_MEM_ACCESS_FLAGS_PROT_READ = 0x1, /**< Make the address range read accessible */
  3658. CU_MEM_ACCESS_FLAGS_PROT_READWRITE = 0x3, /**< Make the address range read-write accessible */
  3659. CU_MEM_ACCESS_FLAGS_PROT_MAX = 0x7FFFFFFF
  3660. } CUmemAccess_flags;
  3661. /**
  3662. * Specifies the type of location
  3663. */
  3664. typedef enum CUmemLocationType_enum {
  3665. CU_MEM_LOCATION_TYPE_INVALID = 0x0,
  3666. CU_MEM_LOCATION_TYPE_DEVICE = 0x1, /**< Location is a device location, thus id is a device ordinal */
  3667. CU_MEM_LOCATION_TYPE_HOST = 0x2, /**< Location is host, id is ignored */
  3668. CU_MEM_LOCATION_TYPE_HOST_NUMA = 0x3, /**< Location is a host NUMA node, thus id is a host NUMA node id */
  3669. CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT = 0x4, /**< Location is a host NUMA node of the current thread, id is ignored */
  3670. CU_MEM_LOCATION_TYPE_MAX = 0x7FFFFFFF
  3671. } CUmemLocationType;
  3672. /**
  3673. * Defines the allocation types available
  3674. */
  3675. typedef enum CUmemAllocationType_enum {
  3676. CU_MEM_ALLOCATION_TYPE_INVALID = 0x0,
  3677. /** This allocation type is 'pinned', i.e. cannot migrate from its current
  3678. * location while the application is actively using it
  3679. */
  3680. CU_MEM_ALLOCATION_TYPE_PINNED = 0x1,
  3681. CU_MEM_ALLOCATION_TYPE_MAX = 0x7FFFFFFF
  3682. } CUmemAllocationType;
  3683. /**
  3684. * Flag for requesting different optimal and required granularities for an allocation.
  3685. */
  3686. typedef enum CUmemAllocationGranularity_flags_enum {
  3687. CU_MEM_ALLOC_GRANULARITY_MINIMUM = 0x0, /**< Minimum required granularity for allocation */
  3688. CU_MEM_ALLOC_GRANULARITY_RECOMMENDED = 0x1 /**< Recommended granularity for allocation for best performance */
  3689. } CUmemAllocationGranularity_flags;
  3690. /**
  3691. * Specifies the handle type for address range
  3692. */
  3693. typedef enum CUmemRangeHandleType_enum
  3694. {
  3695. CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD = 0x1,
  3696. CU_MEM_RANGE_HANDLE_TYPE_MAX = 0x7FFFFFFF
  3697. } CUmemRangeHandleType;
  3698. /**
  3699. * Flag for requesting handle type for address range.
  3700. */
  3701. typedef enum CUmemRangeFlags_enum {
  3702. CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE = 0x1 /**< Indicates that DMA_BUF handle should be mapped via PCIe BAR1 */
  3703. } CUmemRangeFlags;
  3704. /**
  3705. * Sparse subresource types
  3706. */
  3707. typedef enum CUarraySparseSubresourceType_enum {
  3708. CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_SPARSE_LEVEL = 0,
  3709. CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_MIPTAIL = 1
  3710. } CUarraySparseSubresourceType;
  3711. /**
  3712. * Memory operation types
  3713. */
  3714. typedef enum CUmemOperationType_enum {
  3715. CU_MEM_OPERATION_TYPE_MAP = 1,
  3716. CU_MEM_OPERATION_TYPE_UNMAP = 2
  3717. } CUmemOperationType;
  3718. /**
  3719. * Memory handle types
  3720. */
  3721. typedef enum CUmemHandleType_enum {
  3722. CU_MEM_HANDLE_TYPE_GENERIC = 0
  3723. } CUmemHandleType;
  3724. /**
  3725. * Specifies the CUDA array or CUDA mipmapped array memory mapping information
  3726. */
  3727. typedef struct CUarrayMapInfo_st {
  3728. CUresourcetype resourceType; /**< Resource type */
  3729. union {
  3730. CUmipmappedArray mipmap;
  3731. CUarray array;
  3732. } resource;
  3733. CUarraySparseSubresourceType subresourceType; /**< Sparse subresource type */
  3734. union {
  3735. struct {
  3736. unsigned int level; /**< For CUDA mipmapped arrays must a valid mipmap level. For CUDA arrays must be zero */
  3737. unsigned int layer; /**< For CUDA layered arrays must be a valid layer index. Otherwise, must be zero */
  3738. unsigned int offsetX; /**< Starting X offset in elements */
  3739. unsigned int offsetY; /**< Starting Y offset in elements */
  3740. unsigned int offsetZ; /**< Starting Z offset in elements */
  3741. unsigned int extentWidth; /**< Width in elements */
  3742. unsigned int extentHeight; /**< Height in elements */
  3743. unsigned int extentDepth; /**< Depth in elements */
  3744. } sparseLevel;
  3745. struct {
  3746. unsigned int layer; /**< For CUDA layered arrays must be a valid layer index. Otherwise, must be zero */
  3747. unsigned long long offset; /**< Offset within mip tail */
  3748. unsigned long long size; /**< Extent in bytes */
  3749. } miptail;
  3750. } subresource;
  3751. CUmemOperationType memOperationType; /**< Memory operation type */
  3752. CUmemHandleType memHandleType; /**< Memory handle type */
  3753. union {
  3754. CUmemGenericAllocationHandle memHandle;
  3755. } memHandle;
  3756. unsigned long long offset; /**< Offset within the memory */
  3757. unsigned int deviceBitMask; /**< Device ordinal bit mask */
  3758. unsigned int flags; /**< flags for future use, must be zero now. */
  3759. unsigned int reserved[2]; /**< Reserved for future use, must be zero now. */
  3760. } CUarrayMapInfo_v1;
  3761. typedef CUarrayMapInfo_v1 CUarrayMapInfo;
  3762. /**
  3763. * Specifies a memory location.
  3764. */
  3765. typedef struct CUmemLocation_st {
  3766. CUmemLocationType type; /**< Specifies the location type, which modifies the meaning of id. */
  3767. int id; /**< identifier for a given this location's ::CUmemLocationType. */
  3768. } CUmemLocation_v1;
  3769. typedef CUmemLocation_v1 CUmemLocation;
  3770. /**
  3771. * Specifies compression attribute for an allocation.
  3772. */
  3773. typedef enum CUmemAllocationCompType_enum {
  3774. CU_MEM_ALLOCATION_COMP_NONE = 0x0, /**< Allocating non-compressible memory */
  3775. CU_MEM_ALLOCATION_COMP_GENERIC = 0x1 /**< Allocating compressible memory */
  3776. } CUmemAllocationCompType;
  3777. /**
  3778. * This flag if set indicates that the memory will be used as a tile pool.
  3779. */
  3780. #define CU_MEM_CREATE_USAGE_TILE_POOL 0x1
  3781. /**
  3782. * This flag, if set, indicates that the memory will be used as a buffer for
  3783. * hardware accelerated decompression.
  3784. */
  3785. #define CU_MEM_CREATE_USAGE_HW_DECOMPRESS 0x2
  3786. /**
  3787. * Specifies the allocation properties for a allocation.
  3788. */
  3789. typedef struct CUmemAllocationProp_st {
  3790. /** Allocation type */
  3791. CUmemAllocationType type;
  3792. /** requested ::CUmemAllocationHandleType */
  3793. CUmemAllocationHandleType requestedHandleTypes;
  3794. /** Location of allocation */
  3795. CUmemLocation location;
  3796. /**
  3797. * Windows-specific POBJECT_ATTRIBUTES required when
  3798. * ::CU_MEM_HANDLE_TYPE_WIN32 is specified. This object attributes structure
  3799. * includes security attributes that define
  3800. * the scope of which exported allocations may be transferred to other
  3801. * processes. In all other cases, this field is required to be zero.
  3802. */
  3803. void *win32HandleMetaData;
  3804. struct {
  3805. /**
  3806. * Allocation hint for requesting compressible memory.
  3807. * On devices that support Compute Data Compression, compressible
  3808. * memory can be used to accelerate accesses to data with unstructured
  3809. * sparsity and other compressible data patterns. Applications are
  3810. * expected to query allocation property of the handle obtained with
  3811. * ::cuMemCreate using ::cuMemGetAllocationPropertiesFromHandle to
  3812. * validate if the obtained allocation is compressible or not. Note that
  3813. * compressed memory may not be mappable on all devices.
  3814. */
  3815. unsigned char compressionType;
  3816. unsigned char gpuDirectRDMACapable;
  3817. /** Bitmask indicating intended usage for this allocation */
  3818. unsigned short usage;
  3819. unsigned char reserved[4];
  3820. } allocFlags;
  3821. } CUmemAllocationProp_v1;
  3822. typedef CUmemAllocationProp_v1 CUmemAllocationProp;
  3823. /**
  3824. * Flags for querying different granularities for a multicast object
  3825. */
  3826. typedef enum CUmulticastGranularity_flags_enum {
  3827. CU_MULTICAST_GRANULARITY_MINIMUM = 0x0, /**< Minimum required granularity */
  3828. CU_MULTICAST_GRANULARITY_RECOMMENDED = 0x1 /**< Recommended granularity for best performance */
  3829. } CUmulticastGranularity_flags;
  3830. /**
  3831. * Specifies the properties for a multicast object.
  3832. */
  3833. typedef struct CUmulticastObjectProp_st {
  3834. /**
  3835. * The number of devices in the multicast team that will bind memory to this
  3836. * object
  3837. */
  3838. unsigned int numDevices;
  3839. /**
  3840. * The maximum amount of memory that can be bound to this multicast object
  3841. * per device
  3842. */
  3843. size_t size;
  3844. /**
  3845. * Bitmask of exportable handle types (see ::CUmemAllocationHandleType) for
  3846. * this object
  3847. */
  3848. unsigned long long handleTypes;
  3849. /**
  3850. * Flags for future use, must be zero now
  3851. */
  3852. unsigned long long flags;
  3853. } CUmulticastObjectProp_v1;
  3854. typedef CUmulticastObjectProp_v1 CUmulticastObjectProp;
  3855. /**
  3856. * Memory access descriptor
  3857. */
  3858. typedef struct CUmemAccessDesc_st {
  3859. CUmemLocation location; /**< Location on which the request is to change it's accessibility */
  3860. CUmemAccess_flags flags; /**< ::CUmemProt accessibility flags to set on the request */
  3861. } CUmemAccessDesc_v1;
  3862. typedef CUmemAccessDesc_v1 CUmemAccessDesc;
  3863. /**
  3864. * CUDA Graph Update error types
  3865. */
  3866. typedef enum CUgraphExecUpdateResult_enum {
  3867. CU_GRAPH_EXEC_UPDATE_SUCCESS = 0x0, /**< The update succeeded */
  3868. CU_GRAPH_EXEC_UPDATE_ERROR = 0x1, /**< The update failed for an unexpected reason which is described in the return value of the function */
  3869. CU_GRAPH_EXEC_UPDATE_ERROR_TOPOLOGY_CHANGED = 0x2, /**< The update failed because the topology changed */
  3870. CU_GRAPH_EXEC_UPDATE_ERROR_NODE_TYPE_CHANGED = 0x3, /**< The update failed because a node type changed */
  3871. CU_GRAPH_EXEC_UPDATE_ERROR_FUNCTION_CHANGED = 0x4, /**< The update failed because the function of a kernel node changed (CUDA driver < 11.2) */
  3872. CU_GRAPH_EXEC_UPDATE_ERROR_PARAMETERS_CHANGED = 0x5, /**< The update failed because the parameters changed in a way that is not supported */
  3873. CU_GRAPH_EXEC_UPDATE_ERROR_NOT_SUPPORTED = 0x6, /**< The update failed because something about the node is not supported */
  3874. CU_GRAPH_EXEC_UPDATE_ERROR_UNSUPPORTED_FUNCTION_CHANGE = 0x7, /**< The update failed because the function of a kernel node changed in an unsupported way */
  3875. CU_GRAPH_EXEC_UPDATE_ERROR_ATTRIBUTES_CHANGED = 0x8 /**< The update failed because the node attributes changed in a way that is not supported */
  3876. } CUgraphExecUpdateResult;
  3877. /**
  3878. * Result information returned by cuGraphExecUpdate
  3879. */
  3880. typedef struct CUgraphExecUpdateResultInfo_st {
  3881. /**
  3882. * Gives more specific detail when a cuda graph update fails.
  3883. */
  3884. CUgraphExecUpdateResult result;
  3885. /**
  3886. * The "to node" of the error edge when the topologies do not match.
  3887. * The error node when the error is associated with a specific node.
  3888. * NULL when the error is generic.
  3889. */
  3890. CUgraphNode errorNode;
  3891. /**
  3892. * The from node of error edge when the topologies do not match. Otherwise NULL.
  3893. */
  3894. CUgraphNode errorFromNode;
  3895. } CUgraphExecUpdateResultInfo_v1;
  3896. typedef CUgraphExecUpdateResultInfo_v1 CUgraphExecUpdateResultInfo;
  3897. /**
  3898. * CUDA memory pool attributes
  3899. */
  3900. typedef enum CUmemPool_attribute_enum {
  3901. /**
  3902. * (value type = int)
  3903. * Allow cuMemAllocAsync to use memory asynchronously freed
  3904. * in another streams as long as a stream ordering dependency
  3905. * of the allocating stream on the free action exists.
  3906. * Cuda events and null stream interactions can create the required
  3907. * stream ordered dependencies. (default enabled)
  3908. */
  3909. CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES = 1,
  3910. /**
  3911. * (value type = int)
  3912. * Allow reuse of already completed frees when there is no dependency
  3913. * between the free and allocation. (default enabled)
  3914. */
  3915. CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC,
  3916. /**
  3917. * (value type = int)
  3918. * Allow cuMemAllocAsync to insert new stream dependencies
  3919. * in order to establish the stream ordering required to reuse
  3920. * a piece of memory released by cuFreeAsync (default enabled).
  3921. */
  3922. CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES,
  3923. /**
  3924. * (value type = cuuint64_t)
  3925. * Amount of reserved memory in bytes to hold onto before trying
  3926. * to release memory back to the OS. When more than the release
  3927. * threshold bytes of memory are held by the memory pool, the
  3928. * allocator will try to release memory back to the OS on the
  3929. * next call to stream, event or context synchronize. (default 0)
  3930. */
  3931. CU_MEMPOOL_ATTR_RELEASE_THRESHOLD,
  3932. /**
  3933. * (value type = cuuint64_t)
  3934. * Amount of backing memory currently allocated for the mempool.
  3935. */
  3936. CU_MEMPOOL_ATTR_RESERVED_MEM_CURRENT,
  3937. /**
  3938. * (value type = cuuint64_t)
  3939. * High watermark of backing memory allocated for the mempool since the
  3940. * last time it was reset. High watermark can only be reset to zero.
  3941. */
  3942. CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH,
  3943. /**
  3944. * (value type = cuuint64_t)
  3945. * Amount of memory from the pool that is currently in use by the application.
  3946. */
  3947. CU_MEMPOOL_ATTR_USED_MEM_CURRENT,
  3948. /**
  3949. * (value type = cuuint64_t)
  3950. * High watermark of the amount of memory from the pool that was in use by the application since
  3951. * the last time it was reset. High watermark can only be reset to zero.
  3952. */
  3953. CU_MEMPOOL_ATTR_USED_MEM_HIGH
  3954. } CUmemPool_attribute;
  3955. /**
  3956. * This flag, if set, indicates that the memory will be used as a buffer for
  3957. * hardware accelerated decompression.
  3958. */
  3959. #define CU_MEM_POOL_CREATE_USAGE_HW_DECOMPRESS 0x2
  3960. /**
  3961. * Specifies the properties of allocations made from the pool.
  3962. */
  3963. typedef struct CUmemPoolProps_st {
  3964. CUmemAllocationType allocType; /**< Allocation type. Currently must be specified as CU_MEM_ALLOCATION_TYPE_PINNED */
  3965. CUmemAllocationHandleType handleTypes; /**< Handle types that will be supported by allocations from the pool. */
  3966. CUmemLocation location; /**< Location where allocations should reside. */
  3967. /**
  3968. * Windows-specific LPSECURITYATTRIBUTES required when
  3969. * ::CU_MEM_HANDLE_TYPE_WIN32 is specified. This security attribute defines
  3970. * the scope of which exported allocations may be transferred to other
  3971. * processes. In all other cases, this field is required to be zero.
  3972. */
  3973. void *win32SecurityAttributes;
  3974. size_t maxSize; /**< Maximum pool size. When set to 0, defaults to a system dependent value. */
  3975. unsigned short usage; /**< Bitmask indicating intended usage for the pool. */
  3976. unsigned char reserved[54]; /**< reserved for future use, must be 0 */
  3977. } CUmemPoolProps_v1;
  3978. typedef CUmemPoolProps_v1 CUmemPoolProps;
  3979. /**
  3980. * Opaque data for exporting a pool allocation
  3981. */
  3982. typedef struct CUmemPoolPtrExportData_st {
  3983. unsigned char reserved[64];
  3984. } CUmemPoolPtrExportData_v1;
  3985. typedef CUmemPoolPtrExportData_v1 CUmemPoolPtrExportData;
  3986. /**
  3987. * Memory allocation node parameters
  3988. */
  3989. typedef struct CUDA_MEM_ALLOC_NODE_PARAMS_v1_st {
  3990. /**
  3991. * in: location where the allocation should reside (specified in ::location).
  3992. * ::handleTypes must be ::CU_MEM_HANDLE_TYPE_NONE. IPC is not supported.
  3993. */
  3994. CUmemPoolProps poolProps;
  3995. const CUmemAccessDesc *accessDescs; /**< in: array of memory access descriptors. Used to describe peer GPU access */
  3996. size_t accessDescCount; /**< in: number of memory access descriptors. Must not exceed the number of GPUs. */
  3997. size_t bytesize; /**< in: size in bytes of the requested allocation */
  3998. CUdeviceptr dptr; /**< out: address of the allocation returned by CUDA */
  3999. } CUDA_MEM_ALLOC_NODE_PARAMS_v1;
  4000. typedef CUDA_MEM_ALLOC_NODE_PARAMS_v1 CUDA_MEM_ALLOC_NODE_PARAMS;
  4001. /**
  4002. * Memory allocation node parameters
  4003. */
  4004. typedef struct CUDA_MEM_ALLOC_NODE_PARAMS_v2_st {
  4005. /**
  4006. * in: location where the allocation should reside (specified in ::location).
  4007. * ::handleTypes must be ::CU_MEM_HANDLE_TYPE_NONE. IPC is not supported.
  4008. */
  4009. CUmemPoolProps poolProps;
  4010. const CUmemAccessDesc *accessDescs; /**< in: array of memory access descriptors. Used to describe peer GPU access */
  4011. size_t accessDescCount; /**< in: number of memory access descriptors. Must not exceed the number of GPUs. */
  4012. size_t bytesize; /**< in: size in bytes of the requested allocation */
  4013. CUdeviceptr dptr; /**< out: address of the allocation returned by CUDA */
  4014. } CUDA_MEM_ALLOC_NODE_PARAMS_v2;
  4015. /**
  4016. * Memory free node parameters
  4017. */
  4018. typedef struct CUDA_MEM_FREE_NODE_PARAMS_st {
  4019. CUdeviceptr dptr; /**< in: the pointer to free */
  4020. } CUDA_MEM_FREE_NODE_PARAMS;
  4021. typedef enum CUgraphMem_attribute_enum {
  4022. /**
  4023. * (value type = cuuint64_t)
  4024. * Amount of memory, in bytes, currently associated with graphs
  4025. */
  4026. CU_GRAPH_MEM_ATTR_USED_MEM_CURRENT,
  4027. /**
  4028. * (value type = cuuint64_t)
  4029. * High watermark of memory, in bytes, associated with graphs since the
  4030. * last time it was reset. High watermark can only be reset to zero.
  4031. */
  4032. CU_GRAPH_MEM_ATTR_USED_MEM_HIGH,
  4033. /**
  4034. * (value type = cuuint64_t)
  4035. * Amount of memory, in bytes, currently allocated for use by
  4036. * the CUDA graphs asynchronous allocator.
  4037. */
  4038. CU_GRAPH_MEM_ATTR_RESERVED_MEM_CURRENT,
  4039. /**
  4040. * (value type = cuuint64_t)
  4041. * High watermark of memory, in bytes, currently allocated for use by
  4042. * the CUDA graphs asynchronous allocator.
  4043. */
  4044. CU_GRAPH_MEM_ATTR_RESERVED_MEM_HIGH
  4045. } CUgraphMem_attribute;
  4046. /**
  4047. * Child graph node parameters
  4048. */
  4049. typedef struct CUDA_CHILD_GRAPH_NODE_PARAMS_st {
  4050. CUgraph graph; /**< The child graph to clone into the node for node creation, or
  4051. a handle to the graph owned by the node for node query */
  4052. } CUDA_CHILD_GRAPH_NODE_PARAMS;
  4053. /**
  4054. * Event record node parameters
  4055. */
  4056. typedef struct CUDA_EVENT_RECORD_NODE_PARAMS_st {
  4057. CUevent event; /**< The event to record when the node executes */
  4058. } CUDA_EVENT_RECORD_NODE_PARAMS;
  4059. /**
  4060. * Event wait node parameters
  4061. */
  4062. typedef struct CUDA_EVENT_WAIT_NODE_PARAMS_st {
  4063. CUevent event; /**< The event to wait on from the node */
  4064. } CUDA_EVENT_WAIT_NODE_PARAMS;
  4065. /**
  4066. * Graph node parameters. See ::cuGraphAddNode.
  4067. */
  4068. typedef struct CUgraphNodeParams_st {
  4069. CUgraphNodeType type; /**< Type of the node */
  4070. int reserved0[3]; /**< Reserved. Must be zero. */
  4071. union {
  4072. long long reserved1[29]; /**< Padding. Unused bytes must be zero. */
  4073. CUDA_KERNEL_NODE_PARAMS_v3 kernel; /**< Kernel node parameters. */
  4074. CUDA_MEMCPY_NODE_PARAMS memcpy; /**< Memcpy node parameters. */
  4075. CUDA_MEMSET_NODE_PARAMS_v2 memset; /**< Memset node parameters. */
  4076. CUDA_HOST_NODE_PARAMS_v2 host; /**< Host node parameters. */
  4077. CUDA_CHILD_GRAPH_NODE_PARAMS graph; /**< Child graph node parameters. */
  4078. CUDA_EVENT_WAIT_NODE_PARAMS eventWait; /**< Event wait node parameters. */
  4079. CUDA_EVENT_RECORD_NODE_PARAMS eventRecord; /**< Event record node parameters. */
  4080. CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v2 extSemSignal; /**< External semaphore signal node parameters. */
  4081. CUDA_EXT_SEM_WAIT_NODE_PARAMS_v2 extSemWait; /**< External semaphore wait node parameters. */
  4082. CUDA_MEM_ALLOC_NODE_PARAMS_v2 alloc; /**< Memory allocation node parameters. */
  4083. CUDA_MEM_FREE_NODE_PARAMS free; /**< Memory free node parameters. */
  4084. CUDA_BATCH_MEM_OP_NODE_PARAMS_v2 memOp; /**< MemOp node parameters. */
  4085. CUDA_CONDITIONAL_NODE_PARAMS conditional; /**< Conditional node parameters. */
  4086. };
  4087. long long reserved2; /**< Reserved bytes. Must be zero. */
  4088. } CUgraphNodeParams;
  4089. /**
  4090. * If set, each kernel launched as part of ::cuLaunchCooperativeKernelMultiDevice only
  4091. * waits for prior work in the stream corresponding to that GPU to complete before the
  4092. * kernel begins execution.
  4093. */
  4094. #define CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_PRE_LAUNCH_SYNC 0x01
  4095. /**
  4096. * If set, any subsequent work pushed in a stream that participated in a call to
  4097. * ::cuLaunchCooperativeKernelMultiDevice will only wait for the kernel launched on
  4098. * the GPU corresponding to that stream to complete before it begins execution.
  4099. */
  4100. #define CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_POST_LAUNCH_SYNC 0x02
  4101. /**
  4102. * If set, the CUDA array is a collection of layers, where each layer is either a 1D
  4103. * or a 2D array and the Depth member of CUDA_ARRAY3D_DESCRIPTOR specifies the number
  4104. * of layers, not the depth of a 3D array.
  4105. */
  4106. #define CUDA_ARRAY3D_LAYERED 0x01
  4107. /**
  4108. * Deprecated, use CUDA_ARRAY3D_LAYERED
  4109. */
  4110. #define CUDA_ARRAY3D_2DARRAY 0x01
  4111. /**
  4112. * This flag must be set in order to bind a surface reference
  4113. * to the CUDA array
  4114. */
  4115. #define CUDA_ARRAY3D_SURFACE_LDST 0x02
  4116. /**
  4117. * If set, the CUDA array is a collection of six 2D arrays, representing faces of a cube. The
  4118. * width of such a CUDA array must be equal to its height, and Depth must be six.
  4119. * If ::CUDA_ARRAY3D_LAYERED flag is also set, then the CUDA array is a collection of cubemaps
  4120. * and Depth must be a multiple of six.
  4121. */
  4122. #define CUDA_ARRAY3D_CUBEMAP 0x04
  4123. /**
  4124. * This flag must be set in order to perform texture gather operations
  4125. * on a CUDA array.
  4126. */
  4127. #define CUDA_ARRAY3D_TEXTURE_GATHER 0x08
  4128. /**
  4129. * This flag if set indicates that the CUDA
  4130. * array is a DEPTH_TEXTURE.
  4131. */
  4132. #define CUDA_ARRAY3D_DEPTH_TEXTURE 0x10
  4133. /**
  4134. * This flag indicates that the CUDA array may be bound as a color target
  4135. * in an external graphics API
  4136. */
  4137. #define CUDA_ARRAY3D_COLOR_ATTACHMENT 0x20
  4138. /**
  4139. * This flag if set indicates that the CUDA array or CUDA mipmapped array
  4140. * is a sparse CUDA array or CUDA mipmapped array respectively
  4141. */
  4142. #define CUDA_ARRAY3D_SPARSE 0x40
  4143. /**
  4144. * This flag if set indicates that the CUDA array or CUDA mipmapped array
  4145. * will allow deferred memory mapping
  4146. */
  4147. #define CUDA_ARRAY3D_DEFERRED_MAPPING 0x80
  4148. /**
  4149. * This flag indicates that the CUDA array will be used for hardware accelerated
  4150. * video encode/decode operations.
  4151. */
  4152. #define CUDA_ARRAY3D_VIDEO_ENCODE_DECODE 0x100
  4153. /**
  4154. * Override the texref format with a format inferred from the array.
  4155. * Flag for ::cuTexRefSetArray()
  4156. */
  4157. #define CU_TRSA_OVERRIDE_FORMAT 0x01
  4158. /**
  4159. * Read the texture as integers rather than promoting the values to floats
  4160. * in the range [0,1].
  4161. * Flag for ::cuTexRefSetFlags() and ::cuTexObjectCreate()
  4162. */
  4163. #define CU_TRSF_READ_AS_INTEGER 0x01
  4164. /**
  4165. * Use normalized texture coordinates in the range [0,1) instead of [0,dim).
  4166. * Flag for ::cuTexRefSetFlags() and ::cuTexObjectCreate()
  4167. */
  4168. #define CU_TRSF_NORMALIZED_COORDINATES 0x02
  4169. /**
  4170. * Perform sRGB->linear conversion during texture read.
  4171. * Flag for ::cuTexRefSetFlags() and ::cuTexObjectCreate()
  4172. */
  4173. #define CU_TRSF_SRGB 0x10
  4174. /**
  4175. * Disable any trilinear filtering optimizations.
  4176. * Flag for ::cuTexRefSetFlags() and ::cuTexObjectCreate()
  4177. */
  4178. #define CU_TRSF_DISABLE_TRILINEAR_OPTIMIZATION 0x20
  4179. /**
  4180. * Enable seamless cube map filtering.
  4181. * Flag for ::cuTexObjectCreate()
  4182. */
  4183. #define CU_TRSF_SEAMLESS_CUBEMAP 0x40
  4184. /**
  4185. * C++ compile time constant for CU_LAUNCH_PARAM_END
  4186. */
  4187. #define CU_LAUNCH_PARAM_END_AS_INT 0x00
  4188. /**
  4189. * End of array terminator for the \p extra parameter to
  4190. * ::cuLaunchKernel
  4191. */
  4192. #define CU_LAUNCH_PARAM_END ((void*)CU_LAUNCH_PARAM_END_AS_INT)
  4193. /**
  4194. * C++ compile time constant for CU_LAUNCH_PARAM_BUFFER_POINTER
  4195. */
  4196. #define CU_LAUNCH_PARAM_BUFFER_POINTER_AS_INT 0x01
  4197. /**
  4198. * Indicator that the next value in the \p extra parameter to
  4199. * ::cuLaunchKernel will be a pointer to a buffer containing all kernel
  4200. * parameters used for launching kernel \p f. This buffer needs to
  4201. * honor all alignment/padding requirements of the individual parameters.
  4202. * If ::CU_LAUNCH_PARAM_BUFFER_SIZE is not also specified in the
  4203. * \p extra array, then ::CU_LAUNCH_PARAM_BUFFER_POINTER will have no
  4204. * effect.
  4205. */
  4206. #define CU_LAUNCH_PARAM_BUFFER_POINTER ((void*)CU_LAUNCH_PARAM_BUFFER_POINTER_AS_INT)
  4207. /**
  4208. * C++ compile time constant for CU_LAUNCH_PARAM_BUFFER_SIZE
  4209. */
  4210. #define CU_LAUNCH_PARAM_BUFFER_SIZE_AS_INT 0x02
  4211. /**
  4212. * Indicator that the next value in the \p extra parameter to
  4213. * ::cuLaunchKernel will be a pointer to a size_t which contains the
  4214. * size of the buffer specified with ::CU_LAUNCH_PARAM_BUFFER_POINTER.
  4215. * It is required that ::CU_LAUNCH_PARAM_BUFFER_POINTER also be specified
  4216. * in the \p extra array if the value associated with
  4217. * ::CU_LAUNCH_PARAM_BUFFER_SIZE is not zero.
  4218. */
  4219. #define CU_LAUNCH_PARAM_BUFFER_SIZE ((void*)CU_LAUNCH_PARAM_BUFFER_SIZE_AS_INT)
  4220. /**
  4221. * For texture references loaded into the module, use default texunit from
  4222. * texture reference.
  4223. */
  4224. #define CU_PARAM_TR_DEFAULT -1
  4225. /**
  4226. * Device that represents the CPU
  4227. */
  4228. #define CU_DEVICE_CPU ((CUdevice)-1)
  4229. /**
  4230. * Device that represents an invalid device
  4231. */
  4232. #define CU_DEVICE_INVALID ((CUdevice)-2)
  4233. /**
  4234. * Bitmasks for ::CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_FLUSH_WRITES_OPTIONS
  4235. */
  4236. typedef enum CUflushGPUDirectRDMAWritesOptions_enum {
  4237. CU_FLUSH_GPU_DIRECT_RDMA_WRITES_OPTION_HOST = 1<<0, /**< ::cuFlushGPUDirectRDMAWrites() and its CUDA Runtime API counterpart are supported on the device. */
  4238. CU_FLUSH_GPU_DIRECT_RDMA_WRITES_OPTION_MEMOPS = 1<<1 /**< The ::CU_STREAM_WAIT_VALUE_FLUSH flag and the ::CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES MemOp are supported on the device. */
  4239. } CUflushGPUDirectRDMAWritesOptions;
  4240. /**
  4241. * Platform native ordering for GPUDirect RDMA writes
  4242. */
  4243. typedef enum CUGPUDirectRDMAWritesOrdering_enum {
  4244. CU_GPU_DIRECT_RDMA_WRITES_ORDERING_NONE = 0, /**< The device does not natively support ordering of remote writes. ::cuFlushGPUDirectRDMAWrites() can be leveraged if supported. */
  4245. CU_GPU_DIRECT_RDMA_WRITES_ORDERING_OWNER = 100, /**< Natively, the device can consistently consume remote writes, although other CUDA devices may not. */
  4246. CU_GPU_DIRECT_RDMA_WRITES_ORDERING_ALL_DEVICES = 200 /**< Any CUDA device in the system can consistently consume remote writes to this device. */
  4247. } CUGPUDirectRDMAWritesOrdering;
  4248. /**
  4249. * The scopes for ::cuFlushGPUDirectRDMAWrites
  4250. */
  4251. typedef enum CUflushGPUDirectRDMAWritesScope_enum {
  4252. CU_FLUSH_GPU_DIRECT_RDMA_WRITES_TO_OWNER = 100, /**< Blocks until remote writes are visible to the CUDA device context owning the data. */
  4253. CU_FLUSH_GPU_DIRECT_RDMA_WRITES_TO_ALL_DEVICES = 200 /**< Blocks until remote writes are visible to all CUDA device contexts. */
  4254. } CUflushGPUDirectRDMAWritesScope;
  4255. /**
  4256. * The targets for ::cuFlushGPUDirectRDMAWrites
  4257. */
  4258. typedef enum CUflushGPUDirectRDMAWritesTarget_enum {
  4259. CU_FLUSH_GPU_DIRECT_RDMA_WRITES_TARGET_CURRENT_CTX = 0 /**< Sets the target for ::cuFlushGPUDirectRDMAWrites() to the currently active CUDA device context. */
  4260. } CUflushGPUDirectRDMAWritesTarget;
  4261. /**
  4262. * The additional write options for ::cuGraphDebugDotPrint
  4263. */
  4264. typedef enum CUgraphDebugDot_flags_enum {
  4265. CU_GRAPH_DEBUG_DOT_FLAGS_VERBOSE = 1<<0, /**< Output all debug data as if every debug flag is enabled */
  4266. CU_GRAPH_DEBUG_DOT_FLAGS_RUNTIME_TYPES = 1<<1, /**< Use CUDA Runtime structures for output */
  4267. CU_GRAPH_DEBUG_DOT_FLAGS_KERNEL_NODE_PARAMS = 1<<2, /**< Adds CUDA_KERNEL_NODE_PARAMS values to output */
  4268. CU_GRAPH_DEBUG_DOT_FLAGS_MEMCPY_NODE_PARAMS = 1<<3, /**< Adds CUDA_MEMCPY3D values to output */
  4269. CU_GRAPH_DEBUG_DOT_FLAGS_MEMSET_NODE_PARAMS = 1<<4, /**< Adds CUDA_MEMSET_NODE_PARAMS values to output */
  4270. CU_GRAPH_DEBUG_DOT_FLAGS_HOST_NODE_PARAMS = 1<<5, /**< Adds CUDA_HOST_NODE_PARAMS values to output */
  4271. CU_GRAPH_DEBUG_DOT_FLAGS_EVENT_NODE_PARAMS = 1<<6, /**< Adds CUevent handle from record and wait nodes to output */
  4272. CU_GRAPH_DEBUG_DOT_FLAGS_EXT_SEMAS_SIGNAL_NODE_PARAMS = 1<<7, /**< Adds CUDA_EXT_SEM_SIGNAL_NODE_PARAMS values to output */
  4273. CU_GRAPH_DEBUG_DOT_FLAGS_EXT_SEMAS_WAIT_NODE_PARAMS = 1<<8, /**< Adds CUDA_EXT_SEM_WAIT_NODE_PARAMS values to output */
  4274. CU_GRAPH_DEBUG_DOT_FLAGS_KERNEL_NODE_ATTRIBUTES = 1<<9, /**< Adds CUkernelNodeAttrValue values to output */
  4275. CU_GRAPH_DEBUG_DOT_FLAGS_HANDLES = 1<<10, /**< Adds node handles and every kernel function handle to output */
  4276. CU_GRAPH_DEBUG_DOT_FLAGS_MEM_ALLOC_NODE_PARAMS = 1<<11, /**< Adds memory alloc node parameters to output */
  4277. CU_GRAPH_DEBUG_DOT_FLAGS_MEM_FREE_NODE_PARAMS = 1<<12, /**< Adds memory free node parameters to output */
  4278. CU_GRAPH_DEBUG_DOT_FLAGS_BATCH_MEM_OP_NODE_PARAMS = 1<<13, /**< Adds batch mem op node parameters to output */
  4279. CU_GRAPH_DEBUG_DOT_FLAGS_EXTRA_TOPO_INFO = 1<<14, /**< Adds edge numbering information */
  4280. CU_GRAPH_DEBUG_DOT_FLAGS_CONDITIONAL_NODE_PARAMS = 1<<15 /**< Adds conditional node parameters to output */
  4281. } CUgraphDebugDot_flags;
  4282. /**
  4283. * Flags for user objects for graphs
  4284. */
  4285. typedef enum CUuserObject_flags_enum {
  4286. CU_USER_OBJECT_NO_DESTRUCTOR_SYNC = 1 /**< Indicates the destructor execution is not synchronized by any CUDA handle. */
  4287. } CUuserObject_flags;
  4288. /**
  4289. * Flags for retaining user object references for graphs
  4290. */
  4291. typedef enum CUuserObjectRetain_flags_enum {
  4292. CU_GRAPH_USER_OBJECT_MOVE = 1 /**< Transfer references from the caller rather than creating new references. */
  4293. } CUuserObjectRetain_flags;
  4294. /**
  4295. * Flags for instantiating a graph
  4296. */
  4297. typedef enum CUgraphInstantiate_flags_enum {
  4298. CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH = 1 /**< Automatically free memory allocated in a graph before relaunching. */
  4299. , CUDA_GRAPH_INSTANTIATE_FLAG_UPLOAD = 2 /**< Automatically upload the graph after instantiation. Only supported by
  4300. ::cuGraphInstantiateWithParams. The upload will be performed using the
  4301. stream provided in \p instantiateParams. */
  4302. , CUDA_GRAPH_INSTANTIATE_FLAG_DEVICE_LAUNCH = 4 /**< Instantiate the graph to be launchable from the device. This flag can only
  4303. be used on platforms which support unified addressing. This flag cannot be
  4304. used in conjunction with CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH. */
  4305. , CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY = 8 /**< Run the graph using the per-node priority attributes rather than the
  4306. priority of the stream it is launched into. */
  4307. } CUgraphInstantiate_flags;
  4308. /**
  4309. * CUDA device NUMA configuration
  4310. */
  4311. typedef enum CUdeviceNumaConfig_enum {
  4312. CU_DEVICE_NUMA_CONFIG_NONE = 0, /**< The GPU is not a NUMA node */
  4313. CU_DEVICE_NUMA_CONFIG_NUMA_NODE, /**< The GPU is a NUMA node, CU_DEVICE_ATTRIBUTE_NUMA_ID contains its NUMA ID */
  4314. } CUdeviceNumaConfig;
  4315. /**
  4316. * CUDA Process States
  4317. */
  4318. typedef enum CUprocessState_enum {
  4319. CU_PROCESS_STATE_RUNNING = 0, /**< Default process state */
  4320. CU_PROCESS_STATE_LOCKED, /**< CUDA API locks are taken so further CUDA API calls will block */
  4321. CU_PROCESS_STATE_CHECKPOINTED, /**< Application memory contents have been checkpointed and underlying allocations and device handles have been released */
  4322. CU_PROCESS_STATE_FAILED, /**< Application entered an uncorrectable error during the checkpoint/restore process */
  4323. } CUprocessState;
  4324. /**
  4325. * CUDA checkpoint optional lock arguments
  4326. */
  4327. typedef struct CUcheckpointLockArgs_st {
  4328. unsigned int timeoutMs; /**< Timeout in milliseconds to attempt to lock the process, 0 indicates no timeout */
  4329. unsigned int reserved0; /**< Reserved for future use, must be zero */
  4330. cuuint64_t reserved1[7]; /**< Reserved for future use, must be zeroed */
  4331. } CUcheckpointLockArgs;
  4332. /**
  4333. * CUDA checkpoint optional checkpoint arguments
  4334. */
  4335. typedef struct CUcheckpointCheckpointArgs_st {
  4336. cuuint64_t reserved[8]; /**< Reserved for future use, must be zeroed */
  4337. } CUcheckpointCheckpointArgs;
  4338. /**
  4339. * CUDA checkpoint optional restore arguments
  4340. */
  4341. typedef struct CUcheckpointRestoreArgs_st {
  4342. cuuint64_t reserved[8]; /**< Reserved for future use, must be zeroed */
  4343. } CUcheckpointRestoreArgs;
  4344. /**
  4345. * CUDA checkpoint optional unlock arguments
  4346. */
  4347. typedef struct CUcheckpointUnlockArgs_st {
  4348. cuuint64_t reserved[8]; /**< Reserved for future use, must be zeroed */
  4349. } CUcheckpointUnlockArgs;
  4350. /**
  4351. * Flags to specify for copies within a batch. For more details see ::cuMemcpyBatchAsync.
  4352. */
  4353. typedef enum CUmemcpyFlags_enum {
  4354. CU_MEMCPY_FLAG_DEFAULT = 0x0,
  4355. /**
  4356. * Hint to the driver to try and overlap the copy with compute work on the SMs.
  4357. */
  4358. CU_MEMCPY_FLAG_PREFER_OVERLAP_WITH_COMPUTE = 0x1
  4359. } CUmemcpyFlags;
  4360. /**
  4361. * These flags allow applications to convey the source access ordering CUDA must maintain.
  4362. * The destination will always be accessed in stream order.
  4363. */
  4364. typedef enum CUmemcpySrcAccessOrder_enum {
  4365. /**
  4366. * Default invalid.
  4367. */
  4368. CU_MEMCPY_SRC_ACCESS_ORDER_INVALID = 0x0,
  4369. /**
  4370. * Indicates that access to the source pointer must be in stream order.
  4371. */
  4372. CU_MEMCPY_SRC_ACCESS_ORDER_STREAM = 0x1,
  4373. /**
  4374. * Indicates that access to the source pointer can be out of stream order and
  4375. * all accesses must be complete before the API call returns. This flag is suited for
  4376. * ephemeral sources (ex., stack variables) when it's known that no prior operations
  4377. * in the stream can be accessing the memory and also that the lifetime of the memory
  4378. * is limited to the scope that the source variable was declared in. Specifying
  4379. * this flag allows the driver to optimize the copy and removes the need for the user
  4380. * to synchronize the stream after the API call.
  4381. */
  4382. CU_MEMCPY_SRC_ACCESS_ORDER_DURING_API_CALL = 0x2,
  4383. /**
  4384. * Indicates that access to the source pointer can be out of stream order and the accesses
  4385. * can happen even after the API call returns. This flag is suited for host pointers
  4386. * allocated outside CUDA (ex., via malloc) when it's known that no prior operations
  4387. * in the stream can be accessing the memory. Specifying this flag allows the driver
  4388. * to optimize the copy on certain platforms.
  4389. */
  4390. CU_MEMCPY_SRC_ACCESS_ORDER_ANY = 0x3,
  4391. CU_MEMCPY_SRC_ACCESS_ORDER_MAX = 0x7FFFFFFF
  4392. } CUmemcpySrcAccessOrder;
  4393. /**
  4394. * Attributes specific to copies within a batch. For more details on usage see ::cuMemcpyBatchAsync.
  4395. */
  4396. typedef struct CUmemcpyAttributes_st {
  4397. CUmemcpySrcAccessOrder srcAccessOrder; /**< Source access ordering to be observed for copies with this attribute. */
  4398. CUmemLocation srcLocHint; /**< Hint location for the source operand. Ignored when the pointers are not managed memory or memory allocated outside CUDA. */
  4399. CUmemLocation dstLocHint; /**< Hint location for the destination operand. Ignored when the pointers are not managed memory or memory allocated outside CUDA. */
  4400. unsigned int flags; /**< Additional flags for copies with this attribute. See ::CUmemcpyFlags */
  4401. } CUmemcpyAttributes_v1;
  4402. typedef CUmemcpyAttributes_v1 CUmemcpyAttributes;
  4403. /**
  4404. * These flags allow applications to convey the operand type for individual copies specified in ::cuMemcpy3DBatchAsync.
  4405. */
  4406. typedef enum CUmemcpy3DOperandType_enum {
  4407. CU_MEMCPY_OPERAND_TYPE_POINTER = 0x1, /**< Memcpy operand is a valid pointer. */
  4408. CU_MEMCPY_OPERAND_TYPE_ARRAY = 0x2, /**< Memcpy operand is a CUarray. */
  4409. CU_MEMCPY_OPERAND_TYPE_MAX = 0x7FFFFFFF
  4410. } CUmemcpy3DOperandType;
  4411. /**
  4412. * Struct representing offset into a CUarray in elements
  4413. */
  4414. typedef struct CUoffset3D_st {
  4415. size_t x;
  4416. size_t y;
  4417. size_t z;
  4418. } CUoffset3D_v1;
  4419. typedef CUoffset3D_v1 CUoffset3D;
  4420. /**
  4421. * Struct representing width/height/depth of a CUarray in elements
  4422. */
  4423. typedef struct CUextent3D_st {
  4424. size_t width;
  4425. size_t height;
  4426. size_t depth;
  4427. } CUextent3D_v1;
  4428. typedef CUextent3D_v1 CUextent3D;
  4429. /**
  4430. * Struct representing an operand for copy with ::cuMemcpy3DBatchAsync
  4431. */
  4432. typedef struct CUmemcpy3DOperand_st {
  4433. CUmemcpy3DOperandType type;
  4434. union {
  4435. /**
  4436. * Struct representing an operand when ::CUmemcpy3DOperand::type is ::CU_MEMCPY_OPERAND_TYPE_POINTER
  4437. */
  4438. struct {
  4439. CUdeviceptr ptr;
  4440. size_t rowLength; /**< Length of each row in elements. */
  4441. size_t layerHeight; /**< Height of each layer in elements. */
  4442. CUmemLocation locHint; /**< Hint location for the operand. Ignored when the pointers are not managed memory or memory allocated outside CUDA. */
  4443. } ptr;
  4444. /**
  4445. * Struct representing an operand when ::CUmemcpy3DOperand::type is ::CU_MEMCPY_OPERAND_TYPE_ARRAY
  4446. */
  4447. struct {
  4448. CUarray array;
  4449. CUoffset3D offset;
  4450. } array;
  4451. } op;
  4452. } CUmemcpy3DOperand_v1;
  4453. typedef CUmemcpy3DOperand_v1 CUmemcpy3DOperand;
  4454. typedef struct CUDA_MEMCPY3D_BATCH_OP_st {
  4455. CUmemcpy3DOperand src; /**< Source memcpy operand. */
  4456. CUmemcpy3DOperand dst; /**< Destination memcpy operand. */
  4457. CUextent3D extent; /**< Extents of the memcpy between src and dst. The width, height and depth components must not be 0.*/
  4458. CUmemcpySrcAccessOrder srcAccessOrder; /**< Source access ordering to be observed for copy from src to dst. */
  4459. unsigned int flags; /**< Additional flags for copies with this attribute. See ::CUmemcpyFlags */
  4460. } CUDA_MEMCPY3D_BATCH_OP_v1;
  4461. typedef CUDA_MEMCPY3D_BATCH_OP_v1 CUDA_MEMCPY3D_BATCH_OP;
  4462. /** @} */ /* END CUDA_TYPES */
  4463. #if defined(__GNUC__)
  4464. #if defined(__CUDA_API_PUSH_VISIBILITY_DEFAULT)
  4465. #pragma GCC visibility push(default)
  4466. #endif
  4467. #endif
  4468. #ifdef _WIN32
  4469. #define CUDAAPI __stdcall
  4470. #else
  4471. #define CUDAAPI
  4472. #endif
  4473. /**
  4474. * \defgroup CUDA_ERROR Error Handling
  4475. *
  4476. * ___MANBRIEF___ error handling functions of the low-level CUDA driver API
  4477. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  4478. *
  4479. * This section describes the error handling functions of the low-level CUDA
  4480. * driver application programming interface.
  4481. *
  4482. * @{
  4483. */
  4484. /**
  4485. * \brief Gets the string description of an error code
  4486. *
  4487. * Sets \p *pStr to the address of a NULL-terminated string description
  4488. * of the error code \p error.
  4489. * If the error code is not recognized, ::CUDA_ERROR_INVALID_VALUE
  4490. * will be returned and \p *pStr will be set to the NULL address.
  4491. *
  4492. * \param error - Error code to convert to string
  4493. * \param pStr - Address of the string pointer.
  4494. *
  4495. * \return
  4496. * ::CUDA_SUCCESS,
  4497. * ::CUDA_ERROR_INVALID_VALUE
  4498. *
  4499. * \sa
  4500. * ::CUresult,
  4501. * ::cudaGetErrorString
  4502. */
  4503. CUresult CUDAAPI cuGetErrorString(CUresult error, const char **pStr);
  4504. /**
  4505. * \brief Gets the string representation of an error code enum name
  4506. *
  4507. * Sets \p *pStr to the address of a NULL-terminated string representation
  4508. * of the name of the enum error code \p error.
  4509. * If the error code is not recognized, ::CUDA_ERROR_INVALID_VALUE
  4510. * will be returned and \p *pStr will be set to the NULL address.
  4511. *
  4512. * \param error - Error code to convert to string
  4513. * \param pStr - Address of the string pointer.
  4514. *
  4515. * \return
  4516. * ::CUDA_SUCCESS,
  4517. * ::CUDA_ERROR_INVALID_VALUE
  4518. *
  4519. * \sa
  4520. * ::CUresult,
  4521. * ::cudaGetErrorName
  4522. */
  4523. CUresult CUDAAPI cuGetErrorName(CUresult error, const char **pStr);
  4524. /** @} */ /* END CUDA_ERROR */
  4525. /**
  4526. * \defgroup CUDA_INITIALIZE Initialization
  4527. *
  4528. * ___MANBRIEF___ initialization functions of the low-level CUDA driver API
  4529. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  4530. *
  4531. * This section describes the initialization functions of the low-level CUDA
  4532. * driver application programming interface.
  4533. *
  4534. * @{
  4535. */
  4536. /**
  4537. * \brief Initialize the CUDA driver API
  4538. * Initializes the driver API and must be called before any other function from
  4539. * the driver API in the current process. Currently, the \p Flags parameter must be 0. If ::cuInit()
  4540. * has not been called, any function from the driver API will return
  4541. * ::CUDA_ERROR_NOT_INITIALIZED.
  4542. *
  4543. * \param Flags - Initialization flag for CUDA.
  4544. *
  4545. * \return
  4546. * ::CUDA_SUCCESS,
  4547. * ::CUDA_ERROR_INVALID_VALUE,
  4548. * ::CUDA_ERROR_INVALID_DEVICE,
  4549. * ::CUDA_ERROR_SYSTEM_DRIVER_MISMATCH,
  4550. * ::CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE
  4551. * \notefnerr
  4552. */
  4553. CUresult CUDAAPI cuInit(unsigned int Flags);
  4554. /** @} */ /* END CUDA_INITIALIZE */
  4555. /**
  4556. * \defgroup CUDA_VERSION Version Management
  4557. *
  4558. * ___MANBRIEF___ version management functions of the low-level CUDA driver
  4559. * API (___CURRENT_FILE___) ___ENDMANBRIEF___
  4560. *
  4561. * This section describes the version management functions of the low-level
  4562. * CUDA driver application programming interface.
  4563. *
  4564. * @{
  4565. */
  4566. /**
  4567. * \brief Returns the latest CUDA version supported by driver
  4568. *
  4569. * Returns in \p *driverVersion the version of CUDA supported by
  4570. * the driver. The version is returned as
  4571. * (1000 &times; major + 10 &times; minor). For example, CUDA 9.2
  4572. * would be represented by 9020.
  4573. *
  4574. * This function automatically returns ::CUDA_ERROR_INVALID_VALUE if
  4575. * \p driverVersion is NULL.
  4576. *
  4577. * \param driverVersion - Returns the CUDA driver version
  4578. *
  4579. * \return
  4580. * ::CUDA_SUCCESS,
  4581. * ::CUDA_ERROR_INVALID_VALUE
  4582. * \notefnerr
  4583. *
  4584. * \sa
  4585. * ::cudaDriverGetVersion,
  4586. * ::cudaRuntimeGetVersion
  4587. */
  4588. CUresult CUDAAPI cuDriverGetVersion(int *driverVersion);
  4589. /** @} */ /* END CUDA_VERSION */
  4590. /**
  4591. * \defgroup CUDA_DEVICE Device Management
  4592. *
  4593. * ___MANBRIEF___ device management functions of the low-level CUDA driver API
  4594. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  4595. *
  4596. * This section describes the device management functions of the low-level
  4597. * CUDA driver application programming interface.
  4598. *
  4599. * @{
  4600. */
  4601. /**
  4602. * \brief Returns a handle to a compute device
  4603. *
  4604. * Returns in \p *device a device handle given an ordinal in the range <b>[0,
  4605. * ::cuDeviceGetCount()-1]</b>.
  4606. *
  4607. * \param device - Returned device handle
  4608. * \param ordinal - Device number to get handle for
  4609. *
  4610. * \return
  4611. * ::CUDA_SUCCESS,
  4612. * ::CUDA_ERROR_DEINITIALIZED,
  4613. * ::CUDA_ERROR_NOT_INITIALIZED,
  4614. * ::CUDA_ERROR_INVALID_CONTEXT,
  4615. * ::CUDA_ERROR_INVALID_VALUE,
  4616. * ::CUDA_ERROR_INVALID_DEVICE
  4617. * \notefnerr
  4618. *
  4619. * \sa
  4620. * ::cuDeviceGetAttribute,
  4621. * ::cuDeviceGetCount,
  4622. * ::cuDeviceGetName,
  4623. * ::cuDeviceGetUuid,
  4624. * ::cuDeviceGetLuid,
  4625. * ::cuDeviceTotalMem,
  4626. * ::cuDeviceGetExecAffinitySupport
  4627. */
  4628. CUresult CUDAAPI cuDeviceGet(CUdevice *device, int ordinal);
  4629. /**
  4630. * \brief Returns the number of compute-capable devices
  4631. *
  4632. * Returns in \p *count the number of devices with compute capability greater
  4633. * than or equal to 2.0 that are available for execution. If there is no such
  4634. * device, ::cuDeviceGetCount() returns 0.
  4635. *
  4636. * \param count - Returned number of compute-capable devices
  4637. *
  4638. * \return
  4639. * ::CUDA_SUCCESS,
  4640. * ::CUDA_ERROR_DEINITIALIZED,
  4641. * ::CUDA_ERROR_NOT_INITIALIZED,
  4642. * ::CUDA_ERROR_INVALID_CONTEXT,
  4643. * ::CUDA_ERROR_INVALID_VALUE
  4644. * \notefnerr
  4645. *
  4646. * \sa
  4647. * ::cuDeviceGetAttribute,
  4648. * ::cuDeviceGetName,
  4649. * ::cuDeviceGetUuid,
  4650. * ::cuDeviceGetLuid,
  4651. * ::cuDeviceGet,
  4652. * ::cuDeviceTotalMem,
  4653. * ::cuDeviceGetExecAffinitySupport,
  4654. * ::cudaGetDeviceCount
  4655. */
  4656. CUresult CUDAAPI cuDeviceGetCount(int *count);
  4657. /**
  4658. * \brief Returns an identifier string for the device
  4659. *
  4660. * Returns an ASCII string identifying the device \p dev in the NULL-terminated
  4661. * string pointed to by \p name. \p len specifies the maximum length of the
  4662. * string that may be returned.
  4663. *
  4664. * \param name - Returned identifier string for the device
  4665. * \param len - Maximum length of string to store in \p name
  4666. * \param dev - Device to get identifier string for
  4667. *
  4668. * \return
  4669. * ::CUDA_SUCCESS,
  4670. * ::CUDA_ERROR_DEINITIALIZED,
  4671. * ::CUDA_ERROR_NOT_INITIALIZED,
  4672. * ::CUDA_ERROR_INVALID_CONTEXT,
  4673. * ::CUDA_ERROR_INVALID_VALUE,
  4674. * ::CUDA_ERROR_INVALID_DEVICE
  4675. * \notefnerr
  4676. *
  4677. * \sa
  4678. * ::cuDeviceGetAttribute,
  4679. * ::cuDeviceGetUuid,
  4680. * ::cuDeviceGetLuid,
  4681. * ::cuDeviceGetCount,
  4682. * ::cuDeviceGet,
  4683. * ::cuDeviceTotalMem,
  4684. * ::cuDeviceGetExecAffinitySupport,
  4685. * ::cudaGetDeviceProperties
  4686. */
  4687. CUresult CUDAAPI cuDeviceGetName(char *name, int len, CUdevice dev);
  4688. /**
  4689. * \brief Return an UUID for the device
  4690. *
  4691. * Note there is a later version of this API, ::cuDeviceGetUuid_v2. It will
  4692. * supplant this version in 12.0, which is retained for minor version compatibility.
  4693. *
  4694. * Returns 16-octets identifying the device \p dev in the structure
  4695. * pointed by the \p uuid.
  4696. *
  4697. * \param uuid - Returned UUID
  4698. * \param dev - Device to get identifier string for
  4699. *
  4700. * \return
  4701. * ::CUDA_SUCCESS,
  4702. * ::CUDA_ERROR_DEINITIALIZED,
  4703. * ::CUDA_ERROR_NOT_INITIALIZED,
  4704. * ::CUDA_ERROR_INVALID_VALUE,
  4705. * ::CUDA_ERROR_INVALID_DEVICE
  4706. * \notefnerr
  4707. *
  4708. * \sa
  4709. * ::cuDeviceGetUuid_v2
  4710. * ::cuDeviceGetAttribute,
  4711. * ::cuDeviceGetCount,
  4712. * ::cuDeviceGetName,
  4713. * ::cuDeviceGetLuid,
  4714. * ::cuDeviceGet,
  4715. * ::cuDeviceTotalMem,
  4716. * ::cuDeviceGetExecAffinitySupport,
  4717. * ::cudaGetDeviceProperties
  4718. */
  4719. CUresult CUDAAPI cuDeviceGetUuid(CUuuid *uuid, CUdevice dev);
  4720. /**
  4721. * \brief Return an UUID for the device (11.4+)
  4722. *
  4723. * Returns 16-octets identifying the device \p dev in the structure
  4724. * pointed by the \p uuid. If the device is in MIG mode, returns its
  4725. * MIG UUID which uniquely identifies the subscribed MIG compute instance.
  4726. *
  4727. * \param uuid - Returned UUID
  4728. * \param dev - Device to get identifier string for
  4729. *
  4730. * \return
  4731. * ::CUDA_SUCCESS,
  4732. * ::CUDA_ERROR_DEINITIALIZED,
  4733. * ::CUDA_ERROR_NOT_INITIALIZED,
  4734. * ::CUDA_ERROR_INVALID_VALUE,
  4735. * ::CUDA_ERROR_INVALID_DEVICE
  4736. * \notefnerr
  4737. *
  4738. * \sa
  4739. * ::cuDeviceGetAttribute,
  4740. * ::cuDeviceGetCount,
  4741. * ::cuDeviceGetName,
  4742. * ::cuDeviceGetLuid,
  4743. * ::cuDeviceGet,
  4744. * ::cuDeviceTotalMem,
  4745. * ::cudaGetDeviceProperties
  4746. */
  4747. CUresult CUDAAPI cuDeviceGetUuid_v2(CUuuid *uuid, CUdevice dev);
  4748. /**
  4749. * \brief Return an LUID and device node mask for the device
  4750. *
  4751. * Return identifying information (\p luid and \p deviceNodeMask) to allow
  4752. * matching device with graphics APIs.
  4753. *
  4754. * \param luid - Returned LUID
  4755. * \param deviceNodeMask - Returned device node mask
  4756. * \param dev - Device to get identifier string for
  4757. *
  4758. * \return
  4759. * ::CUDA_SUCCESS,
  4760. * ::CUDA_ERROR_DEINITIALIZED,
  4761. * ::CUDA_ERROR_NOT_INITIALIZED,
  4762. * ::CUDA_ERROR_INVALID_VALUE,
  4763. * ::CUDA_ERROR_INVALID_DEVICE
  4764. * \notefnerr
  4765. *
  4766. * \sa
  4767. * ::cuDeviceGetAttribute,
  4768. * ::cuDeviceGetCount,
  4769. * ::cuDeviceGetName,
  4770. * ::cuDeviceGet,
  4771. * ::cuDeviceTotalMem,
  4772. * ::cuDeviceGetExecAffinitySupport,
  4773. * ::cudaGetDeviceProperties
  4774. */
  4775. CUresult CUDAAPI cuDeviceGetLuid(char *luid, unsigned int *deviceNodeMask, CUdevice dev);
  4776. /**
  4777. * \brief Returns the total amount of memory on the device
  4778. *
  4779. * Returns in \p *bytes the total amount of memory available on the device
  4780. * \p dev in bytes.
  4781. *
  4782. * \param bytes - Returned memory available on device in bytes
  4783. * \param dev - Device handle
  4784. *
  4785. * \return
  4786. * ::CUDA_SUCCESS,
  4787. * ::CUDA_ERROR_DEINITIALIZED,
  4788. * ::CUDA_ERROR_NOT_INITIALIZED,
  4789. * ::CUDA_ERROR_INVALID_CONTEXT,
  4790. * ::CUDA_ERROR_INVALID_VALUE,
  4791. * ::CUDA_ERROR_INVALID_DEVICE
  4792. * \notefnerr
  4793. *
  4794. * \sa
  4795. * ::cuDeviceGetAttribute,
  4796. * ::cuDeviceGetCount,
  4797. * ::cuDeviceGetName,
  4798. * ::cuDeviceGetUuid,
  4799. * ::cuDeviceGet,
  4800. * ::cuDeviceGetExecAffinitySupport,
  4801. * ::cudaMemGetInfo
  4802. */
  4803. CUresult CUDAAPI cuDeviceTotalMem(size_t *bytes, CUdevice dev);
  4804. /**
  4805. * \brief Returns the maximum number of elements allocatable in a 1D linear texture for a given texture element size.
  4806. *
  4807. * Returns in \p maxWidthInElements the maximum number of texture elements allocatable in a 1D linear texture
  4808. * for given \p format and \p numChannels.
  4809. *
  4810. * \param maxWidthInElements - Returned maximum number of texture elements allocatable for given \p format and \p numChannels.
  4811. * \param format - Texture format.
  4812. * \param numChannels - Number of channels per texture element.
  4813. * \param dev - Device handle.
  4814. *
  4815. * \return
  4816. * ::CUDA_SUCCESS,
  4817. * ::CUDA_ERROR_DEINITIALIZED,
  4818. * ::CUDA_ERROR_NOT_INITIALIZED,
  4819. * ::CUDA_ERROR_INVALID_CONTEXT,
  4820. * ::CUDA_ERROR_INVALID_VALUE,
  4821. * ::CUDA_ERROR_INVALID_DEVICE
  4822. * \notefnerr
  4823. *
  4824. * \sa
  4825. * ::cuDeviceGetAttribute,
  4826. * ::cuDeviceGetCount,
  4827. * ::cuDeviceGetName,
  4828. * ::cuDeviceGetUuid,
  4829. * ::cuDeviceGet,
  4830. * ::cudaMemGetInfo,
  4831. * ::cuDeviceTotalMem
  4832. */
  4833. CUresult CUDAAPI cuDeviceGetTexture1DLinearMaxWidth(size_t *maxWidthInElements, CUarray_format format, unsigned numChannels, CUdevice dev);
  4834. /**
  4835. * \brief Returns information about the device
  4836. *
  4837. * Returns in \p *pi the integer value of the attribute \p attrib on device
  4838. * \p dev. The supported attributes are:
  4839. * - ::CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK: Maximum number of threads per
  4840. * block;
  4841. * - ::CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X: Maximum x-dimension of a block
  4842. * - ::CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y: Maximum y-dimension of a block
  4843. * - ::CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z: Maximum z-dimension of a block
  4844. * - ::CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X: Maximum x-dimension of a grid
  4845. * - ::CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y: Maximum y-dimension of a grid
  4846. * - ::CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z: Maximum z-dimension of a grid
  4847. * - ::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK: Maximum amount of
  4848. * shared memory available to a thread block in bytes
  4849. * - ::CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY: Memory available on device for
  4850. * __constant__ variables in a CUDA C kernel in bytes
  4851. * - ::CU_DEVICE_ATTRIBUTE_WARP_SIZE: Warp size in threads
  4852. * - ::CU_DEVICE_ATTRIBUTE_MAX_PITCH: Maximum pitch in bytes allowed by the
  4853. * memory copy functions that involve memory regions allocated through
  4854. * ::cuMemAllocPitch()
  4855. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH: Maximum 1D
  4856. * texture width
  4857. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH: Maximum width
  4858. * for a 1D texture bound to linear memory
  4859. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH: Maximum
  4860. * mipmapped 1D texture width
  4861. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH: Maximum 2D
  4862. * texture width
  4863. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT: Maximum 2D
  4864. * texture height
  4865. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH: Maximum width
  4866. * for a 2D texture bound to linear memory
  4867. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT: Maximum height
  4868. * for a 2D texture bound to linear memory
  4869. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH: Maximum pitch
  4870. * in bytes for a 2D texture bound to linear memory
  4871. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH: Maximum
  4872. * mipmapped 2D texture width
  4873. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT: Maximum
  4874. * mipmapped 2D texture height
  4875. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH: Maximum 3D
  4876. * texture width
  4877. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT: Maximum 3D
  4878. * texture height
  4879. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH: Maximum 3D
  4880. * texture depth
  4881. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE:
  4882. * Alternate maximum 3D texture width, 0 if no alternate
  4883. * maximum 3D texture size is supported
  4884. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE:
  4885. * Alternate maximum 3D texture height, 0 if no alternate
  4886. * maximum 3D texture size is supported
  4887. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE:
  4888. * Alternate maximum 3D texture depth, 0 if no alternate
  4889. * maximum 3D texture size is supported
  4890. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH:
  4891. * Maximum cubemap texture width or height
  4892. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH:
  4893. * Maximum 1D layered texture width
  4894. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS:
  4895. * Maximum layers in a 1D layered texture
  4896. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH:
  4897. * Maximum 2D layered texture width
  4898. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT:
  4899. * Maximum 2D layered texture height
  4900. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS:
  4901. * Maximum layers in a 2D layered texture
  4902. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH:
  4903. * Maximum cubemap layered texture width or height
  4904. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS:
  4905. * Maximum layers in a cubemap layered texture
  4906. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH:
  4907. * Maximum 1D surface width
  4908. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH:
  4909. * Maximum 2D surface width
  4910. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT:
  4911. * Maximum 2D surface height
  4912. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH:
  4913. * Maximum 3D surface width
  4914. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT:
  4915. * Maximum 3D surface height
  4916. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH:
  4917. * Maximum 3D surface depth
  4918. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH:
  4919. * Maximum 1D layered surface width
  4920. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS:
  4921. * Maximum layers in a 1D layered surface
  4922. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH:
  4923. * Maximum 2D layered surface width
  4924. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT:
  4925. * Maximum 2D layered surface height
  4926. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS:
  4927. * Maximum layers in a 2D layered surface
  4928. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH:
  4929. * Maximum cubemap surface width
  4930. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH:
  4931. * Maximum cubemap layered surface width
  4932. * - ::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS:
  4933. * Maximum layers in a cubemap layered surface
  4934. * - ::CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK: Maximum number of 32-bit
  4935. * registers available to a thread block
  4936. * - ::CU_DEVICE_ATTRIBUTE_CLOCK_RATE: The typical clock frequency in kilohertz
  4937. * - ::CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT: Alignment requirement; texture
  4938. * base addresses aligned to ::textureAlign bytes do not need an offset
  4939. * applied to texture fetches
  4940. * - ::CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT: Pitch alignment requirement
  4941. * for 2D texture references bound to pitched memory
  4942. * - ::CU_DEVICE_ATTRIBUTE_GPU_OVERLAP: 1 if the device can concurrently copy
  4943. * memory between host and device while executing a kernel, or 0 if not
  4944. * - ::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT: Number of multiprocessors on
  4945. * the device
  4946. * - ::CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT: 1 if there is a run time limit
  4947. * for kernels executed on the device, or 0 if not
  4948. * - ::CU_DEVICE_ATTRIBUTE_INTEGRATED: 1 if the device is integrated with the
  4949. * memory subsystem, or 0 if not
  4950. * - ::CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY: 1 if the device can map host
  4951. * memory into the CUDA address space, or 0 if not
  4952. * - ::CU_DEVICE_ATTRIBUTE_COMPUTE_MODE: Compute mode that device is currently
  4953. * in. Available modes are as follows:
  4954. * - ::CU_COMPUTEMODE_DEFAULT: Default mode - Device is not restricted and
  4955. * can have multiple CUDA contexts present at a single time.
  4956. * - ::CU_COMPUTEMODE_PROHIBITED: Compute-prohibited mode - Device is
  4957. * prohibited from creating new CUDA contexts.
  4958. * - ::CU_COMPUTEMODE_EXCLUSIVE_PROCESS: Compute-exclusive-process mode - Device
  4959. * can have only one context used by a single process at a time.
  4960. * - ::CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS: 1 if the device supports
  4961. * executing multiple kernels within the same context simultaneously, or 0 if
  4962. * not. It is not guaranteed that multiple kernels will be resident
  4963. * on the device concurrently so this feature should not be relied upon for
  4964. * correctness.
  4965. * - ::CU_DEVICE_ATTRIBUTE_ECC_ENABLED: 1 if error correction is enabled on the
  4966. * device, 0 if error correction is disabled or not supported by the device
  4967. * - ::CU_DEVICE_ATTRIBUTE_PCI_BUS_ID: PCI bus identifier of the device
  4968. * - ::CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID: PCI device (also known as slot) identifier
  4969. * of the device
  4970. * - ::CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID: PCI domain identifier of the device
  4971. * - ::CU_DEVICE_ATTRIBUTE_TCC_DRIVER: 1 if the device is using a TCC driver. TCC
  4972. * is only available on Tesla hardware running Windows Vista or later
  4973. * - ::CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE: Peak memory clock frequency in kilohertz
  4974. * - ::CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH: Global memory bus width in bits
  4975. * - ::CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE: Size of L2 cache in bytes. 0 if the device doesn't have L2 cache
  4976. * - ::CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR: Maximum resident threads per multiprocessor
  4977. * - ::CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING: 1 if the device shares a unified address space with
  4978. * the host, or 0 if not
  4979. * - ::CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR: Major compute capability version number
  4980. * - ::CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR: Minor compute capability version number
  4981. * - ::CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED: 1 if device supports caching globals
  4982. * in L1 cache, 0 if caching globals in L1 cache is not supported by the device
  4983. * - ::CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED: 1 if device supports caching locals
  4984. * in L1 cache, 0 if caching locals in L1 cache is not supported by the device
  4985. * - ::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR: Maximum amount of
  4986. * shared memory available to a multiprocessor in bytes; this amount is shared
  4987. * by all thread blocks simultaneously resident on a multiprocessor
  4988. * - ::CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR: Maximum number of 32-bit
  4989. * registers available to a multiprocessor; this number is shared by all thread
  4990. * blocks simultaneously resident on a multiprocessor
  4991. * - ::CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY: 1 if device supports allocating managed memory
  4992. * on this system, 0 if allocating managed memory is not supported by the device on this system.
  4993. * - ::CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD: 1 if device is on a multi-GPU board, 0 if not.
  4994. * - ::CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID: Unique identifier for a group of devices
  4995. * associated with the same board. Devices on the same multi-GPU board will share the same identifier.
  4996. * - ::CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED: 1 if Link between the device and the host
  4997. * supports native atomic operations.
  4998. * - ::CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO: Ratio of single precision performance
  4999. * (in floating-point operations per second) to double precision performance.
  5000. * - ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS: Device supports coherently accessing
  5001. * pageable memory without calling cudaHostRegister on it.
  5002. * - ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS: Device can coherently access managed memory
  5003. * concurrently with the CPU.
  5004. * - ::CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED: Device supports Compute Preemption.
  5005. * - ::CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM: Device can access host registered
  5006. * memory at the same virtual address as the CPU.
  5007. * - ::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN: The maximum per block shared memory size
  5008. * supported on this device. This is the maximum value that can be opted into when using the cuFuncSetAttribute() or cuKernelSetAttribute() call.
  5009. * For more details see ::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES
  5010. * - ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES: Device accesses pageable memory via the host's
  5011. * page tables.
  5012. * - ::CU_DEVICE_ATTRIBUTE_DIRECT_MANAGED_MEM_ACCESS_FROM_HOST: The host can directly access managed memory on the device without migration.
  5013. * - ::CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED: Device supports virtual memory management APIs like ::cuMemAddressReserve, ::cuMemCreate, ::cuMemMap and related APIs
  5014. * - ::CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR_SUPPORTED: Device supports exporting memory to a posix file descriptor with ::cuMemExportToShareableHandle, if requested via ::cuMemCreate
  5015. * - ::CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_HANDLE_SUPPORTED: Device supports exporting memory to a Win32 NT handle with ::cuMemExportToShareableHandle, if requested via ::cuMemCreate
  5016. * - ::CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_KMT_HANDLE_SUPPORTED: Device supports exporting memory to a Win32 KMT handle with ::cuMemExportToShareableHandle, if requested via ::cuMemCreate
  5017. * - ::CU_DEVICE_ATTRIBUTE_MAX_BLOCKS_PER_MULTIPROCESSOR: Maximum number of thread blocks that can reside on a multiprocessor
  5018. * - ::CU_DEVICE_ATTRIBUTE_GENERIC_COMPRESSION_SUPPORTED: Device supports compressible memory allocation via ::cuMemCreate
  5019. * - ::CU_DEVICE_ATTRIBUTE_MAX_PERSISTING_L2_CACHE_SIZE: Maximum L2 persisting lines capacity setting in bytes
  5020. * - ::CU_DEVICE_ATTRIBUTE_MAX_ACCESS_POLICY_WINDOW_SIZE: Maximum value of CUaccessPolicyWindow::num_bytes
  5021. * - ::CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED: Device supports specifying the GPUDirect RDMA flag with ::cuMemCreate.
  5022. * - ::CU_DEVICE_ATTRIBUTE_RESERVED_SHARED_MEMORY_PER_BLOCK: Amount of shared memory per block reserved by CUDA driver in bytes
  5023. * - ::CU_DEVICE_ATTRIBUTE_SPARSE_CUDA_ARRAY_SUPPORTED: Device supports sparse CUDA arrays and sparse CUDA mipmapped arrays.
  5024. * - ::CU_DEVICE_ATTRIBUTE_READ_ONLY_HOST_REGISTER_SUPPORTED: Device supports using the ::cuMemHostRegister flag ::CU_MEMHOSTERGISTER_READ_ONLY to register memory that must be mapped as read-only to the GPU
  5025. * - ::CU_DEVICE_ATTRIBUTE_MEMORY_POOLS_SUPPORTED: Device supports using the ::cuMemAllocAsync and ::cuMemPool family of APIs
  5026. * - ::CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_SUPPORTED: Device supports GPUDirect RDMA APIs, like nvidia_p2p_get_pages (see https://docs.nvidia.com/cuda/gpudirect-rdma for more information)
  5027. * - ::CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_FLUSH_WRITES_OPTIONS: The returned attribute shall be interpreted as a bitmask, where the individual bits are described by the ::CUflushGPUDirectRDMAWritesOptions enum
  5028. * - ::CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WRITES_ORDERING: GPUDirect RDMA writes to the device do not need to be flushed for consumers within the scope indicated by the returned attribute. See ::CUGPUDirectRDMAWritesOrdering for the numerical values returned here.
  5029. * - ::CU_DEVICE_ATTRIBUTE_MEMPOOL_SUPPORTED_HANDLE_TYPES: Bitmask of handle types supported with mempool based IPC
  5030. * - ::CU_DEVICE_ATTRIBUTE_DEFERRED_MAPPING_CUDA_ARRAY_SUPPORTED: Device supports deferred mapping CUDA arrays and CUDA mipmapped arrays.
  5031. * - ::CU_DEVICE_ATTRIBUTE_NUMA_CONFIG: NUMA configuration of a device: value is of type ::CUdeviceNumaConfig enum
  5032. * - ::CU_DEVICE_ATTRIBUTE_NUMA_ID: NUMA node ID of the GPU memory
  5033. * - ::CU_DEVICE_ATTRIBUTE_MULTICAST_SUPPORTED: Device supports switch multicast and reduction operations.
  5034. * - ::CU_DEVICE_ATTRIBUTE_GPU_PCI_DEVICE_ID: The combined 16-bit PCI device ID and 16-bit PCI vendor ID.
  5035. * - ::CU_DEVICE_ATTRIBUTE_GPU_PCI_SUBSYSTEM_ID: The combined 16-bit PCI subsystem ID and 16-bit PCI subsystem vendor ID.
  5036. ID.
  5037. *
  5038. * \param pi - Returned device attribute value
  5039. * \param attrib - Device attribute to query
  5040. * \param dev - Device handle
  5041. *
  5042. * \return
  5043. * ::CUDA_SUCCESS,
  5044. * ::CUDA_ERROR_DEINITIALIZED,
  5045. * ::CUDA_ERROR_NOT_INITIALIZED,
  5046. * ::CUDA_ERROR_INVALID_CONTEXT,
  5047. * ::CUDA_ERROR_INVALID_VALUE,
  5048. * ::CUDA_ERROR_INVALID_DEVICE
  5049. * \notefnerr
  5050. *
  5051. * \sa
  5052. * ::cuDeviceGetCount,
  5053. * ::cuDeviceGetName,
  5054. * ::cuDeviceGetUuid,
  5055. * ::cuDeviceGet,
  5056. * ::cuDeviceTotalMem,
  5057. * ::cuDeviceGetExecAffinitySupport,
  5058. * ::cudaDeviceGetAttribute,
  5059. * ::cudaGetDeviceProperties
  5060. */
  5061. CUresult CUDAAPI cuDeviceGetAttribute(int *pi, CUdevice_attribute attrib, CUdevice dev);
  5062. /**
  5063. * \brief Return NvSciSync attributes that this device can support.
  5064. *
  5065. * Returns in \p nvSciSyncAttrList, the properties of NvSciSync that
  5066. * this CUDA device, \p dev can support. The returned \p nvSciSyncAttrList
  5067. * can be used to create an NvSciSync object that matches this device's capabilities.
  5068. *
  5069. * If NvSciSyncAttrKey_RequiredPerm field in \p nvSciSyncAttrList is
  5070. * already set this API will return ::CUDA_ERROR_INVALID_VALUE.
  5071. *
  5072. * The applications should set \p nvSciSyncAttrList to a valid
  5073. * NvSciSyncAttrList failing which this API will return
  5074. * ::CUDA_ERROR_INVALID_HANDLE.
  5075. *
  5076. * The \p flags controls how applications intends to use
  5077. * the NvSciSync created from the \p nvSciSyncAttrList. The valid flags are:
  5078. * - ::CUDA_NVSCISYNC_ATTR_SIGNAL, specifies that the applications intends to
  5079. * signal an NvSciSync on this CUDA device.
  5080. * - ::CUDA_NVSCISYNC_ATTR_WAIT, specifies that the applications intends to
  5081. * wait on an NvSciSync on this CUDA device.
  5082. *
  5083. * At least one of these flags must be set, failing which the API
  5084. * returns ::CUDA_ERROR_INVALID_VALUE. Both the flags are orthogonal
  5085. * to one another: a developer may set both these flags that allows to
  5086. * set both wait and signal specific attributes in the same \p nvSciSyncAttrList.
  5087. *
  5088. * Note that this API updates the input \p nvSciSyncAttrList with values equivalent
  5089. * to the following public attribute key-values:
  5090. * NvSciSyncAttrKey_RequiredPerm is set to
  5091. * - NvSciSyncAccessPerm_SignalOnly if ::CUDA_NVSCISYNC_ATTR_SIGNAL is set in \p flags.
  5092. * - NvSciSyncAccessPerm_WaitOnly if ::CUDA_NVSCISYNC_ATTR_WAIT is set in \p flags.
  5093. * - NvSciSyncAccessPerm_WaitSignal if both ::CUDA_NVSCISYNC_ATTR_WAIT and
  5094. * ::CUDA_NVSCISYNC_ATTR_SIGNAL are set in \p flags.
  5095. * NvSciSyncAttrKey_PrimitiveInfo is set to
  5096. * - NvSciSyncAttrValPrimitiveType_SysmemSemaphore on any valid \p device.
  5097. * - NvSciSyncAttrValPrimitiveType_Syncpoint if \p device is a Tegra device.
  5098. * - NvSciSyncAttrValPrimitiveType_SysmemSemaphorePayload64b if \p device is GA10X+.
  5099. * NvSciSyncAttrKey_GpuId is set to the same UUID that is returned for this
  5100. * \p device from ::cuDeviceGetUuid.
  5101. *
  5102. * \param nvSciSyncAttrList - Return NvSciSync attributes supported.
  5103. * \param dev - Valid Cuda Device to get NvSciSync attributes for.
  5104. * \param flags - flags describing NvSciSync usage.
  5105. *
  5106. * \return
  5107. *
  5108. * ::CUDA_SUCCESS,
  5109. * ::CUDA_ERROR_DEINITIALIZED,
  5110. * ::CUDA_ERROR_NOT_INITIALIZED,
  5111. * ::CUDA_ERROR_INVALID_VALUE,
  5112. * ::CUDA_ERROR_INVALID_HANDLE,
  5113. * ::CUDA_ERROR_INVALID_DEVICE,
  5114. * ::CUDA_ERROR_NOT_SUPPORTED,
  5115. * ::CUDA_ERROR_OUT_OF_MEMORY
  5116. *
  5117. * \sa
  5118. * ::cuImportExternalSemaphore,
  5119. * ::cuDestroyExternalSemaphore,
  5120. * ::cuSignalExternalSemaphoresAsync,
  5121. * ::cuWaitExternalSemaphoresAsync
  5122. */
  5123. CUresult CUDAAPI cuDeviceGetNvSciSyncAttributes(void *nvSciSyncAttrList, CUdevice dev, int flags);
  5124. /**
  5125. * \brief Sets the current memory pool of a device
  5126. *
  5127. * The memory pool must be local to the specified device.
  5128. * ::cuMemAllocAsync allocates from the current mempool of the provided stream's device.
  5129. * By default, a device's current memory pool is its default memory pool.
  5130. *
  5131. * \note Use ::cuMemAllocFromPoolAsync to specify asynchronous allocations from a device different
  5132. * than the one the stream runs on.
  5133. *
  5134. * \returns
  5135. * ::CUDA_SUCCESS,
  5136. * ::CUDA_ERROR_INVALID_VALUE
  5137. *
  5138. * \sa ::cuDeviceGetDefaultMemPool, ::cuDeviceGetMemPool, ::cuMemPoolCreate, ::cuMemPoolDestroy, ::cuMemAllocFromPoolAsync
  5139. */
  5140. CUresult CUDAAPI cuDeviceSetMemPool(CUdevice dev, CUmemoryPool pool);
  5141. /**
  5142. * \brief Gets the current mempool for a device
  5143. *
  5144. * Returns the last pool provided to ::cuDeviceSetMemPool for this device
  5145. * or the device's default memory pool if ::cuDeviceSetMemPool has never been called.
  5146. * By default the current mempool is the default mempool for a device.
  5147. * Otherwise the returned pool must have been set with ::cuDeviceSetMemPool.
  5148. *
  5149. * \returns
  5150. * ::CUDA_SUCCESS,
  5151. * ::CUDA_ERROR_INVALID_VALUE
  5152. *
  5153. * \sa ::cuDeviceGetDefaultMemPool, ::cuMemPoolCreate, ::cuDeviceSetMemPool
  5154. */
  5155. CUresult CUDAAPI cuDeviceGetMemPool(CUmemoryPool *pool, CUdevice dev);
  5156. /**
  5157. * \brief Returns the default mempool of a device
  5158. *
  5159. * The default mempool of a device contains device memory from that device.
  5160. *
  5161. * \return
  5162. * ::CUDA_SUCCESS,
  5163. * ::CUDA_ERROR_DEINITIALIZED
  5164. * ::CUDA_ERROR_NOT_INITIALIZED,
  5165. * ::CUDA_ERROR_INVALID_VALUE,
  5166. * ::CUDA_ERROR_INVALID_DEVICE,
  5167. * ::CUDA_ERROR_NOT_SUPPORTED
  5168. * \notefnerr
  5169. *
  5170. * \sa ::cuMemAllocAsync, ::cuMemPoolTrimTo, ::cuMemPoolGetAttribute, ::cuMemPoolSetAttribute, cuMemPoolSetAccess, ::cuDeviceGetMemPool, ::cuMemPoolCreate
  5171. */
  5172. CUresult CUDAAPI cuDeviceGetDefaultMemPool(CUmemoryPool *pool_out, CUdevice dev);
  5173. /**
  5174. * \brief Returns information about the execution affinity support of the device.
  5175. *
  5176. * Returns in \p *pi whether execution affinity type \p type is supported by device \p dev.
  5177. * The supported types are:
  5178. * - ::CU_EXEC_AFFINITY_TYPE_SM_COUNT: 1 if context with limited SMs is supported by the device,
  5179. * or 0 if not;
  5180. *
  5181. * \param pi - 1 if the execution affinity type \p type is supported by the device, or 0 if not
  5182. * \param type - Execution affinity type to query
  5183. * \param dev - Device handle
  5184. *
  5185. * \return
  5186. * ::CUDA_SUCCESS,
  5187. * ::CUDA_ERROR_DEINITIALIZED,
  5188. * ::CUDA_ERROR_NOT_INITIALIZED,
  5189. * ::CUDA_ERROR_INVALID_CONTEXT,
  5190. * ::CUDA_ERROR_INVALID_VALUE,
  5191. * ::CUDA_ERROR_INVALID_DEVICE
  5192. * \notefnerr
  5193. *
  5194. * \sa
  5195. * ::cuDeviceGetAttribute,
  5196. * ::cuDeviceGetCount,
  5197. * ::cuDeviceGetName,
  5198. * ::cuDeviceGetUuid,
  5199. * ::cuDeviceGet,
  5200. * ::cuDeviceTotalMem
  5201. */
  5202. CUresult CUDAAPI cuDeviceGetExecAffinitySupport(int *pi, CUexecAffinityType type, CUdevice dev);
  5203. /**
  5204. * \brief Blocks until remote writes are visible to the specified scope
  5205. *
  5206. * Blocks until GPUDirect RDMA writes to the target context via mappings
  5207. * created through APIs like nvidia_p2p_get_pages (see
  5208. * https://docs.nvidia.com/cuda/gpudirect-rdma for more information), are
  5209. * visible to the specified scope.
  5210. *
  5211. * If the scope equals or lies within the scope indicated by
  5212. * ::CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WRITES_ORDERING, the call
  5213. * will be a no-op and can be safely omitted for performance. This can be
  5214. * determined by comparing the numerical values between the two enums, with
  5215. * smaller scopes having smaller values.
  5216. *
  5217. * On platforms that support GPUDirect RDMA writes via more than one path in
  5218. * hardware (see ::CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE), the user should
  5219. * consider those paths as belonging to separate ordering domains. Note that in
  5220. * such cases CUDA driver will report both RDMA writes ordering and RDMA write
  5221. * scope as ALL_DEVICES and a call to cuFlushGPUDirectRDMA will be a no-op,
  5222. * but when these multiple paths are used simultaneously, it is the user's
  5223. * responsibility to ensure ordering by using mechanisms outside the scope of
  5224. * CUDA.
  5225. *
  5226. * Users may query support for this API via
  5227. * ::CU_DEVICE_ATTRIBUTE_FLUSH_FLUSH_GPU_DIRECT_RDMA_OPTIONS.
  5228. *
  5229. * \param target - The target of the operation, see ::CUflushGPUDirectRDMAWritesTarget
  5230. * \param scope - The scope of the operation, see ::CUflushGPUDirectRDMAWritesScope
  5231. *
  5232. * \return
  5233. * ::CUDA_SUCCESS,
  5234. * ::CUDA_ERROR_DEINITIALIZED,
  5235. * ::CUDA_ERROR_NOT_INITIALIZED,
  5236. * ::CUDA_ERROR_INVALID_CONTEXT,
  5237. * ::CUDA_ERROR_INVALID_VALUE,
  5238. * \notefnerr
  5239. *
  5240. */
  5241. CUresult CUDAAPI cuFlushGPUDirectRDMAWrites(CUflushGPUDirectRDMAWritesTarget target, CUflushGPUDirectRDMAWritesScope scope);
  5242. /** @} */ /* END CUDA_DEVICE */
  5243. /**
  5244. * \defgroup CUDA_DEVICE_DEPRECATED Device Management [DEPRECATED]
  5245. *
  5246. * ___MANBRIEF___ deprecated device management functions of the low-level CUDA
  5247. * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  5248. *
  5249. * This section describes the device management functions of the low-level
  5250. * CUDA driver application programming interface.
  5251. *
  5252. * @{
  5253. */
  5254. /**
  5255. * \brief Returns properties for a selected device
  5256. *
  5257. * \deprecated
  5258. *
  5259. * This function was deprecated as of CUDA 5.0 and replaced by ::cuDeviceGetAttribute().
  5260. *
  5261. * Returns in \p *prop the properties of device \p dev. The ::CUdevprop
  5262. * structure is defined as:
  5263. *
  5264. * \code
  5265. typedef struct CUdevprop_st {
  5266. int maxThreadsPerBlock;
  5267. int maxThreadsDim[3];
  5268. int maxGridSize[3];
  5269. int sharedMemPerBlock;
  5270. int totalConstantMemory;
  5271. int SIMDWidth;
  5272. int memPitch;
  5273. int regsPerBlock;
  5274. int clockRate;
  5275. int textureAlign
  5276. } CUdevprop;
  5277. * \endcode
  5278. * where:
  5279. *
  5280. * - ::maxThreadsPerBlock is the maximum number of threads per block;
  5281. * - ::maxThreadsDim[3] is the maximum sizes of each dimension of a block;
  5282. * - ::maxGridSize[3] is the maximum sizes of each dimension of a grid;
  5283. * - ::sharedMemPerBlock is the total amount of shared memory available per
  5284. * block in bytes;
  5285. * - ::totalConstantMemory is the total amount of constant memory available on
  5286. * the device in bytes;
  5287. * - ::SIMDWidth is the warp size;
  5288. * - ::memPitch is the maximum pitch allowed by the memory copy functions that
  5289. * involve memory regions allocated through ::cuMemAllocPitch();
  5290. * - ::regsPerBlock is the total number of registers available per block;
  5291. * - ::clockRate is the clock frequency in kilohertz;
  5292. * - ::textureAlign is the alignment requirement; texture base addresses that
  5293. * are aligned to ::textureAlign bytes do not need an offset applied to
  5294. * texture fetches.
  5295. *
  5296. * \param prop - Returned properties of device
  5297. * \param dev - Device to get properties for
  5298. *
  5299. * \return
  5300. * ::CUDA_SUCCESS,
  5301. * ::CUDA_ERROR_DEINITIALIZED,
  5302. * ::CUDA_ERROR_NOT_INITIALIZED,
  5303. * ::CUDA_ERROR_INVALID_CONTEXT,
  5304. * ::CUDA_ERROR_INVALID_VALUE,
  5305. * ::CUDA_ERROR_INVALID_DEVICE
  5306. * \notefnerr
  5307. *
  5308. * \sa
  5309. * ::cuDeviceGetAttribute,
  5310. * ::cuDeviceGetCount,
  5311. * ::cuDeviceGetName,
  5312. * ::cuDeviceGetUuid,
  5313. * ::cuDeviceGet,
  5314. * ::cuDeviceTotalMem
  5315. */
  5316. __CUDA_DEPRECATED CUresult CUDAAPI cuDeviceGetProperties(CUdevprop *prop, CUdevice dev);
  5317. /**
  5318. * \brief Returns the compute capability of the device
  5319. *
  5320. * \deprecated
  5321. *
  5322. * This function was deprecated as of CUDA 5.0 and its functionality superseded
  5323. * by ::cuDeviceGetAttribute().
  5324. *
  5325. * Returns in \p *major and \p *minor the major and minor revision numbers that
  5326. * define the compute capability of the device \p dev.
  5327. *
  5328. * \param major - Major revision number
  5329. * \param minor - Minor revision number
  5330. * \param dev - Device handle
  5331. *
  5332. * \return
  5333. * ::CUDA_SUCCESS,
  5334. * ::CUDA_ERROR_DEINITIALIZED,
  5335. * ::CUDA_ERROR_NOT_INITIALIZED,
  5336. * ::CUDA_ERROR_INVALID_CONTEXT,
  5337. * ::CUDA_ERROR_INVALID_VALUE,
  5338. * ::CUDA_ERROR_INVALID_DEVICE
  5339. * \notefnerr
  5340. *
  5341. * \sa
  5342. * ::cuDeviceGetAttribute,
  5343. * ::cuDeviceGetCount,
  5344. * ::cuDeviceGetName,
  5345. * ::cuDeviceGetUuid,
  5346. * ::cuDeviceGet,
  5347. * ::cuDeviceTotalMem
  5348. */
  5349. __CUDA_DEPRECATED CUresult CUDAAPI cuDeviceComputeCapability(int *major, int *minor, CUdevice dev);
  5350. /** @} */ /* END CUDA_DEVICE_DEPRECATED */
  5351. /**
  5352. * \defgroup CUDA_PRIMARY_CTX Primary Context Management
  5353. *
  5354. * ___MANBRIEF___ primary context management functions of the low-level CUDA driver
  5355. * API (___CURRENT_FILE___) ___ENDMANBRIEF___
  5356. *
  5357. * This section describes the primary context management functions of the low-level
  5358. * CUDA driver application programming interface.
  5359. *
  5360. * The primary context is unique per device and shared with the CUDA runtime API.
  5361. * These functions allow integration with other libraries using CUDA.
  5362. *
  5363. * @{
  5364. */
  5365. /**
  5366. * \brief Retain the primary context on the GPU
  5367. *
  5368. * Retains the primary context on the device.
  5369. * Once the user successfully retains the primary context, the primary context
  5370. * will be active and available to the user until the user releases it
  5371. * with ::cuDevicePrimaryCtxRelease() or resets it with ::cuDevicePrimaryCtxReset().
  5372. * Unlike ::cuCtxCreate() the newly retained context is not pushed onto the stack.
  5373. *
  5374. * Retaining the primary context for the first time will fail with ::CUDA_ERROR_UNKNOWN
  5375. * if the compute mode of the device is ::CU_COMPUTEMODE_PROHIBITED. The function
  5376. * ::cuDeviceGetAttribute() can be used with ::CU_DEVICE_ATTRIBUTE_COMPUTE_MODE to
  5377. * determine the compute mode of the device.
  5378. * The <i>nvidia-smi</i> tool can be used to set the compute mode for
  5379. * devices. Documentation for <i>nvidia-smi</i> can be obtained by passing a
  5380. * -h option to it.
  5381. *
  5382. * Please note that the primary context always supports pinned allocations. Other
  5383. * flags can be specified by ::cuDevicePrimaryCtxSetFlags().
  5384. *
  5385. * \param pctx - Returned context handle of the new context
  5386. * \param dev - Device for which primary context is requested
  5387. *
  5388. * \return
  5389. * ::CUDA_SUCCESS,
  5390. * ::CUDA_ERROR_DEINITIALIZED,
  5391. * ::CUDA_ERROR_NOT_INITIALIZED,
  5392. * ::CUDA_ERROR_INVALID_CONTEXT,
  5393. * ::CUDA_ERROR_INVALID_DEVICE,
  5394. * ::CUDA_ERROR_INVALID_VALUE,
  5395. * ::CUDA_ERROR_OUT_OF_MEMORY,
  5396. * ::CUDA_ERROR_UNKNOWN
  5397. * \notefnerr
  5398. *
  5399. * \sa ::cuDevicePrimaryCtxRelease,
  5400. * ::cuDevicePrimaryCtxSetFlags,
  5401. * ::cuCtxCreate,
  5402. * ::cuCtxGetApiVersion,
  5403. * ::cuCtxGetCacheConfig,
  5404. * ::cuCtxGetDevice,
  5405. * ::cuCtxGetFlags,
  5406. * ::cuCtxGetLimit,
  5407. * ::cuCtxPopCurrent,
  5408. * ::cuCtxPushCurrent,
  5409. * ::cuCtxSetCacheConfig,
  5410. * ::cuCtxSetLimit,
  5411. * ::cuCtxSynchronize
  5412. */
  5413. CUresult CUDAAPI cuDevicePrimaryCtxRetain(CUcontext *pctx, CUdevice dev);
  5414. /**
  5415. * \brief Release the primary context on the GPU
  5416. *
  5417. * Releases the primary context interop on the device.
  5418. * A retained context should always be released once the user is done using
  5419. * it. The context is automatically reset once the last reference to it is
  5420. * released. This behavior is different when the primary context was retained
  5421. * by the CUDA runtime from CUDA 4.0 and earlier. In this case, the primary
  5422. * context remains always active.
  5423. *
  5424. * Releasing a primary context that has not been previously retained will
  5425. * fail with ::CUDA_ERROR_INVALID_CONTEXT.
  5426. *
  5427. * Please note that unlike ::cuCtxDestroy() this method does not pop the context
  5428. * from stack in any circumstances.
  5429. *
  5430. * \param dev - Device which primary context is released
  5431. *
  5432. * \return
  5433. * ::CUDA_SUCCESS,
  5434. * ::CUDA_ERROR_DEINITIALIZED,
  5435. * ::CUDA_ERROR_NOT_INITIALIZED,
  5436. * ::CUDA_ERROR_INVALID_DEVICE,
  5437. * ::CUDA_ERROR_INVALID_CONTEXT
  5438. * \notefnerr
  5439. *
  5440. * \sa ::cuDevicePrimaryCtxRetain,
  5441. * ::cuCtxDestroy,
  5442. * ::cuCtxGetApiVersion,
  5443. * ::cuCtxGetCacheConfig,
  5444. * ::cuCtxGetDevice,
  5445. * ::cuCtxGetFlags,
  5446. * ::cuCtxGetLimit,
  5447. * ::cuCtxPopCurrent,
  5448. * ::cuCtxPushCurrent,
  5449. * ::cuCtxSetCacheConfig,
  5450. * ::cuCtxSetLimit,
  5451. * ::cuCtxSynchronize
  5452. */
  5453. CUresult CUDAAPI cuDevicePrimaryCtxRelease(CUdevice dev);
  5454. /**
  5455. * \brief Set flags for the primary context
  5456. *
  5457. * Sets the flags for the primary context on the device overwriting perviously
  5458. * set ones.
  5459. *
  5460. * The three LSBs of the \p flags parameter can be used to control how the OS
  5461. * thread, which owns the CUDA context at the time of an API call, interacts
  5462. * with the OS scheduler when waiting for results from the GPU. Only one of
  5463. * the scheduling flags can be set when creating a context.
  5464. *
  5465. * - ::CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for
  5466. * results from the GPU. This can decrease latency when waiting for the GPU,
  5467. * but may lower the performance of CPU threads if they are performing work in
  5468. * parallel with the CUDA thread.
  5469. *
  5470. * - ::CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for
  5471. * results from the GPU. This can increase latency when waiting for the GPU,
  5472. * but can increase the performance of CPU threads performing work in parallel
  5473. * with the GPU.
  5474. *
  5475. * - ::CU_CTX_SCHED_BLOCKING_SYNC: Instruct CUDA to block the CPU thread on a
  5476. * synchronization primitive when waiting for the GPU to finish work.
  5477. *
  5478. * - ::CU_CTX_BLOCKING_SYNC: Instruct CUDA to block the CPU thread on a
  5479. * synchronization primitive when waiting for the GPU to finish work. <br>
  5480. * <b>Deprecated:</b> This flag was deprecated as of CUDA 4.0 and was
  5481. * replaced with ::CU_CTX_SCHED_BLOCKING_SYNC.
  5482. *
  5483. * - ::CU_CTX_SCHED_AUTO: The default value if the \p flags parameter is zero,
  5484. * uses a heuristic based on the number of active CUDA contexts in the
  5485. * process \e C and the number of logical processors in the system \e P. If
  5486. * \e C > \e P, then CUDA will yield to other OS threads when waiting for
  5487. * the GPU (::CU_CTX_SCHED_YIELD), otherwise CUDA will not yield while
  5488. * waiting for results and actively spin on the processor (::CU_CTX_SCHED_SPIN).
  5489. * Additionally, on Tegra devices, ::CU_CTX_SCHED_AUTO uses a heuristic based on
  5490. * the power profile of the platform and may choose ::CU_CTX_SCHED_BLOCKING_SYNC
  5491. * for low-powered devices.
  5492. *
  5493. * - ::CU_CTX_LMEM_RESIZE_TO_MAX: Instruct CUDA to not reduce local memory
  5494. * after resizing local memory for a kernel. This can prevent thrashing by
  5495. * local memory allocations when launching many kernels with high local
  5496. * memory usage at the cost of potentially increased memory usage. <br>
  5497. * <b>Deprecated:</b> This flag is deprecated and the behavior enabled
  5498. * by this flag is now the default and cannot be disabled.
  5499. *
  5500. * - ::CU_CTX_COREDUMP_ENABLE: If GPU coredumps have not been enabled globally
  5501. * with ::cuCoredumpSetAttributeGlobal or environment variables, this flag can
  5502. * be set during context creation to instruct CUDA to create a coredump if
  5503. * this context raises an exception during execution. These environment variables
  5504. * are described in the CUDA-GDB user guide under the "GPU core dump support"
  5505. * section.
  5506. * The initial settings will be taken from the global settings at the time of
  5507. * context creation. The other settings that control coredump output can be
  5508. * modified by calling ::cuCoredumpSetAttribute from the created context after
  5509. * it becomes current.
  5510. *
  5511. * - ::CU_CTX_USER_COREDUMP_ENABLE: If user-triggered GPU coredumps have not
  5512. * been enabled globally with ::cuCoredumpSetAttributeGlobal or environment
  5513. * variables, this flag can be set during context creation to instruct CUDA to
  5514. * create a coredump if data is written to a certain pipe that is present in the
  5515. * OS space. These environment variables are described in the CUDA-GDB user
  5516. * guide under the "GPU core dump support" section.
  5517. * It is important to note that the pipe name *must* be set with
  5518. * ::cuCoredumpSetAttributeGlobal before creating the context if this flag is
  5519. * used. Setting this flag implies that ::CU_CTX_COREDUMP_ENABLE is set.
  5520. * The initial settings will be taken from the global settings at the time of
  5521. * context creation. The other settings that control coredump output can be
  5522. * modified by calling ::cuCoredumpSetAttribute from the created context after
  5523. * it becomes current.
  5524. *
  5525. * - ::CU_CTX_SYNC_MEMOPS: Ensures that synchronous memory operations initiated
  5526. * on this context will always synchronize. See further documentation in the
  5527. * section titled "API Synchronization behavior" to learn more about cases when
  5528. * synchronous memory operations can exhibit asynchronous behavior.
  5529. *
  5530. * \param dev - Device for which the primary context flags are set
  5531. * \param flags - New flags for the device
  5532. *
  5533. * \return
  5534. * ::CUDA_SUCCESS,
  5535. * ::CUDA_ERROR_DEINITIALIZED,
  5536. * ::CUDA_ERROR_NOT_INITIALIZED,
  5537. * ::CUDA_ERROR_INVALID_DEVICE,
  5538. * ::CUDA_ERROR_INVALID_VALUE,
  5539. * \notefnerr
  5540. *
  5541. * \sa ::cuDevicePrimaryCtxRetain,
  5542. * ::cuDevicePrimaryCtxGetState,
  5543. * ::cuCtxCreate,
  5544. * ::cuCtxGetFlags,
  5545. * ::cuCtxSetFlags,
  5546. * ::cudaSetDeviceFlags
  5547. */
  5548. CUresult CUDAAPI cuDevicePrimaryCtxSetFlags(CUdevice dev, unsigned int flags);
  5549. /**
  5550. * \brief Get the state of the primary context
  5551. *
  5552. * Returns in \p *flags the flags for the primary context of \p dev, and in
  5553. * \p *active whether it is active. See ::cuDevicePrimaryCtxSetFlags for flag
  5554. * values.
  5555. *
  5556. * \param dev - Device to get primary context flags for
  5557. * \param flags - Pointer to store flags
  5558. * \param active - Pointer to store context state; 0 = inactive, 1 = active
  5559. *
  5560. * \return
  5561. * ::CUDA_SUCCESS,
  5562. * ::CUDA_ERROR_DEINITIALIZED,
  5563. * ::CUDA_ERROR_NOT_INITIALIZED,
  5564. * ::CUDA_ERROR_INVALID_DEVICE,
  5565. * ::CUDA_ERROR_INVALID_VALUE,
  5566. * \notefnerr
  5567. *
  5568. * \sa
  5569. * ::cuDevicePrimaryCtxSetFlags,
  5570. * ::cuCtxGetFlags,
  5571. * ::cuCtxSetFlags,
  5572. * ::cudaGetDeviceFlags
  5573. */
  5574. CUresult CUDAAPI cuDevicePrimaryCtxGetState(CUdevice dev, unsigned int *flags, int *active);
  5575. /**
  5576. * \brief Destroy all allocations and reset all state on the primary context
  5577. *
  5578. * Explicitly destroys and cleans up all resources associated with the current
  5579. * device in the current process.
  5580. *
  5581. * Note that it is responsibility of the calling function to ensure that no
  5582. * other module in the process is using the device any more. For that reason
  5583. * it is recommended to use ::cuDevicePrimaryCtxRelease() in most cases.
  5584. * However it is safe for other modules to call ::cuDevicePrimaryCtxRelease()
  5585. * even after resetting the device.
  5586. * Resetting the primary context does not release it, an application that has
  5587. * retained the primary context should explicitly release its usage.
  5588. *
  5589. * \param dev - Device for which primary context is destroyed
  5590. *
  5591. * \return
  5592. * ::CUDA_SUCCESS,
  5593. * ::CUDA_ERROR_DEINITIALIZED,
  5594. * ::CUDA_ERROR_NOT_INITIALIZED,
  5595. * ::CUDA_ERROR_INVALID_DEVICE,
  5596. * ::CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE
  5597. * \notefnerr
  5598. *
  5599. * \sa ::cuDevicePrimaryCtxRetain,
  5600. * ::cuDevicePrimaryCtxRelease,
  5601. * ::cuCtxGetApiVersion,
  5602. * ::cuCtxGetCacheConfig,
  5603. * ::cuCtxGetDevice,
  5604. * ::cuCtxGetFlags,
  5605. * ::cuCtxGetLimit,
  5606. * ::cuCtxPopCurrent,
  5607. * ::cuCtxPushCurrent,
  5608. * ::cuCtxSetCacheConfig,
  5609. * ::cuCtxSetLimit,
  5610. * ::cuCtxSynchronize,
  5611. * ::cudaDeviceReset
  5612. */
  5613. CUresult CUDAAPI cuDevicePrimaryCtxReset(CUdevice dev);
  5614. /** @} */ /* END CUDA_PRIMARY_CTX */
  5615. /**
  5616. * \defgroup CUDA_CTX Context Management
  5617. *
  5618. * ___MANBRIEF___ context management functions of the low-level CUDA driver
  5619. * API (___CURRENT_FILE___) ___ENDMANBRIEF___
  5620. *
  5621. * This section describes the context management functions of the low-level
  5622. * CUDA driver application programming interface.
  5623. *
  5624. * Please note that some functions are described in
  5625. * \ref CUDA_PRIMARY_CTX "Primary Context Management" section.
  5626. *
  5627. * @{
  5628. */
  5629. /**
  5630. * \brief Create a CUDA context
  5631. *
  5632. * \note In most cases it is recommended to use ::cuDevicePrimaryCtxRetain.
  5633. *
  5634. * Creates a new CUDA context and associates it with the calling thread. The
  5635. * \p flags parameter is described below. The context is created with a usage
  5636. * count of 1 and the caller of ::cuCtxCreate() must call ::cuCtxDestroy()
  5637. * when done using the context. If a context is already current to the thread,
  5638. * it is supplanted by the newly created context and may be restored by a subsequent
  5639. * call to ::cuCtxPopCurrent().
  5640. *
  5641. * The three LSBs of the \p flags parameter can be used to control how the OS
  5642. * thread, which owns the CUDA context at the time of an API call, interacts
  5643. * with the OS scheduler when waiting for results from the GPU. Only one of
  5644. * the scheduling flags can be set when creating a context.
  5645. *
  5646. * - ::CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for
  5647. * results from the GPU. This can decrease latency when waiting for the GPU,
  5648. * but may lower the performance of CPU threads if they are performing work in
  5649. * parallel with the CUDA thread.
  5650. *
  5651. * - ::CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for
  5652. * results from the GPU. This can increase latency when waiting for the GPU,
  5653. * but can increase the performance of CPU threads performing work in parallel
  5654. * with the GPU.
  5655. *
  5656. * - ::CU_CTX_SCHED_BLOCKING_SYNC: Instruct CUDA to block the CPU thread on a
  5657. * synchronization primitive when waiting for the GPU to finish work.
  5658. *
  5659. * - ::CU_CTX_BLOCKING_SYNC: Instruct CUDA to block the CPU thread on a
  5660. * synchronization primitive when waiting for the GPU to finish work. <br>
  5661. * <b>Deprecated:</b> This flag was deprecated as of CUDA 4.0 and was
  5662. * replaced with ::CU_CTX_SCHED_BLOCKING_SYNC.
  5663. *
  5664. * - ::CU_CTX_SCHED_AUTO: The default value if the \p flags parameter is zero,
  5665. * uses a heuristic based on the number of active CUDA contexts in the
  5666. * process \e C and the number of logical processors in the system \e P. If
  5667. * \e C > \e P, then CUDA will yield to other OS threads when waiting for
  5668. * the GPU (::CU_CTX_SCHED_YIELD), otherwise CUDA will not yield while
  5669. * waiting for results and actively spin on the processor (::CU_CTX_SCHED_SPIN).
  5670. * Additionally, on Tegra devices, ::CU_CTX_SCHED_AUTO uses a heuristic based on
  5671. * the power profile of the platform and may choose ::CU_CTX_SCHED_BLOCKING_SYNC
  5672. * for low-powered devices.
  5673. *
  5674. * - ::CU_CTX_MAP_HOST: Instruct CUDA to support mapped pinned allocations.
  5675. * This flag must be set in order to allocate pinned host memory that is
  5676. * accessible to the GPU.
  5677. *
  5678. * - ::CU_CTX_LMEM_RESIZE_TO_MAX: Instruct CUDA to not reduce local memory
  5679. * after resizing local memory for a kernel. This can prevent thrashing by
  5680. * local memory allocations when launching many kernels with high local
  5681. * memory usage at the cost of potentially increased memory usage. <br>
  5682. * <b>Deprecated:</b> This flag is deprecated and the behavior enabled
  5683. * by this flag is now the default and cannot be disabled.
  5684. * Instead, the per-thread stack size can be controlled with ::cuCtxSetLimit().
  5685. *
  5686. * - ::CU_CTX_COREDUMP_ENABLE: If GPU coredumps have not been enabled globally
  5687. * with ::cuCoredumpSetAttributeGlobal or environment variables, this flag can
  5688. * be set during context creation to instruct CUDA to create a coredump if
  5689. * this context raises an exception during execution. These environment variables
  5690. * are described in the CUDA-GDB user guide under the "GPU core dump support"
  5691. * section.
  5692. * The initial attributes will be taken from the global attributes at the time of
  5693. * context creation. The other attributes that control coredump output can be
  5694. * modified by calling ::cuCoredumpSetAttribute from the created context after
  5695. * it becomes current.
  5696. *
  5697. * - ::CU_CTX_USER_COREDUMP_ENABLE: If user-triggered GPU coredumps have not
  5698. * been enabled globally with ::cuCoredumpSetAttributeGlobal or environment
  5699. * variables, this flag can be set during context creation to instruct CUDA to
  5700. * create a coredump if data is written to a certain pipe that is present in the
  5701. * OS space. These environment variables are described in the CUDA-GDB user
  5702. * guide under the "GPU core dump support" section.
  5703. * It is important to note that the pipe name *must* be set with
  5704. * ::cuCoredumpSetAttributeGlobal before creating the context if this flag is
  5705. * used. Setting this flag implies that ::CU_CTX_COREDUMP_ENABLE is set.
  5706. * The initial attributes will be taken from the global attributes at the time of
  5707. * context creation. The other attributes that control coredump output can be
  5708. * modified by calling ::cuCoredumpSetAttribute from the created context after
  5709. * it becomes current.
  5710. * Setting this flag on any context creation is equivalent to setting the
  5711. * ::CU_COREDUMP_ENABLE_USER_TRIGGER attribute to \p true globally.
  5712. *
  5713. * - ::CU_CTX_SYNC_MEMOPS: Ensures that synchronous memory operations initiated
  5714. * on this context will always synchronize. See further documentation in the
  5715. * section titled "API Synchronization behavior" to learn more about cases when
  5716. * synchronous memory operations can exhibit asynchronous behavior.
  5717. *
  5718. * Context creation will fail with ::CUDA_ERROR_UNKNOWN if the compute mode of
  5719. * the device is ::CU_COMPUTEMODE_PROHIBITED. The function ::cuDeviceGetAttribute()
  5720. * can be used with ::CU_DEVICE_ATTRIBUTE_COMPUTE_MODE to determine the
  5721. * compute mode of the device. The <i>nvidia-smi</i> tool can be used to set
  5722. * the compute mode for * devices.
  5723. * Documentation for <i>nvidia-smi</i> can be obtained by passing a
  5724. * -h option to it.
  5725. *
  5726. * \param pctx - Returned context handle of the new context
  5727. * \param flags - Context creation flags
  5728. * \param dev - Device to create context on
  5729. *
  5730. * \return
  5731. * ::CUDA_SUCCESS,
  5732. * ::CUDA_ERROR_DEINITIALIZED,
  5733. * ::CUDA_ERROR_NOT_INITIALIZED,
  5734. * ::CUDA_ERROR_INVALID_CONTEXT,
  5735. * ::CUDA_ERROR_INVALID_DEVICE,
  5736. * ::CUDA_ERROR_INVALID_VALUE,
  5737. * ::CUDA_ERROR_OUT_OF_MEMORY,
  5738. * ::CUDA_ERROR_UNKNOWN
  5739. * \notefnerr
  5740. *
  5741. * \sa ::cuCtxDestroy,
  5742. * ::cuCtxGetApiVersion,
  5743. * ::cuCtxGetCacheConfig,
  5744. * ::cuCtxGetDevice,
  5745. * ::cuCtxGetFlags,
  5746. * ::cuCtxGetLimit,
  5747. * ::cuCtxPopCurrent,
  5748. * ::cuCtxPushCurrent,
  5749. * ::cuCtxSetCacheConfig,
  5750. * ::cuCtxSetLimit,
  5751. * ::cuCoredumpSetAttributeGlobal,
  5752. * ::cuCoredumpSetAttribute,
  5753. * ::cuCtxSynchronize
  5754. */
  5755. CUresult CUDAAPI cuCtxCreate(CUcontext *pctx, unsigned int flags, CUdevice dev);
  5756. /**
  5757. * \brief Create a CUDA context with execution affinity
  5758. *
  5759. * Creates a new CUDA context with execution affinity and associates it with
  5760. * the calling thread. The \p paramsArray and \p flags parameter are described below.
  5761. * The context is created with a usage count of 1 and the caller of ::cuCtxCreate() must
  5762. * call ::cuCtxDestroy() when done using the context. If a context is already
  5763. * current to the thread, it is supplanted by the newly created context and may
  5764. * be restored by a subsequent call to ::cuCtxPopCurrent().
  5765. *
  5766. * The type and the amount of execution resource the context can use is limited by \p paramsArray
  5767. * and \p numParams. The \p paramsArray is an array of \p CUexecAffinityParam and the \p numParams
  5768. * describes the size of the array. If two \p CUexecAffinityParam in the array have the same type,
  5769. * the latter execution affinity parameter overrides the former execution affinity parameter.
  5770. * The supported execution affinity types are:
  5771. * - ::CU_EXEC_AFFINITY_TYPE_SM_COUNT limits the portion of SMs that the context can use. The portion
  5772. * of SMs is specified as the number of SMs via \p CUexecAffinitySmCount. This limit will be internally
  5773. * rounded up to the next hardware-supported amount. Hence, it is imperative to query the actual execution
  5774. * affinity of the context via \p cuCtxGetExecAffinity after context creation. Currently, this attribute
  5775. * is only supported under Volta+ MPS.
  5776. *
  5777. * The three LSBs of the \p flags parameter can be used to control how the OS
  5778. * thread, which owns the CUDA context at the time of an API call, interacts
  5779. * with the OS scheduler when waiting for results from the GPU. Only one of
  5780. * the scheduling flags can be set when creating a context.
  5781. *
  5782. * - ::CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for
  5783. * results from the GPU. This can decrease latency when waiting for the GPU,
  5784. * but may lower the performance of CPU threads if they are performing work in
  5785. * parallel with the CUDA thread.
  5786. *
  5787. * - ::CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for
  5788. * results from the GPU. This can increase latency when waiting for the GPU,
  5789. * but can increase the performance of CPU threads performing work in parallel
  5790. * with the GPU.
  5791. *
  5792. * - ::CU_CTX_SCHED_BLOCKING_SYNC: Instruct CUDA to block the CPU thread on a
  5793. * synchronization primitive when waiting for the GPU to finish work.
  5794. *
  5795. * - ::CU_CTX_BLOCKING_SYNC: Instruct CUDA to block the CPU thread on a
  5796. * synchronization primitive when waiting for the GPU to finish work. <br>
  5797. * <b>Deprecated:</b> This flag was deprecated as of CUDA 4.0 and was
  5798. * replaced with ::CU_CTX_SCHED_BLOCKING_SYNC.
  5799. *
  5800. * - ::CU_CTX_SCHED_AUTO: The default value if the \p flags parameter is zero,
  5801. * uses a heuristic based on the number of active CUDA contexts in the
  5802. * process \e C and the number of logical processors in the system \e P. If
  5803. * \e C > \e P, then CUDA will yield to other OS threads when waiting for
  5804. * the GPU (::CU_CTX_SCHED_YIELD), otherwise CUDA will not yield while
  5805. * waiting for results and actively spin on the processor (::CU_CTX_SCHED_SPIN).
  5806. * Additionally, on Tegra devices, ::CU_CTX_SCHED_AUTO uses a heuristic based on
  5807. * the power profile of the platform and may choose ::CU_CTX_SCHED_BLOCKING_SYNC
  5808. * for low-powered devices.
  5809. *
  5810. * - ::CU_CTX_MAP_HOST: Instruct CUDA to support mapped pinned allocations.
  5811. * This flag must be set in order to allocate pinned host memory that is
  5812. * accessible to the GPU.
  5813. *
  5814. * - ::CU_CTX_LMEM_RESIZE_TO_MAX: Instruct CUDA to not reduce local memory
  5815. * after resizing local memory for a kernel. This can prevent thrashing by
  5816. * local memory allocations when launching many kernels with high local
  5817. * memory usage at the cost of potentially increased memory usage. <br>
  5818. * <b>Deprecated:</b> This flag is deprecated and the behavior enabled
  5819. * by this flag is now the default and cannot be disabled.
  5820. * Instead, the per-thread stack size can be controlled with ::cuCtxSetLimit().
  5821. *
  5822. * - ::CU_CTX_COREDUMP_ENABLE: If GPU coredumps have not been enabled globally
  5823. * with ::cuCoredumpSetAttributeGlobal or environment variables, this flag can
  5824. * be set during context creation to instruct CUDA to create a coredump if
  5825. * this context raises an exception during execution. These environment variables
  5826. * are described in the CUDA-GDB user guide under the "GPU core dump support"
  5827. * section.
  5828. * The initial attributes will be taken from the global attributes at the time of
  5829. * context creation. The other attributes that control coredump output can be
  5830. * modified by calling ::cuCoredumpSetAttribute from the created context after
  5831. * it becomes current.
  5832. *
  5833. * - ::CU_CTX_USER_COREDUMP_ENABLE: If user-triggered GPU coredumps have not
  5834. * been enabled globally with ::cuCoredumpSetAttributeGlobal or environment
  5835. * variables, this flag can be set during context creation to instruct CUDA to
  5836. * create a coredump if data is written to a certain pipe that is present in the
  5837. * OS space. These environment variables are described in the CUDA-GDB user
  5838. * guide under the "GPU core dump support" section.
  5839. * It is important to note that the pipe name *must* be set with
  5840. * ::cuCoredumpSetAttributeGlobal before creating the context if this flag is
  5841. * used. Setting this flag implies that ::CU_CTX_COREDUMP_ENABLE is set.
  5842. * The initial attributes will be taken from the global attributes at the time of
  5843. * context creation. The other attributes that control coredump output can be
  5844. * modified by calling ::cuCoredumpSetAttribute from the created context after
  5845. * it becomes current.
  5846. * Setting this flag on any context creation is equivalent to setting the
  5847. * ::CU_COREDUMP_ENABLE_USER_TRIGGER attribute to \p true globally.
  5848. *
  5849. * Context creation will fail with ::CUDA_ERROR_UNKNOWN if the compute mode of
  5850. * the device is ::CU_COMPUTEMODE_PROHIBITED. The function ::cuDeviceGetAttribute()
  5851. * can be used with ::CU_DEVICE_ATTRIBUTE_COMPUTE_MODE to determine the
  5852. * compute mode of the device. The <i>nvidia-smi</i> tool can be used to set
  5853. * the compute mode for * devices.
  5854. * Documentation for <i>nvidia-smi</i> can be obtained by passing a
  5855. * -h option to it.
  5856. *
  5857. * \param pctx - Returned context handle of the new context
  5858. * \param paramsArray - Execution affinity parameters
  5859. * \param numParams - Number of execution affinity parameters
  5860. * \param flags - Context creation flags
  5861. * \param dev - Device to create context on
  5862. *
  5863. * \return
  5864. * ::CUDA_SUCCESS,
  5865. * ::CUDA_ERROR_DEINITIALIZED,
  5866. * ::CUDA_ERROR_NOT_INITIALIZED,
  5867. * ::CUDA_ERROR_INVALID_CONTEXT,
  5868. * ::CUDA_ERROR_INVALID_DEVICE,
  5869. * ::CUDA_ERROR_INVALID_VALUE,
  5870. * ::CUDA_ERROR_OUT_OF_MEMORY,
  5871. * ::CUDA_ERROR_UNSUPPORTED_EXEC_AFFINITY,
  5872. * ::CUDA_ERROR_UNKNOWN
  5873. * \notefnerr
  5874. *
  5875. * \sa ::cuCtxDestroy,
  5876. * ::cuCtxGetApiVersion,
  5877. * ::cuCtxGetCacheConfig,
  5878. * ::cuCtxGetDevice,
  5879. * ::cuCtxGetFlags,
  5880. * ::cuCtxGetLimit,
  5881. * ::cuCtxPopCurrent,
  5882. * ::cuCtxPushCurrent,
  5883. * ::cuCtxSetCacheConfig,
  5884. * ::cuCtxSetLimit,
  5885. * ::cuCtxSynchronize,
  5886. * ::cuCoredumpSetAttributeGlobal,
  5887. * ::cuCoredumpSetAttribute,
  5888. * ::CUexecAffinityParam
  5889. */
  5890. CUresult CUDAAPI cuCtxCreate_v3(CUcontext *pctx, CUexecAffinityParam *paramsArray, int numParams, unsigned int flags, CUdevice dev);
  5891. /**
  5892. * \brief Create a CUDA context
  5893. *
  5894. * Creates a new CUDA context and associates it with the calling thread. The
  5895. * \p flags parameter is described below. The context is created with a usage
  5896. * count of 1 and the caller of ::cuCtxCreate() must call ::cuCtxDestroy()
  5897. * when done using the context. If a context is already current to the thread,
  5898. * it is supplanted by the newly created context and may be restored by a subsequent
  5899. * call to ::cuCtxPopCurrent().
  5900. *
  5901. * CUDA context can be created with execution affinity. The type and the amount of
  5902. execution resource the context can use is limited by \p paramsArray and \p numExecAffinityParams
  5903. in \p execAffinity. The \p paramsArray is an array of \p CUexecAffinityParam and the \p numExecAffinityParams
  5904. * describes the size of the paramsArray. If two \p CUexecAffinityParam in the array have the same type,
  5905. * the latter execution affinity parameter overrides the former execution affinity parameter.
  5906. * The supported execution affinity types are:
  5907. * - ::CU_EXEC_AFFINITY_TYPE_SM_COUNT limits the portion of SMs that the context can use. The portion
  5908. * of SMs is specified as the number of SMs via \p CUexecAffinitySmCount. This limit will be internally
  5909. * rounded up to the next hardware-supported amount. Hence, it is imperative to query the actual execution
  5910. * affinity of the context via \p cuCtxGetExecAffinity after context creation. Currently, this attribute
  5911. * is only supported under Volta+ MPS.
  5912. *
  5913. * CUDA context can be created in CIG(CUDA in Graphics) mode by setting \p cigParams.
  5914. * Data from graphics client is shared with CUDA via the \p sharedData in \p cigParams.
  5915. * Support for D3D12 graphics client can be determined using ::cuDeviceGetAttribute() with
  5916. * ::CU_DEVICE_ATTRIBUTE_D3D12_CIG_SUPPORTED. \p sharedData is a ID3D12CommandQueue handle.
  5917. * Either \p execAffinityParams or \p cigParams can be set to a non-null value. Setting both to a
  5918. * non-null value will result in an undefined behavior.
  5919. *
  5920. * The three LSBs of the \p flags parameter can be used to control how the OS
  5921. * thread, which owns the CUDA context at the time of an API call, interacts
  5922. * with the OS scheduler when waiting for results from the GPU. Only one of
  5923. * the scheduling flags can be set when creating a context.
  5924. *
  5925. * - ::CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for
  5926. * results from the GPU. This can decrease latency when waiting for the GPU,
  5927. * but may lower the performance of CPU threads if they are performing work in
  5928. * parallel with the CUDA thread.
  5929. *
  5930. * - ::CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for
  5931. * results from the GPU. This can increase latency when waiting for the GPU,
  5932. * but can increase the performance of CPU threads performing work in parallel
  5933. * with the GPU.
  5934. *
  5935. * - ::CU_CTX_SCHED_BLOCKING_SYNC: Instruct CUDA to block the CPU thread on a
  5936. * synchronization primitive when waiting for the GPU to finish work.
  5937. *
  5938. * - ::CU_CTX_BLOCKING_SYNC: Instruct CUDA to block the CPU thread on a
  5939. * synchronization primitive when waiting for the GPU to finish work. <br>
  5940. * <b>Deprecated:</b> This flag was deprecated as of CUDA 4.0 and was
  5941. * replaced with ::CU_CTX_SCHED_BLOCKING_SYNC.
  5942. *
  5943. * - ::CU_CTX_SCHED_AUTO: The default value if the \p flags parameter is zero,
  5944. * uses a heuristic based on the number of active CUDA contexts in the
  5945. * process \e C and the number of logical processors in the system \e P. If
  5946. * \e C > \e P, then CUDA will yield to other OS threads when waiting for
  5947. * the GPU (::CU_CTX_SCHED_YIELD), otherwise CUDA will not yield while
  5948. * waiting for results and actively spin on the processor (::CU_CTX_SCHED_SPIN).
  5949. * Additionally, on Tegra devices, ::CU_CTX_SCHED_AUTO uses a heuristic based on
  5950. * the power profile of the platform and may choose ::CU_CTX_SCHED_BLOCKING_SYNC
  5951. * for low-powered devices.
  5952. *
  5953. * - ::CU_CTX_MAP_HOST: Instruct CUDA to support mapped pinned allocations.
  5954. * This flag must be set in order to allocate pinned host memory that is
  5955. * accessible to the GPU.
  5956. *
  5957. * - ::CU_CTX_LMEM_RESIZE_TO_MAX: Instruct CUDA to not reduce local memory
  5958. * after resizing local memory for a kernel. This can prevent thrashing by
  5959. * local memory allocations when launching many kernels with high local
  5960. * memory usage at the cost of potentially increased memory usage. <br>
  5961. * <b>Deprecated:</b> This flag is deprecated and the behavior enabled
  5962. * by this flag is now the default and cannot be disabled.
  5963. * Instead, the per-thread stack size can be controlled with ::cuCtxSetLimit().
  5964. *
  5965. * - ::CU_CTX_COREDUMP_ENABLE: If GPU coredumps have not been enabled globally
  5966. * with ::cuCoredumpSetAttributeGlobal or environment variables, this flag can
  5967. * be set during context creation to instruct CUDA to create a coredump if
  5968. * this context raises an exception during execution. These environment variables
  5969. * are described in the CUDA-GDB user guide under the "GPU core dump support"
  5970. * section.
  5971. * The initial attributes will be taken from the global attributes at the time of
  5972. * context creation. The other attributes that control coredump output can be
  5973. * modified by calling ::cuCoredumpSetAttribute from the created context after
  5974. * it becomes current. This flag is not supported when CUDA context is created in
  5975. * CIG(CUDA in Graphics) mode.
  5976. *
  5977. * - ::CU_CTX_USER_COREDUMP_ENABLE: If user-triggered GPU coredumps have not
  5978. * been enabled globally with ::cuCoredumpSetAttributeGlobal or environment
  5979. * variables, this flag can be set during context creation to instruct CUDA to
  5980. * create a coredump if data is written to a certain pipe that is present in the
  5981. * OS space. These environment variables are described in the CUDA-GDB user
  5982. * guide under the "GPU core dump support" section.
  5983. * It is important to note that the pipe name *must* be set with
  5984. * ::cuCoredumpSetAttributeGlobal before creating the context if this flag is
  5985. * used. Setting this flag implies that ::CU_CTX_COREDUMP_ENABLE is set.
  5986. * The initial attributes will be taken from the global attributes at the time of
  5987. * context creation. The other attributes that control coredump output can be
  5988. * modified by calling ::cuCoredumpSetAttribute from the created context after
  5989. * it becomes current.
  5990. * Setting this flag on any context creation is equivalent to setting the
  5991. * ::CU_COREDUMP_ENABLE_USER_TRIGGER attribute to \p true globally.
  5992. * This flag is not supported when CUDA context is created in
  5993. * CIG(CUDA in Graphics) mode.
  5994. *
  5995. * - ::CU_CTX_SYNC_MEMOPS: Ensures that synchronous memory operations initiated
  5996. * on this context will always synchronize. See further documentation in the
  5997. * section titled "API Synchronization behavior" to learn more about cases when
  5998. * synchronous memory operations can exhibit asynchronous behavior.
  5999. *
  6000. * Context creation will fail with ::CUDA_ERROR_UNKNOWN if the compute mode of
  6001. * the device is ::CU_COMPUTEMODE_PROHIBITED. The function ::cuDeviceGetAttribute()
  6002. * can be used with ::CU_DEVICE_ATTRIBUTE_COMPUTE_MODE to determine the
  6003. * compute mode of the device. The <i>nvidia-smi</i> tool can be used to set
  6004. * the compute mode for * devices.
  6005. * Documentation for <i>nvidia-smi</i> can be obtained by passing a
  6006. * -h option to it.
  6007. *
  6008. * Context creation will fail with :: CUDA_ERROR_INVALID_VALUE if invalid parameter was
  6009. * passed by client to create the CUDA context.
  6010. *
  6011. * Context creation in CIG mode will fail with ::CUDA_ERROR_NOT_SUPPORTED if CIG is not supported
  6012. * by the device or the driver.
  6013. * \param pctx - Returned context handle of the new context
  6014. * \param ctxCreateParams - Context creation parameters
  6015. * \param flags - Context creation flags
  6016. * \param dev - Device to create context on
  6017. *
  6018. * \return
  6019. * ::CUDA_SUCCESS,
  6020. * ::CUDA_ERROR_DEINITIALIZED,
  6021. * ::CUDA_ERROR_NOT_INITIALIZED,
  6022. * ::CUDA_ERROR_INVALID_CONTEXT,
  6023. * ::CUDA_ERROR_INVALID_DEVICE,
  6024. * ::CUDA_ERROR_INVALID_VALUE,
  6025. * ::CUDA_ERROR_NOT_SUPPORTED,
  6026. * ::CUDA_ERROR_OUT_OF_MEMORY,
  6027. * ::CUDA_ERROR_UNKNOWN
  6028. * \notefnerr
  6029. *
  6030. * \sa ::cuCtxDestroy,
  6031. * ::cuCtxGetApiVersion,
  6032. * ::cuCtxGetCacheConfig,
  6033. * ::cuCtxGetDevice,
  6034. * ::cuCtxGetFlags,
  6035. * ::cuCtxGetLimit,
  6036. * ::cuCtxPopCurrent,
  6037. * ::cuCtxPushCurrent,
  6038. * ::cuCtxSetCacheConfig,
  6039. * ::cuCtxSetLimit,
  6040. * ::cuCoredumpSetAttributeGlobal,
  6041. * ::cuCoredumpSetAttribute,
  6042. * ::cuCtxSynchronize
  6043. */
  6044. CUresult CUDAAPI cuCtxCreate_v4(CUcontext *pctx, CUctxCreateParams *ctxCreateParams, unsigned int flags, CUdevice dev);
  6045. /**
  6046. * \brief Destroy a CUDA context
  6047. *
  6048. * Destroys the CUDA context specified by \p ctx. The context \p ctx will be
  6049. * destroyed regardless of how many threads it is current to.
  6050. * It is the responsibility of the calling function to ensure that no API
  6051. * call issues using \p ctx while ::cuCtxDestroy() is executing.
  6052. *
  6053. * Destroys and cleans up all resources associated with the context.
  6054. * It is the caller's responsibility to ensure that the context or its resources
  6055. * are not accessed or passed in subsequent API calls and doing so will result in undefined behavior.
  6056. * These resources include CUDA types ::CUmodule, ::CUfunction, ::CUstream, ::CUevent,
  6057. * ::CUarray, ::CUmipmappedArray, ::CUtexObject, ::CUsurfObject, ::CUtexref, ::CUsurfref,
  6058. * ::CUgraphicsResource, ::CUlinkState, ::CUexternalMemory and ::CUexternalSemaphore.
  6059. * These resources also include memory allocations by ::cuMemAlloc(), ::cuMemAllocHost(),
  6060. * ::cuMemAllocManaged() and ::cuMemAllocPitch().
  6061. *
  6062. * If \p ctx is current to the calling thread then \p ctx will also be
  6063. * popped from the current thread's context stack (as though ::cuCtxPopCurrent()
  6064. * were called). If \p ctx is current to other threads, then \p ctx will
  6065. * remain current to those threads, and attempting to access \p ctx from
  6066. * those threads will result in the error ::CUDA_ERROR_CONTEXT_IS_DESTROYED.
  6067. *
  6068. * \note ::cuCtxDestroy() will not destroy memory allocations by ::cuMemCreate(), ::cuMemAllocAsync() and
  6069. * ::cuMemAllocFromPoolAsync(). These memory allocations are not associated with any CUDA context and need to
  6070. * be destroyed explicitly.
  6071. *
  6072. * \param ctx - Context to destroy
  6073. *
  6074. * \return
  6075. * ::CUDA_SUCCESS,
  6076. * ::CUDA_ERROR_DEINITIALIZED,
  6077. * ::CUDA_ERROR_NOT_INITIALIZED,
  6078. * ::CUDA_ERROR_INVALID_CONTEXT,
  6079. * ::CUDA_ERROR_INVALID_VALUE
  6080. * \notefnerr
  6081. *
  6082. * \sa ::cuCtxCreate,
  6083. * ::cuCtxGetApiVersion,
  6084. * ::cuCtxGetCacheConfig,
  6085. * ::cuCtxGetDevice,
  6086. * ::cuCtxGetFlags,
  6087. * ::cuCtxGetLimit,
  6088. * ::cuCtxPopCurrent,
  6089. * ::cuCtxPushCurrent,
  6090. * ::cuCtxSetCacheConfig,
  6091. * ::cuCtxSetLimit,
  6092. * ::cuCtxSynchronize
  6093. */
  6094. CUresult CUDAAPI cuCtxDestroy(CUcontext ctx);
  6095. /**
  6096. * \brief Pushes a context on the current CPU thread
  6097. *
  6098. * Pushes the given context \p ctx onto the CPU thread's stack of current
  6099. * contexts. The specified context becomes the CPU thread's current context, so
  6100. * all CUDA functions that operate on the current context are affected.
  6101. *
  6102. * The previous current context may be made current again by calling
  6103. * ::cuCtxDestroy() or ::cuCtxPopCurrent().
  6104. *
  6105. * \param ctx - Context to push
  6106. *
  6107. * \return
  6108. * ::CUDA_SUCCESS,
  6109. * ::CUDA_ERROR_DEINITIALIZED,
  6110. * ::CUDA_ERROR_NOT_INITIALIZED,
  6111. * ::CUDA_ERROR_INVALID_CONTEXT,
  6112. * ::CUDA_ERROR_INVALID_VALUE
  6113. * \notefnerr
  6114. *
  6115. * \sa ::cuCtxCreate,
  6116. * ::cuCtxDestroy,
  6117. * ::cuCtxGetApiVersion,
  6118. * ::cuCtxGetCacheConfig,
  6119. * ::cuCtxGetDevice,
  6120. * ::cuCtxGetFlags,
  6121. * ::cuCtxGetLimit,
  6122. * ::cuCtxPopCurrent,
  6123. * ::cuCtxSetCacheConfig,
  6124. * ::cuCtxSetLimit,
  6125. * ::cuCtxSynchronize
  6126. */
  6127. CUresult CUDAAPI cuCtxPushCurrent(CUcontext ctx);
  6128. /**
  6129. * \brief Pops the current CUDA context from the current CPU thread.
  6130. *
  6131. * Pops the current CUDA context from the CPU thread and passes back the
  6132. * old context handle in \p *pctx. That context may then be made current
  6133. * to a different CPU thread by calling ::cuCtxPushCurrent().
  6134. *
  6135. * If a context was current to the CPU thread before ::cuCtxCreate() or
  6136. * ::cuCtxPushCurrent() was called, this function makes that context current to
  6137. * the CPU thread again.
  6138. *
  6139. * \param pctx - Returned popped context handle
  6140. *
  6141. * \return
  6142. * ::CUDA_SUCCESS,
  6143. * ::CUDA_ERROR_DEINITIALIZED,
  6144. * ::CUDA_ERROR_NOT_INITIALIZED,
  6145. * ::CUDA_ERROR_INVALID_CONTEXT
  6146. * \notefnerr
  6147. *
  6148. * \sa ::cuCtxCreate,
  6149. * ::cuCtxDestroy,
  6150. * ::cuCtxGetApiVersion,
  6151. * ::cuCtxGetCacheConfig,
  6152. * ::cuCtxGetDevice,
  6153. * ::cuCtxGetFlags,
  6154. * ::cuCtxGetLimit,
  6155. * ::cuCtxPushCurrent,
  6156. * ::cuCtxSetCacheConfig,
  6157. * ::cuCtxSetLimit,
  6158. * ::cuCtxSynchronize
  6159. */
  6160. CUresult CUDAAPI cuCtxPopCurrent(CUcontext *pctx);
  6161. /**
  6162. * \brief Binds the specified CUDA context to the calling CPU thread
  6163. *
  6164. * Binds the specified CUDA context to the calling CPU thread.
  6165. * If \p ctx is NULL then the CUDA context previously bound to the
  6166. * calling CPU thread is unbound and ::CUDA_SUCCESS is returned.
  6167. *
  6168. * If there exists a CUDA context stack on the calling CPU thread, this
  6169. * will replace the top of that stack with \p ctx.
  6170. * If \p ctx is NULL then this will be equivalent to popping the top
  6171. * of the calling CPU thread's CUDA context stack (or a no-op if the
  6172. * calling CPU thread's CUDA context stack is empty).
  6173. *
  6174. * \param ctx - Context to bind to the calling CPU thread
  6175. *
  6176. * \return
  6177. * ::CUDA_SUCCESS,
  6178. * ::CUDA_ERROR_DEINITIALIZED,
  6179. * ::CUDA_ERROR_NOT_INITIALIZED,
  6180. * ::CUDA_ERROR_INVALID_CONTEXT
  6181. * \notefnerr
  6182. *
  6183. * \sa
  6184. * ::cuCtxGetCurrent,
  6185. * ::cuCtxCreate,
  6186. * ::cuCtxDestroy,
  6187. * ::cudaSetDevice
  6188. */
  6189. CUresult CUDAAPI cuCtxSetCurrent(CUcontext ctx);
  6190. /**
  6191. * \brief Returns the CUDA context bound to the calling CPU thread.
  6192. *
  6193. * Returns in \p *pctx the CUDA context bound to the calling CPU thread.
  6194. * If no context is bound to the calling CPU thread then \p *pctx is
  6195. * set to NULL and ::CUDA_SUCCESS is returned.
  6196. *
  6197. * \param pctx - Returned context handle
  6198. *
  6199. * \return
  6200. * ::CUDA_SUCCESS,
  6201. * ::CUDA_ERROR_DEINITIALIZED,
  6202. * ::CUDA_ERROR_NOT_INITIALIZED,
  6203. * \notefnerr
  6204. *
  6205. * \sa
  6206. * ::cuCtxSetCurrent,
  6207. * ::cuCtxCreate,
  6208. * ::cuCtxDestroy,
  6209. * ::cudaGetDevice
  6210. */
  6211. CUresult CUDAAPI cuCtxGetCurrent(CUcontext *pctx);
  6212. /**
  6213. * \brief Returns the device handle for the current context
  6214. *
  6215. * Returns in \p *device the handle of the current context's device.
  6216. *
  6217. * \param device - Returned device handle for the current context
  6218. *
  6219. * \return
  6220. * ::CUDA_SUCCESS,
  6221. * ::CUDA_ERROR_DEINITIALIZED,
  6222. * ::CUDA_ERROR_NOT_INITIALIZED,
  6223. * ::CUDA_ERROR_INVALID_CONTEXT,
  6224. * ::CUDA_ERROR_INVALID_VALUE,
  6225. * \notefnerr
  6226. *
  6227. * \sa ::cuCtxCreate,
  6228. * ::cuCtxDestroy,
  6229. * ::cuCtxGetApiVersion,
  6230. * ::cuCtxGetCacheConfig,
  6231. * ::cuCtxGetFlags,
  6232. * ::cuCtxGetLimit,
  6233. * ::cuCtxPopCurrent,
  6234. * ::cuCtxPushCurrent,
  6235. * ::cuCtxSetCacheConfig,
  6236. * ::cuCtxSetLimit,
  6237. * ::cuCtxSynchronize,
  6238. * ::cudaGetDevice
  6239. */
  6240. CUresult CUDAAPI cuCtxGetDevice(CUdevice *device);
  6241. /**
  6242. * \brief Returns the flags for the current context
  6243. *
  6244. * Returns in \p *flags the flags of the current context. See ::cuCtxCreate
  6245. * for flag values.
  6246. *
  6247. * \param flags - Pointer to store flags of current context
  6248. *
  6249. * \return
  6250. * ::CUDA_SUCCESS,
  6251. * ::CUDA_ERROR_DEINITIALIZED,
  6252. * ::CUDA_ERROR_NOT_INITIALIZED,
  6253. * ::CUDA_ERROR_INVALID_CONTEXT,
  6254. * ::CUDA_ERROR_INVALID_VALUE,
  6255. * \notefnerr
  6256. *
  6257. * \sa ::cuCtxCreate,
  6258. * ::cuCtxGetApiVersion,
  6259. * ::cuCtxGetCacheConfig,
  6260. * ::cuCtxGetCurrent,
  6261. * ::cuCtxGetDevice,
  6262. * ::cuCtxGetLimit,
  6263. * ::cuCtxGetSharedMemConfig,
  6264. * ::cuCtxGetStreamPriorityRange,
  6265. * ::cuCtxSetFlags,
  6266. * ::cudaGetDeviceFlags
  6267. */
  6268. CUresult CUDAAPI cuCtxGetFlags(unsigned int *flags);
  6269. /**
  6270. * \brief Sets the flags for the current context
  6271. *
  6272. * Sets the flags for the current context overwriting previously set ones. See
  6273. * ::cuDevicePrimaryCtxSetFlags for flag values.
  6274. *
  6275. * \param flags - Flags to set on the current context
  6276. *
  6277. * \return
  6278. * ::CUDA_SUCCESS,
  6279. * ::CUDA_ERROR_DEINITIALIZED,
  6280. * ::CUDA_ERROR_NOT_INITIALIZED,
  6281. * ::CUDA_ERROR_INVALID_CONTEXT,
  6282. * ::CUDA_ERROR_INVALID_VALUE,
  6283. * \notefnerr
  6284. *
  6285. * \sa ::cuCtxCreate,
  6286. * ::cuCtxGetApiVersion,
  6287. * ::cuCtxGetCacheConfig,
  6288. * ::cuCtxGetCurrent,
  6289. * ::cuCtxGetDevice,
  6290. * ::cuCtxGetLimit,
  6291. * ::cuCtxGetSharedMemConfig,
  6292. * ::cuCtxGetStreamPriorityRange,
  6293. * ::cuCtxGetFlags,
  6294. * ::cudaGetDeviceFlags,
  6295. * ::cuDevicePrimaryCtxSetFlags,
  6296. */
  6297. CUresult CUDAAPI cuCtxSetFlags(unsigned int flags);
  6298. /**
  6299. * \brief Returns the unique Id associated with the context supplied
  6300. *
  6301. * Returns in \p ctxId the unique Id which is associated with a given context.
  6302. * The Id is unique for the life of the program for this instance of CUDA.
  6303. * If context is supplied as NULL and there is one current, the Id of the
  6304. * current context is returned.
  6305. *
  6306. * \param ctx - Context for which to obtain the Id
  6307. * \param ctxId - Pointer to store the Id of the context
  6308. *
  6309. * \return
  6310. * ::CUDA_SUCCESS,
  6311. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED,
  6312. * ::CUDA_ERROR_DEINITIALIZED,
  6313. * ::CUDA_ERROR_NOT_INITIALIZED,
  6314. * ::CUDA_ERROR_INVALID_CONTEXT,
  6315. * ::CUDA_ERROR_INVALID_VALUE
  6316. * \notefnerr
  6317. *
  6318. * \sa ::cuCtxCreate,
  6319. * ::cuCtxDestroy,
  6320. * ::cuCtxGetApiVersion,
  6321. * ::cuCtxGetCacheConfig,
  6322. * ::cuCtxGetDevice,
  6323. * ::cuCtxGetFlags,
  6324. * ::cuCtxGetLimit,
  6325. * ::cuCtxPushCurrent
  6326. */
  6327. CUresult CUDAAPI cuCtxGetId(CUcontext ctx, unsigned long long *ctxId);
  6328. /**
  6329. * \brief Block for the current context's tasks to complete
  6330. *
  6331. * Blocks until the current context has completed all preceding requested tasks.
  6332. * If the current context is the primary context, green contexts that have been
  6333. * created will also be synchronized.
  6334. * ::cuCtxSynchronize() returns an error if one of the preceding tasks failed.
  6335. * If the context was created with the ::CU_CTX_SCHED_BLOCKING_SYNC flag, the
  6336. * CPU thread will block until the GPU context has finished its work.
  6337. *
  6338. * \return
  6339. * ::CUDA_SUCCESS,
  6340. * ::CUDA_ERROR_DEINITIALIZED,
  6341. * ::CUDA_ERROR_NOT_INITIALIZED,
  6342. * ::CUDA_ERROR_INVALID_CONTEXT
  6343. * \notefnerr
  6344. *
  6345. * \sa ::cuCtxCreate,
  6346. * ::cuCtxDestroy,
  6347. * ::cuCtxGetApiVersion,
  6348. * ::cuCtxGetCacheConfig,
  6349. * ::cuCtxGetDevice,
  6350. * ::cuCtxGetFlags,
  6351. * ::cuCtxGetLimit,
  6352. * ::cuCtxPopCurrent,
  6353. * ::cuCtxPushCurrent,
  6354. * ::cuCtxSetCacheConfig,
  6355. * ::cuCtxSetLimit,
  6356. * ::cudaDeviceSynchronize
  6357. */
  6358. CUresult CUDAAPI cuCtxSynchronize(void);
  6359. /**
  6360. * \brief Set resource limits
  6361. *
  6362. * Setting \p limit to \p value is a request by the application to update
  6363. * the current limit maintained by the context. The driver is free to
  6364. * modify the requested value to meet h/w requirements (this could be
  6365. * clamping to minimum or maximum values, rounding up to nearest element
  6366. * size, etc). The application can use ::cuCtxGetLimit() to find out exactly
  6367. * what the limit has been set to.
  6368. *
  6369. * Setting each ::CUlimit has its own specific restrictions, so each is
  6370. * discussed here.
  6371. *
  6372. * - ::CU_LIMIT_STACK_SIZE controls the stack size in bytes of each GPU thread.
  6373. * The driver automatically increases the per-thread stack size
  6374. * for each kernel launch as needed. This size isn't reset back to the
  6375. * original value after each launch. Setting this value will take effect
  6376. * immediately, and if necessary, the device will block until all preceding
  6377. * requested tasks are complete.
  6378. *
  6379. * - ::CU_LIMIT_PRINTF_FIFO_SIZE controls the size in bytes of the FIFO used
  6380. * by the ::printf() device system call. Setting ::CU_LIMIT_PRINTF_FIFO_SIZE
  6381. * must be performed before launching any kernel that uses the ::printf()
  6382. * device system call, otherwise ::CUDA_ERROR_INVALID_VALUE will be returned.
  6383. *
  6384. * - ::CU_LIMIT_MALLOC_HEAP_SIZE controls the size in bytes of the heap used
  6385. * by the ::malloc() and ::free() device system calls. Setting
  6386. * ::CU_LIMIT_MALLOC_HEAP_SIZE must be performed before launching any kernel
  6387. * that uses the ::malloc() or ::free() device system calls, otherwise
  6388. * ::CUDA_ERROR_INVALID_VALUE will be returned.
  6389. *
  6390. * - ::CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH controls the maximum nesting depth of
  6391. * a grid at which a thread can safely call ::cudaDeviceSynchronize(). Setting
  6392. * this limit must be performed before any launch of a kernel that uses the
  6393. * device runtime and calls ::cudaDeviceSynchronize() above the default sync
  6394. * depth, two levels of grids. Calls to ::cudaDeviceSynchronize() will fail
  6395. * with error code ::cudaErrorSyncDepthExceeded if the limitation is
  6396. * violated. This limit can be set smaller than the default or up the maximum
  6397. * launch depth of 24. When setting this limit, keep in mind that additional
  6398. * levels of sync depth require the driver to reserve large amounts of device
  6399. * memory which can no longer be used for user allocations. If these
  6400. * reservations of device memory fail, ::cuCtxSetLimit() will return
  6401. * ::CUDA_ERROR_OUT_OF_MEMORY, and the limit can be reset to a lower value.
  6402. * This limit is only applicable to devices of compute capability < 9.0.
  6403. * Attempting to set this limit on devices of other compute capability
  6404. * versions will result in the error ::CUDA_ERROR_UNSUPPORTED_LIMIT being
  6405. * returned.
  6406. *
  6407. * - ::CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT controls the maximum number of
  6408. * outstanding device runtime launches that can be made from the current
  6409. * context. A grid is outstanding from the point of launch up until the grid
  6410. * is known to have been completed. Device runtime launches which violate
  6411. * this limitation fail and return ::cudaErrorLaunchPendingCountExceeded when
  6412. * ::cudaGetLastError() is called after launch. If more pending launches than
  6413. * the default (2048 launches) are needed for a module using the device
  6414. * runtime, this limit can be increased. Keep in mind that being able to
  6415. * sustain additional pending launches will require the driver to reserve
  6416. * larger amounts of device memory upfront which can no longer be used for
  6417. * allocations. If these reservations fail, ::cuCtxSetLimit() will return
  6418. * ::CUDA_ERROR_OUT_OF_MEMORY, and the limit can be reset to a lower value.
  6419. * This limit is only applicable to devices of compute capability 3.5 and
  6420. * higher. Attempting to set this limit on devices of compute capability less
  6421. * than 3.5 will result in the error ::CUDA_ERROR_UNSUPPORTED_LIMIT being
  6422. * returned.
  6423. *
  6424. * - ::CU_LIMIT_MAX_L2_FETCH_GRANULARITY controls the L2 cache fetch granularity.
  6425. * Values can range from 0B to 128B. This is purely a performance hint and
  6426. * it can be ignored or clamped depending on the platform.
  6427. *
  6428. * - ::CU_LIMIT_PERSISTING_L2_CACHE_SIZE controls size in bytes available for
  6429. * persisting L2 cache. This is purely a performance hint and it can be
  6430. * ignored or clamped depending on the platform.
  6431. *
  6432. * \param limit - Limit to set
  6433. * \param value - Size of limit
  6434. *
  6435. * \return
  6436. * ::CUDA_SUCCESS,
  6437. * ::CUDA_ERROR_INVALID_VALUE,
  6438. * ::CUDA_ERROR_UNSUPPORTED_LIMIT,
  6439. * ::CUDA_ERROR_OUT_OF_MEMORY,
  6440. * ::CUDA_ERROR_INVALID_CONTEXT
  6441. * \notefnerr
  6442. *
  6443. * \sa ::cuCtxCreate,
  6444. * ::cuCtxDestroy,
  6445. * ::cuCtxGetApiVersion,
  6446. * ::cuCtxGetCacheConfig,
  6447. * ::cuCtxGetDevice,
  6448. * ::cuCtxGetFlags,
  6449. * ::cuCtxGetLimit,
  6450. * ::cuCtxPopCurrent,
  6451. * ::cuCtxPushCurrent,
  6452. * ::cuCtxSetCacheConfig,
  6453. * ::cuCtxSynchronize,
  6454. * ::cudaDeviceSetLimit
  6455. */
  6456. CUresult CUDAAPI cuCtxSetLimit(CUlimit limit, size_t value);
  6457. /**
  6458. * \brief Returns resource limits
  6459. *
  6460. * Returns in \p *pvalue the current size of \p limit. The supported
  6461. * ::CUlimit values are:
  6462. * - ::CU_LIMIT_STACK_SIZE: stack size in bytes of each GPU thread.
  6463. * - ::CU_LIMIT_PRINTF_FIFO_SIZE: size in bytes of the FIFO used by the
  6464. * ::printf() device system call.
  6465. * - ::CU_LIMIT_MALLOC_HEAP_SIZE: size in bytes of the heap used by the
  6466. * ::malloc() and ::free() device system calls.
  6467. * - ::CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH: maximum grid depth at which a thread
  6468. * can issue the device runtime call ::cudaDeviceSynchronize() to wait on
  6469. * child grid launches to complete.
  6470. * - ::CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT: maximum number of outstanding
  6471. * device runtime launches that can be made from this context.
  6472. * - ::CU_LIMIT_MAX_L2_FETCH_GRANULARITY: L2 cache fetch granularity.
  6473. * - ::CU_LIMIT_PERSISTING_L2_CACHE_SIZE: Persisting L2 cache size in bytes
  6474. *
  6475. * \param limit - Limit to query
  6476. * \param pvalue - Returned size of limit
  6477. *
  6478. * \return
  6479. * ::CUDA_SUCCESS,
  6480. * ::CUDA_ERROR_INVALID_VALUE,
  6481. * ::CUDA_ERROR_UNSUPPORTED_LIMIT
  6482. * \notefnerr
  6483. *
  6484. * \sa ::cuCtxCreate,
  6485. * ::cuCtxDestroy,
  6486. * ::cuCtxGetApiVersion,
  6487. * ::cuCtxGetCacheConfig,
  6488. * ::cuCtxGetDevice,
  6489. * ::cuCtxGetFlags,
  6490. * ::cuCtxPopCurrent,
  6491. * ::cuCtxPushCurrent,
  6492. * ::cuCtxSetCacheConfig,
  6493. * ::cuCtxSetLimit,
  6494. * ::cuCtxSynchronize,
  6495. * ::cudaDeviceGetLimit
  6496. */
  6497. CUresult CUDAAPI cuCtxGetLimit(size_t *pvalue, CUlimit limit);
  6498. /**
  6499. * \brief Returns the preferred cache configuration for the current context.
  6500. *
  6501. * On devices where the L1 cache and shared memory use the same hardware
  6502. * resources, this function returns through \p pconfig the preferred cache configuration
  6503. * for the current context. This is only a preference. The driver will use
  6504. * the requested configuration if possible, but it is free to choose a different
  6505. * configuration if required to execute functions.
  6506. *
  6507. * This will return a \p pconfig of ::CU_FUNC_CACHE_PREFER_NONE on devices
  6508. * where the size of the L1 cache and shared memory are fixed.
  6509. *
  6510. * The supported cache configurations are:
  6511. * - ::CU_FUNC_CACHE_PREFER_NONE: no preference for shared memory or L1 (default)
  6512. * - ::CU_FUNC_CACHE_PREFER_SHARED: prefer larger shared memory and smaller L1 cache
  6513. * - ::CU_FUNC_CACHE_PREFER_L1: prefer larger L1 cache and smaller shared memory
  6514. * - ::CU_FUNC_CACHE_PREFER_EQUAL: prefer equal sized L1 cache and shared memory
  6515. *
  6516. * \param pconfig - Returned cache configuration
  6517. *
  6518. * \return
  6519. * ::CUDA_SUCCESS,
  6520. * ::CUDA_ERROR_DEINITIALIZED,
  6521. * ::CUDA_ERROR_NOT_INITIALIZED,
  6522. * ::CUDA_ERROR_INVALID_CONTEXT,
  6523. * ::CUDA_ERROR_INVALID_VALUE
  6524. * \notefnerr
  6525. *
  6526. * \sa ::cuCtxCreate,
  6527. * ::cuCtxDestroy,
  6528. * ::cuCtxGetApiVersion,
  6529. * ::cuCtxGetDevice,
  6530. * ::cuCtxGetFlags,
  6531. * ::cuCtxGetLimit,
  6532. * ::cuCtxPopCurrent,
  6533. * ::cuCtxPushCurrent,
  6534. * ::cuCtxSetCacheConfig,
  6535. * ::cuCtxSetLimit,
  6536. * ::cuCtxSynchronize,
  6537. * ::cuFuncSetCacheConfig,
  6538. * ::cudaDeviceGetCacheConfig
  6539. */
  6540. CUresult CUDAAPI cuCtxGetCacheConfig(CUfunc_cache *pconfig);
  6541. /**
  6542. * \brief Sets the preferred cache configuration for the current context.
  6543. *
  6544. * On devices where the L1 cache and shared memory use the same hardware
  6545. * resources, this sets through \p config the preferred cache configuration for
  6546. * the current context. This is only a preference. The driver will use
  6547. * the requested configuration if possible, but it is free to choose a different
  6548. * configuration if required to execute the function. Any function preference
  6549. * set via ::cuFuncSetCacheConfig() or ::cuKernelSetCacheConfig() will be preferred over this context-wide
  6550. * setting. Setting the context-wide cache configuration to
  6551. * ::CU_FUNC_CACHE_PREFER_NONE will cause subsequent kernel launches to prefer
  6552. * to not change the cache configuration unless required to launch the kernel.
  6553. *
  6554. * This setting does nothing on devices where the size of the L1 cache and
  6555. * shared memory are fixed.
  6556. *
  6557. * Launching a kernel with a different preference than the most recent
  6558. * preference setting may insert a device-side synchronization point.
  6559. *
  6560. * The supported cache configurations are:
  6561. * - ::CU_FUNC_CACHE_PREFER_NONE: no preference for shared memory or L1 (default)
  6562. * - ::CU_FUNC_CACHE_PREFER_SHARED: prefer larger shared memory and smaller L1 cache
  6563. * - ::CU_FUNC_CACHE_PREFER_L1: prefer larger L1 cache and smaller shared memory
  6564. * - ::CU_FUNC_CACHE_PREFER_EQUAL: prefer equal sized L1 cache and shared memory
  6565. *
  6566. * \param config - Requested cache configuration
  6567. *
  6568. * \return
  6569. * ::CUDA_SUCCESS,
  6570. * ::CUDA_ERROR_DEINITIALIZED,
  6571. * ::CUDA_ERROR_NOT_INITIALIZED,
  6572. * ::CUDA_ERROR_INVALID_CONTEXT,
  6573. * ::CUDA_ERROR_INVALID_VALUE
  6574. * \notefnerr
  6575. *
  6576. * \sa ::cuCtxCreate,
  6577. * ::cuCtxDestroy,
  6578. * ::cuCtxGetApiVersion,
  6579. * ::cuCtxGetCacheConfig,
  6580. * ::cuCtxGetDevice,
  6581. * ::cuCtxGetFlags,
  6582. * ::cuCtxGetLimit,
  6583. * ::cuCtxPopCurrent,
  6584. * ::cuCtxPushCurrent,
  6585. * ::cuCtxSetLimit,
  6586. * ::cuCtxSynchronize,
  6587. * ::cuFuncSetCacheConfig,
  6588. * ::cudaDeviceSetCacheConfig,
  6589. * ::cuKernelSetCacheConfig
  6590. */
  6591. CUresult CUDAAPI cuCtxSetCacheConfig(CUfunc_cache config);
  6592. /**
  6593. * \brief Gets the context's API version.
  6594. *
  6595. * Returns a version number in \p version corresponding to the capabilities of
  6596. * the context (e.g. 3010 or 3020), which library developers can use to direct
  6597. * callers to a specific API version. If \p ctx is NULL, returns the API version
  6598. * used to create the currently bound context.
  6599. *
  6600. * Note that new API versions are only introduced when context capabilities are
  6601. * changed that break binary compatibility, so the API version and driver version
  6602. * may be different. For example, it is valid for the API version to be 3020 while
  6603. * the driver version is 4020.
  6604. *
  6605. * \param ctx - Context to check
  6606. * \param version - Pointer to version
  6607. *
  6608. * \return
  6609. * ::CUDA_SUCCESS,
  6610. * ::CUDA_ERROR_DEINITIALIZED,
  6611. * ::CUDA_ERROR_NOT_INITIALIZED,
  6612. * ::CUDA_ERROR_INVALID_CONTEXT,
  6613. * ::CUDA_ERROR_INVALID_VALUE,
  6614. * ::CUDA_ERROR_UNKNOWN
  6615. * \notefnerr
  6616. *
  6617. * \sa ::cuCtxCreate,
  6618. * ::cuCtxDestroy,
  6619. * ::cuCtxGetDevice,
  6620. * ::cuCtxGetFlags,
  6621. * ::cuCtxGetLimit,
  6622. * ::cuCtxPopCurrent,
  6623. * ::cuCtxPushCurrent,
  6624. * ::cuCtxSetCacheConfig,
  6625. * ::cuCtxSetLimit,
  6626. * ::cuCtxSynchronize
  6627. */
  6628. CUresult CUDAAPI cuCtxGetApiVersion(CUcontext ctx, unsigned int *version);
  6629. /**
  6630. * \brief Returns numerical values that correspond to the least and
  6631. * greatest stream priorities.
  6632. *
  6633. * Returns in \p *leastPriority and \p *greatestPriority the numerical values that correspond
  6634. * to the least and greatest stream priorities respectively. Stream priorities
  6635. * follow a convention where lower numbers imply greater priorities. The range of
  6636. * meaningful stream priorities is given by [\p *greatestPriority, \p *leastPriority].
  6637. * If the user attempts to create a stream with a priority value that is
  6638. * outside the meaningful range as specified by this API, the priority is
  6639. * automatically clamped down or up to either \p *leastPriority or \p *greatestPriority
  6640. * respectively. See ::cuStreamCreateWithPriority for details on creating a
  6641. * priority stream.
  6642. * A NULL may be passed in for \p *leastPriority or \p *greatestPriority if the value
  6643. * is not desired.
  6644. *
  6645. * This function will return '0' in both \p *leastPriority and \p *greatestPriority if
  6646. * the current context's device does not support stream priorities
  6647. * (see ::cuDeviceGetAttribute).
  6648. *
  6649. * \param leastPriority - Pointer to an int in which the numerical value for least
  6650. * stream priority is returned
  6651. * \param greatestPriority - Pointer to an int in which the numerical value for greatest
  6652. * stream priority is returned
  6653. *
  6654. * \return
  6655. * ::CUDA_SUCCESS,
  6656. * ::CUDA_ERROR_INVALID_VALUE,
  6657. * \notefnerr
  6658. *
  6659. * \sa ::cuStreamCreateWithPriority,
  6660. * ::cuStreamGetPriority,
  6661. * ::cuCtxGetDevice,
  6662. * ::cuCtxGetFlags,
  6663. * ::cuCtxSetLimit,
  6664. * ::cuCtxSynchronize,
  6665. * ::cudaDeviceGetStreamPriorityRange
  6666. */
  6667. CUresult CUDAAPI cuCtxGetStreamPriorityRange(int *leastPriority, int *greatestPriority);
  6668. /**
  6669. * \brief Resets all persisting lines in cache to normal status.
  6670. *
  6671. * ::cuCtxResetPersistingL2Cache Resets all persisting lines in cache to normal
  6672. * status. Takes effect on function return.
  6673. *
  6674. * \return
  6675. * ::CUDA_SUCCESS,
  6676. * ::CUDA_ERROR_NOT_SUPPORTED
  6677. * \notefnerr
  6678. *
  6679. * \sa
  6680. * ::CUaccessPolicyWindow
  6681. */
  6682. CUresult CUDAAPI cuCtxResetPersistingL2Cache(void);
  6683. /**
  6684. * \brief Returns the execution affinity setting for the current context.
  6685. *
  6686. * Returns in \p *pExecAffinity the current value of \p type. The supported
  6687. * ::CUexecAffinityType values are:
  6688. * - ::CU_EXEC_AFFINITY_TYPE_SM_COUNT: number of SMs the context is limited to use.
  6689. *
  6690. * \param type - Execution affinity type to query
  6691. * \param pExecAffinity - Returned execution affinity
  6692. *
  6693. * \return
  6694. * ::CUDA_SUCCESS,
  6695. * ::CUDA_ERROR_DEINITIALIZED,
  6696. * ::CUDA_ERROR_NOT_INITIALIZED,
  6697. * ::CUDA_ERROR_INVALID_CONTEXT,
  6698. * ::CUDA_ERROR_INVALID_VALUE,
  6699. * ::CUDA_ERROR_UNSUPPORTED_EXEC_AFFINITY
  6700. * \notefnerr
  6701. *
  6702. * \sa
  6703. * ::CUexecAffinityParam
  6704. */
  6705. CUresult CUDAAPI cuCtxGetExecAffinity(CUexecAffinityParam *pExecAffinity, CUexecAffinityType type);
  6706. /**
  6707. * \brief Records an event.
  6708. *
  6709. * Captures in \p hEvent all the activities of the context \p hCtx
  6710. * at the time of this call. \p hEvent and \p hCtx must be from the same
  6711. * CUDA context, otherwise ::CUDA_ERROR_INVALID_HANDLE will be returned.
  6712. * Calls such as ::cuEventQuery() or ::cuCtxWaitEvent() will then examine
  6713. * or wait for completion of the work that was captured.
  6714. * Uses of \p hCtx after this call do not modify \p hEvent.
  6715. * If the context passed to \p hCtx is the primary context, \p hEvent will
  6716. * capture all the activities of the primary context and its green contexts.
  6717. * If the context passed to \p hCtx is a context converted from green context
  6718. * via ::cuCtxFromGreenCtx(), \p hEvent will capture only the activities of the green context.
  6719. *
  6720. * \note The API will return ::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED if the
  6721. * specified context \p hCtx has a stream in the capture mode. In such a case,
  6722. * the call will invalidate all the conflicting captures.
  6723. *
  6724. * \param hCtx - Context to record event for
  6725. * \param hEvent - Event to record
  6726. *
  6727. * \return
  6728. * ::CUDA_SUCCESS
  6729. * ::CUDA_ERROR_DEINITIALIZED,
  6730. * ::CUDA_ERROR_NOT_INITIALIZED,
  6731. * ::CUDA_ERROR_INVALID_CONTEXT,
  6732. * ::CUDA_ERROR_INVALID_HANDLE,
  6733. * ::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED
  6734. *
  6735. * \sa
  6736. * ::cuCtxWaitEvent,
  6737. * ::cuGreenCtxRecordEvent,
  6738. * ::cuGreenCtxWaitEvent,
  6739. * ::cuEventRecord
  6740. */
  6741. CUresult CUDAAPI cuCtxRecordEvent(CUcontext hCtx, CUevent hEvent);
  6742. /**
  6743. * \brief Make a context wait on an event
  6744. *
  6745. * Makes all future work submitted to context \p hCtx wait for all work
  6746. * captured in \p hEvent. The synchronization will be performed on the device
  6747. * and will not block the calling CPU thread. See ::cuCtxRecordEvent()
  6748. * for details on what is captured by an event.
  6749. * If the context passed to \p hCtx is the primary context, the primary context
  6750. * and its green contexts will wait for \p hEvent.
  6751. * If the context passed to \p hCtx is a context converted from green context
  6752. * via ::cuCtxFromGreenCtx(), the green context will wait for \p hEvent.
  6753. *
  6754. * \note \p hEvent may be from a different context or device than \p hCtx.
  6755. *
  6756. * \note The API will return ::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED and
  6757. * invalidate the capture if the specified event \p hEvent is part of an ongoing
  6758. * capture sequence or if the specified context \p hCtx has a stream in the capture mode.
  6759. *
  6760. * \param hCtx - Context to wait
  6761. * \param hEvent - Event to wait on
  6762. *
  6763. * \return
  6764. * ::CUDA_SUCCESS,
  6765. * ::CUDA_ERROR_DEINITIALIZED,
  6766. * ::CUDA_ERROR_NOT_INITIALIZED,
  6767. * ::CUDA_ERROR_INVALID_CONTEXT,
  6768. * ::CUDA_ERROR_INVALID_HANDLE,
  6769. * ::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED
  6770. *
  6771. * \sa
  6772. * ::cuCtxRecordEvent,
  6773. * ::cuGreenCtxRecordEvent,
  6774. * ::cuGreenCtxWaitEvent,
  6775. * ::cuStreamWaitEvent
  6776. */
  6777. CUresult CUDAAPI cuCtxWaitEvent(CUcontext hCtx, CUevent hEvent);
  6778. /** @} */ /* END CUDA_CTX */
  6779. /**
  6780. * \defgroup CUDA_CTX_DEPRECATED Context Management [DEPRECATED]
  6781. *
  6782. * ___MANBRIEF___ deprecated context management functions of the low-level CUDA
  6783. * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  6784. *
  6785. * This section describes the deprecated context management functions of the low-level
  6786. * CUDA driver application programming interface.
  6787. *
  6788. * @{
  6789. */
  6790. /**
  6791. * \brief Increment a context's usage-count
  6792. *
  6793. * \deprecated
  6794. *
  6795. * Note that this function is deprecated and should not be used.
  6796. *
  6797. * Increments the usage count of the context and passes back a context handle
  6798. * in \p *pctx that must be passed to ::cuCtxDetach() when the application is
  6799. * done with the context. ::cuCtxAttach() fails if there is no context current
  6800. * to the thread.
  6801. *
  6802. * Currently, the \p flags parameter must be 0.
  6803. *
  6804. * \param pctx - Returned context handle of the current context
  6805. * \param flags - Context attach flags (must be 0)
  6806. *
  6807. * \return
  6808. * ::CUDA_SUCCESS,
  6809. * ::CUDA_ERROR_DEINITIALIZED,
  6810. * ::CUDA_ERROR_NOT_INITIALIZED,
  6811. * ::CUDA_ERROR_INVALID_CONTEXT,
  6812. * ::CUDA_ERROR_INVALID_VALUE
  6813. * \notefnerr
  6814. *
  6815. * \sa ::cuCtxCreate,
  6816. * ::cuCtxDestroy,
  6817. * ::cuCtxDetach,
  6818. * ::cuCtxGetApiVersion,
  6819. * ::cuCtxGetCacheConfig,
  6820. * ::cuCtxGetDevice,
  6821. * ::cuCtxGetFlags,
  6822. * ::cuCtxGetLimit,
  6823. * ::cuCtxPopCurrent,
  6824. * ::cuCtxPushCurrent,
  6825. * ::cuCtxSetCacheConfig,
  6826. * ::cuCtxSetLimit,
  6827. * ::cuCtxSynchronize
  6828. */
  6829. __CUDA_DEPRECATED CUresult CUDAAPI cuCtxAttach(CUcontext *pctx, unsigned int flags);
  6830. /**
  6831. * \brief Decrement a context's usage-count
  6832. *
  6833. * \deprecated
  6834. *
  6835. * Note that this function is deprecated and should not be used.
  6836. *
  6837. * Decrements the usage count of the context \p ctx, and destroys the context
  6838. * if the usage count goes to 0. The context must be a handle that was passed
  6839. * back by ::cuCtxCreate() or ::cuCtxAttach(), and must be current to the
  6840. * calling thread.
  6841. *
  6842. * \param ctx - Context to destroy
  6843. *
  6844. * \return
  6845. * ::CUDA_SUCCESS,
  6846. * ::CUDA_ERROR_DEINITIALIZED,
  6847. * ::CUDA_ERROR_NOT_INITIALIZED,
  6848. * ::CUDA_ERROR_INVALID_CONTEXT
  6849. * \notefnerr
  6850. *
  6851. * \sa ::cuCtxCreate,
  6852. * ::cuCtxDestroy,
  6853. * ::cuCtxGetApiVersion,
  6854. * ::cuCtxGetCacheConfig,
  6855. * ::cuCtxGetDevice,
  6856. * ::cuCtxGetFlags,
  6857. * ::cuCtxGetLimit,
  6858. * ::cuCtxPopCurrent,
  6859. * ::cuCtxPushCurrent,
  6860. * ::cuCtxSetCacheConfig,
  6861. * ::cuCtxSetLimit,
  6862. * ::cuCtxSynchronize
  6863. */
  6864. __CUDA_DEPRECATED CUresult CUDAAPI cuCtxDetach(CUcontext ctx);
  6865. /**
  6866. * \brief Returns the current shared memory configuration for the current context.
  6867. *
  6868. * \deprecated
  6869. *
  6870. * This function will return in \p pConfig the current size of shared memory banks
  6871. * in the current context. On devices with configurable shared memory banks,
  6872. * ::cuCtxSetSharedMemConfig can be used to change this setting, so that all
  6873. * subsequent kernel launches will by default use the new bank size. When
  6874. * ::cuCtxGetSharedMemConfig is called on devices without configurable shared
  6875. * memory, it will return the fixed bank size of the hardware.
  6876. *
  6877. * The returned bank configurations can be either:
  6878. * - ::CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE: shared memory bank width is
  6879. * four bytes.
  6880. * - ::CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE: shared memory bank width will
  6881. * eight bytes.
  6882. *
  6883. * \param pConfig - returned shared memory configuration
  6884. * \return
  6885. * ::CUDA_SUCCESS,
  6886. * ::CUDA_ERROR_DEINITIALIZED,
  6887. * ::CUDA_ERROR_NOT_INITIALIZED,
  6888. * ::CUDA_ERROR_INVALID_CONTEXT,
  6889. * ::CUDA_ERROR_INVALID_VALUE
  6890. * \notefnerr
  6891. *
  6892. * \sa ::cuCtxCreate,
  6893. * ::cuCtxDestroy,
  6894. * ::cuCtxGetApiVersion,
  6895. * ::cuCtxGetCacheConfig,
  6896. * ::cuCtxGetDevice,
  6897. * ::cuCtxGetFlags,
  6898. * ::cuCtxGetLimit,
  6899. * ::cuCtxPopCurrent,
  6900. * ::cuCtxPushCurrent,
  6901. * ::cuCtxSetLimit,
  6902. * ::cuCtxSynchronize,
  6903. * ::cuCtxGetSharedMemConfig,
  6904. * ::cuFuncSetCacheConfig,
  6905. * ::cudaDeviceGetSharedMemConfig
  6906. */
  6907. __CUDA_DEPRECATED CUresult CUDAAPI cuCtxGetSharedMemConfig(CUsharedconfig *pConfig);
  6908. /**
  6909. * \brief Sets the shared memory configuration for the current context.
  6910. *
  6911. * \deprecated
  6912. *
  6913. * On devices with configurable shared memory banks, this function will set
  6914. * the context's shared memory bank size which is used for subsequent kernel
  6915. * launches.
  6916. *
  6917. * Changed the shared memory configuration between launches may insert a device
  6918. * side synchronization point between those launches.
  6919. *
  6920. * Changing the shared memory bank size will not increase shared memory usage
  6921. * or affect occupancy of kernels, but may have major effects on performance.
  6922. * Larger bank sizes will allow for greater potential bandwidth to shared memory,
  6923. * but will change what kinds of accesses to shared memory will result in bank
  6924. * conflicts.
  6925. *
  6926. * This function will do nothing on devices with fixed shared memory bank size.
  6927. *
  6928. * The supported bank configurations are:
  6929. * - ::CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE: set bank width to the default initial
  6930. * setting (currently, four bytes).
  6931. * - ::CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE: set shared memory bank width to
  6932. * be natively four bytes.
  6933. * - ::CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE: set shared memory bank width to
  6934. * be natively eight bytes.
  6935. *
  6936. * \param config - requested shared memory configuration
  6937. *
  6938. * \return
  6939. * ::CUDA_SUCCESS,
  6940. * ::CUDA_ERROR_DEINITIALIZED,
  6941. * ::CUDA_ERROR_NOT_INITIALIZED,
  6942. * ::CUDA_ERROR_INVALID_CONTEXT,
  6943. * ::CUDA_ERROR_INVALID_VALUE
  6944. * \notefnerr
  6945. *
  6946. * \sa ::cuCtxCreate,
  6947. * ::cuCtxDestroy,
  6948. * ::cuCtxGetApiVersion,
  6949. * ::cuCtxGetCacheConfig,
  6950. * ::cuCtxGetDevice,
  6951. * ::cuCtxGetFlags,
  6952. * ::cuCtxGetLimit,
  6953. * ::cuCtxPopCurrent,
  6954. * ::cuCtxPushCurrent,
  6955. * ::cuCtxSetLimit,
  6956. * ::cuCtxSynchronize,
  6957. * ::cuCtxGetSharedMemConfig,
  6958. * ::cuFuncSetCacheConfig,
  6959. * ::cudaDeviceSetSharedMemConfig
  6960. */
  6961. __CUDA_DEPRECATED CUresult CUDAAPI cuCtxSetSharedMemConfig(CUsharedconfig config);
  6962. /** @} */ /* END CUDA_CTX_DEPRECATED */
  6963. /**
  6964. * \defgroup CUDA_MODULE Module Management
  6965. *
  6966. * ___MANBRIEF___ module management functions of the low-level CUDA driver API
  6967. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  6968. *
  6969. * This section describes the module management functions of the low-level CUDA
  6970. * driver application programming interface.
  6971. *
  6972. * @{
  6973. */
  6974. /**
  6975. * \brief Loads a compute module
  6976. *
  6977. * Takes a filename \p fname and loads the corresponding module \p module into
  6978. * the current context. The CUDA driver API does not attempt to lazily
  6979. * allocate the resources needed by a module; if the memory for functions and
  6980. * data (constant and global) needed by the module cannot be allocated,
  6981. * ::cuModuleLoad() fails. The file should be a \e cubin file as output by
  6982. * \b nvcc, or a \e PTX file either as output by \b nvcc or handwritten, or
  6983. * a \e fatbin file as output by \b nvcc from toolchain 4.0 or later.
  6984. *
  6985. * \param module - Returned module
  6986. * \param fname - Filename of module to load
  6987. *
  6988. * \return
  6989. * ::CUDA_SUCCESS,
  6990. * ::CUDA_ERROR_DEINITIALIZED,
  6991. * ::CUDA_ERROR_NOT_INITIALIZED,
  6992. * ::CUDA_ERROR_INVALID_CONTEXT,
  6993. * ::CUDA_ERROR_INVALID_VALUE,
  6994. * ::CUDA_ERROR_INVALID_PTX,
  6995. * ::CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
  6996. * ::CUDA_ERROR_NOT_FOUND,
  6997. * ::CUDA_ERROR_OUT_OF_MEMORY,
  6998. * ::CUDA_ERROR_FILE_NOT_FOUND,
  6999. * ::CUDA_ERROR_NO_BINARY_FOR_GPU,
  7000. * ::CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND,
  7001. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
  7002. * ::CUDA_ERROR_JIT_COMPILER_NOT_FOUND
  7003. * \notefnerr
  7004. *
  7005. * \sa ::cuModuleGetFunction,
  7006. * ::cuModuleGetGlobal,
  7007. * ::cuModuleGetTexRef,
  7008. * ::cuModuleLoadData,
  7009. * ::cuModuleLoadDataEx,
  7010. * ::cuModuleLoadFatBinary,
  7011. * ::cuModuleUnload
  7012. */
  7013. CUresult CUDAAPI cuModuleLoad(CUmodule *module, const char *fname);
  7014. /**
  7015. * \brief Load a module's data
  7016. *
  7017. * Takes a pointer \p image and loads the corresponding module \p module into
  7018. * the current context. The \p image may be a \e cubin or \e fatbin
  7019. * as output by \b nvcc, or a NULL-terminated \e PTX, either as output by \b nvcc
  7020. * or hand-written.
  7021. *
  7022. * \param module - Returned module
  7023. * \param image - Module data to load
  7024. *
  7025. * \return
  7026. * ::CUDA_SUCCESS,
  7027. * ::CUDA_ERROR_DEINITIALIZED,
  7028. * ::CUDA_ERROR_NOT_INITIALIZED,
  7029. * ::CUDA_ERROR_INVALID_CONTEXT,
  7030. * ::CUDA_ERROR_INVALID_VALUE,
  7031. * ::CUDA_ERROR_INVALID_PTX,
  7032. * ::CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
  7033. * ::CUDA_ERROR_OUT_OF_MEMORY,
  7034. * ::CUDA_ERROR_NO_BINARY_FOR_GPU,
  7035. * ::CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND,
  7036. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
  7037. * ::CUDA_ERROR_JIT_COMPILER_NOT_FOUND
  7038. * \notefnerr
  7039. *
  7040. * \sa ::cuModuleGetFunction,
  7041. * ::cuModuleGetGlobal,
  7042. * ::cuModuleGetTexRef,
  7043. * ::cuModuleLoad,
  7044. * ::cuModuleLoadDataEx,
  7045. * ::cuModuleLoadFatBinary,
  7046. * ::cuModuleUnload
  7047. */
  7048. CUresult CUDAAPI cuModuleLoadData(CUmodule *module, const void *image);
  7049. /**
  7050. * \brief Load a module's data with options
  7051. *
  7052. * Takes a pointer \p image and loads the corresponding module \p module into
  7053. * the current context. The \p image may be a \e cubin or \e fatbin
  7054. * as output by \b nvcc, or a NULL-terminated \e PTX, either as output by \b nvcc
  7055. * or hand-written.
  7056. *
  7057. * \param module - Returned module
  7058. * \param image - Module data to load
  7059. * \param numOptions - Number of options
  7060. * \param options - Options for JIT
  7061. * \param optionValues - Option values for JIT
  7062. *
  7063. * \return
  7064. * ::CUDA_SUCCESS,
  7065. * ::CUDA_ERROR_DEINITIALIZED,
  7066. * ::CUDA_ERROR_NOT_INITIALIZED,
  7067. * ::CUDA_ERROR_INVALID_CONTEXT,
  7068. * ::CUDA_ERROR_INVALID_VALUE,
  7069. * ::CUDA_ERROR_INVALID_PTX,
  7070. * ::CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
  7071. * ::CUDA_ERROR_OUT_OF_MEMORY,
  7072. * ::CUDA_ERROR_NO_BINARY_FOR_GPU,
  7073. * ::CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND,
  7074. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
  7075. * ::CUDA_ERROR_JIT_COMPILER_NOT_FOUND
  7076. * \notefnerr
  7077. *
  7078. * \sa ::cuModuleGetFunction,
  7079. * ::cuModuleGetGlobal,
  7080. * ::cuModuleGetTexRef,
  7081. * ::cuModuleLoad,
  7082. * ::cuModuleLoadData,
  7083. * ::cuModuleLoadFatBinary,
  7084. * ::cuModuleUnload
  7085. */
  7086. CUresult CUDAAPI cuModuleLoadDataEx(CUmodule *module, const void *image, unsigned int numOptions, CUjit_option *options, void **optionValues);
  7087. /**
  7088. * \brief Load a module's data
  7089. *
  7090. * Takes a pointer \p fatCubin and loads the corresponding module \p module
  7091. * into the current context. The pointer represents a <i>fat binary</i> object,
  7092. * which is a collection of different \e cubin and/or \e PTX files, all
  7093. * representing the same device code, but compiled and optimized for different
  7094. * architectures.
  7095. *
  7096. * Prior to CUDA 4.0, there was no documented API for constructing and using
  7097. * fat binary objects by programmers. Starting with CUDA 4.0, fat binary
  7098. * objects can be constructed by providing the <i>-fatbin option</i> to \b nvcc.
  7099. * More information can be found in the \b nvcc document.
  7100. *
  7101. * \param module - Returned module
  7102. * \param fatCubin - Fat binary to load
  7103. *
  7104. * \return
  7105. * ::CUDA_SUCCESS,
  7106. * ::CUDA_ERROR_DEINITIALIZED,
  7107. * ::CUDA_ERROR_NOT_INITIALIZED,
  7108. * ::CUDA_ERROR_INVALID_CONTEXT,
  7109. * ::CUDA_ERROR_INVALID_VALUE,
  7110. * ::CUDA_ERROR_INVALID_PTX,
  7111. * ::CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
  7112. * ::CUDA_ERROR_NOT_FOUND,
  7113. * ::CUDA_ERROR_OUT_OF_MEMORY,
  7114. * ::CUDA_ERROR_NO_BINARY_FOR_GPU,
  7115. * ::CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND,
  7116. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
  7117. * ::CUDA_ERROR_JIT_COMPILER_NOT_FOUND
  7118. * \notefnerr
  7119. *
  7120. * \sa ::cuModuleGetFunction,
  7121. * ::cuModuleGetGlobal,
  7122. * ::cuModuleGetTexRef,
  7123. * ::cuModuleLoad,
  7124. * ::cuModuleLoadData,
  7125. * ::cuModuleLoadDataEx,
  7126. * ::cuModuleUnload
  7127. */
  7128. CUresult CUDAAPI cuModuleLoadFatBinary(CUmodule *module, const void *fatCubin);
  7129. /**
  7130. * \brief Unloads a module
  7131. *
  7132. * Unloads a module \p hmod from the current context. Attempting to unload
  7133. * a module which was obtained from the Library Management API such as
  7134. * ::cuLibraryGetModule will return ::CUDA_ERROR_NOT_PERMITTED.
  7135. *
  7136. * \param hmod - Module to unload
  7137. *
  7138. * \return
  7139. * ::CUDA_SUCCESS,
  7140. * ::CUDA_ERROR_DEINITIALIZED,
  7141. * ::CUDA_ERROR_NOT_INITIALIZED,
  7142. * ::CUDA_ERROR_INVALID_CONTEXT,
  7143. * ::CUDA_ERROR_INVALID_VALUE,
  7144. * ::CUDA_ERROR_NOT_PERMITTED
  7145. * \notefnerr
  7146. * \note_destroy_ub
  7147. *
  7148. * \sa ::cuModuleGetFunction,
  7149. * ::cuModuleGetGlobal,
  7150. * ::cuModuleGetTexRef,
  7151. * ::cuModuleLoad,
  7152. * ::cuModuleLoadData,
  7153. * ::cuModuleLoadDataEx,
  7154. * ::cuModuleLoadFatBinary
  7155. */
  7156. CUresult CUDAAPI cuModuleUnload(CUmodule hmod);
  7157. /**
  7158. * CUDA Lazy Loading status
  7159. */
  7160. typedef enum CUmoduleLoadingMode_enum {
  7161. CU_MODULE_EAGER_LOADING = 0x1, /**< Lazy Kernel Loading is not enabled */
  7162. CU_MODULE_LAZY_LOADING = 0x2, /**< Lazy Kernel Loading is enabled */
  7163. } CUmoduleLoadingMode;
  7164. /**
  7165. * \brief Query lazy loading mode
  7166. *
  7167. * Returns lazy loading mode
  7168. * Module loading mode is controlled by CUDA_MODULE_LOADING env variable
  7169. *
  7170. * \param mode - Returns the lazy loading mode
  7171. *
  7172. * \return
  7173. * ::CUDA_SUCCESS,
  7174. * ::CUDA_ERROR_INVALID_VALUE,
  7175. * \notefnerr
  7176. *
  7177. * \sa
  7178. * ::cuModuleLoad,
  7179. */
  7180. CUresult CUDAAPI cuModuleGetLoadingMode(CUmoduleLoadingMode *mode);
  7181. /**
  7182. * \brief Returns a function handle
  7183. *
  7184. * Returns in \p *hfunc the handle of the function of name \p name located in
  7185. * module \p hmod. If no function of that name exists, ::cuModuleGetFunction()
  7186. * returns ::CUDA_ERROR_NOT_FOUND.
  7187. *
  7188. * \param hfunc - Returned function handle
  7189. * \param hmod - Module to retrieve function from
  7190. * \param name - Name of function to retrieve
  7191. *
  7192. * \return
  7193. * ::CUDA_SUCCESS,
  7194. * ::CUDA_ERROR_DEINITIALIZED,
  7195. * ::CUDA_ERROR_NOT_INITIALIZED,
  7196. * ::CUDA_ERROR_INVALID_CONTEXT,
  7197. * ::CUDA_ERROR_INVALID_VALUE,
  7198. * ::CUDA_ERROR_NOT_FOUND
  7199. * \notefnerr
  7200. *
  7201. * \sa ::cuModuleGetGlobal,
  7202. * ::cuModuleGetTexRef,
  7203. * ::cuModuleLoad,
  7204. * ::cuModuleLoadData,
  7205. * ::cuModuleLoadDataEx,
  7206. * ::cuModuleLoadFatBinary,
  7207. * ::cuModuleUnload
  7208. */
  7209. CUresult CUDAAPI cuModuleGetFunction(CUfunction *hfunc, CUmodule hmod, const char *name);
  7210. /**
  7211. * \brief Returns the number of functions within a module
  7212. *
  7213. * Returns in \p count the number of functions in \p mod.
  7214. *
  7215. * \param count - Number of functions found within the module
  7216. * \param mod - Module to query
  7217. *
  7218. * \return
  7219. * ::CUDA_SUCCESS,
  7220. * ::CUDA_ERROR_INVALID_HANDLE,
  7221. * ::CUDA_ERROR_INVALID_VALUE
  7222. */
  7223. CUresult CUDAAPI cuModuleGetFunctionCount(unsigned int *count, CUmodule mod);
  7224. /**
  7225. * \brief Returns the function handles within a module.
  7226. *
  7227. * Returns in \p functions a maximum number of \p numFunctions function handles within \p mod. When
  7228. * function loading mode is set to LAZY the function retrieved may be partially loaded. The loading
  7229. * state of a function can be queried using ::cuFunctionIsLoaded. CUDA APIs may load the function
  7230. * automatically when called with partially loaded function handle which may incur additional
  7231. * latency. Alternatively, ::cuFunctionLoad can be used to explicitly load a function. The returned
  7232. * function handles become invalid when the module is unloaded.
  7233. *
  7234. * \param functions - Buffer where the function handles are returned to
  7235. * \param numFunctions - Maximum number of function handles may be returned to the buffer
  7236. * \param mod - Module to query from
  7237. *
  7238. * \return
  7239. * ::CUDA_SUCCESS,
  7240. * ::CUDA_ERROR_INVALID_CONTEXT,
  7241. * ::CUDA_ERROR_INVALID_HANDLE,
  7242. * ::CUDA_ERROR_INVALID_VALUE
  7243. *
  7244. * \sa ::cuModuleGetFunction,
  7245. * ::cuModuleGetFunctionCount,
  7246. * ::cuFuncIsLoaded,
  7247. * ::cuFuncLoad
  7248. */
  7249. CUresult CUDAAPI cuModuleEnumerateFunctions(CUfunction *functions, unsigned int numFunctions, CUmodule mod);
  7250. /**
  7251. * \brief Returns a global pointer from a module
  7252. *
  7253. * Returns in \p *dptr and \p *bytes the base pointer and size of the
  7254. * global of name \p name located in module \p hmod. If no variable of that name
  7255. * exists, ::cuModuleGetGlobal() returns ::CUDA_ERROR_NOT_FOUND.
  7256. * One of the parameters \p dptr or \p bytes (not both) can be NULL in which
  7257. * case it is ignored.
  7258. *
  7259. * \param dptr - Returned global device pointer
  7260. * \param bytes - Returned global size in bytes
  7261. * \param hmod - Module to retrieve global from
  7262. * \param name - Name of global to retrieve
  7263. *
  7264. * \return
  7265. * ::CUDA_SUCCESS,
  7266. * ::CUDA_ERROR_DEINITIALIZED,
  7267. * ::CUDA_ERROR_NOT_INITIALIZED,
  7268. * ::CUDA_ERROR_INVALID_CONTEXT,
  7269. * ::CUDA_ERROR_INVALID_VALUE,
  7270. * ::CUDA_ERROR_NOT_FOUND
  7271. * \notefnerr
  7272. *
  7273. * \sa ::cuModuleGetFunction,
  7274. * ::cuModuleGetTexRef,
  7275. * ::cuModuleLoad,
  7276. * ::cuModuleLoadData,
  7277. * ::cuModuleLoadDataEx,
  7278. * ::cuModuleLoadFatBinary,
  7279. * ::cuModuleUnload,
  7280. * ::cudaGetSymbolAddress,
  7281. * ::cudaGetSymbolSize
  7282. */
  7283. CUresult CUDAAPI cuModuleGetGlobal(CUdeviceptr *dptr, size_t *bytes, CUmodule hmod, const char *name);
  7284. /**
  7285. * \brief Creates a pending JIT linker invocation.
  7286. *
  7287. * If the call is successful, the caller owns the returned CUlinkState, which
  7288. * should eventually be destroyed with ::cuLinkDestroy. The
  7289. * device code machine size (32 or 64 bit) will match the calling application.
  7290. *
  7291. * Both linker and compiler options may be specified. Compiler options will
  7292. * be applied to inputs to this linker action which must be compiled from PTX.
  7293. * The options ::CU_JIT_WALL_TIME,
  7294. * ::CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES, and ::CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES
  7295. * will accumulate data until the CUlinkState is destroyed.
  7296. *
  7297. * The data passed in via ::cuLinkAddData and ::cuLinkAddFile will be treated
  7298. * as relocatable (-rdc=true to nvcc) when linking the final cubin during
  7299. * ::cuLinkComplete and will have similar consequences as offline relocatable
  7300. * device code linking.
  7301. *
  7302. * \p optionValues must remain valid for the life of the CUlinkState if output
  7303. * options are used. No other references to inputs are maintained after this
  7304. * call returns.
  7305. *
  7306. * \note For LTO-IR input, only LTO-IR compiled with toolkits prior to CUDA 12.0 will be accepted
  7307. *
  7308. * \param numOptions Size of options arrays
  7309. * \param options Array of linker and compiler options
  7310. * \param optionValues Array of option values, each cast to void *
  7311. * \param stateOut On success, this will contain a CUlinkState to specify
  7312. * and complete this action
  7313. *
  7314. * \return
  7315. * ::CUDA_SUCCESS,
  7316. * ::CUDA_ERROR_DEINITIALIZED,
  7317. * ::CUDA_ERROR_NOT_INITIALIZED,
  7318. * ::CUDA_ERROR_INVALID_CONTEXT,
  7319. * ::CUDA_ERROR_INVALID_VALUE,
  7320. * ::CUDA_ERROR_OUT_OF_MEMORY,
  7321. * ::CUDA_ERROR_JIT_COMPILER_NOT_FOUND
  7322. * \notefnerr
  7323. *
  7324. * \sa ::cuLinkAddData,
  7325. * ::cuLinkAddFile,
  7326. * ::cuLinkComplete,
  7327. * ::cuLinkDestroy
  7328. */
  7329. CUresult CUDAAPI
  7330. cuLinkCreate(unsigned int numOptions, CUjit_option *options, void **optionValues, CUlinkState *stateOut);
  7331. /**
  7332. * \brief Add an input to a pending linker invocation
  7333. *
  7334. * Ownership of \p data is retained by the caller. No reference is retained to any
  7335. * inputs after this call returns.
  7336. *
  7337. * This method accepts only compiler options, which are used if the data must
  7338. * be compiled from PTX, and does not accept any of
  7339. * ::CU_JIT_WALL_TIME, ::CU_JIT_INFO_LOG_BUFFER, ::CU_JIT_ERROR_LOG_BUFFER,
  7340. * ::CU_JIT_TARGET_FROM_CUCONTEXT, or ::CU_JIT_TARGET.
  7341. *
  7342. * \note For LTO-IR input, only LTO-IR compiled with toolkits prior to CUDA 12.0 will be accepted
  7343. *
  7344. * \param state A pending linker action.
  7345. * \param type The type of the input data.
  7346. * \param data The input data. PTX must be NULL-terminated.
  7347. * \param size The length of the input data.
  7348. * \param name An optional name for this input in log messages.
  7349. * \param numOptions Size of options.
  7350. * \param options Options to be applied only for this input (overrides options from ::cuLinkCreate).
  7351. * \param optionValues Array of option values, each cast to void *.
  7352. *
  7353. * \return
  7354. * ::CUDA_SUCCESS,
  7355. * ::CUDA_ERROR_INVALID_HANDLE,
  7356. * ::CUDA_ERROR_INVALID_VALUE,
  7357. * ::CUDA_ERROR_INVALID_IMAGE,
  7358. * ::CUDA_ERROR_INVALID_PTX,
  7359. * ::CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
  7360. * ::CUDA_ERROR_OUT_OF_MEMORY,
  7361. * ::CUDA_ERROR_NO_BINARY_FOR_GPU
  7362. *
  7363. * \sa ::cuLinkCreate,
  7364. * ::cuLinkAddFile,
  7365. * ::cuLinkComplete,
  7366. * ::cuLinkDestroy
  7367. */
  7368. CUresult CUDAAPI
  7369. cuLinkAddData(CUlinkState state, CUjitInputType type, void *data, size_t size, const char *name,
  7370. unsigned int numOptions, CUjit_option *options, void **optionValues);
  7371. /**
  7372. * \brief Add a file input to a pending linker invocation
  7373. *
  7374. * No reference is retained to any inputs after this call returns.
  7375. *
  7376. * This method accepts only compiler options, which are used if the input
  7377. * must be compiled from PTX, and does not accept any of
  7378. * ::CU_JIT_WALL_TIME, ::CU_JIT_INFO_LOG_BUFFER, ::CU_JIT_ERROR_LOG_BUFFER,
  7379. * ::CU_JIT_TARGET_FROM_CUCONTEXT, or ::CU_JIT_TARGET.
  7380. *
  7381. * This method is equivalent to invoking ::cuLinkAddData on the contents
  7382. * of the file.
  7383. *
  7384. * \note For LTO-IR input, only LTO-IR compiled with toolkits prior to CUDA 12.0 will be accepted
  7385. *
  7386. * \param state A pending linker action
  7387. * \param type The type of the input data
  7388. * \param path Path to the input file
  7389. * \param numOptions Size of options
  7390. * \param options Options to be applied only for this input (overrides options from ::cuLinkCreate)
  7391. * \param optionValues Array of option values, each cast to void *
  7392. *
  7393. * \return
  7394. * ::CUDA_SUCCESS,
  7395. * ::CUDA_ERROR_FILE_NOT_FOUND
  7396. * ::CUDA_ERROR_INVALID_HANDLE,
  7397. * ::CUDA_ERROR_INVALID_VALUE,
  7398. * ::CUDA_ERROR_INVALID_IMAGE,
  7399. * ::CUDA_ERROR_INVALID_PTX,
  7400. * ::CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
  7401. * ::CUDA_ERROR_OUT_OF_MEMORY,
  7402. * ::CUDA_ERROR_NO_BINARY_FOR_GPU
  7403. *
  7404. * \sa ::cuLinkCreate,
  7405. * ::cuLinkAddData,
  7406. * ::cuLinkComplete,
  7407. * ::cuLinkDestroy
  7408. */
  7409. CUresult CUDAAPI
  7410. cuLinkAddFile(CUlinkState state, CUjitInputType type, const char *path,
  7411. unsigned int numOptions, CUjit_option *options, void **optionValues);
  7412. /**
  7413. * \brief Complete a pending linker invocation
  7414. *
  7415. * Completes the pending linker action and returns the cubin image for the linked
  7416. * device code, which can be used with ::cuModuleLoadData. The cubin is owned by
  7417. * \p state, so it should be loaded before \p state is destroyed via ::cuLinkDestroy.
  7418. * This call does not destroy \p state.
  7419. *
  7420. * \param state A pending linker invocation
  7421. * \param cubinOut On success, this will point to the output image
  7422. * \param sizeOut Optional parameter to receive the size of the generated image
  7423. *
  7424. * \return
  7425. * ::CUDA_SUCCESS,
  7426. * ::CUDA_ERROR_INVALID_HANDLE,
  7427. * ::CUDA_ERROR_OUT_OF_MEMORY
  7428. *
  7429. * \sa ::cuLinkCreate,
  7430. * ::cuLinkAddData,
  7431. * ::cuLinkAddFile,
  7432. * ::cuLinkDestroy,
  7433. * ::cuModuleLoadData
  7434. */
  7435. CUresult CUDAAPI
  7436. cuLinkComplete(CUlinkState state, void **cubinOut, size_t *sizeOut);
  7437. /**
  7438. * \brief Destroys state for a JIT linker invocation.
  7439. *
  7440. * \param state State object for the linker invocation
  7441. *
  7442. * \return
  7443. * ::CUDA_SUCCESS,
  7444. * ::CUDA_ERROR_INVALID_HANDLE
  7445. *
  7446. * \sa ::cuLinkCreate
  7447. */
  7448. CUresult CUDAAPI
  7449. cuLinkDestroy(CUlinkState state);
  7450. /** @} */ /* END CUDA_MODULE */
  7451. /**
  7452. * \defgroup CUDA_MODULE_DEPRECATED Module Management [DEPRECATED]
  7453. *
  7454. * ___MANBRIEF___ deprecated module management functions of the low-level CUDA
  7455. * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  7456. *
  7457. * This section describes the deprecated module management functions of the low-level
  7458. * CUDA driver application programming interface.
  7459. *
  7460. * @{
  7461. */
  7462. /**
  7463. * \brief Returns a handle to a texture reference
  7464. *
  7465. * \deprecated
  7466. *
  7467. * Returns in \p *pTexRef the handle of the texture reference of name \p name
  7468. * in the module \p hmod. If no texture reference of that name exists,
  7469. * ::cuModuleGetTexRef() returns ::CUDA_ERROR_NOT_FOUND. This texture reference
  7470. * handle should not be destroyed, since it will be destroyed when the module
  7471. * is unloaded.
  7472. *
  7473. * \param pTexRef - Returned texture reference
  7474. * \param hmod - Module to retrieve texture reference from
  7475. * \param name - Name of texture reference to retrieve
  7476. *
  7477. * \return
  7478. * ::CUDA_SUCCESS,
  7479. * ::CUDA_ERROR_DEINITIALIZED,
  7480. * ::CUDA_ERROR_NOT_INITIALIZED,
  7481. * ::CUDA_ERROR_INVALID_CONTEXT,
  7482. * ::CUDA_ERROR_INVALID_VALUE,
  7483. * ::CUDA_ERROR_NOT_FOUND
  7484. * \notefnerr
  7485. *
  7486. * \sa
  7487. * ::cuModuleGetFunction,
  7488. * ::cuModuleGetGlobal,
  7489. * ::cuModuleGetSurfRef,
  7490. * ::cuModuleLoad,
  7491. * ::cuModuleLoadData,
  7492. * ::cuModuleLoadDataEx,
  7493. * ::cuModuleLoadFatBinary,
  7494. * ::cuModuleUnload
  7495. */
  7496. __CUDA_DEPRECATED CUresult CUDAAPI cuModuleGetTexRef(CUtexref *pTexRef, CUmodule hmod, const char *name);
  7497. /**
  7498. * \brief Returns a handle to a surface reference
  7499. *
  7500. * \deprecated
  7501. *
  7502. * Returns in \p *pSurfRef the handle of the surface reference of name \p name
  7503. * in the module \p hmod. If no surface reference of that name exists,
  7504. * ::cuModuleGetSurfRef() returns ::CUDA_ERROR_NOT_FOUND.
  7505. *
  7506. * \param pSurfRef - Returned surface reference
  7507. * \param hmod - Module to retrieve surface reference from
  7508. * \param name - Name of surface reference to retrieve
  7509. *
  7510. * \return
  7511. * ::CUDA_SUCCESS,
  7512. * ::CUDA_ERROR_DEINITIALIZED,
  7513. * ::CUDA_ERROR_NOT_INITIALIZED,
  7514. * ::CUDA_ERROR_INVALID_CONTEXT,
  7515. * ::CUDA_ERROR_INVALID_VALUE,
  7516. * ::CUDA_ERROR_NOT_FOUND
  7517. * \notefnerr
  7518. *
  7519. * \sa
  7520. * ::cuModuleGetFunction,
  7521. * ::cuModuleGetGlobal,
  7522. * ::cuModuleGetTexRef,
  7523. * ::cuModuleLoad,
  7524. * ::cuModuleLoadData,
  7525. * ::cuModuleLoadDataEx,
  7526. * ::cuModuleLoadFatBinary,
  7527. * ::cuModuleUnload
  7528. */
  7529. __CUDA_DEPRECATED CUresult CUDAAPI cuModuleGetSurfRef(CUsurfref *pSurfRef, CUmodule hmod, const char *name);
  7530. /** @} */ /* END CUDA_MODULE_DEPRECATED */
  7531. /**
  7532. * \defgroup CUDA_LIBRARY Library Management
  7533. *
  7534. * ___MANBRIEF___ library management functions of the low-level CUDA driver API
  7535. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  7536. *
  7537. * This section describes the library management functions of the low-level CUDA
  7538. * driver application programming interface.
  7539. *
  7540. * @{
  7541. */
  7542. /**
  7543. * \brief Load a library with specified code and options
  7544. *
  7545. * Takes a pointer \p code and loads the corresponding library \p library based on
  7546. * the application defined library loading mode:
  7547. * - If module loading is set to EAGER, via the environment variables described in "Module loading",
  7548. * \p library is loaded eagerly into all contexts at the time of the call and future contexts
  7549. * at the time of creation until the library is unloaded with ::cuLibraryUnload().
  7550. * - If the environment variables are set to LAZY, \p library
  7551. * is not immediately loaded onto all existent contexts and will only be
  7552. * loaded when a function is needed for that context, such as a kernel launch.
  7553. *
  7554. * These environment variables are described in the CUDA programming guide under the
  7555. * "CUDA environment variables" section.
  7556. *
  7557. * The \p code may be a \e cubin or \e fatbin as output by \b nvcc,
  7558. * or a NULL-terminated \e PTX, either as output by \b nvcc or hand-written.
  7559. * A fatbin should also contain relocatable code when doing separate compilation.
  7560. *
  7561. * Options are passed as an array via \p jitOptions and any corresponding parameters are passed in
  7562. * \p jitOptionsValues. The number of total JIT options is supplied via \p numJitOptions.
  7563. * Any outputs will be returned via \p jitOptionsValues.
  7564. *
  7565. * Library load options are passed as an array via \p libraryOptions and any corresponding parameters are passed in
  7566. * \p libraryOptionValues. The number of total library load options is supplied via \p numLibraryOptions.
  7567. *
  7568. * \note If the library contains managed variables and no device in the system
  7569. * supports managed variables this call is expected to return ::CUDA_ERROR_NOT_SUPPORTED
  7570. *
  7571. * \param library - Returned library
  7572. * \param code - Code to load
  7573. * \param jitOptions - Options for JIT
  7574. * \param jitOptionsValues - Option values for JIT
  7575. * \param numJitOptions - Number of options
  7576. * \param libraryOptions - Options for loading
  7577. * \param libraryOptionValues - Option values for loading
  7578. * \param numLibraryOptions - Number of options for loading
  7579. *
  7580. * \return
  7581. * ::CUDA_SUCCESS,
  7582. * ::CUDA_ERROR_DEINITIALIZED,
  7583. * ::CUDA_ERROR_NOT_INITIALIZED,
  7584. * ::CUDA_ERROR_INVALID_VALUE,
  7585. * ::CUDA_ERROR_INVALID_PTX,
  7586. * ::CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
  7587. * ::CUDA_ERROR_OUT_OF_MEMORY,
  7588. * ::CUDA_ERROR_NO_BINARY_FOR_GPU,
  7589. * ::CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND,
  7590. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
  7591. * ::CUDA_ERROR_JIT_COMPILER_NOT_FOUND,
  7592. * ::CUDA_ERROR_NOT_SUPPORTED
  7593. *
  7594. * \sa ::cuLibraryLoadFromFile,
  7595. * ::cuLibraryUnload,
  7596. * ::cuModuleLoad,
  7597. * ::cuModuleLoadData,
  7598. * ::cuModuleLoadDataEx
  7599. */
  7600. CUresult CUDAAPI cuLibraryLoadData(CUlibrary *library, const void *code,
  7601. CUjit_option *jitOptions, void **jitOptionsValues, unsigned int numJitOptions,
  7602. CUlibraryOption *libraryOptions, void** libraryOptionValues, unsigned int numLibraryOptions);
  7603. /**
  7604. * \brief Load a library with specified file and options
  7605. *
  7606. * Takes a pointer \p code and loads the corresponding library \p library based on
  7607. * the application defined library loading mode:
  7608. * - If module loading is set to EAGER, via the environment variables described in "Module loading",
  7609. * \p library is loaded eagerly into all contexts at the time of the call and future contexts
  7610. * at the time of creation until the library is unloaded with ::cuLibraryUnload().
  7611. * - If the environment variables are set to LAZY, \p library
  7612. * is not immediately loaded onto all existent contexts and will only be
  7613. * loaded when a function is needed for that context, such as a kernel launch.
  7614. *
  7615. * These environment variables are described in the CUDA programming guide under the
  7616. * "CUDA environment variables" section.
  7617. *
  7618. * The file should be a \e cubin file as output by \b nvcc, or a \e PTX file either
  7619. * as output by \b nvcc or handwritten, or a \e fatbin file as output by \b nvcc.
  7620. * A fatbin should also contain relocatable code when doing separate compilation.
  7621. *
  7622. * Options are passed as an array via \p jitOptions and any corresponding parameters are
  7623. * passed in \p jitOptionsValues. The number of total options is supplied via \p numJitOptions.
  7624. * Any outputs will be returned via \p jitOptionsValues.
  7625. *
  7626. * Library load options are passed as an array via \p libraryOptions and any corresponding parameters are passed in
  7627. * \p libraryOptionValues. The number of total library load options is supplied via \p numLibraryOptions.
  7628. *
  7629. * \note If the library contains managed variables and no device in the system
  7630. * supports managed variables this call is expected to return ::CUDA_ERROR_NOT_SUPPORTED
  7631. *
  7632. * \param library - Returned library
  7633. * \param fileName - File to load from
  7634. * \param jitOptions - Options for JIT
  7635. * \param jitOptionsValues - Option values for JIT
  7636. * \param numJitOptions - Number of options
  7637. * \param libraryOptions - Options for loading
  7638. * \param libraryOptionValues - Option values for loading
  7639. * \param numLibraryOptions - Number of options for loading
  7640. *
  7641. * \return
  7642. * ::CUDA_SUCCESS,
  7643. * ::CUDA_ERROR_DEINITIALIZED,
  7644. * ::CUDA_ERROR_NOT_INITIALIZED,
  7645. * ::CUDA_ERROR_INVALID_VALUE,
  7646. * ::CUDA_ERROR_INVALID_PTX,
  7647. * ::CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
  7648. * ::CUDA_ERROR_OUT_OF_MEMORY,
  7649. * ::CUDA_ERROR_NO_BINARY_FOR_GPU,
  7650. * ::CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND,
  7651. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
  7652. * ::CUDA_ERROR_JIT_COMPILER_NOT_FOUND,
  7653. * ::CUDA_ERROR_NOT_SUPPORTED
  7654. *
  7655. * \sa ::cuLibraryLoadData,
  7656. * ::cuLibraryUnload,
  7657. * ::cuModuleLoad,
  7658. * ::cuModuleLoadData,
  7659. * ::cuModuleLoadDataEx
  7660. */
  7661. CUresult CUDAAPI cuLibraryLoadFromFile(CUlibrary *library, const char *fileName,
  7662. CUjit_option *jitOptions, void **jitOptionsValues, unsigned int numJitOptions,
  7663. CUlibraryOption *libraryOptions, void **libraryOptionValues, unsigned int numLibraryOptions);
  7664. /**
  7665. * \brief Unloads a library
  7666. *
  7667. * Unloads the library specified with \p library
  7668. *
  7669. * \param library - Library to unload
  7670. *
  7671. * \return
  7672. * ::CUDA_SUCCESS,
  7673. * ::CUDA_ERROR_DEINITIALIZED,
  7674. * ::CUDA_ERROR_NOT_INITIALIZED,
  7675. * ::CUDA_ERROR_INVALID_VALUE
  7676. *
  7677. * \sa ::cuLibraryLoadData,
  7678. * ::cuLibraryLoadFromFile,
  7679. * ::cuModuleUnload
  7680. */
  7681. CUresult CUDAAPI cuLibraryUnload(CUlibrary library);
  7682. /**
  7683. * \brief Returns a kernel handle
  7684. *
  7685. * Returns in \p pKernel the handle of the kernel with name \p name located in library \p library.
  7686. * If kernel handle is not found, the call returns ::CUDA_ERROR_NOT_FOUND.
  7687. *
  7688. * \param pKernel - Returned kernel handle
  7689. * \param library - Library to retrieve kernel from
  7690. * \param name - Name of kernel to retrieve
  7691. *
  7692. * \return
  7693. * ::CUDA_SUCCESS,
  7694. * ::CUDA_ERROR_DEINITIALIZED,
  7695. * ::CUDA_ERROR_NOT_INITIALIZED,
  7696. * ::CUDA_ERROR_INVALID_VALUE,
  7697. * ::CUDA_ERROR_INVALID_HANDLE,
  7698. * ::CUDA_ERROR_NOT_FOUND
  7699. *
  7700. * \sa ::cuLibraryLoadData,
  7701. * ::cuLibraryLoadFromFile,
  7702. * ::cuLibraryUnload,
  7703. * ::cuKernelGetFunction,
  7704. * ::cuLibraryGetModule,
  7705. * ::cuModuleGetFunction
  7706. */
  7707. CUresult CUDAAPI cuLibraryGetKernel(CUkernel *pKernel, CUlibrary library, const char *name);
  7708. /**
  7709. * \brief Returns the number of kernels within a library
  7710. *
  7711. * Returns in \p count the number of kernels in \p lib.
  7712. *
  7713. * \param count - Number of kernels found within the library
  7714. * \param lib - Library to query
  7715. *
  7716. * \return
  7717. * ::CUDA_SUCCESS,
  7718. * ::CUDA_ERROR_INVALID_HANDLE,
  7719. * ::CUDA_ERROR_INVALID_VALUE
  7720. */
  7721. CUresult CUDAAPI cuLibraryGetKernelCount(unsigned int *count, CUlibrary lib);
  7722. /**
  7723. * \brief Retrieve the kernel handles within a library.
  7724. *
  7725. * Returns in \p kernels a maximum number of \p numKernels kernel handles within \p lib.
  7726. * The returned kernel handle becomes invalid when the library is unloaded.
  7727. *
  7728. * \param kernels - Buffer where the kernel handles are returned to
  7729. * \param numKernels - Maximum number of kernel handles may be returned to the buffer
  7730. * \param lib - Library to query from
  7731. *
  7732. * \return
  7733. * ::CUDA_SUCCESS,
  7734. * ::CUDA_ERROR_INVALID_HANDLE,
  7735. * ::CUDA_ERROR_INVALID_VALUE
  7736. *
  7737. * \sa ::cuLibraryGetKernelCount
  7738. */
  7739. CUresult CUDAAPI cuLibraryEnumerateKernels(CUkernel *kernels, unsigned int numKernels, CUlibrary lib);
  7740. /**
  7741. * \brief Returns a module handle
  7742. *
  7743. * Returns in \p pMod the module handle associated with the current context located in
  7744. * library \p library. If module handle is not found, the call returns ::CUDA_ERROR_NOT_FOUND.
  7745. *
  7746. * \param pMod - Returned module handle
  7747. * \param library - Library to retrieve module from
  7748. *
  7749. * \return
  7750. * ::CUDA_SUCCESS,
  7751. * ::CUDA_ERROR_DEINITIALIZED,
  7752. * ::CUDA_ERROR_NOT_INITIALIZED,
  7753. * ::CUDA_ERROR_INVALID_VALUE,
  7754. * ::CUDA_ERROR_INVALID_HANDLE,
  7755. * ::CUDA_ERROR_NOT_FOUND,
  7756. * ::CUDA_ERROR_INVALID_CONTEXT,
  7757. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED
  7758. *
  7759. * \sa ::cuLibraryLoadData,
  7760. * ::cuLibraryLoadFromFile,
  7761. * ::cuLibraryUnload,
  7762. * ::cuModuleGetFunction
  7763. */
  7764. CUresult CUDAAPI cuLibraryGetModule(CUmodule *pMod, CUlibrary library);
  7765. /**
  7766. * \brief Returns a function handle
  7767. *
  7768. * Returns in \p pFunc the handle of the function for the requested kernel \p kernel and
  7769. * the current context. If function handle is not found, the call returns ::CUDA_ERROR_NOT_FOUND.
  7770. *
  7771. * \param pFunc - Returned function handle
  7772. * \param kernel - Kernel to retrieve function for the requested context
  7773. *
  7774. * \return
  7775. * ::CUDA_SUCCESS,
  7776. * ::CUDA_ERROR_DEINITIALIZED,
  7777. * ::CUDA_ERROR_NOT_INITIALIZED,
  7778. * ::CUDA_ERROR_INVALID_VALUE,
  7779. * ::CUDA_ERROR_INVALID_HANDLE,
  7780. * ::CUDA_ERROR_NOT_FOUND,
  7781. * ::CUDA_ERROR_INVALID_CONTEXT,
  7782. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED
  7783. *
  7784. * \sa ::cuLibraryLoadData,
  7785. * ::cuLibraryLoadFromFile,
  7786. * ::cuLibraryUnload,
  7787. * ::cuLibraryGetKernel,
  7788. * ::cuLibraryGetModule,
  7789. * ::cuModuleGetFunction
  7790. */
  7791. CUresult CUDAAPI cuKernelGetFunction(CUfunction *pFunc, CUkernel kernel);
  7792. /**
  7793. * \brief Returns a library handle
  7794. *
  7795. * Returns in \p pLib the handle of the library for the requested kernel \p kernel
  7796. *
  7797. * \param pLib - Returned library handle
  7798. * \param kernel - Kernel to retrieve library handle
  7799. *
  7800. * \return
  7801. * ::CUDA_SUCCESS,
  7802. * ::CUDA_ERROR_DEINITIALIZED,
  7803. * ::CUDA_ERROR_NOT_INITIALIZED,
  7804. * ::CUDA_ERROR_INVALID_VALUE,
  7805. * ::CUDA_ERROR_INVALID_HANDLE,
  7806. * ::CUDA_ERROR_NOT_FOUND
  7807. *
  7808. * \sa ::cuLibraryLoadData,
  7809. * ::cuLibraryLoadFromFile,
  7810. * ::cuLibraryUnload,
  7811. * ::cuLibraryGetKernel
  7812. */
  7813. CUresult CUDAAPI cuKernelGetLibrary(CUlibrary *pLib, CUkernel kernel);
  7814. /**
  7815. * \brief Returns a global device pointer
  7816. *
  7817. * Returns in \p *dptr and \p *bytes the base pointer and size of the global with
  7818. * name \p name for the requested library \p library and the current context.
  7819. * If no global for the requested name \p name exists, the call returns ::CUDA_ERROR_NOT_FOUND.
  7820. * One of the parameters \p dptr or \p bytes (not both) can be NULL in which
  7821. * case it is ignored.
  7822. *
  7823. * \param dptr - Returned global device pointer for the requested context
  7824. * \param bytes - Returned global size in bytes
  7825. * \param library - Library to retrieve global from
  7826. * \param name - Name of global to retrieve
  7827. *
  7828. * \return
  7829. * ::CUDA_SUCCESS,
  7830. * ::CUDA_ERROR_DEINITIALIZED,
  7831. * ::CUDA_ERROR_NOT_INITIALIZED,
  7832. * ::CUDA_ERROR_INVALID_VALUE,
  7833. * ::CUDA_ERROR_INVALID_HANDLE,
  7834. * ::CUDA_ERROR_NOT_FOUND,
  7835. * ::CUDA_ERROR_INVALID_CONTEXT,
  7836. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED
  7837. *
  7838. * \sa ::cuLibraryLoadData,
  7839. * ::cuLibraryLoadFromFile,
  7840. * ::cuLibraryUnload,
  7841. * ::cuLibraryGetModule,
  7842. * cuModuleGetGlobal
  7843. */
  7844. CUresult CUDAAPI cuLibraryGetGlobal(CUdeviceptr *dptr, size_t *bytes, CUlibrary library, const char *name);
  7845. /**
  7846. * \brief Returns a pointer to managed memory
  7847. *
  7848. * Returns in \p *dptr and \p *bytes the base pointer and size of the managed memory with
  7849. * name \p name for the requested library \p library. If no managed memory with the
  7850. * requested name \p name exists, the call returns ::CUDA_ERROR_NOT_FOUND. One of the parameters
  7851. * \p dptr or \p bytes (not both) can be NULL in which case it is ignored.
  7852. * Note that managed memory for library \p library is shared across devices and is registered
  7853. * when the library is loaded into atleast one context.
  7854. *
  7855. * \param dptr - Returned pointer to the managed memory
  7856. * \param bytes - Returned memory size in bytes
  7857. * \param library - Library to retrieve managed memory from
  7858. * \param name - Name of managed memory to retrieve
  7859. *
  7860. * \return
  7861. * ::CUDA_SUCCESS,
  7862. * ::CUDA_ERROR_DEINITIALIZED,
  7863. * ::CUDA_ERROR_NOT_INITIALIZED,
  7864. * ::CUDA_ERROR_INVALID_VALUE,
  7865. * ::CUDA_ERROR_INVALID_HANDLE,
  7866. * ::CUDA_ERROR_NOT_FOUND
  7867. *
  7868. * \sa ::cuLibraryLoadData,
  7869. * ::cuLibraryLoadFromFile,
  7870. * ::cuLibraryUnload
  7871. */
  7872. CUresult CUDAAPI cuLibraryGetManaged(CUdeviceptr *dptr, size_t *bytes, CUlibrary library, const char *name);
  7873. /**
  7874. * \brief Returns a pointer to a unified function
  7875. *
  7876. * Returns in \p *fptr the function pointer to a unified function denoted by \p symbol.
  7877. * If no unified function with name \p symbol exists, the call returns ::CUDA_ERROR_NOT_FOUND.
  7878. * If there is no device with attribute ::CU_DEVICE_ATTRIBUTE_UNIFIED_FUNCTION_POINTERS present in the system,
  7879. * the call may return ::CUDA_ERROR_NOT_FOUND.
  7880. *
  7881. * \param fptr - Returned pointer to a unified function
  7882. * \param library - Library to retrieve function pointer memory from
  7883. * \param symbol - Name of function pointer to retrieve
  7884. *
  7885. * \return
  7886. * ::CUDA_SUCCESS,
  7887. * ::CUDA_ERROR_DEINITIALIZED,
  7888. * ::CUDA_ERROR_NOT_INITIALIZED,
  7889. * ::CUDA_ERROR_INVALID_VALUE,
  7890. * ::CUDA_ERROR_INVALID_HANDLE,
  7891. * ::CUDA_ERROR_NOT_FOUND
  7892. *
  7893. * \sa ::cuLibraryLoadData,
  7894. * ::cuLibraryLoadFromFile,
  7895. * ::cuLibraryUnload
  7896. */
  7897. CUresult CUDAAPI cuLibraryGetUnifiedFunction(void **fptr, CUlibrary library, const char *symbol);
  7898. /**
  7899. * \brief Returns information about a kernel
  7900. *
  7901. * Returns in \p *pi the integer value of the attribute \p attrib for the kernel
  7902. * \p kernel for the requested device \p dev. The supported attributes are:
  7903. * - ::CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK: The maximum number of threads
  7904. * per block, beyond which a launch of the kernel would fail. This number
  7905. * depends on both the kernel and the requested device.
  7906. * - ::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES: The size in bytes of
  7907. * statically-allocated shared memory per block required by this kernel.
  7908. * This does not include dynamically-allocated shared memory requested by
  7909. * the user at runtime.
  7910. * - ::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES: The size in bytes of user-allocated
  7911. * constant memory required by this kernel.
  7912. * - ::CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES: The size in bytes of local memory
  7913. * used by each thread of this kernel.
  7914. * - ::CU_FUNC_ATTRIBUTE_NUM_REGS: The number of registers used by each thread
  7915. * of this kernel.
  7916. * - ::CU_FUNC_ATTRIBUTE_PTX_VERSION: The PTX virtual architecture version for
  7917. * which the kernel was compiled. This value is the major PTX version * 10
  7918. * + the minor PTX version, so a PTX version 1.3 function would return the
  7919. * value 13. Note that this may return the undefined value of 0 for cubins
  7920. * compiled prior to CUDA 3.0.
  7921. * - ::CU_FUNC_ATTRIBUTE_BINARY_VERSION: The binary architecture version for
  7922. * which the kernel was compiled. This value is the major binary
  7923. * version * 10 + the minor binary version, so a binary version 1.3 function
  7924. * would return the value 13. Note that this will return a value of 10 for
  7925. * legacy cubins that do not have a properly-encoded binary architecture
  7926. * version.
  7927. * - ::CU_FUNC_CACHE_MODE_CA: The attribute to indicate whether the kernel has
  7928. * been compiled with user specified option "-Xptxas --dlcm=ca" set.
  7929. * - ::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES: The maximum size in bytes of
  7930. * dynamically-allocated shared memory.
  7931. * - ::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT: Preferred shared memory-L1
  7932. * cache split ratio in percent of total shared memory.
  7933. * - ::CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET: If this attribute is set, the
  7934. * kernel must launch with a valid cluster size specified.
  7935. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH: The required cluster width in
  7936. * blocks.
  7937. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT: The required cluster height in
  7938. * blocks.
  7939. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH: The required cluster depth in
  7940. * blocks.
  7941. * - ::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED: Indicates whether
  7942. * the function can be launched with non-portable cluster size. 1 is allowed,
  7943. * 0 is disallowed. A non-portable cluster size may only function on the
  7944. * specific SKUs the program is tested on. The launch might fail if the
  7945. * program is run on a different hardware platform. CUDA API provides
  7946. * cudaOccupancyMaxActiveClusters to assist with checking whether the desired
  7947. * size can be launched on the current device. A portable cluster size is
  7948. * guaranteed to be functional on all compute capabilities higher than the
  7949. * target compute capability. The portable cluster size for sm_90 is 8 blocks
  7950. * per cluster. This value may increase for future compute capabilities. The
  7951. * specific hardware unit may support higher cluster sizes that’s not
  7952. * guaranteed to be portable.
  7953. * - ::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE: The block
  7954. * scheduling policy of a function. The value type is CUclusterSchedulingPolicy.
  7955. *
  7956. * \note If another thread is trying to set the same attribute on the same device using
  7957. * ::cuKernelSetAttribute() simultaneously, the attribute query will give the old or new
  7958. * value depending on the interleavings chosen by the OS scheduler and memory consistency.
  7959. *
  7960. * \param pi - Returned attribute value
  7961. * \param attrib - Attribute requested
  7962. * \param kernel - Kernel to query attribute of
  7963. * \param dev - Device to query attribute of
  7964. *
  7965. * \return
  7966. * ::CUDA_SUCCESS,
  7967. * ::CUDA_ERROR_DEINITIALIZED,
  7968. * ::CUDA_ERROR_NOT_INITIALIZED,
  7969. * ::CUDA_ERROR_INVALID_HANDLE,
  7970. * ::CUDA_ERROR_INVALID_VALUE,
  7971. * ::CUDA_ERROR_INVALID_DEVICE
  7972. *
  7973. * \sa ::cuLibraryLoadData,
  7974. * ::cuLibraryLoadFromFile,
  7975. * ::cuLibraryUnload,
  7976. * ::cuKernelSetAttribute,
  7977. * ::cuLibraryGetKernel,
  7978. * ::cuLaunchKernel,
  7979. * ::cuKernelGetFunction,
  7980. * ::cuLibraryGetModule,
  7981. * ::cuModuleGetFunction,
  7982. * ::cuFuncGetAttribute
  7983. */
  7984. CUresult CUDAAPI cuKernelGetAttribute(int *pi, CUfunction_attribute attrib, CUkernel kernel, CUdevice dev);
  7985. /**
  7986. * \brief Sets information about a kernel
  7987. *
  7988. * This call sets the value of a specified attribute \p attrib on the kernel \p kernel
  7989. * for the requested device \p dev to an integer value specified by \p val.
  7990. * This function returns CUDA_SUCCESS if the new value of the attribute could be
  7991. * successfully set. If the set fails, this call will return an error.
  7992. * Not all attributes can have values set. Attempting to set a value on a read-only
  7993. * attribute will result in an error (CUDA_ERROR_INVALID_VALUE)
  7994. *
  7995. * Note that attributes set using ::cuFuncSetAttribute() will override the attribute
  7996. * set by this API irrespective of whether the call to ::cuFuncSetAttribute() is made
  7997. * before or after this API call. However, ::cuKernelGetAttribute() will always
  7998. * return the attribute value set by this API.
  7999. *
  8000. * Supported attributes are:
  8001. * - ::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES: This is the maximum size in bytes of
  8002. * dynamically-allocated shared memory. The value should contain the requested
  8003. * maximum size of dynamically-allocated shared memory. The sum of this value and
  8004. * the function attribute ::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES cannot exceed the
  8005. * device attribute ::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN.
  8006. * The maximal size of requestable dynamic shared memory may differ by GPU
  8007. * architecture.
  8008. * - ::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT: On devices where the L1
  8009. * cache and shared memory use the same hardware resources, this sets the shared memory
  8010. * carveout preference, in percent of the total shared memory.
  8011. * See ::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR
  8012. * This is only a hint, and the driver can choose a different ratio if required to execute the function.
  8013. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH: The required cluster width in
  8014. * blocks. The width, height, and depth values must either all be 0 or all be
  8015. * positive. The validity of the cluster dimensions is checked at launch time.
  8016. * If the value is set during compile time, it cannot be set at runtime.
  8017. * Setting it at runtime will return CUDA_ERROR_NOT_PERMITTED.
  8018. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT: The required cluster height in
  8019. * blocks. The width, height, and depth values must either all be 0 or all be
  8020. * positive. The validity of the cluster dimensions is checked at launch time.
  8021. * If the value is set during compile time, it cannot be set at runtime.
  8022. * Setting it at runtime will return CUDA_ERROR_NOT_PERMITTED.
  8023. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH: The required cluster depth in
  8024. * blocks. The width, height, and depth values must either all be 0 or all be
  8025. * positive. The validity of the cluster dimensions is checked at launch time.
  8026. * If the value is set during compile time, it cannot be set at runtime.
  8027. * Setting it at runtime will return CUDA_ERROR_NOT_PERMITTED.
  8028. * - ::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED: Indicates whether
  8029. * the function can be launched with non-portable cluster size. 1 is allowed,
  8030. * 0 is disallowed.
  8031. * - ::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE: The block
  8032. * scheduling policy of a function. The value type is CUclusterSchedulingPolicy.
  8033. *
  8034. * \note The API has stricter locking requirements in comparison to its legacy counterpart
  8035. * ::cuFuncSetAttribute() due to device-wide semantics. If multiple threads are trying to
  8036. * set the same attribute on the same device simultaneously, the attribute setting will depend
  8037. * on the interleavings chosen by the OS scheduler and memory consistency.
  8038. *
  8039. * \param attrib - Attribute requested
  8040. * \param val - Value to set
  8041. * \param kernel - Kernel to set attribute of
  8042. * \param dev - Device to set attribute of
  8043. *
  8044. * \return
  8045. * ::CUDA_SUCCESS,
  8046. * ::CUDA_ERROR_DEINITIALIZED,
  8047. * ::CUDA_ERROR_NOT_INITIALIZED,
  8048. * ::CUDA_ERROR_INVALID_HANDLE,
  8049. * ::CUDA_ERROR_INVALID_VALUE,
  8050. * ::CUDA_ERROR_INVALID_DEVICE,
  8051. * ::CUDA_ERROR_OUT_OF_MEMORY
  8052. *
  8053. * \sa ::cuLibraryLoadData,
  8054. * ::cuLibraryLoadFromFile,
  8055. * ::cuLibraryUnload,
  8056. * ::cuKernelGetAttribute,
  8057. * ::cuLibraryGetKernel,
  8058. * ::cuLaunchKernel,
  8059. * ::cuKernelGetFunction,
  8060. * ::cuLibraryGetModule,
  8061. * ::cuModuleGetFunction,
  8062. * ::cuFuncSetAttribute
  8063. */
  8064. CUresult CUDAAPI cuKernelSetAttribute(CUfunction_attribute attrib, int val, CUkernel kernel, CUdevice dev);
  8065. /**
  8066. * \brief Sets the preferred cache configuration for a device kernel.
  8067. *
  8068. * On devices where the L1 cache and shared memory use the same hardware
  8069. * resources, this sets through \p config the preferred cache configuration for
  8070. * the device kernel \p kernel on the requested device \p dev. This is only a preference.
  8071. * The driver will use the requested configuration if possible, but it is free to choose a different
  8072. * configuration if required to execute \p kernel. Any context-wide preference
  8073. * set via ::cuCtxSetCacheConfig() will be overridden by this per-kernel
  8074. * setting.
  8075. *
  8076. * Note that attributes set using ::cuFuncSetCacheConfig() will override the attribute
  8077. * set by this API irrespective of whether the call to ::cuFuncSetCacheConfig() is made
  8078. * before or after this API call.
  8079. *
  8080. * This setting does nothing on devices where the size of the L1 cache and
  8081. * shared memory are fixed.
  8082. *
  8083. * Launching a kernel with a different preference than the most recent
  8084. * preference setting may insert a device-side synchronization point.
  8085. *
  8086. *
  8087. * The supported cache configurations are:
  8088. * - ::CU_FUNC_CACHE_PREFER_NONE: no preference for shared memory or L1 (default)
  8089. * - ::CU_FUNC_CACHE_PREFER_SHARED: prefer larger shared memory and smaller L1 cache
  8090. * - ::CU_FUNC_CACHE_PREFER_L1: prefer larger L1 cache and smaller shared memory
  8091. * - ::CU_FUNC_CACHE_PREFER_EQUAL: prefer equal sized L1 cache and shared memory
  8092. *
  8093. * \note The API has stricter locking requirements in comparison to its legacy counterpart
  8094. * ::cuFuncSetCacheConfig() due to device-wide semantics. If multiple threads are trying to
  8095. * set a config on the same device simultaneously, the cache config setting will depend
  8096. * on the interleavings chosen by the OS scheduler and memory consistency.
  8097. *
  8098. * \param kernel - Kernel to configure cache for
  8099. * \param config - Requested cache configuration
  8100. * \param dev - Device to set attribute of
  8101. *
  8102. * \return
  8103. * ::CUDA_SUCCESS,
  8104. * ::CUDA_ERROR_DEINITIALIZED,
  8105. * ::CUDA_ERROR_NOT_INITIALIZED,
  8106. * ::CUDA_ERROR_INVALID_HANDLE,
  8107. * ::CUDA_ERROR_INVALID_VALUE,
  8108. * ::CUDA_ERROR_INVALID_DEVICE,
  8109. * ::CUDA_ERROR_OUT_OF_MEMORY
  8110. *
  8111. * \sa ::cuLibraryLoadData,
  8112. * ::cuLibraryLoadFromFile,
  8113. * ::cuLibraryUnload,
  8114. * ::cuLibraryGetKernel,
  8115. * ::cuKernelGetFunction,
  8116. * ::cuLibraryGetModule,
  8117. * ::cuModuleGetFunction,
  8118. * ::cuFuncSetCacheConfig,
  8119. * ::cuCtxSetCacheConfig,
  8120. * ::cuLaunchKernel
  8121. */
  8122. CUresult CUDAAPI cuKernelSetCacheConfig(CUkernel kernel, CUfunc_cache config, CUdevice dev);
  8123. /**
  8124. * \brief Returns the function name for a ::CUkernel handle
  8125. *
  8126. * Returns in \p **name the function name associated with the kernel handle \p hfunc .
  8127. * The function name is returned as a null-terminated string. The returned name is only
  8128. * valid when the kernel handle is valid. If the library is unloaded or reloaded, one
  8129. * must call the API again to get the updated name. This API may return a mangled name if
  8130. * the function is not declared as having C linkage. If either \p **name or \p hfunc
  8131. * is NULL, ::CUDA_ERROR_INVALID_VALUE is returned.
  8132. *
  8133. * \param name - The returned name of the function
  8134. * \param hfunc - The function handle to retrieve the name for
  8135. *
  8136. * \return
  8137. * ::CUDA_SUCCESS,
  8138. * ::CUDA_ERROR_INVALID_VALUE
  8139. * \notefnerr
  8140. *
  8141. */
  8142. CUresult CUDAAPI cuKernelGetName(const char **name, CUkernel hfunc);
  8143. /**
  8144. * \brief Returns the offset and size of a kernel parameter in the device-side parameter layout
  8145. *
  8146. * Queries the kernel parameter at \p paramIndex into \p kernel's list of parameters, and returns
  8147. * in \p paramOffset and \p paramSize the offset and size, respectively, where the parameter
  8148. * will reside in the device-side parameter layout. This information can be used to update kernel
  8149. * node parameters from the device via ::cudaGraphKernelNodeSetParam() and
  8150. * ::cudaGraphKernelNodeUpdatesApply(). \p paramIndex must be less than the number of parameters
  8151. * that \p kernel takes. \p paramSize can be set to NULL if only the parameter offset is desired.
  8152. *
  8153. * \param kernel - The kernel to query
  8154. * \param paramIndex - The parameter index to query
  8155. * \param paramOffset - Returns the offset into the device-side parameter layout at which the parameter resides
  8156. * \param paramSize - Optionally returns the size of the parameter in the device-side parameter layout
  8157. *
  8158. * \return
  8159. * ::CUDA_SUCCESS,
  8160. * ::CUDA_ERROR_INVALID_VALUE,
  8161. * \notefnerr
  8162. *
  8163. * \sa ::cuFuncGetParamInfo
  8164. */
  8165. CUresult CUDAAPI cuKernelGetParamInfo(CUkernel kernel, size_t paramIndex, size_t *paramOffset, size_t *paramSize);
  8166. /** @} */ /* END CUDA_LIBRARY */
  8167. /**
  8168. * \defgroup CUDA_MEM Memory Management
  8169. *
  8170. * ___MANBRIEF___ memory management functions of the low-level CUDA driver API
  8171. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  8172. *
  8173. * This section describes the memory management functions of the low-level CUDA
  8174. * driver application programming interface.
  8175. *
  8176. * @{
  8177. */
  8178. /**
  8179. * \brief Gets free and total memory
  8180. *
  8181. * Returns in \p *total the total amount of memory available to the the current context.
  8182. * Returns in \p *free the amount of memory on the device that is free according to the OS.
  8183. * CUDA is not guaranteed to be able to allocate all of the memory that the OS reports as free.
  8184. * In a multi-tenet situation, free estimate returned is prone to race condition where
  8185. * a new allocation/free done by a different process or a different thread in the same
  8186. * process between the time when free memory was estimated and reported, will result in
  8187. * deviation in free value reported and actual free memory.
  8188. *
  8189. * The integrated GPU on Tegra shares memory with CPU and other component
  8190. * of the SoC. The free and total values returned by the API excludes
  8191. * the SWAP memory space maintained by the OS on some platforms.
  8192. * The OS may move some of the memory pages into swap area as the GPU or
  8193. * CPU allocate or access memory. See Tegra app note on how to calculate
  8194. * total and free memory on Tegra.
  8195. *
  8196. * \param free - Returned free memory in bytes
  8197. * \param total - Returned total memory in bytes
  8198. *
  8199. * \return
  8200. * ::CUDA_SUCCESS,
  8201. * ::CUDA_ERROR_DEINITIALIZED,
  8202. * ::CUDA_ERROR_NOT_INITIALIZED,
  8203. * ::CUDA_ERROR_INVALID_CONTEXT,
  8204. * ::CUDA_ERROR_INVALID_VALUE
  8205. * \notefnerr
  8206. *
  8207. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8208. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  8209. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  8210. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  8211. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  8212. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  8213. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  8214. * ::cuMemGetAddressRange, ::cuMemHostAlloc,
  8215. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  8216. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  8217. * ::cudaMemGetInfo
  8218. */
  8219. CUresult CUDAAPI cuMemGetInfo(size_t *free, size_t *total);
  8220. /**
  8221. * \brief Allocates device memory
  8222. *
  8223. * Allocates \p bytesize bytes of linear memory on the device and returns in
  8224. * \p *dptr a pointer to the allocated memory. The allocated memory is suitably
  8225. * aligned for any kind of variable. The memory is not cleared. If \p bytesize
  8226. * is 0, ::cuMemAlloc() returns ::CUDA_ERROR_INVALID_VALUE.
  8227. *
  8228. * \param dptr - Returned device pointer
  8229. * \param bytesize - Requested allocation size in bytes
  8230. *
  8231. * \return
  8232. * ::CUDA_SUCCESS,
  8233. * ::CUDA_ERROR_DEINITIALIZED,
  8234. * ::CUDA_ERROR_NOT_INITIALIZED,
  8235. * ::CUDA_ERROR_INVALID_CONTEXT,
  8236. * ::CUDA_ERROR_INVALID_VALUE,
  8237. * ::CUDA_ERROR_OUT_OF_MEMORY
  8238. * \notefnerr
  8239. *
  8240. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8241. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAllocHost,
  8242. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  8243. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  8244. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  8245. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  8246. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  8247. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  8248. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  8249. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  8250. * ::cudaMalloc
  8251. */
  8252. CUresult CUDAAPI cuMemAlloc(CUdeviceptr *dptr, size_t bytesize);
  8253. /**
  8254. * \brief Allocates pitched device memory
  8255. *
  8256. * Allocates at least \p WidthInBytes * \p Height bytes of linear memory on
  8257. * the device and returns in \p *dptr a pointer to the allocated memory. The
  8258. * function may pad the allocation to ensure that corresponding pointers in
  8259. * any given row will continue to meet the alignment requirements for
  8260. * coalescing as the address is updated from row to row. \p ElementSizeBytes
  8261. * specifies the size of the largest reads and writes that will be performed
  8262. * on the memory range. \p ElementSizeBytes may be 4, 8 or 16 (since coalesced
  8263. * memory transactions are not possible on other data sizes). If
  8264. * \p ElementSizeBytes is smaller than the actual read/write size of a kernel,
  8265. * the kernel will run correctly, but possibly at reduced speed. The pitch
  8266. * returned in \p *pPitch by ::cuMemAllocPitch() is the width in bytes of the
  8267. * allocation. The intended usage of pitch is as a separate parameter of the
  8268. * allocation, used to compute addresses within the 2D array. Given the row
  8269. * and column of an array element of type \b T, the address is computed as:
  8270. * \code
  8271. T* pElement = (T*)((char*)BaseAddress + Row * Pitch) + Column;
  8272. * \endcode
  8273. *
  8274. * The pitch returned by ::cuMemAllocPitch() is guaranteed to work with
  8275. * ::cuMemcpy2D() under all circumstances. For allocations of 2D arrays, it is
  8276. * recommended that programmers consider performing pitch allocations using
  8277. * ::cuMemAllocPitch(). Due to alignment restrictions in the hardware, this is
  8278. * especially true if the application will be performing 2D memory copies
  8279. * between different regions of device memory (whether linear memory or CUDA
  8280. * arrays).
  8281. *
  8282. * The byte alignment of the pitch returned by ::cuMemAllocPitch() is guaranteed
  8283. * to match or exceed the alignment requirement for texture binding with
  8284. * ::cuTexRefSetAddress2D().
  8285. *
  8286. * \param dptr - Returned device pointer
  8287. * \param pPitch - Returned pitch of allocation in bytes
  8288. * \param WidthInBytes - Requested allocation width in bytes
  8289. * \param Height - Requested allocation height in rows
  8290. * \param ElementSizeBytes - Size of largest reads/writes for range
  8291. *
  8292. * \return
  8293. * ::CUDA_SUCCESS,
  8294. * ::CUDA_ERROR_DEINITIALIZED,
  8295. * ::CUDA_ERROR_NOT_INITIALIZED,
  8296. * ::CUDA_ERROR_INVALID_CONTEXT,
  8297. * ::CUDA_ERROR_INVALID_VALUE,
  8298. * ::CUDA_ERROR_OUT_OF_MEMORY
  8299. * \notefnerr
  8300. *
  8301. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8302. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  8303. * ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  8304. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  8305. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  8306. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  8307. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  8308. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  8309. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  8310. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  8311. * ::cudaMallocPitch
  8312. */
  8313. CUresult CUDAAPI cuMemAllocPitch(CUdeviceptr *dptr, size_t *pPitch, size_t WidthInBytes, size_t Height, unsigned int ElementSizeBytes);
  8314. /**
  8315. * \brief Frees device memory
  8316. *
  8317. * Frees the memory space pointed to by \p dptr, which must have been returned
  8318. * by a previous call to one of the following memory allocation APIs - ::cuMemAlloc(),
  8319. * ::cuMemAllocPitch(), ::cuMemAllocManaged(), ::cuMemAllocAsync(), ::cuMemAllocFromPoolAsync()
  8320. *
  8321. * Note - This API will not perform any implict synchronization when the pointer was allocated with
  8322. * ::cuMemAllocAsync or ::cuMemAllocFromPoolAsync. Callers must ensure that all accesses to these
  8323. * pointer have completed before invoking ::cuMemFree. For best performance and memory reuse, users
  8324. * should use ::cuMemFreeAsync to free memory allocated via the stream ordered memory allocator.
  8325. * For all other pointers, this API may perform implicit synchronization.
  8326. *
  8327. * \param dptr - Pointer to memory to free
  8328. *
  8329. * \return
  8330. * ::CUDA_SUCCESS,
  8331. * ::CUDA_ERROR_DEINITIALIZED,
  8332. * ::CUDA_ERROR_NOT_INITIALIZED,
  8333. * ::CUDA_ERROR_INVALID_CONTEXT,
  8334. * ::CUDA_ERROR_INVALID_VALUE
  8335. * \notefnerr
  8336. *
  8337. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8338. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  8339. * ::cuMemAllocPitch, ::cuMemAllocManaged, ::cuMemAllocAsync, ::cuMemAllocFromPoolAsync,
  8340. * ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned, ::cuMemcpy3D, ::cuMemcpy3DAsync,
  8341. * ::cuMemcpyAtoA, ::cuMemcpyAtoD, ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA,
  8342. * ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync, ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA,
  8343. * ::cuMemcpyHtoAAsync, ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFreeHost,
  8344. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc, ::cuMemFreeAsync,
  8345. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  8346. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  8347. * ::cudaFree
  8348. */
  8349. CUresult CUDAAPI cuMemFree(CUdeviceptr dptr);
  8350. /**
  8351. * \brief Get information on memory allocations
  8352. *
  8353. * Returns the base address in \p *pbase and size in \p *psize of the
  8354. * allocation by ::cuMemAlloc() or ::cuMemAllocPitch() that contains the input
  8355. * pointer \p dptr. Both parameters \p pbase and \p psize are optional. If one
  8356. * of them is NULL, it is ignored.
  8357. *
  8358. * \param pbase - Returned base address
  8359. * \param psize - Returned size of device memory allocation
  8360. * \param dptr - Device pointer to query
  8361. *
  8362. * \return
  8363. * ::CUDA_SUCCESS,
  8364. * ::CUDA_ERROR_DEINITIALIZED,
  8365. * ::CUDA_ERROR_NOT_INITIALIZED,
  8366. * ::CUDA_ERROR_INVALID_CONTEXT,
  8367. * ::CUDA_ERROR_NOT_FOUND,
  8368. * ::CUDA_ERROR_INVALID_VALUE
  8369. * \notefnerr
  8370. *
  8371. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8372. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  8373. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  8374. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  8375. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  8376. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  8377. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  8378. * ::cuMemGetInfo, ::cuMemHostAlloc,
  8379. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  8380. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32
  8381. */
  8382. CUresult CUDAAPI cuMemGetAddressRange(CUdeviceptr *pbase, size_t *psize, CUdeviceptr dptr);
  8383. /**
  8384. * \brief Allocates page-locked host memory
  8385. *
  8386. * Allocates \p bytesize bytes of host memory that is page-locked and
  8387. * accessible to the device. The driver tracks the virtual memory ranges
  8388. * allocated with this function and automatically accelerates calls to
  8389. * functions such as ::cuMemcpy(). Since the memory can be accessed directly by
  8390. * the device, it can be read or written with much higher bandwidth than
  8391. * pageable memory obtained with functions such as ::malloc().
  8392. *
  8393. * On systems where ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES
  8394. * is true, ::cuMemAllocHost may not page-lock the allocated memory.
  8395. *
  8396. * Page-locking excessive amounts of memory with ::cuMemAllocHost() may degrade system
  8397. * performance, since it reduces the amount of memory available to the system
  8398. * for paging. As a result, this function is best used sparingly to allocate
  8399. * staging areas for data exchange between host and device.
  8400. *
  8401. * Note all host memory allocated using ::cuMemAllocHost() will automatically
  8402. * be immediately accessible to all contexts on all devices which support unified
  8403. * addressing (as may be queried using ::CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING).
  8404. * The device pointer that may be used to access this host memory from those
  8405. * contexts is always equal to the returned host pointer \p *pp.
  8406. * See \ref CUDA_UNIFIED for additional details.
  8407. *
  8408. * \param pp - Returned pointer to host memory
  8409. * \param bytesize - Requested allocation size in bytes
  8410. *
  8411. * \return
  8412. * ::CUDA_SUCCESS,
  8413. * ::CUDA_ERROR_DEINITIALIZED,
  8414. * ::CUDA_ERROR_NOT_INITIALIZED,
  8415. * ::CUDA_ERROR_INVALID_CONTEXT,
  8416. * ::CUDA_ERROR_INVALID_VALUE,
  8417. * ::CUDA_ERROR_OUT_OF_MEMORY
  8418. * \notefnerr
  8419. *
  8420. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8421. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc,
  8422. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  8423. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  8424. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  8425. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  8426. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  8427. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  8428. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  8429. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  8430. * ::cudaMallocHost
  8431. */
  8432. CUresult CUDAAPI cuMemAllocHost(void **pp, size_t bytesize);
  8433. /**
  8434. * \brief Frees page-locked host memory
  8435. *
  8436. * Frees the memory space pointed to by \p p, which must have been returned by
  8437. * a previous call to ::cuMemAllocHost().
  8438. *
  8439. * \param p - Pointer to memory to free
  8440. *
  8441. * \return
  8442. * ::CUDA_SUCCESS,
  8443. * ::CUDA_ERROR_DEINITIALIZED,
  8444. * ::CUDA_ERROR_NOT_INITIALIZED,
  8445. * ::CUDA_ERROR_INVALID_CONTEXT,
  8446. * ::CUDA_ERROR_INVALID_VALUE
  8447. * \notefnerr
  8448. *
  8449. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8450. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  8451. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  8452. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  8453. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  8454. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  8455. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree,
  8456. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  8457. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  8458. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  8459. * ::cudaFreeHost
  8460. */
  8461. CUresult CUDAAPI cuMemFreeHost(void *p);
  8462. /**
  8463. * \brief Allocates page-locked host memory
  8464. *
  8465. * Allocates \p bytesize bytes of host memory that is page-locked and accessible
  8466. * to the device. The driver tracks the virtual memory ranges allocated with
  8467. * this function and automatically accelerates calls to functions such as
  8468. * ::cuMemcpyHtoD(). Since the memory can be accessed directly by the device,
  8469. * it can be read or written with much higher bandwidth than pageable memory
  8470. * obtained with functions such as ::malloc().
  8471. *
  8472. * On systems where ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES
  8473. * is true, ::cuMemHostAlloc may not page-lock the allocated memory.
  8474. *
  8475. * Page-locking excessive amounts of memory may degrade system performance,
  8476. * since it reduces the amount of memory available to the system for paging.
  8477. * As a result, this function is best used sparingly to allocate staging areas
  8478. * for data exchange between host and device.
  8479. *
  8480. * The \p Flags parameter enables different options to be specified that
  8481. * affect the allocation, as follows.
  8482. *
  8483. * - ::CU_MEMHOSTALLOC_PORTABLE: The memory returned by this call will be
  8484. * considered as pinned memory by all CUDA contexts, not just the one that
  8485. * performed the allocation.
  8486. *
  8487. * - ::CU_MEMHOSTALLOC_DEVICEMAP: Maps the allocation into the CUDA address
  8488. * space. The device pointer to the memory may be obtained by calling
  8489. * ::cuMemHostGetDevicePointer().
  8490. *
  8491. * - ::CU_MEMHOSTALLOC_WRITECOMBINED: Allocates the memory as write-combined
  8492. * (WC). WC memory can be transferred across the PCI Express bus more
  8493. * quickly on some system configurations, but cannot be read efficiently by
  8494. * most CPUs. WC memory is a good option for buffers that will be written by
  8495. * the CPU and read by the GPU via mapped pinned memory or host->device
  8496. * transfers.
  8497. *
  8498. * All of these flags are orthogonal to one another: a developer may allocate
  8499. * memory that is portable, mapped and/or write-combined with no restrictions.
  8500. *
  8501. * The ::CU_MEMHOSTALLOC_DEVICEMAP flag may be specified on CUDA contexts for
  8502. * devices that do not support mapped pinned memory. The failure is deferred
  8503. * to ::cuMemHostGetDevicePointer() because the memory may be mapped into
  8504. * other CUDA contexts via the ::CU_MEMHOSTALLOC_PORTABLE flag.
  8505. *
  8506. * The memory allocated by this function must be freed with ::cuMemFreeHost().
  8507. *
  8508. * Note all host memory allocated using ::cuMemHostAlloc() will automatically
  8509. * be immediately accessible to all contexts on all devices which support unified
  8510. * addressing (as may be queried using ::CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING).
  8511. * Unless the flag ::CU_MEMHOSTALLOC_WRITECOMBINED is specified, the device pointer
  8512. * that may be used to access this host memory from those contexts is always equal
  8513. * to the returned host pointer \p *pp. If the flag ::CU_MEMHOSTALLOC_WRITECOMBINED
  8514. * is specified, then the function ::cuMemHostGetDevicePointer() must be used
  8515. * to query the device pointer, even if the context supports unified addressing.
  8516. * See \ref CUDA_UNIFIED for additional details.
  8517. *
  8518. * \param pp - Returned pointer to host memory
  8519. * \param bytesize - Requested allocation size in bytes
  8520. * \param Flags - Flags for allocation request
  8521. *
  8522. * \return
  8523. * ::CUDA_SUCCESS,
  8524. * ::CUDA_ERROR_DEINITIALIZED,
  8525. * ::CUDA_ERROR_NOT_INITIALIZED,
  8526. * ::CUDA_ERROR_INVALID_CONTEXT,
  8527. * ::CUDA_ERROR_INVALID_VALUE,
  8528. * ::CUDA_ERROR_OUT_OF_MEMORY
  8529. * \notefnerr
  8530. *
  8531. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8532. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  8533. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  8534. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  8535. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  8536. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  8537. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  8538. * ::cuMemGetAddressRange, ::cuMemGetInfo,
  8539. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  8540. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  8541. * ::cudaHostAlloc
  8542. */
  8543. CUresult CUDAAPI cuMemHostAlloc(void **pp, size_t bytesize, unsigned int Flags);
  8544. /**
  8545. * \brief Passes back device pointer of mapped pinned memory
  8546. *
  8547. * Passes back the device pointer \p pdptr corresponding to the mapped, pinned
  8548. * host buffer \p p allocated by ::cuMemHostAlloc.
  8549. *
  8550. * ::cuMemHostGetDevicePointer() will fail if the ::CU_MEMHOSTALLOC_DEVICEMAP
  8551. * flag was not specified at the time the memory was allocated, or if the
  8552. * function is called on a GPU that does not support mapped pinned memory.
  8553. *
  8554. * For devices that have a non-zero value for the device attribute
  8555. * ::CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM, the memory
  8556. * can also be accessed from the device using the host pointer \p p.
  8557. * The device pointer returned by ::cuMemHostGetDevicePointer() may or may not
  8558. * match the original host pointer \p p and depends on the devices visible to the
  8559. * application. If all devices visible to the application have a non-zero value for the
  8560. * device attribute, the device pointer returned by ::cuMemHostGetDevicePointer()
  8561. * will match the original pointer \p p. If any device visible to the application
  8562. * has a zero value for the device attribute, the device pointer returned by
  8563. * ::cuMemHostGetDevicePointer() will not match the original host pointer \p p,
  8564. * but it will be suitable for use on all devices provided Unified Virtual Addressing
  8565. * is enabled. In such systems, it is valid to access the memory using either pointer
  8566. * on devices that have a non-zero value for the device attribute. Note however that
  8567. * such devices should access the memory using only one of the two pointers and not both.
  8568. *
  8569. * \p Flags provides for future releases. For now, it must be set to 0.
  8570. *
  8571. * \param pdptr - Returned device pointer
  8572. * \param p - Host pointer
  8573. * \param Flags - Options (must be 0)
  8574. *
  8575. * \return
  8576. * ::CUDA_SUCCESS,
  8577. * ::CUDA_ERROR_DEINITIALIZED,
  8578. * ::CUDA_ERROR_NOT_INITIALIZED,
  8579. * ::CUDA_ERROR_INVALID_CONTEXT,
  8580. * ::CUDA_ERROR_INVALID_VALUE
  8581. * \notefnerr
  8582. *
  8583. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8584. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  8585. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  8586. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  8587. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  8588. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  8589. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  8590. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  8591. * ::cuMemsetD2D8, ::cuMemsetD2D16,
  8592. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  8593. * ::cudaHostGetDevicePointer
  8594. */
  8595. CUresult CUDAAPI cuMemHostGetDevicePointer(CUdeviceptr *pdptr, void *p, unsigned int Flags);
  8596. /**
  8597. * \brief Passes back flags that were used for a pinned allocation
  8598. *
  8599. * Passes back the flags \p pFlags that were specified when allocating
  8600. * the pinned host buffer \p p allocated by ::cuMemHostAlloc.
  8601. *
  8602. * ::cuMemHostGetFlags() will fail if the pointer does not reside in
  8603. * an allocation performed by ::cuMemAllocHost() or ::cuMemHostAlloc().
  8604. *
  8605. * \param pFlags - Returned flags word
  8606. * \param p - Host pointer
  8607. *
  8608. * \return
  8609. * ::CUDA_SUCCESS,
  8610. * ::CUDA_ERROR_DEINITIALIZED,
  8611. * ::CUDA_ERROR_NOT_INITIALIZED,
  8612. * ::CUDA_ERROR_INVALID_CONTEXT,
  8613. * ::CUDA_ERROR_INVALID_VALUE
  8614. * \notefnerr
  8615. *
  8616. * \sa
  8617. * ::cuMemAllocHost,
  8618. * ::cuMemHostAlloc,
  8619. * ::cudaHostGetFlags
  8620. */
  8621. CUresult CUDAAPI cuMemHostGetFlags(unsigned int *pFlags, void *p);
  8622. /**
  8623. * \brief Allocates memory that will be automatically managed by the Unified Memory system
  8624. *
  8625. * Allocates \p bytesize bytes of managed memory on the device and returns in
  8626. * \p *dptr a pointer to the allocated memory. If the device doesn't support
  8627. * allocating managed memory, ::CUDA_ERROR_NOT_SUPPORTED is returned. Support
  8628. * for managed memory can be queried using the device attribute
  8629. * ::CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY. The allocated memory is suitably
  8630. * aligned for any kind of variable. The memory is not cleared. If \p bytesize
  8631. * is 0, ::cuMemAllocManaged returns ::CUDA_ERROR_INVALID_VALUE. The pointer
  8632. * is valid on the CPU and on all GPUs in the system that support managed memory.
  8633. * All accesses to this pointer must obey the Unified Memory programming model.
  8634. *
  8635. * \p flags specifies the default stream association for this allocation.
  8636. * \p flags must be one of ::CU_MEM_ATTACH_GLOBAL or ::CU_MEM_ATTACH_HOST. If
  8637. * ::CU_MEM_ATTACH_GLOBAL is specified, then this memory is accessible from
  8638. * any stream on any device. If ::CU_MEM_ATTACH_HOST is specified, then the
  8639. * allocation should not be accessed from devices that have a zero value for the
  8640. * device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS; an explicit call to
  8641. * ::cuStreamAttachMemAsync will be required to enable access on such devices.
  8642. *
  8643. * If the association is later changed via ::cuStreamAttachMemAsync to
  8644. * a single stream, the default association as specified during ::cuMemAllocManaged
  8645. * is restored when that stream is destroyed. For __managed__ variables, the
  8646. * default association is always ::CU_MEM_ATTACH_GLOBAL. Note that destroying a
  8647. * stream is an asynchronous operation, and as a result, the change to default
  8648. * association won't happen until all work in the stream has completed.
  8649. *
  8650. * Memory allocated with ::cuMemAllocManaged should be released with ::cuMemFree.
  8651. *
  8652. * Device memory oversubscription is possible for GPUs that have a non-zero value for the
  8653. * device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS. Managed memory on
  8654. * such GPUs may be evicted from device memory to host memory at any time by the Unified
  8655. * Memory driver in order to make room for other allocations.
  8656. *
  8657. * In a system where all GPUs have a non-zero value for the device attribute
  8658. * ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS, managed memory may not be populated when this
  8659. * API returns and instead may be populated on access. In such systems, managed memory can
  8660. * migrate to any processor's memory at any time. The Unified Memory driver will employ heuristics to
  8661. * maintain data locality and prevent excessive page faults to the extent possible. The application
  8662. * can also guide the driver about memory usage patterns via ::cuMemAdvise. The application
  8663. * can also explicitly migrate memory to a desired processor's memory via
  8664. * ::cuMemPrefetchAsync.
  8665. *
  8666. * In a multi-GPU system where all of the GPUs have a zero value for the device attribute
  8667. * ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS and all the GPUs have peer-to-peer support
  8668. * with each other, the physical storage for managed memory is created on the GPU which is active
  8669. * at the time ::cuMemAllocManaged is called. All other GPUs will reference the data at reduced
  8670. * bandwidth via peer mappings over the PCIe bus. The Unified Memory driver does not migrate
  8671. * memory among such GPUs.
  8672. *
  8673. * In a multi-GPU system where not all GPUs have peer-to-peer support with each other and
  8674. * where the value of the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS
  8675. * is zero for at least one of those GPUs, the location chosen for physical storage of managed
  8676. * memory is system-dependent.
  8677. * - On Linux, the location chosen will be device memory as long as the current set of active
  8678. * contexts are on devices that either have peer-to-peer support with each other or have a
  8679. * non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS.
  8680. * If there is an active context on a GPU that does not have a non-zero value for that device
  8681. * attribute and it does not have peer-to-peer support with the other devices that have active
  8682. * contexts on them, then the location for physical storage will be 'zero-copy' or host memory.
  8683. * Note that this means that managed memory that is located in device memory is migrated to
  8684. * host memory if a new context is created on a GPU that doesn't have a non-zero value for
  8685. * the device attribute and does not support peer-to-peer with at least one of the other devices
  8686. * that has an active context. This in turn implies that context creation may fail if there is
  8687. * insufficient host memory to migrate all managed allocations.
  8688. * - On Windows, the physical storage is always created in 'zero-copy' or host memory.
  8689. * All GPUs will reference the data at reduced bandwidth over the PCIe bus. In these
  8690. * circumstances, use of the environment variable CUDA_VISIBLE_DEVICES is recommended to
  8691. * restrict CUDA to only use those GPUs that have peer-to-peer support.
  8692. * Alternatively, users can also set CUDA_MANAGED_FORCE_DEVICE_ALLOC to a
  8693. * non-zero value to force the driver to always use device memory for physical storage.
  8694. * When this environment variable is set to a non-zero value, all contexts created in
  8695. * that process on devices that support managed memory have to be peer-to-peer compatible
  8696. * with each other. Context creation will fail if a context is created on a device that
  8697. * supports managed memory and is not peer-to-peer compatible with any of the other
  8698. * managed memory supporting devices on which contexts were previously created, even if
  8699. * those contexts have been destroyed. These environment variables are described
  8700. * in the CUDA programming guide under the "CUDA environment variables" section.
  8701. * - On ARM, managed memory is not available on discrete gpu with Drive PX-2.
  8702. *
  8703. * \param dptr - Returned device pointer
  8704. * \param bytesize - Requested allocation size in bytes
  8705. * \param flags - Must be one of ::CU_MEM_ATTACH_GLOBAL or ::CU_MEM_ATTACH_HOST
  8706. *
  8707. * \return
  8708. * ::CUDA_SUCCESS,
  8709. * ::CUDA_ERROR_DEINITIALIZED,
  8710. * ::CUDA_ERROR_NOT_INITIALIZED,
  8711. * ::CUDA_ERROR_INVALID_CONTEXT,
  8712. * ::CUDA_ERROR_NOT_SUPPORTED,
  8713. * ::CUDA_ERROR_INVALID_VALUE,
  8714. * ::CUDA_ERROR_OUT_OF_MEMORY
  8715. * \notefnerr
  8716. *
  8717. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  8718. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAllocHost,
  8719. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  8720. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  8721. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  8722. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  8723. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  8724. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  8725. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  8726. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  8727. * ::cuDeviceGetAttribute, ::cuStreamAttachMemAsync,
  8728. * ::cudaMallocManaged
  8729. */
  8730. CUresult CUDAAPI cuMemAllocManaged(CUdeviceptr *dptr, size_t bytesize, unsigned int flags);
  8731. /**
  8732. * \brief Registers a callback function to receive async notifications
  8733. *
  8734. * Registers \p callbackFunc to receive async notifications.
  8735. *
  8736. * The \p userData parameter is passed to the callback function at async notification time.
  8737. * Likewise, \p callback is also passed to the callback function to distinguish between
  8738. * multiple registered callbacks.
  8739. *
  8740. * The callback function being registered should be designed to return quickly (~10ms).
  8741. * Any long running tasks should be queued for execution on an application thread.
  8742. *
  8743. * Callbacks may not call cuDeviceRegisterAsyncNotification or cuDeviceUnregisterAsyncNotification.
  8744. * Doing so will result in ::CUDA_ERROR_NOT_PERMITTED. Async notification callbacks execute
  8745. * in an undefined order and may be serialized.
  8746. *
  8747. * Returns in \p *callback a handle representing the registered callback instance.
  8748. *
  8749. * \param device - The device on which to register the callback
  8750. * \param callbackFunc - The function to register as a callback
  8751. * \param userData - A generic pointer to user data. This is passed into the callback function.
  8752. * \param callback - A handle representing the registered callback instance
  8753. *
  8754. * \return
  8755. * ::CUDA_SUCCESS
  8756. * ::CUDA_ERROR_NOT_SUPPORTED
  8757. * ::CUDA_ERROR_INVALID_DEVICE
  8758. * ::CUDA_ERROR_INVALID_VALUE
  8759. * ::CUDA_ERROR_NOT_PERMITTED
  8760. * ::CUDA_ERROR_UNKNOWN
  8761. * \notefnerr
  8762. *
  8763. * \sa
  8764. * ::cuDeviceUnregisterAsyncNotification
  8765. */
  8766. CUresult CUDAAPI cuDeviceRegisterAsyncNotification(CUdevice device, CUasyncCallback callbackFunc, void *userData, CUasyncCallbackHandle *callback);
  8767. /**
  8768. * \brief Unregisters an async notification callback
  8769. *
  8770. * Unregisters \p callback so that the corresponding callback function will stop receiving
  8771. * async notifications.
  8772. *
  8773. * \param device - The device from which to remove \p callback.
  8774. * \param callback - The callback instance to unregister from receiving async notifications.
  8775. *
  8776. * \return
  8777. * ::CUDA_SUCCESS
  8778. * ::CUDA_ERROR_NOT_SUPPORTED
  8779. * ::CUDA_ERROR_INVALID_DEVICE
  8780. * ::CUDA_ERROR_INVALID_VALUE
  8781. * ::CUDA_ERROR_NOT_PERMITTED
  8782. * ::CUDA_ERROR_UNKNOWN
  8783. * \notefnerr
  8784. *
  8785. * \sa
  8786. * ::cuDeviceRegisterAsyncNotification
  8787. */
  8788. CUresult CUDAAPI cuDeviceUnregisterAsyncNotification(CUdevice device, CUasyncCallbackHandle callback);
  8789. /**
  8790. * \brief Returns a handle to a compute device
  8791. *
  8792. * Returns in \p *device a device handle given a PCI bus ID string.
  8793. *
  8794. * \param dev - Returned device handle
  8795. *
  8796. * \param pciBusId - String in one of the following forms:
  8797. * [domain]:[bus]:[device].[function]
  8798. * [domain]:[bus]:[device]
  8799. * [bus]:[device].[function]
  8800. * where \p domain, \p bus, \p device, and \p function are all hexadecimal values
  8801. *
  8802. * \return
  8803. * ::CUDA_SUCCESS,
  8804. * ::CUDA_ERROR_DEINITIALIZED,
  8805. * ::CUDA_ERROR_NOT_INITIALIZED,
  8806. * ::CUDA_ERROR_INVALID_VALUE,
  8807. * ::CUDA_ERROR_INVALID_DEVICE
  8808. * \notefnerr
  8809. *
  8810. * \sa
  8811. * ::cuDeviceGet,
  8812. * ::cuDeviceGetAttribute,
  8813. * ::cuDeviceGetPCIBusId,
  8814. * ::cudaDeviceGetByPCIBusId
  8815. */
  8816. CUresult CUDAAPI cuDeviceGetByPCIBusId(CUdevice *dev, const char *pciBusId);
  8817. /**
  8818. * \brief Returns a PCI Bus Id string for the device
  8819. *
  8820. * Returns an ASCII string identifying the device \p dev in the NULL-terminated
  8821. * string pointed to by \p pciBusId. \p len specifies the maximum length of the
  8822. * string that may be returned.
  8823. *
  8824. * \param pciBusId - Returned identifier string for the device in the following format
  8825. * [domain]:[bus]:[device].[function]
  8826. * where \p domain, \p bus, \p device, and \p function are all hexadecimal values.
  8827. * pciBusId should be large enough to store 13 characters including the NULL-terminator.
  8828. *
  8829. * \param len - Maximum length of string to store in \p name
  8830. *
  8831. * \param dev - Device to get identifier string for
  8832. *
  8833. * \return
  8834. * ::CUDA_SUCCESS,
  8835. * ::CUDA_ERROR_DEINITIALIZED,
  8836. * ::CUDA_ERROR_NOT_INITIALIZED,
  8837. * ::CUDA_ERROR_INVALID_VALUE,
  8838. * ::CUDA_ERROR_INVALID_DEVICE
  8839. * \notefnerr
  8840. *
  8841. * \sa
  8842. * ::cuDeviceGet,
  8843. * ::cuDeviceGetAttribute,
  8844. * ::cuDeviceGetByPCIBusId,
  8845. * ::cudaDeviceGetPCIBusId
  8846. */
  8847. CUresult CUDAAPI cuDeviceGetPCIBusId(char *pciBusId, int len, CUdevice dev);
  8848. /**
  8849. * \brief Gets an interprocess handle for a previously allocated event
  8850. *
  8851. * Takes as input a previously allocated event. This event must have been
  8852. * created with the ::CU_EVENT_INTERPROCESS and ::CU_EVENT_DISABLE_TIMING
  8853. * flags set. This opaque handle may be copied into other processes and
  8854. * opened with ::cuIpcOpenEventHandle to allow efficient hardware
  8855. * synchronization between GPU work in different processes.
  8856. *
  8857. * After the event has been opened in the importing process,
  8858. * ::cuEventRecord, ::cuEventSynchronize, ::cuStreamWaitEvent and
  8859. * ::cuEventQuery may be used in either process. Performing operations
  8860. * on the imported event after the exported event has been freed
  8861. * with ::cuEventDestroy will result in undefined behavior.
  8862. *
  8863. * IPC functionality is restricted to devices with support for unified
  8864. * addressing on Linux and Windows operating systems.
  8865. * IPC functionality on Windows is supported for compatibility purposes
  8866. * but not recommended as it comes with performance cost.
  8867. * Users can test their device for IPC functionality by calling
  8868. * ::cuapiDeviceGetAttribute with ::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED
  8869. *
  8870. * \param pHandle - Pointer to a user allocated CUipcEventHandle
  8871. * in which to return the opaque event handle
  8872. * \param event - Event allocated with ::CU_EVENT_INTERPROCESS and
  8873. * ::CU_EVENT_DISABLE_TIMING flags.
  8874. *
  8875. * \return
  8876. * ::CUDA_SUCCESS,
  8877. * ::CUDA_ERROR_INVALID_HANDLE,
  8878. * ::CUDA_ERROR_OUT_OF_MEMORY,
  8879. * ::CUDA_ERROR_MAP_FAILED,
  8880. * ::CUDA_ERROR_INVALID_VALUE
  8881. *
  8882. * \sa
  8883. * ::cuEventCreate,
  8884. * ::cuEventDestroy,
  8885. * ::cuEventSynchronize,
  8886. * ::cuEventQuery,
  8887. * ::cuStreamWaitEvent,
  8888. * ::cuIpcOpenEventHandle,
  8889. * ::cuIpcGetMemHandle,
  8890. * ::cuIpcOpenMemHandle,
  8891. * ::cuIpcCloseMemHandle,
  8892. * ::cudaIpcGetEventHandle
  8893. */
  8894. CUresult CUDAAPI cuIpcGetEventHandle(CUipcEventHandle *pHandle, CUevent event);
  8895. /**
  8896. * \brief Opens an interprocess event handle for use in the current process
  8897. *
  8898. * Opens an interprocess event handle exported from another process with
  8899. * ::cuIpcGetEventHandle. This function returns a ::CUevent that behaves like
  8900. * a locally created event with the ::CU_EVENT_DISABLE_TIMING flag specified.
  8901. * This event must be freed with ::cuEventDestroy.
  8902. *
  8903. * Performing operations on the imported event after the exported event has
  8904. * been freed with ::cuEventDestroy will result in undefined behavior.
  8905. *
  8906. * IPC functionality is restricted to devices with support for unified
  8907. * addressing on Linux and Windows operating systems.
  8908. * IPC functionality on Windows is supported for compatibility purposes
  8909. * but not recommended as it comes with performance cost.
  8910. * Users can test their device for IPC functionality by calling
  8911. * ::cuapiDeviceGetAttribute with ::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED
  8912. *
  8913. * \param phEvent - Returns the imported event
  8914. * \param handle - Interprocess handle to open
  8915. *
  8916. * \returns
  8917. * ::CUDA_SUCCESS,
  8918. * ::CUDA_ERROR_INVALID_CONTEXT,
  8919. * ::CUDA_ERROR_MAP_FAILED,
  8920. * ::CUDA_ERROR_PEER_ACCESS_UNSUPPORTED,
  8921. * ::CUDA_ERROR_INVALID_HANDLE,
  8922. * ::CUDA_ERROR_INVALID_VALUE
  8923. *
  8924. * \sa
  8925. * ::cuEventCreate,
  8926. * ::cuEventDestroy,
  8927. * ::cuEventSynchronize,
  8928. * ::cuEventQuery,
  8929. * ::cuStreamWaitEvent,
  8930. * ::cuIpcGetEventHandle,
  8931. * ::cuIpcGetMemHandle,
  8932. * ::cuIpcOpenMemHandle,
  8933. * ::cuIpcCloseMemHandle,
  8934. * ::cudaIpcOpenEventHandle
  8935. */
  8936. CUresult CUDAAPI cuIpcOpenEventHandle(CUevent *phEvent, CUipcEventHandle handle);
  8937. /**
  8938. * \brief Gets an interprocess memory handle for an existing device memory
  8939. * allocation
  8940. *
  8941. * Takes a pointer to the base of an existing device memory allocation created
  8942. * with ::cuMemAlloc and exports it for use in another process. This is a
  8943. * lightweight operation and may be called multiple times on an allocation
  8944. * without adverse effects.
  8945. *
  8946. * If a region of memory is freed with ::cuMemFree and a subsequent call
  8947. * to ::cuMemAlloc returns memory with the same device address,
  8948. * ::cuIpcGetMemHandle will return a unique handle for the
  8949. * new memory.
  8950. *
  8951. * IPC functionality is restricted to devices with support for unified
  8952. * addressing on Linux and Windows operating systems.
  8953. * IPC functionality on Windows is supported for compatibility purposes
  8954. * but not recommended as it comes with performance cost.
  8955. * Users can test their device for IPC functionality by calling
  8956. * ::cuapiDeviceGetAttribute with ::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED
  8957. *
  8958. * \param pHandle - Pointer to user allocated ::CUipcMemHandle to return
  8959. * the handle in.
  8960. * \param dptr - Base pointer to previously allocated device memory
  8961. *
  8962. * \returns
  8963. * ::CUDA_SUCCESS,
  8964. * ::CUDA_ERROR_INVALID_HANDLE,
  8965. * ::CUDA_ERROR_INVALID_CONTEXT,
  8966. * ::CUDA_ERROR_OUT_OF_MEMORY,
  8967. * ::CUDA_ERROR_MAP_FAILED,
  8968. * ::CUDA_ERROR_INVALID_VALUE
  8969. *
  8970. * \sa
  8971. * ::cuMemAlloc,
  8972. * ::cuMemFree,
  8973. * ::cuIpcGetEventHandle,
  8974. * ::cuIpcOpenEventHandle,
  8975. * ::cuIpcOpenMemHandle,
  8976. * ::cuIpcCloseMemHandle,
  8977. * ::cudaIpcGetMemHandle
  8978. */
  8979. CUresult CUDAAPI cuIpcGetMemHandle(CUipcMemHandle *pHandle, CUdeviceptr dptr);
  8980. /**
  8981. * \brief Opens an interprocess memory handle exported from another process
  8982. * and returns a device pointer usable in the local process.
  8983. *
  8984. * Maps memory exported from another process with ::cuIpcGetMemHandle into
  8985. * the current device address space. For contexts on different devices
  8986. * ::cuIpcOpenMemHandle can attempt to enable peer access between the
  8987. * devices as if the user called ::cuCtxEnablePeerAccess. This behavior is
  8988. * controlled by the ::CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS flag.
  8989. * ::cuDeviceCanAccessPeer can determine if a mapping is possible.
  8990. *
  8991. * Contexts that may open ::CUipcMemHandles are restricted in the following way.
  8992. * ::CUipcMemHandles from each ::CUdevice in a given process may only be opened
  8993. * by one ::CUcontext per ::CUdevice per other process.
  8994. *
  8995. * If the memory handle has already been opened by the current context, the
  8996. * reference count on the handle is incremented by 1 and the existing device pointer
  8997. * is returned.
  8998. *
  8999. * Memory returned from ::cuIpcOpenMemHandle must be freed with
  9000. * ::cuIpcCloseMemHandle.
  9001. *
  9002. * Calling ::cuMemFree on an exported memory region before calling
  9003. * ::cuIpcCloseMemHandle in the importing context will result in undefined
  9004. * behavior.
  9005. *
  9006. * IPC functionality is restricted to devices with support for unified
  9007. * addressing on Linux and Windows operating systems.
  9008. * IPC functionality on Windows is supported for compatibility purposes
  9009. * but not recommended as it comes with performance cost.
  9010. * Users can test their device for IPC functionality by calling
  9011. * ::cuapiDeviceGetAttribute with ::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED
  9012. *
  9013. * \param pdptr - Returned device pointer
  9014. * \param handle - ::CUipcMemHandle to open
  9015. * \param Flags - Flags for this operation. Must be specified as ::CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS
  9016. *
  9017. * \returns
  9018. * ::CUDA_SUCCESS,
  9019. * ::CUDA_ERROR_INVALID_CONTEXT,
  9020. * ::CUDA_ERROR_MAP_FAILED,
  9021. * ::CUDA_ERROR_INVALID_HANDLE,
  9022. * ::CUDA_ERROR_TOO_MANY_PEERS,
  9023. * ::CUDA_ERROR_INVALID_VALUE
  9024. *
  9025. * \note No guarantees are made about the address returned in \p *pdptr.
  9026. * In particular, multiple processes may not receive the same address for the same \p handle.
  9027. *
  9028. * \sa
  9029. * ::cuMemAlloc,
  9030. * ::cuMemFree,
  9031. * ::cuIpcGetEventHandle,
  9032. * ::cuIpcOpenEventHandle,
  9033. * ::cuIpcGetMemHandle,
  9034. * ::cuIpcCloseMemHandle,
  9035. * ::cuCtxEnablePeerAccess,
  9036. * ::cuDeviceCanAccessPeer,
  9037. * ::cudaIpcOpenMemHandle
  9038. */
  9039. CUresult CUDAAPI cuIpcOpenMemHandle(CUdeviceptr *pdptr, CUipcMemHandle handle, unsigned int Flags);
  9040. /**
  9041. * \brief Attempts to close memory mapped with ::cuIpcOpenMemHandle
  9042. *
  9043. * Decrements the reference count of the memory returned by ::cuIpcOpenMemHandle by 1.
  9044. * When the reference count reaches 0, this API unmaps the memory. The original allocation
  9045. * in the exporting process as well as imported mappings in other processes
  9046. * will be unaffected.
  9047. *
  9048. * Any resources used to enable peer access will be freed if this is the
  9049. * last mapping using them.
  9050. *
  9051. * IPC functionality is restricted to devices with support for unified
  9052. * addressing on Linux and Windows operating systems.
  9053. * IPC functionality on Windows is supported for compatibility purposes
  9054. * but not recommended as it comes with performance cost.
  9055. * Users can test their device for IPC functionality by calling
  9056. * ::cuapiDeviceGetAttribute with ::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED
  9057. *
  9058. * \param dptr - Device pointer returned by ::cuIpcOpenMemHandle
  9059. *
  9060. * \returns
  9061. * ::CUDA_SUCCESS,
  9062. * ::CUDA_ERROR_INVALID_CONTEXT,
  9063. * ::CUDA_ERROR_MAP_FAILED,
  9064. * ::CUDA_ERROR_INVALID_HANDLE,
  9065. * ::CUDA_ERROR_INVALID_VALUE
  9066. * \sa
  9067. * ::cuMemAlloc,
  9068. * ::cuMemFree,
  9069. * ::cuIpcGetEventHandle,
  9070. * ::cuIpcOpenEventHandle,
  9071. * ::cuIpcGetMemHandle,
  9072. * ::cuIpcOpenMemHandle,
  9073. * ::cudaIpcCloseMemHandle
  9074. */
  9075. CUresult CUDAAPI cuIpcCloseMemHandle(CUdeviceptr dptr);
  9076. /**
  9077. * \brief Registers an existing host memory range for use by CUDA
  9078. *
  9079. * Page-locks the memory range specified by \p p and \p bytesize and maps it
  9080. * for the device(s) as specified by \p Flags. This memory range also is added
  9081. * to the same tracking mechanism as ::cuMemHostAlloc to automatically accelerate
  9082. * calls to functions such as ::cuMemcpyHtoD(). Since the memory can be accessed
  9083. * directly by the device, it can be read or written with much higher bandwidth
  9084. * than pageable memory that has not been registered. Page-locking excessive
  9085. * amounts of memory may degrade system performance, since it reduces the amount
  9086. * of memory available to the system for paging. As a result, this function is
  9087. * best used sparingly to register staging areas for data exchange between
  9088. * host and device.
  9089. *
  9090. * On systems where ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES
  9091. * is true, ::cuMemHostRegister will not page-lock the memory range specified
  9092. * by \p ptr but only populate unpopulated pages.
  9093. *
  9094. * The \p Flags parameter enables different options to be specified that
  9095. * affect the allocation, as follows.
  9096. *
  9097. * - ::CU_MEMHOSTREGISTER_PORTABLE: The memory returned by this call will be
  9098. * considered as pinned memory by all CUDA contexts, not just the one that
  9099. * performed the allocation.
  9100. *
  9101. * - ::CU_MEMHOSTREGISTER_DEVICEMAP: Maps the allocation into the CUDA address
  9102. * space. The device pointer to the memory may be obtained by calling
  9103. * ::cuMemHostGetDevicePointer().
  9104. *
  9105. * - ::CU_MEMHOSTREGISTER_IOMEMORY: The pointer is treated as pointing to some
  9106. * I/O memory space, e.g. the PCI Express resource of a 3rd party device.
  9107. *
  9108. * - ::CU_MEMHOSTREGISTER_READ_ONLY: The pointer is treated as pointing to memory
  9109. * that is considered read-only by the device. On platforms without
  9110. * ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES, this flag is
  9111. * required in order to register memory mapped to the CPU as read-only. Support
  9112. * for the use of this flag can be queried from the device attribute
  9113. * ::CU_DEVICE_ATTRIBUTE_READ_ONLY_HOST_REGISTER_SUPPORTED. Using this flag with
  9114. * a current context associated with a device that does not have this attribute
  9115. * set will cause ::cuMemHostRegister to error with CUDA_ERROR_NOT_SUPPORTED.
  9116. *
  9117. * All of these flags are orthogonal to one another: a developer may page-lock
  9118. * memory that is portable or mapped with no restrictions.
  9119. *
  9120. * The ::CU_MEMHOSTREGISTER_DEVICEMAP flag may be specified on CUDA contexts for
  9121. * devices that do not support mapped pinned memory. The failure is deferred
  9122. * to ::cuMemHostGetDevicePointer() because the memory may be mapped into
  9123. * other CUDA contexts via the ::CU_MEMHOSTREGISTER_PORTABLE flag.
  9124. *
  9125. * For devices that have a non-zero value for the device attribute
  9126. * ::CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM, the memory
  9127. * can also be accessed from the device using the host pointer \p p.
  9128. * The device pointer returned by ::cuMemHostGetDevicePointer() may or may not
  9129. * match the original host pointer \p ptr and depends on the devices visible to the
  9130. * application. If all devices visible to the application have a non-zero value for the
  9131. * device attribute, the device pointer returned by ::cuMemHostGetDevicePointer()
  9132. * will match the original pointer \p ptr. If any device visible to the application
  9133. * has a zero value for the device attribute, the device pointer returned by
  9134. * ::cuMemHostGetDevicePointer() will not match the original host pointer \p ptr,
  9135. * but it will be suitable for use on all devices provided Unified Virtual Addressing
  9136. * is enabled. In such systems, it is valid to access the memory using either pointer
  9137. * on devices that have a non-zero value for the device attribute. Note however that
  9138. * such devices should access the memory using only of the two pointers and not both.
  9139. *
  9140. * The memory page-locked by this function must be unregistered with
  9141. * ::cuMemHostUnregister().
  9142. *
  9143. * \param p - Host pointer to memory to page-lock
  9144. * \param bytesize - Size in bytes of the address range to page-lock
  9145. * \param Flags - Flags for allocation request
  9146. *
  9147. * \return
  9148. * ::CUDA_SUCCESS,
  9149. * ::CUDA_ERROR_DEINITIALIZED,
  9150. * ::CUDA_ERROR_NOT_INITIALIZED,
  9151. * ::CUDA_ERROR_INVALID_CONTEXT,
  9152. * ::CUDA_ERROR_INVALID_VALUE,
  9153. * ::CUDA_ERROR_OUT_OF_MEMORY,
  9154. * ::CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED,
  9155. * ::CUDA_ERROR_NOT_PERMITTED,
  9156. * ::CUDA_ERROR_NOT_SUPPORTED
  9157. * \notefnerr
  9158. *
  9159. * \sa
  9160. * ::cuMemHostUnregister,
  9161. * ::cuMemHostGetFlags,
  9162. * ::cuMemHostGetDevicePointer,
  9163. * ::cudaHostRegister
  9164. */
  9165. CUresult CUDAAPI cuMemHostRegister(void *p, size_t bytesize, unsigned int Flags);
  9166. /**
  9167. * \brief Unregisters a memory range that was registered with cuMemHostRegister.
  9168. *
  9169. * Unmaps the memory range whose base address is specified by \p p, and makes
  9170. * it pageable again.
  9171. *
  9172. * The base address must be the same one specified to ::cuMemHostRegister().
  9173. *
  9174. * \param p - Host pointer to memory to unregister
  9175. *
  9176. * \return
  9177. * ::CUDA_SUCCESS,
  9178. * ::CUDA_ERROR_DEINITIALIZED,
  9179. * ::CUDA_ERROR_NOT_INITIALIZED,
  9180. * ::CUDA_ERROR_INVALID_CONTEXT,
  9181. * ::CUDA_ERROR_INVALID_VALUE,
  9182. * ::CUDA_ERROR_OUT_OF_MEMORY,
  9183. * ::CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED,
  9184. * \notefnerr
  9185. *
  9186. * \sa
  9187. * ::cuMemHostRegister,
  9188. * ::cudaHostUnregister
  9189. */
  9190. CUresult CUDAAPI cuMemHostUnregister(void *p);
  9191. /**
  9192. * \brief Copies memory
  9193. *
  9194. * Copies data between two pointers.
  9195. * \p dst and \p src are base pointers of the destination and source, respectively.
  9196. * \p ByteCount specifies the number of bytes to copy.
  9197. * Note that this function infers the type of the transfer (host to host, host to
  9198. * device, device to device, or device to host) from the pointer values. This
  9199. * function is only allowed in contexts which support unified addressing.
  9200. *
  9201. * \param dst - Destination unified virtual address space pointer
  9202. * \param src - Source unified virtual address space pointer
  9203. * \param ByteCount - Size of memory copy in bytes
  9204. *
  9205. * \return
  9206. * ::CUDA_SUCCESS,
  9207. * ::CUDA_ERROR_DEINITIALIZED,
  9208. * ::CUDA_ERROR_NOT_INITIALIZED,
  9209. * ::CUDA_ERROR_INVALID_CONTEXT,
  9210. * ::CUDA_ERROR_INVALID_VALUE
  9211. * \notefnerr
  9212. * \note_sync
  9213. * \note_memcpy
  9214. *
  9215. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9216. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9217. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9218. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  9219. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA,
  9220. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9221. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9222. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9223. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9224. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9225. * ::cudaMemcpy,
  9226. * ::cudaMemcpyToSymbol,
  9227. * ::cudaMemcpyFromSymbol
  9228. */
  9229. CUresult CUDAAPI cuMemcpy(CUdeviceptr dst, CUdeviceptr src, size_t ByteCount);
  9230. /**
  9231. * \brief Copies device memory between two contexts
  9232. *
  9233. * Copies from device memory in one context to device memory in another
  9234. * context. \p dstDevice is the base device pointer of the destination memory
  9235. * and \p dstContext is the destination context. \p srcDevice is the base
  9236. * device pointer of the source memory and \p srcContext is the source pointer.
  9237. * \p ByteCount specifies the number of bytes to copy.
  9238. *
  9239. * \param dstDevice - Destination device pointer
  9240. * \param dstContext - Destination context
  9241. * \param srcDevice - Source device pointer
  9242. * \param srcContext - Source context
  9243. * \param ByteCount - Size of memory copy in bytes
  9244. *
  9245. * \return
  9246. * ::CUDA_SUCCESS,
  9247. * ::CUDA_ERROR_DEINITIALIZED,
  9248. * ::CUDA_ERROR_NOT_INITIALIZED,
  9249. * ::CUDA_ERROR_INVALID_CONTEXT,
  9250. * ::CUDA_ERROR_INVALID_VALUE
  9251. * \notefnerr
  9252. * \note_sync
  9253. *
  9254. * \sa ::cuMemcpyDtoD, ::cuMemcpy3DPeer, ::cuMemcpyDtoDAsync, ::cuMemcpyPeerAsync,
  9255. * ::cuMemcpy3DPeerAsync,
  9256. * ::cudaMemcpyPeer
  9257. */
  9258. CUresult CUDAAPI cuMemcpyPeer(CUdeviceptr dstDevice, CUcontext dstContext, CUdeviceptr srcDevice, CUcontext srcContext, size_t ByteCount);
  9259. /**
  9260. * \brief Copies memory from Host to Device
  9261. *
  9262. * Copies from host memory to device memory. \p dstDevice and \p srcHost are
  9263. * the base addresses of the destination and source, respectively. \p ByteCount
  9264. * specifies the number of bytes to copy.
  9265. *
  9266. * \param dstDevice - Destination device pointer
  9267. * \param srcHost - Source host pointer
  9268. * \param ByteCount - Size of memory copy in bytes
  9269. *
  9270. * \return
  9271. * ::CUDA_SUCCESS,
  9272. * ::CUDA_ERROR_DEINITIALIZED,
  9273. * ::CUDA_ERROR_NOT_INITIALIZED,
  9274. * ::CUDA_ERROR_INVALID_CONTEXT,
  9275. * ::CUDA_ERROR_INVALID_VALUE
  9276. * \notefnerr
  9277. * \note_sync
  9278. * \note_memcpy
  9279. *
  9280. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9281. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9282. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9283. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  9284. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  9285. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9286. * ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9287. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9288. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9289. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9290. * ::cudaMemcpy,
  9291. * ::cudaMemcpyToSymbol
  9292. */
  9293. CUresult CUDAAPI cuMemcpyHtoD(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount);
  9294. /**
  9295. * \brief Copies memory from Device to Host
  9296. *
  9297. * Copies from device to host memory. \p dstHost and \p srcDevice specify the
  9298. * base pointers of the destination and source, respectively. \p ByteCount
  9299. * specifies the number of bytes to copy.
  9300. *
  9301. * \param dstHost - Destination host pointer
  9302. * \param srcDevice - Source device pointer
  9303. * \param ByteCount - Size of memory copy in bytes
  9304. *
  9305. * \return
  9306. * ::CUDA_SUCCESS,
  9307. * ::CUDA_ERROR_DEINITIALIZED,
  9308. * ::CUDA_ERROR_NOT_INITIALIZED,
  9309. * ::CUDA_ERROR_INVALID_CONTEXT,
  9310. * ::CUDA_ERROR_INVALID_VALUE
  9311. * \notefnerr
  9312. * \note_sync
  9313. * \note_memcpy
  9314. *
  9315. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9316. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9317. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9318. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  9319. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  9320. * ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9321. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9322. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9323. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9324. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9325. * ::cudaMemcpy,
  9326. * ::cudaMemcpyFromSymbol
  9327. */
  9328. CUresult CUDAAPI cuMemcpyDtoH(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount);
  9329. /**
  9330. * \brief Copies memory from Device to Device
  9331. *
  9332. * Copies from device memory to device memory. \p dstDevice and \p srcDevice
  9333. * are the base pointers of the destination and source, respectively.
  9334. * \p ByteCount specifies the number of bytes to copy.
  9335. *
  9336. * \param dstDevice - Destination device pointer
  9337. * \param srcDevice - Source device pointer
  9338. * \param ByteCount - Size of memory copy in bytes
  9339. *
  9340. * \return
  9341. * ::CUDA_SUCCESS,
  9342. * ::CUDA_ERROR_DEINITIALIZED,
  9343. * ::CUDA_ERROR_NOT_INITIALIZED,
  9344. * ::CUDA_ERROR_INVALID_CONTEXT,
  9345. * ::CUDA_ERROR_INVALID_VALUE
  9346. * \notefnerr
  9347. * \note_sync
  9348. *
  9349. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9350. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9351. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9352. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  9353. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA,
  9354. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9355. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9356. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9357. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9358. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9359. * ::cudaMemcpy,
  9360. * ::cudaMemcpyToSymbol,
  9361. * ::cudaMemcpyFromSymbol
  9362. */
  9363. CUresult CUDAAPI cuMemcpyDtoD(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount);
  9364. /**
  9365. * \brief Copies memory from Device to Array
  9366. *
  9367. * Copies from device memory to a 1D CUDA array. \p dstArray and \p dstOffset
  9368. * specify the CUDA array handle and starting index of the destination data.
  9369. * \p srcDevice specifies the base pointer of the source. \p ByteCount
  9370. * specifies the number of bytes to copy.
  9371. *
  9372. * \param dstArray - Destination array
  9373. * \param dstOffset - Offset in bytes of destination array
  9374. * \param srcDevice - Source device pointer
  9375. * \param ByteCount - Size of memory copy in bytes
  9376. *
  9377. * \return
  9378. * ::CUDA_SUCCESS,
  9379. * ::CUDA_ERROR_DEINITIALIZED,
  9380. * ::CUDA_ERROR_NOT_INITIALIZED,
  9381. * ::CUDA_ERROR_INVALID_CONTEXT,
  9382. * ::CUDA_ERROR_INVALID_VALUE
  9383. * \notefnerr
  9384. * \note_sync
  9385. *
  9386. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9387. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9388. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9389. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  9390. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  9391. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9392. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9393. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9394. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9395. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9396. * ::cudaMemcpyToArray
  9397. */
  9398. CUresult CUDAAPI cuMemcpyDtoA(CUarray dstArray, size_t dstOffset, CUdeviceptr srcDevice, size_t ByteCount);
  9399. /**
  9400. * \brief Copies memory from Array to Device
  9401. *
  9402. * Copies from one 1D CUDA array to device memory. \p dstDevice specifies the
  9403. * base pointer of the destination and must be naturally aligned with the CUDA
  9404. * array elements. \p srcArray and \p srcOffset specify the CUDA array handle
  9405. * and the offset in bytes into the array where the copy is to begin.
  9406. * \p ByteCount specifies the number of bytes to copy and must be evenly
  9407. * divisible by the array element size.
  9408. *
  9409. * \param dstDevice - Destination device pointer
  9410. * \param srcArray - Source array
  9411. * \param srcOffset - Offset in bytes of source array
  9412. * \param ByteCount - Size of memory copy in bytes
  9413. *
  9414. * \return
  9415. * ::CUDA_SUCCESS,
  9416. * ::CUDA_ERROR_DEINITIALIZED,
  9417. * ::CUDA_ERROR_NOT_INITIALIZED,
  9418. * ::CUDA_ERROR_INVALID_CONTEXT,
  9419. * ::CUDA_ERROR_INVALID_VALUE
  9420. * \notefnerr
  9421. * \note_sync
  9422. *
  9423. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9424. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9425. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9426. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA,
  9427. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  9428. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9429. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9430. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9431. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9432. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9433. * ::cudaMemcpyFromArray
  9434. */
  9435. CUresult CUDAAPI cuMemcpyAtoD(CUdeviceptr dstDevice, CUarray srcArray, size_t srcOffset, size_t ByteCount);
  9436. /**
  9437. * \brief Copies memory from Host to Array
  9438. *
  9439. * Copies from host memory to a 1D CUDA array. \p dstArray and \p dstOffset
  9440. * specify the CUDA array handle and starting offset in bytes of the destination
  9441. * data. \p pSrc specifies the base address of the source. \p ByteCount specifies
  9442. * the number of bytes to copy.
  9443. *
  9444. * \param dstArray - Destination array
  9445. * \param dstOffset - Offset in bytes of destination array
  9446. * \param srcHost - Source host pointer
  9447. * \param ByteCount - Size of memory copy in bytes
  9448. *
  9449. * \return
  9450. * ::CUDA_SUCCESS,
  9451. * ::CUDA_ERROR_DEINITIALIZED,
  9452. * ::CUDA_ERROR_NOT_INITIALIZED,
  9453. * ::CUDA_ERROR_INVALID_CONTEXT,
  9454. * ::CUDA_ERROR_INVALID_VALUE
  9455. * \notefnerr
  9456. * \note_sync
  9457. * \note_memcpy
  9458. *
  9459. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9460. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9461. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9462. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  9463. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  9464. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoAAsync,
  9465. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9466. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9467. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9468. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9469. * ::cudaMemcpyToArray
  9470. */
  9471. CUresult CUDAAPI cuMemcpyHtoA(CUarray dstArray, size_t dstOffset, const void *srcHost, size_t ByteCount);
  9472. /**
  9473. * \brief Copies memory from Array to Host
  9474. *
  9475. * Copies from one 1D CUDA array to host memory. \p dstHost specifies the base
  9476. * pointer of the destination. \p srcArray and \p srcOffset specify the CUDA
  9477. * array handle and starting offset in bytes of the source data.
  9478. * \p ByteCount specifies the number of bytes to copy.
  9479. *
  9480. * \param dstHost - Destination device pointer
  9481. * \param srcArray - Source array
  9482. * \param srcOffset - Offset in bytes of source array
  9483. * \param ByteCount - Size of memory copy in bytes
  9484. *
  9485. * \return
  9486. * ::CUDA_SUCCESS,
  9487. * ::CUDA_ERROR_DEINITIALIZED,
  9488. * ::CUDA_ERROR_NOT_INITIALIZED,
  9489. * ::CUDA_ERROR_INVALID_CONTEXT,
  9490. * ::CUDA_ERROR_INVALID_VALUE
  9491. * \notefnerr
  9492. * \note_sync
  9493. * \note_memcpy
  9494. *
  9495. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9496. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9497. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9498. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  9499. * ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  9500. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9501. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9502. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9503. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9504. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9505. * ::cudaMemcpyFromArray
  9506. */
  9507. CUresult CUDAAPI cuMemcpyAtoH(void *dstHost, CUarray srcArray, size_t srcOffset, size_t ByteCount);
  9508. /**
  9509. * \brief Copies memory from Array to Array
  9510. *
  9511. * Copies from one 1D CUDA array to another. \p dstArray and \p srcArray
  9512. * specify the handles of the destination and source CUDA arrays for the copy,
  9513. * respectively. \p dstOffset and \p srcOffset specify the destination and
  9514. * source offsets in bytes into the CUDA arrays. \p ByteCount is the number of
  9515. * bytes to be copied. The size of the elements in the CUDA arrays need not be
  9516. * the same format, but the elements must be the same size; and count must be
  9517. * evenly divisible by that size.
  9518. *
  9519. * \param dstArray - Destination array
  9520. * \param dstOffset - Offset in bytes of destination array
  9521. * \param srcArray - Source array
  9522. * \param srcOffset - Offset in bytes of source array
  9523. * \param ByteCount - Size of memory copy in bytes
  9524. *
  9525. * \return
  9526. * ::CUDA_SUCCESS,
  9527. * ::CUDA_ERROR_DEINITIALIZED,
  9528. * ::CUDA_ERROR_NOT_INITIALIZED,
  9529. * ::CUDA_ERROR_INVALID_CONTEXT,
  9530. * ::CUDA_ERROR_INVALID_VALUE
  9531. * \notefnerr
  9532. * \note_sync
  9533. *
  9534. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9535. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9536. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9537. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoD,
  9538. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  9539. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9540. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9541. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9542. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9543. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9544. * ::cudaMemcpyArrayToArray
  9545. */
  9546. CUresult CUDAAPI cuMemcpyAtoA(CUarray dstArray, size_t dstOffset, CUarray srcArray, size_t srcOffset, size_t ByteCount);
  9547. /**
  9548. * \brief Copies memory for 2D arrays
  9549. *
  9550. * Perform a 2D memory copy according to the parameters specified in \p pCopy.
  9551. * The ::CUDA_MEMCPY2D structure is defined as:
  9552. *
  9553. * \code
  9554. typedef struct CUDA_MEMCPY2D_st {
  9555. unsigned int srcXInBytes, srcY;
  9556. CUmemorytype srcMemoryType;
  9557. const void *srcHost;
  9558. CUdeviceptr srcDevice;
  9559. CUarray srcArray;
  9560. unsigned int srcPitch;
  9561. unsigned int dstXInBytes, dstY;
  9562. CUmemorytype dstMemoryType;
  9563. void *dstHost;
  9564. CUdeviceptr dstDevice;
  9565. CUarray dstArray;
  9566. unsigned int dstPitch;
  9567. unsigned int WidthInBytes;
  9568. unsigned int Height;
  9569. } CUDA_MEMCPY2D;
  9570. * \endcode
  9571. * where:
  9572. * - ::srcMemoryType and ::dstMemoryType specify the type of memory of the
  9573. * source and destination, respectively; ::CUmemorytype_enum is defined as:
  9574. *
  9575. * \code
  9576. typedef enum CUmemorytype_enum {
  9577. CU_MEMORYTYPE_HOST = 0x01,
  9578. CU_MEMORYTYPE_DEVICE = 0x02,
  9579. CU_MEMORYTYPE_ARRAY = 0x03,
  9580. CU_MEMORYTYPE_UNIFIED = 0x04
  9581. } CUmemorytype;
  9582. * \endcode
  9583. *
  9584. * \par
  9585. * If ::srcMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::srcDevice and ::srcPitch
  9586. * specify the (unified virtual address space) base address of the source data
  9587. * and the bytes per row to apply. ::srcArray is ignored.
  9588. * This value may be used only if unified addressing is supported in the calling
  9589. * context.
  9590. *
  9591. * \par
  9592. * If ::srcMemoryType is ::CU_MEMORYTYPE_HOST, ::srcHost and ::srcPitch
  9593. * specify the (host) base address of the source data and the bytes per row to
  9594. * apply. ::srcArray is ignored.
  9595. *
  9596. * \par
  9597. * If ::srcMemoryType is ::CU_MEMORYTYPE_DEVICE, ::srcDevice and ::srcPitch
  9598. * specify the (device) base address of the source data and the bytes per row
  9599. * to apply. ::srcArray is ignored.
  9600. *
  9601. * \par
  9602. * If ::srcMemoryType is ::CU_MEMORYTYPE_ARRAY, ::srcArray specifies the
  9603. * handle of the source data. ::srcHost, ::srcDevice and ::srcPitch are
  9604. * ignored.
  9605. *
  9606. * \par
  9607. * If ::dstMemoryType is ::CU_MEMORYTYPE_HOST, ::dstHost and ::dstPitch
  9608. * specify the (host) base address of the destination data and the bytes per
  9609. * row to apply. ::dstArray is ignored.
  9610. *
  9611. * \par
  9612. * If ::dstMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::dstDevice and ::dstPitch
  9613. * specify the (unified virtual address space) base address of the source data
  9614. * and the bytes per row to apply. ::dstArray is ignored.
  9615. * This value may be used only if unified addressing is supported in the calling
  9616. * context.
  9617. *
  9618. * \par
  9619. * If ::dstMemoryType is ::CU_MEMORYTYPE_DEVICE, ::dstDevice and ::dstPitch
  9620. * specify the (device) base address of the destination data and the bytes per
  9621. * row to apply. ::dstArray is ignored.
  9622. *
  9623. * \par
  9624. * If ::dstMemoryType is ::CU_MEMORYTYPE_ARRAY, ::dstArray specifies the
  9625. * handle of the destination data. ::dstHost, ::dstDevice and ::dstPitch are
  9626. * ignored.
  9627. *
  9628. * - ::srcXInBytes and ::srcY specify the base address of the source data for
  9629. * the copy.
  9630. *
  9631. * \par
  9632. * For host pointers, the starting address is
  9633. * \code
  9634. void* Start = (void*)((char*)srcHost+srcY*srcPitch + srcXInBytes);
  9635. * \endcode
  9636. *
  9637. * \par
  9638. * For device pointers, the starting address is
  9639. * \code
  9640. CUdeviceptr Start = srcDevice+srcY*srcPitch+srcXInBytes;
  9641. * \endcode
  9642. *
  9643. * \par
  9644. * For CUDA arrays, ::srcXInBytes must be evenly divisible by the array
  9645. * element size.
  9646. *
  9647. * - ::dstXInBytes and ::dstY specify the base address of the destination data
  9648. * for the copy.
  9649. *
  9650. * \par
  9651. * For host pointers, the base address is
  9652. * \code
  9653. void* dstStart = (void*)((char*)dstHost+dstY*dstPitch + dstXInBytes);
  9654. * \endcode
  9655. *
  9656. * \par
  9657. * For device pointers, the starting address is
  9658. * \code
  9659. CUdeviceptr dstStart = dstDevice+dstY*dstPitch+dstXInBytes;
  9660. * \endcode
  9661. *
  9662. * \par
  9663. * For CUDA arrays, ::dstXInBytes must be evenly divisible by the array
  9664. * element size.
  9665. *
  9666. * - ::WidthInBytes and ::Height specify the width (in bytes) and height of
  9667. * the 2D copy being performed.
  9668. * - If specified, ::srcPitch must be greater than or equal to ::WidthInBytes +
  9669. * ::srcXInBytes, and ::dstPitch must be greater than or equal to
  9670. * ::WidthInBytes + dstXInBytes.
  9671. *
  9672. * \par
  9673. * ::cuMemcpy2D() returns an error if any pitch is greater than the maximum
  9674. * allowed (::CU_DEVICE_ATTRIBUTE_MAX_PITCH). ::cuMemAllocPitch() passes back
  9675. * pitches that always work with ::cuMemcpy2D(). On intra-device memory copies
  9676. * (device to device, CUDA array to device, CUDA array to CUDA array),
  9677. * ::cuMemcpy2D() may fail for pitches not computed by ::cuMemAllocPitch().
  9678. * ::cuMemcpy2DUnaligned() does not have this restriction, but may run
  9679. * significantly slower in the cases where ::cuMemcpy2D() would have returned
  9680. * an error code.
  9681. *
  9682. * \param pCopy - Parameters for the memory copy
  9683. *
  9684. * \return
  9685. * ::CUDA_SUCCESS,
  9686. * ::CUDA_ERROR_DEINITIALIZED,
  9687. * ::CUDA_ERROR_NOT_INITIALIZED,
  9688. * ::CUDA_ERROR_INVALID_CONTEXT,
  9689. * ::CUDA_ERROR_INVALID_VALUE
  9690. * \notefnerr
  9691. * \note_sync
  9692. *
  9693. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9694. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9695. * ::cuMemAllocPitch, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  9696. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  9697. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  9698. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9699. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9700. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9701. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9702. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9703. * ::cudaMemcpy2D,
  9704. * ::cudaMemcpy2DToArray,
  9705. * ::cudaMemcpy2DFromArray
  9706. */
  9707. CUresult CUDAAPI cuMemcpy2D(const CUDA_MEMCPY2D *pCopy);
  9708. /**
  9709. * \brief Copies memory for 2D arrays
  9710. *
  9711. * Perform a 2D memory copy according to the parameters specified in \p pCopy.
  9712. * The ::CUDA_MEMCPY2D structure is defined as:
  9713. *
  9714. * \code
  9715. typedef struct CUDA_MEMCPY2D_st {
  9716. unsigned int srcXInBytes, srcY;
  9717. CUmemorytype srcMemoryType;
  9718. const void *srcHost;
  9719. CUdeviceptr srcDevice;
  9720. CUarray srcArray;
  9721. unsigned int srcPitch;
  9722. unsigned int dstXInBytes, dstY;
  9723. CUmemorytype dstMemoryType;
  9724. void *dstHost;
  9725. CUdeviceptr dstDevice;
  9726. CUarray dstArray;
  9727. unsigned int dstPitch;
  9728. unsigned int WidthInBytes;
  9729. unsigned int Height;
  9730. } CUDA_MEMCPY2D;
  9731. * \endcode
  9732. * where:
  9733. * - ::srcMemoryType and ::dstMemoryType specify the type of memory of the
  9734. * source and destination, respectively; ::CUmemorytype_enum is defined as:
  9735. *
  9736. * \code
  9737. typedef enum CUmemorytype_enum {
  9738. CU_MEMORYTYPE_HOST = 0x01,
  9739. CU_MEMORYTYPE_DEVICE = 0x02,
  9740. CU_MEMORYTYPE_ARRAY = 0x03,
  9741. CU_MEMORYTYPE_UNIFIED = 0x04
  9742. } CUmemorytype;
  9743. * \endcode
  9744. *
  9745. * \par
  9746. * If ::srcMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::srcDevice and ::srcPitch
  9747. * specify the (unified virtual address space) base address of the source data
  9748. * and the bytes per row to apply. ::srcArray is ignored.
  9749. * This value may be used only if unified addressing is supported in the calling
  9750. * context.
  9751. *
  9752. * \par
  9753. * If ::srcMemoryType is ::CU_MEMORYTYPE_HOST, ::srcHost and ::srcPitch
  9754. * specify the (host) base address of the source data and the bytes per row to
  9755. * apply. ::srcArray is ignored.
  9756. *
  9757. * \par
  9758. * If ::srcMemoryType is ::CU_MEMORYTYPE_DEVICE, ::srcDevice and ::srcPitch
  9759. * specify the (device) base address of the source data and the bytes per row
  9760. * to apply. ::srcArray is ignored.
  9761. *
  9762. * \par
  9763. * If ::srcMemoryType is ::CU_MEMORYTYPE_ARRAY, ::srcArray specifies the
  9764. * handle of the source data. ::srcHost, ::srcDevice and ::srcPitch are
  9765. * ignored.
  9766. *
  9767. * \par
  9768. * If ::dstMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::dstDevice and ::dstPitch
  9769. * specify the (unified virtual address space) base address of the source data
  9770. * and the bytes per row to apply. ::dstArray is ignored.
  9771. * This value may be used only if unified addressing is supported in the calling
  9772. * context.
  9773. *
  9774. * \par
  9775. * If ::dstMemoryType is ::CU_MEMORYTYPE_HOST, ::dstHost and ::dstPitch
  9776. * specify the (host) base address of the destination data and the bytes per
  9777. * row to apply. ::dstArray is ignored.
  9778. *
  9779. * \par
  9780. * If ::dstMemoryType is ::CU_MEMORYTYPE_DEVICE, ::dstDevice and ::dstPitch
  9781. * specify the (device) base address of the destination data and the bytes per
  9782. * row to apply. ::dstArray is ignored.
  9783. *
  9784. * \par
  9785. * If ::dstMemoryType is ::CU_MEMORYTYPE_ARRAY, ::dstArray specifies the
  9786. * handle of the destination data. ::dstHost, ::dstDevice and ::dstPitch are
  9787. * ignored.
  9788. *
  9789. * - ::srcXInBytes and ::srcY specify the base address of the source data for
  9790. * the copy.
  9791. *
  9792. * \par
  9793. * For host pointers, the starting address is
  9794. * \code
  9795. void* Start = (void*)((char*)srcHost+srcY*srcPitch + srcXInBytes);
  9796. * \endcode
  9797. *
  9798. * \par
  9799. * For device pointers, the starting address is
  9800. * \code
  9801. CUdeviceptr Start = srcDevice+srcY*srcPitch+srcXInBytes;
  9802. * \endcode
  9803. *
  9804. * \par
  9805. * For CUDA arrays, ::srcXInBytes must be evenly divisible by the array
  9806. * element size.
  9807. *
  9808. * - ::dstXInBytes and ::dstY specify the base address of the destination data
  9809. * for the copy.
  9810. *
  9811. * \par
  9812. * For host pointers, the base address is
  9813. * \code
  9814. void* dstStart = (void*)((char*)dstHost+dstY*dstPitch + dstXInBytes);
  9815. * \endcode
  9816. *
  9817. * \par
  9818. * For device pointers, the starting address is
  9819. * \code
  9820. CUdeviceptr dstStart = dstDevice+dstY*dstPitch+dstXInBytes;
  9821. * \endcode
  9822. *
  9823. * \par
  9824. * For CUDA arrays, ::dstXInBytes must be evenly divisible by the array
  9825. * element size.
  9826. *
  9827. * - ::WidthInBytes and ::Height specify the width (in bytes) and height of
  9828. * the 2D copy being performed.
  9829. * - If specified, ::srcPitch must be greater than or equal to ::WidthInBytes +
  9830. * ::srcXInBytes, and ::dstPitch must be greater than or equal to
  9831. * ::WidthInBytes + dstXInBytes.
  9832. *
  9833. * \par
  9834. * ::cuMemcpy2D() returns an error if any pitch is greater than the maximum
  9835. * allowed (::CU_DEVICE_ATTRIBUTE_MAX_PITCH). ::cuMemAllocPitch() passes back
  9836. * pitches that always work with ::cuMemcpy2D(). On intra-device memory copies
  9837. * (device to device, CUDA array to device, CUDA array to CUDA array),
  9838. * ::cuMemcpy2D() may fail for pitches not computed by ::cuMemAllocPitch().
  9839. * ::cuMemcpy2DUnaligned() does not have this restriction, but may run
  9840. * significantly slower in the cases where ::cuMemcpy2D() would have returned
  9841. * an error code.
  9842. *
  9843. * \param pCopy - Parameters for the memory copy
  9844. *
  9845. * \return
  9846. * ::CUDA_SUCCESS,
  9847. * ::CUDA_ERROR_DEINITIALIZED,
  9848. * ::CUDA_ERROR_NOT_INITIALIZED,
  9849. * ::CUDA_ERROR_INVALID_CONTEXT,
  9850. * ::CUDA_ERROR_INVALID_VALUE
  9851. * \notefnerr
  9852. * \note_sync
  9853. *
  9854. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  9855. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  9856. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync,
  9857. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  9858. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  9859. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  9860. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  9861. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  9862. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  9863. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  9864. * ::cudaMemcpy2D,
  9865. * ::cudaMemcpy2DToArray,
  9866. * ::cudaMemcpy2DFromArray
  9867. */
  9868. CUresult CUDAAPI cuMemcpy2DUnaligned(const CUDA_MEMCPY2D *pCopy);
  9869. /**
  9870. * \brief Copies memory for 3D arrays
  9871. *
  9872. * Perform a 3D memory copy according to the parameters specified in
  9873. * \p pCopy. The ::CUDA_MEMCPY3D structure is defined as:
  9874. *
  9875. * \code
  9876. typedef struct CUDA_MEMCPY3D_st {
  9877. unsigned int srcXInBytes, srcY, srcZ;
  9878. unsigned int srcLOD;
  9879. CUmemorytype srcMemoryType;
  9880. const void *srcHost;
  9881. CUdeviceptr srcDevice;
  9882. CUarray srcArray;
  9883. unsigned int srcPitch; // ignored when src is array
  9884. unsigned int srcHeight; // ignored when src is array; may be 0 if Depth==1
  9885. unsigned int dstXInBytes, dstY, dstZ;
  9886. unsigned int dstLOD;
  9887. CUmemorytype dstMemoryType;
  9888. void *dstHost;
  9889. CUdeviceptr dstDevice;
  9890. CUarray dstArray;
  9891. unsigned int dstPitch; // ignored when dst is array
  9892. unsigned int dstHeight; // ignored when dst is array; may be 0 if Depth==1
  9893. unsigned int WidthInBytes;
  9894. unsigned int Height;
  9895. unsigned int Depth;
  9896. } CUDA_MEMCPY3D;
  9897. * \endcode
  9898. * where:
  9899. * - ::srcMemoryType and ::dstMemoryType specify the type of memory of the
  9900. * source and destination, respectively; ::CUmemorytype_enum is defined as:
  9901. *
  9902. * \code
  9903. typedef enum CUmemorytype_enum {
  9904. CU_MEMORYTYPE_HOST = 0x01,
  9905. CU_MEMORYTYPE_DEVICE = 0x02,
  9906. CU_MEMORYTYPE_ARRAY = 0x03,
  9907. CU_MEMORYTYPE_UNIFIED = 0x04
  9908. } CUmemorytype;
  9909. * \endcode
  9910. *
  9911. * \par
  9912. * If ::srcMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::srcDevice and ::srcPitch
  9913. * specify the (unified virtual address space) base address of the source data
  9914. * and the bytes per row to apply. ::srcArray is ignored.
  9915. * This value may be used only if unified addressing is supported in the calling
  9916. * context.
  9917. *
  9918. * \par
  9919. * If ::srcMemoryType is ::CU_MEMORYTYPE_HOST, ::srcHost, ::srcPitch and
  9920. * ::srcHeight specify the (host) base address of the source data, the bytes
  9921. * per row, and the height of each 2D slice of the 3D array. ::srcArray is
  9922. * ignored.
  9923. *
  9924. * \par
  9925. * If ::srcMemoryType is ::CU_MEMORYTYPE_DEVICE, ::srcDevice, ::srcPitch and
  9926. * ::srcHeight specify the (device) base address of the source data, the bytes
  9927. * per row, and the height of each 2D slice of the 3D array. ::srcArray is
  9928. * ignored.
  9929. *
  9930. * \par
  9931. * If ::srcMemoryType is ::CU_MEMORYTYPE_ARRAY, ::srcArray specifies the
  9932. * handle of the source data. ::srcHost, ::srcDevice, ::srcPitch and
  9933. * ::srcHeight are ignored.
  9934. *
  9935. * \par
  9936. * If ::dstMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::dstDevice and ::dstPitch
  9937. * specify the (unified virtual address space) base address of the source data
  9938. * and the bytes per row to apply. ::dstArray is ignored.
  9939. * This value may be used only if unified addressing is supported in the calling
  9940. * context.
  9941. *
  9942. * \par
  9943. * If ::dstMemoryType is ::CU_MEMORYTYPE_HOST, ::dstHost and ::dstPitch
  9944. * specify the (host) base address of the destination data, the bytes per row,
  9945. * and the height of each 2D slice of the 3D array. ::dstArray is ignored.
  9946. *
  9947. * \par
  9948. * If ::dstMemoryType is ::CU_MEMORYTYPE_DEVICE, ::dstDevice and ::dstPitch
  9949. * specify the (device) base address of the destination data, the bytes per
  9950. * row, and the height of each 2D slice of the 3D array. ::dstArray is ignored.
  9951. *
  9952. * \par
  9953. * If ::dstMemoryType is ::CU_MEMORYTYPE_ARRAY, ::dstArray specifies the
  9954. * handle of the destination data. ::dstHost, ::dstDevice, ::dstPitch and
  9955. * ::dstHeight are ignored.
  9956. *
  9957. * - ::srcXInBytes, ::srcY and ::srcZ specify the base address of the source
  9958. * data for the copy.
  9959. *
  9960. * \par
  9961. * For host pointers, the starting address is
  9962. * \code
  9963. void* Start = (void*)((char*)srcHost+(srcZ*srcHeight+srcY)*srcPitch + srcXInBytes);
  9964. * \endcode
  9965. *
  9966. * \par
  9967. * For device pointers, the starting address is
  9968. * \code
  9969. CUdeviceptr Start = srcDevice+(srcZ*srcHeight+srcY)*srcPitch+srcXInBytes;
  9970. * \endcode
  9971. *
  9972. * \par
  9973. * For CUDA arrays, ::srcXInBytes must be evenly divisible by the array
  9974. * element size.
  9975. *
  9976. * - dstXInBytes, ::dstY and ::dstZ specify the base address of the
  9977. * destination data for the copy.
  9978. *
  9979. * \par
  9980. * For host pointers, the base address is
  9981. * \code
  9982. void* dstStart = (void*)((char*)dstHost+(dstZ*dstHeight+dstY)*dstPitch + dstXInBytes);
  9983. * \endcode
  9984. *
  9985. * \par
  9986. * For device pointers, the starting address is
  9987. * \code
  9988. CUdeviceptr dstStart = dstDevice+(dstZ*dstHeight+dstY)*dstPitch+dstXInBytes;
  9989. * \endcode
  9990. *
  9991. * \par
  9992. * For CUDA arrays, ::dstXInBytes must be evenly divisible by the array
  9993. * element size.
  9994. *
  9995. * - ::WidthInBytes, ::Height and ::Depth specify the width (in bytes), height
  9996. * and depth of the 3D copy being performed.
  9997. * - If specified, ::srcPitch must be greater than or equal to ::WidthInBytes +
  9998. * ::srcXInBytes, and ::dstPitch must be greater than or equal to
  9999. * ::WidthInBytes + dstXInBytes.
  10000. * - If specified, ::srcHeight must be greater than or equal to ::Height +
  10001. * ::srcY, and ::dstHeight must be greater than or equal to ::Height + ::dstY.
  10002. *
  10003. * \par
  10004. * ::cuMemcpy3D() returns an error if any pitch is greater than the maximum
  10005. * allowed (::CU_DEVICE_ATTRIBUTE_MAX_PITCH).
  10006. *
  10007. * The ::srcLOD and ::dstLOD members of the ::CUDA_MEMCPY3D structure must be
  10008. * set to 0.
  10009. *
  10010. * \param pCopy - Parameters for the memory copy
  10011. *
  10012. * \return
  10013. * ::CUDA_SUCCESS,
  10014. * ::CUDA_ERROR_DEINITIALIZED,
  10015. * ::CUDA_ERROR_NOT_INITIALIZED,
  10016. * ::CUDA_ERROR_INVALID_CONTEXT,
  10017. * ::CUDA_ERROR_INVALID_VALUE
  10018. * \notefnerr
  10019. * \note_sync
  10020. *
  10021. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10022. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10023. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10024. * ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10025. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10026. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10027. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10028. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10029. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  10030. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  10031. * ::cudaMemcpy3D
  10032. */
  10033. CUresult CUDAAPI cuMemcpy3D(const CUDA_MEMCPY3D *pCopy);
  10034. /**
  10035. * \brief Copies memory between contexts
  10036. *
  10037. * Perform a 3D memory copy according to the parameters specified in
  10038. * \p pCopy. See the definition of the ::CUDA_MEMCPY3D_PEER structure
  10039. * for documentation of its parameters.
  10040. *
  10041. * \param pCopy - Parameters for the memory copy
  10042. *
  10043. * \return
  10044. * ::CUDA_SUCCESS,
  10045. * ::CUDA_ERROR_DEINITIALIZED,
  10046. * ::CUDA_ERROR_NOT_INITIALIZED,
  10047. * ::CUDA_ERROR_INVALID_CONTEXT,
  10048. * ::CUDA_ERROR_INVALID_VALUE
  10049. * \notefnerr
  10050. * \note_sync
  10051. *
  10052. * \sa ::cuMemcpyDtoD, ::cuMemcpyPeer, ::cuMemcpyDtoDAsync, ::cuMemcpyPeerAsync,
  10053. * ::cuMemcpy3DPeerAsync,
  10054. * ::cudaMemcpy3DPeer
  10055. */
  10056. CUresult CUDAAPI cuMemcpy3DPeer(const CUDA_MEMCPY3D_PEER *pCopy);
  10057. /**
  10058. * \brief Copies memory asynchronously
  10059. *
  10060. * Copies data between two pointers.
  10061. * \p dst and \p src are base pointers of the destination and source, respectively.
  10062. * \p ByteCount specifies the number of bytes to copy.
  10063. * Note that this function infers the type of the transfer (host to host, host to
  10064. * device, device to device, or device to host) from the pointer values. This
  10065. * function is only allowed in contexts which support unified addressing.
  10066. *
  10067. * \param dst - Destination unified virtual address space pointer
  10068. * \param src - Source unified virtual address space pointer
  10069. * \param ByteCount - Size of memory copy in bytes
  10070. * \param hStream - Stream identifier
  10071. *
  10072. * \return
  10073. * ::CUDA_SUCCESS,
  10074. * ::CUDA_ERROR_DEINITIALIZED,
  10075. * ::CUDA_ERROR_NOT_INITIALIZED,
  10076. * ::CUDA_ERROR_INVALID_CONTEXT,
  10077. * ::CUDA_ERROR_INVALID_VALUE,
  10078. * ::CUDA_ERROR_INVALID_HANDLE
  10079. * \notefnerr
  10080. * \note_async
  10081. * \note_null_stream
  10082. * \note_memcpy
  10083. *
  10084. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10085. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10086. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10087. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10088. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD,
  10089. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10090. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10091. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10092. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10093. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10094. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10095. * ::cuMemsetD32, ::cuMemsetD32Async,
  10096. * ::cudaMemcpyAsync,
  10097. * ::cudaMemcpyToSymbolAsync,
  10098. * ::cudaMemcpyFromSymbolAsync
  10099. */
  10100. CUresult CUDAAPI cuMemcpyAsync(CUdeviceptr dst, CUdeviceptr src, size_t ByteCount, CUstream hStream);
  10101. /**
  10102. * \brief Copies device memory between two contexts asynchronously.
  10103. *
  10104. * Copies from device memory in one context to device memory in another
  10105. * context. \p dstDevice is the base device pointer of the destination memory
  10106. * and \p dstContext is the destination context. \p srcDevice is the base
  10107. * device pointer of the source memory and \p srcContext is the source pointer.
  10108. * \p ByteCount specifies the number of bytes to copy.
  10109. *
  10110. * \param dstDevice - Destination device pointer
  10111. * \param dstContext - Destination context
  10112. * \param srcDevice - Source device pointer
  10113. * \param srcContext - Source context
  10114. * \param ByteCount - Size of memory copy in bytes
  10115. * \param hStream - Stream identifier
  10116. *
  10117. * \return
  10118. * ::CUDA_SUCCESS,
  10119. * ::CUDA_ERROR_DEINITIALIZED,
  10120. * ::CUDA_ERROR_NOT_INITIALIZED,
  10121. * ::CUDA_ERROR_INVALID_CONTEXT,
  10122. * ::CUDA_ERROR_INVALID_VALUE,
  10123. * ::CUDA_ERROR_INVALID_HANDLE
  10124. * \notefnerr
  10125. * \note_async
  10126. * \note_null_stream
  10127. *
  10128. * \sa ::cuMemcpyDtoD, ::cuMemcpyPeer, ::cuMemcpy3DPeer, ::cuMemcpyDtoDAsync,
  10129. * ::cuMemcpy3DPeerAsync,
  10130. * ::cudaMemcpyPeerAsync
  10131. */
  10132. CUresult CUDAAPI cuMemcpyPeerAsync(CUdeviceptr dstDevice, CUcontext dstContext, CUdeviceptr srcDevice, CUcontext srcContext, size_t ByteCount, CUstream hStream);
  10133. /**
  10134. * \brief Copies memory from Host to Device
  10135. *
  10136. * Copies from host memory to device memory. \p dstDevice and \p srcHost are
  10137. * the base addresses of the destination and source, respectively. \p ByteCount
  10138. * specifies the number of bytes to copy.
  10139. *
  10140. * \param dstDevice - Destination device pointer
  10141. * \param srcHost - Source host pointer
  10142. * \param ByteCount - Size of memory copy in bytes
  10143. * \param hStream - Stream identifier
  10144. *
  10145. * \return
  10146. * ::CUDA_SUCCESS,
  10147. * ::CUDA_ERROR_DEINITIALIZED,
  10148. * ::CUDA_ERROR_NOT_INITIALIZED,
  10149. * ::CUDA_ERROR_INVALID_CONTEXT,
  10150. * ::CUDA_ERROR_INVALID_VALUE,
  10151. * ::CUDA_ERROR_INVALID_HANDLE
  10152. * \notefnerr
  10153. * \note_async
  10154. * \note_null_stream
  10155. * \note_memcpy
  10156. *
  10157. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10158. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10159. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10160. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10161. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10162. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10163. * ::cuMemcpyHtoD, ::cuMemFree, ::cuMemFreeHost,
  10164. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10165. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10166. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10167. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10168. * ::cuMemsetD32, ::cuMemsetD32Async,
  10169. * ::cudaMemcpyAsync,
  10170. * ::cudaMemcpyToSymbolAsync
  10171. */
  10172. CUresult CUDAAPI cuMemcpyHtoDAsync(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount, CUstream hStream);
  10173. /**
  10174. * \brief Copies memory from Device to Host
  10175. *
  10176. * Copies from device to host memory. \p dstHost and \p srcDevice specify the
  10177. * base pointers of the destination and source, respectively. \p ByteCount
  10178. * specifies the number of bytes to copy.
  10179. *
  10180. * \param dstHost - Destination host pointer
  10181. * \param srcDevice - Source device pointer
  10182. * \param ByteCount - Size of memory copy in bytes
  10183. * \param hStream - Stream identifier
  10184. *
  10185. * \return
  10186. * ::CUDA_SUCCESS,
  10187. * ::CUDA_ERROR_DEINITIALIZED,
  10188. * ::CUDA_ERROR_NOT_INITIALIZED,
  10189. * ::CUDA_ERROR_INVALID_CONTEXT,
  10190. * ::CUDA_ERROR_INVALID_VALUE,
  10191. * ::CUDA_ERROR_INVALID_HANDLE
  10192. * \notefnerr
  10193. * \note_async
  10194. * \note_null_stream
  10195. * \note_memcpy
  10196. *
  10197. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10198. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10199. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10200. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10201. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10202. * ::cuMemcpyDtoH, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10203. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10204. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10205. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10206. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10207. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10208. * ::cuMemsetD32, ::cuMemsetD32Async,
  10209. * ::cudaMemcpyAsync,
  10210. * ::cudaMemcpyFromSymbolAsync
  10211. */
  10212. CUresult CUDAAPI cuMemcpyDtoHAsync(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream);
  10213. /**
  10214. * \brief Copies memory from Device to Device
  10215. *
  10216. * Copies from device memory to device memory. \p dstDevice and \p srcDevice
  10217. * are the base pointers of the destination and source, respectively.
  10218. * \p ByteCount specifies the number of bytes to copy.
  10219. *
  10220. * \param dstDevice - Destination device pointer
  10221. * \param srcDevice - Source device pointer
  10222. * \param ByteCount - Size of memory copy in bytes
  10223. * \param hStream - Stream identifier
  10224. *
  10225. * \return
  10226. * ::CUDA_SUCCESS,
  10227. * ::CUDA_ERROR_DEINITIALIZED,
  10228. * ::CUDA_ERROR_NOT_INITIALIZED,
  10229. * ::CUDA_ERROR_INVALID_CONTEXT,
  10230. * ::CUDA_ERROR_INVALID_VALUE,
  10231. * ::CUDA_ERROR_INVALID_HANDLE
  10232. * \notefnerr
  10233. * \note_async
  10234. * \note_null_stream
  10235. *
  10236. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10237. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10238. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10239. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10240. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD,
  10241. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10242. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10243. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10244. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10245. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10246. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10247. * ::cuMemsetD32, ::cuMemsetD32Async,
  10248. * ::cudaMemcpyAsync,
  10249. * ::cudaMemcpyToSymbolAsync,
  10250. * ::cudaMemcpyFromSymbolAsync
  10251. */
  10252. CUresult CUDAAPI cuMemcpyDtoDAsync(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream);
  10253. /**
  10254. * \brief Copies memory from Host to Array
  10255. *
  10256. * Copies from host memory to a 1D CUDA array. \p dstArray and \p dstOffset
  10257. * specify the CUDA array handle and starting offset in bytes of the
  10258. * destination data. \p srcHost specifies the base address of the source.
  10259. * \p ByteCount specifies the number of bytes to copy.
  10260. *
  10261. * \param dstArray - Destination array
  10262. * \param dstOffset - Offset in bytes of destination array
  10263. * \param srcHost - Source host pointer
  10264. * \param ByteCount - Size of memory copy in bytes
  10265. * \param hStream - Stream identifier
  10266. *
  10267. * \return
  10268. * ::CUDA_SUCCESS,
  10269. * ::CUDA_ERROR_DEINITIALIZED,
  10270. * ::CUDA_ERROR_NOT_INITIALIZED,
  10271. * ::CUDA_ERROR_INVALID_CONTEXT,
  10272. * ::CUDA_ERROR_INVALID_VALUE,
  10273. * ::CUDA_ERROR_INVALID_HANDLE
  10274. * \notefnerr
  10275. * \note_async
  10276. * \note_null_stream
  10277. * \note_memcpy
  10278. *
  10279. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10280. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10281. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10282. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10283. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10284. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA,
  10285. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10286. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10287. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10288. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10289. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10290. * ::cuMemsetD32, ::cuMemsetD32Async,
  10291. * ::cudaMemcpyToArrayAsync
  10292. */
  10293. CUresult CUDAAPI cuMemcpyHtoAAsync(CUarray dstArray, size_t dstOffset, const void *srcHost, size_t ByteCount, CUstream hStream);
  10294. /**
  10295. * \brief Copies memory from Array to Host
  10296. *
  10297. * Copies from one 1D CUDA array to host memory. \p dstHost specifies the base
  10298. * pointer of the destination. \p srcArray and \p srcOffset specify the CUDA
  10299. * array handle and starting offset in bytes of the source data.
  10300. * \p ByteCount specifies the number of bytes to copy.
  10301. *
  10302. * \param dstHost - Destination pointer
  10303. * \param srcArray - Source array
  10304. * \param srcOffset - Offset in bytes of source array
  10305. * \param ByteCount - Size of memory copy in bytes
  10306. * \param hStream - Stream identifier
  10307. *
  10308. * \return
  10309. * ::CUDA_SUCCESS,
  10310. * ::CUDA_ERROR_DEINITIALIZED,
  10311. * ::CUDA_ERROR_NOT_INITIALIZED,
  10312. * ::CUDA_ERROR_INVALID_CONTEXT,
  10313. * ::CUDA_ERROR_INVALID_VALUE,
  10314. * ::CUDA_ERROR_INVALID_HANDLE
  10315. * \notefnerr
  10316. * \note_async
  10317. * \note_null_stream
  10318. * \note_memcpy
  10319. *
  10320. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10321. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10322. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10323. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10324. * ::cuMemcpyAtoH, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10325. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10326. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10327. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10328. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10329. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10330. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10331. * ::cuMemsetD32, ::cuMemsetD32Async,
  10332. * ::cudaMemcpyFromArrayAsync
  10333. */
  10334. CUresult CUDAAPI cuMemcpyAtoHAsync(void *dstHost, CUarray srcArray, size_t srcOffset, size_t ByteCount, CUstream hStream);
  10335. /**
  10336. * \brief Copies memory for 2D arrays
  10337. *
  10338. * Perform a 2D memory copy according to the parameters specified in \p pCopy.
  10339. * The ::CUDA_MEMCPY2D structure is defined as:
  10340. *
  10341. * \code
  10342. typedef struct CUDA_MEMCPY2D_st {
  10343. unsigned int srcXInBytes, srcY;
  10344. CUmemorytype srcMemoryType;
  10345. const void *srcHost;
  10346. CUdeviceptr srcDevice;
  10347. CUarray srcArray;
  10348. unsigned int srcPitch;
  10349. unsigned int dstXInBytes, dstY;
  10350. CUmemorytype dstMemoryType;
  10351. void *dstHost;
  10352. CUdeviceptr dstDevice;
  10353. CUarray dstArray;
  10354. unsigned int dstPitch;
  10355. unsigned int WidthInBytes;
  10356. unsigned int Height;
  10357. } CUDA_MEMCPY2D;
  10358. * \endcode
  10359. * where:
  10360. * - ::srcMemoryType and ::dstMemoryType specify the type of memory of the
  10361. * source and destination, respectively; ::CUmemorytype_enum is defined as:
  10362. *
  10363. * \code
  10364. typedef enum CUmemorytype_enum {
  10365. CU_MEMORYTYPE_HOST = 0x01,
  10366. CU_MEMORYTYPE_DEVICE = 0x02,
  10367. CU_MEMORYTYPE_ARRAY = 0x03,
  10368. CU_MEMORYTYPE_UNIFIED = 0x04
  10369. } CUmemorytype;
  10370. * \endcode
  10371. *
  10372. * \par
  10373. * If ::srcMemoryType is ::CU_MEMORYTYPE_HOST, ::srcHost and ::srcPitch
  10374. * specify the (host) base address of the source data and the bytes per row to
  10375. * apply. ::srcArray is ignored.
  10376. *
  10377. * \par
  10378. * If ::srcMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::srcDevice and ::srcPitch
  10379. * specify the (unified virtual address space) base address of the source data
  10380. * and the bytes per row to apply. ::srcArray is ignored.
  10381. * This value may be used only if unified addressing is supported in the calling
  10382. * context.
  10383. *
  10384. * \par
  10385. * If ::srcMemoryType is ::CU_MEMORYTYPE_DEVICE, ::srcDevice and ::srcPitch
  10386. * specify the (device) base address of the source data and the bytes per row
  10387. * to apply. ::srcArray is ignored.
  10388. *
  10389. * \par
  10390. * If ::srcMemoryType is ::CU_MEMORYTYPE_ARRAY, ::srcArray specifies the
  10391. * handle of the source data. ::srcHost, ::srcDevice and ::srcPitch are
  10392. * ignored.
  10393. *
  10394. * \par
  10395. * If ::dstMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::dstDevice and ::dstPitch
  10396. * specify the (unified virtual address space) base address of the source data
  10397. * and the bytes per row to apply. ::dstArray is ignored.
  10398. * This value may be used only if unified addressing is supported in the calling
  10399. * context.
  10400. *
  10401. * \par
  10402. * If ::dstMemoryType is ::CU_MEMORYTYPE_HOST, ::dstHost and ::dstPitch
  10403. * specify the (host) base address of the destination data and the bytes per
  10404. * row to apply. ::dstArray is ignored.
  10405. *
  10406. * \par
  10407. * If ::dstMemoryType is ::CU_MEMORYTYPE_DEVICE, ::dstDevice and ::dstPitch
  10408. * specify the (device) base address of the destination data and the bytes per
  10409. * row to apply. ::dstArray is ignored.
  10410. *
  10411. * \par
  10412. * If ::dstMemoryType is ::CU_MEMORYTYPE_ARRAY, ::dstArray specifies the
  10413. * handle of the destination data. ::dstHost, ::dstDevice and ::dstPitch are
  10414. * ignored.
  10415. *
  10416. * - ::srcXInBytes and ::srcY specify the base address of the source data for
  10417. * the copy.
  10418. *
  10419. * \par
  10420. * For host pointers, the starting address is
  10421. * \code
  10422. void* Start = (void*)((char*)srcHost+srcY*srcPitch + srcXInBytes);
  10423. * \endcode
  10424. *
  10425. * \par
  10426. * For device pointers, the starting address is
  10427. * \code
  10428. CUdeviceptr Start = srcDevice+srcY*srcPitch+srcXInBytes;
  10429. * \endcode
  10430. *
  10431. * \par
  10432. * For CUDA arrays, ::srcXInBytes must be evenly divisible by the array
  10433. * element size.
  10434. *
  10435. * - ::dstXInBytes and ::dstY specify the base address of the destination data
  10436. * for the copy.
  10437. *
  10438. * \par
  10439. * For host pointers, the base address is
  10440. * \code
  10441. void* dstStart = (void*)((char*)dstHost+dstY*dstPitch + dstXInBytes);
  10442. * \endcode
  10443. *
  10444. * \par
  10445. * For device pointers, the starting address is
  10446. * \code
  10447. CUdeviceptr dstStart = dstDevice+dstY*dstPitch+dstXInBytes;
  10448. * \endcode
  10449. *
  10450. * \par
  10451. * For CUDA arrays, ::dstXInBytes must be evenly divisible by the array
  10452. * element size.
  10453. *
  10454. * - ::WidthInBytes and ::Height specify the width (in bytes) and height of
  10455. * the 2D copy being performed.
  10456. * - If specified, ::srcPitch must be greater than or equal to ::WidthInBytes +
  10457. * ::srcXInBytes, and ::dstPitch must be greater than or equal to
  10458. * ::WidthInBytes + dstXInBytes.
  10459. * - If specified, ::srcPitch must be greater than or equal to ::WidthInBytes +
  10460. * ::srcXInBytes, and ::dstPitch must be greater than or equal to
  10461. * ::WidthInBytes + dstXInBytes.
  10462. * - If specified, ::srcHeight must be greater than or equal to ::Height +
  10463. * ::srcY, and ::dstHeight must be greater than or equal to ::Height + ::dstY.
  10464. *
  10465. * \par
  10466. * ::cuMemcpy2DAsync() returns an error if any pitch is greater than the maximum
  10467. * allowed (::CU_DEVICE_ATTRIBUTE_MAX_PITCH). ::cuMemAllocPitch() passes back
  10468. * pitches that always work with ::cuMemcpy2D(). On intra-device memory copies
  10469. * (device to device, CUDA array to device, CUDA array to CUDA array),
  10470. * ::cuMemcpy2DAsync() may fail for pitches not computed by ::cuMemAllocPitch().
  10471. *
  10472. * \param pCopy - Parameters for the memory copy
  10473. * \param hStream - Stream identifier
  10474. *
  10475. * \return
  10476. * ::CUDA_SUCCESS,
  10477. * ::CUDA_ERROR_DEINITIALIZED,
  10478. * ::CUDA_ERROR_NOT_INITIALIZED,
  10479. * ::CUDA_ERROR_INVALID_CONTEXT,
  10480. * ::CUDA_ERROR_INVALID_VALUE,
  10481. * ::CUDA_ERROR_INVALID_HANDLE
  10482. * \notefnerr
  10483. * \note_async
  10484. * \note_null_stream
  10485. *
  10486. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10487. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10488. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DUnaligned,
  10489. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10490. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10491. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10492. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10493. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10494. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10495. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10496. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10497. * ::cuMemsetD32, ::cuMemsetD32Async,
  10498. * ::cudaMemcpy2DAsync,
  10499. * ::cudaMemcpy2DToArrayAsync,
  10500. * ::cudaMemcpy2DFromArrayAsync
  10501. */
  10502. CUresult CUDAAPI cuMemcpy2DAsync(const CUDA_MEMCPY2D *pCopy, CUstream hStream);
  10503. /**
  10504. * \brief Copies memory for 3D arrays
  10505. *
  10506. * Perform a 3D memory copy according to the parameters specified in
  10507. * \p pCopy. The ::CUDA_MEMCPY3D structure is defined as:
  10508. *
  10509. * \code
  10510. typedef struct CUDA_MEMCPY3D_st {
  10511. unsigned int srcXInBytes, srcY, srcZ;
  10512. unsigned int srcLOD;
  10513. CUmemorytype srcMemoryType;
  10514. const void *srcHost;
  10515. CUdeviceptr srcDevice;
  10516. CUarray srcArray;
  10517. unsigned int srcPitch; // ignored when src is array
  10518. unsigned int srcHeight; // ignored when src is array; may be 0 if Depth==1
  10519. unsigned int dstXInBytes, dstY, dstZ;
  10520. unsigned int dstLOD;
  10521. CUmemorytype dstMemoryType;
  10522. void *dstHost;
  10523. CUdeviceptr dstDevice;
  10524. CUarray dstArray;
  10525. unsigned int dstPitch; // ignored when dst is array
  10526. unsigned int dstHeight; // ignored when dst is array; may be 0 if Depth==1
  10527. unsigned int WidthInBytes;
  10528. unsigned int Height;
  10529. unsigned int Depth;
  10530. } CUDA_MEMCPY3D;
  10531. * \endcode
  10532. * where:
  10533. * - ::srcMemoryType and ::dstMemoryType specify the type of memory of the
  10534. * source and destination, respectively; ::CUmemorytype_enum is defined as:
  10535. *
  10536. * \code
  10537. typedef enum CUmemorytype_enum {
  10538. CU_MEMORYTYPE_HOST = 0x01,
  10539. CU_MEMORYTYPE_DEVICE = 0x02,
  10540. CU_MEMORYTYPE_ARRAY = 0x03,
  10541. CU_MEMORYTYPE_UNIFIED = 0x04
  10542. } CUmemorytype;
  10543. * \endcode
  10544. *
  10545. * \par
  10546. * If ::srcMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::srcDevice and ::srcPitch
  10547. * specify the (unified virtual address space) base address of the source data
  10548. * and the bytes per row to apply. ::srcArray is ignored.
  10549. * This value may be used only if unified addressing is supported in the calling
  10550. * context.
  10551. *
  10552. * \par
  10553. * If ::srcMemoryType is ::CU_MEMORYTYPE_HOST, ::srcHost, ::srcPitch and
  10554. * ::srcHeight specify the (host) base address of the source data, the bytes
  10555. * per row, and the height of each 2D slice of the 3D array. ::srcArray is
  10556. * ignored.
  10557. *
  10558. * \par
  10559. * If ::srcMemoryType is ::CU_MEMORYTYPE_DEVICE, ::srcDevice, ::srcPitch and
  10560. * ::srcHeight specify the (device) base address of the source data, the bytes
  10561. * per row, and the height of each 2D slice of the 3D array. ::srcArray is
  10562. * ignored.
  10563. *
  10564. * \par
  10565. * If ::srcMemoryType is ::CU_MEMORYTYPE_ARRAY, ::srcArray specifies the
  10566. * handle of the source data. ::srcHost, ::srcDevice, ::srcPitch and
  10567. * ::srcHeight are ignored.
  10568. *
  10569. * \par
  10570. * If ::dstMemoryType is ::CU_MEMORYTYPE_UNIFIED, ::dstDevice and ::dstPitch
  10571. * specify the (unified virtual address space) base address of the source data
  10572. * and the bytes per row to apply. ::dstArray is ignored.
  10573. * This value may be used only if unified addressing is supported in the calling
  10574. * context.
  10575. *
  10576. * \par
  10577. * If ::dstMemoryType is ::CU_MEMORYTYPE_HOST, ::dstHost and ::dstPitch
  10578. * specify the (host) base address of the destination data, the bytes per row,
  10579. * and the height of each 2D slice of the 3D array. ::dstArray is ignored.
  10580. *
  10581. * \par
  10582. * If ::dstMemoryType is ::CU_MEMORYTYPE_DEVICE, ::dstDevice and ::dstPitch
  10583. * specify the (device) base address of the destination data, the bytes per
  10584. * row, and the height of each 2D slice of the 3D array. ::dstArray is ignored.
  10585. *
  10586. * \par
  10587. * If ::dstMemoryType is ::CU_MEMORYTYPE_ARRAY, ::dstArray specifies the
  10588. * handle of the destination data. ::dstHost, ::dstDevice, ::dstPitch and
  10589. * ::dstHeight are ignored.
  10590. *
  10591. * - ::srcXInBytes, ::srcY and ::srcZ specify the base address of the source
  10592. * data for the copy.
  10593. *
  10594. * \par
  10595. * For host pointers, the starting address is
  10596. * \code
  10597. void* Start = (void*)((char*)srcHost+(srcZ*srcHeight+srcY)*srcPitch + srcXInBytes);
  10598. * \endcode
  10599. *
  10600. * \par
  10601. * For device pointers, the starting address is
  10602. * \code
  10603. CUdeviceptr Start = srcDevice+(srcZ*srcHeight+srcY)*srcPitch+srcXInBytes;
  10604. * \endcode
  10605. *
  10606. * \par
  10607. * For CUDA arrays, ::srcXInBytes must be evenly divisible by the array
  10608. * element size.
  10609. *
  10610. * - dstXInBytes, ::dstY and ::dstZ specify the base address of the
  10611. * destination data for the copy.
  10612. *
  10613. * \par
  10614. * For host pointers, the base address is
  10615. * \code
  10616. void* dstStart = (void*)((char*)dstHost+(dstZ*dstHeight+dstY)*dstPitch + dstXInBytes);
  10617. * \endcode
  10618. *
  10619. * \par
  10620. * For device pointers, the starting address is
  10621. * \code
  10622. CUdeviceptr dstStart = dstDevice+(dstZ*dstHeight+dstY)*dstPitch+dstXInBytes;
  10623. * \endcode
  10624. *
  10625. * \par
  10626. * For CUDA arrays, ::dstXInBytes must be evenly divisible by the array
  10627. * element size.
  10628. *
  10629. * - ::WidthInBytes, ::Height and ::Depth specify the width (in bytes), height
  10630. * and depth of the 3D copy being performed.
  10631. * - If specified, ::srcPitch must be greater than or equal to ::WidthInBytes +
  10632. * ::srcXInBytes, and ::dstPitch must be greater than or equal to
  10633. * ::WidthInBytes + dstXInBytes.
  10634. * - If specified, ::srcHeight must be greater than or equal to ::Height +
  10635. * ::srcY, and ::dstHeight must be greater than or equal to ::Height + ::dstY.
  10636. *
  10637. * \par
  10638. * ::cuMemcpy3DAsync() returns an error if any pitch is greater than the maximum
  10639. * allowed (::CU_DEVICE_ATTRIBUTE_MAX_PITCH).
  10640. *
  10641. * The ::srcLOD and ::dstLOD members of the ::CUDA_MEMCPY3D structure must be
  10642. * set to 0.
  10643. *
  10644. * \param pCopy - Parameters for the memory copy
  10645. * \param hStream - Stream identifier
  10646. *
  10647. * \return
  10648. * ::CUDA_SUCCESS,
  10649. * ::CUDA_ERROR_DEINITIALIZED,
  10650. * ::CUDA_ERROR_NOT_INITIALIZED,
  10651. * ::CUDA_ERROR_INVALID_CONTEXT,
  10652. * ::CUDA_ERROR_INVALID_VALUE,
  10653. * ::CUDA_ERROR_INVALID_HANDLE
  10654. * \notefnerr
  10655. * \note_async
  10656. * \note_null_stream
  10657. *
  10658. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10659. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10660. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10661. * ::cuMemcpy3D, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10662. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10663. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10664. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10665. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10666. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10667. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10668. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10669. * ::cuMemsetD32, ::cuMemsetD32Async,
  10670. * ::cudaMemcpy3DAsync
  10671. */
  10672. CUresult CUDAAPI cuMemcpy3DAsync(const CUDA_MEMCPY3D *pCopy, CUstream hStream);
  10673. /**
  10674. * \brief Copies memory between contexts asynchronously.
  10675. *
  10676. * Perform a 3D memory copy according to the parameters specified in
  10677. * \p pCopy. See the definition of the ::CUDA_MEMCPY3D_PEER structure
  10678. * for documentation of its parameters.
  10679. *
  10680. * \param pCopy - Parameters for the memory copy
  10681. * \param hStream - Stream identifier
  10682. *
  10683. * \return
  10684. * ::CUDA_SUCCESS,
  10685. * ::CUDA_ERROR_DEINITIALIZED,
  10686. * ::CUDA_ERROR_NOT_INITIALIZED,
  10687. * ::CUDA_ERROR_INVALID_CONTEXT,
  10688. * ::CUDA_ERROR_INVALID_VALUE
  10689. * \notefnerr
  10690. * \note_async
  10691. * \note_null_stream
  10692. *
  10693. * \sa ::cuMemcpyDtoD, ::cuMemcpyPeer, ::cuMemcpyDtoDAsync, ::cuMemcpyPeerAsync,
  10694. * ::cuMemcpy3DPeerAsync,
  10695. * ::cudaMemcpy3DPeerAsync
  10696. */
  10697. CUresult CUDAAPI cuMemcpy3DPeerAsync(const CUDA_MEMCPY3D_PEER *pCopy, CUstream hStream);
  10698. /**
  10699. * \brief Performs a batch of memory copies asynchronously.
  10700. *
  10701. * Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a
  10702. * batch are not guaranteed to execute in any specific order. This API only supports pointer-to-pointer copies.
  10703. * For copies involving CUDA arrays, please see ::cuMemcpy3DBatchAsync.
  10704. *
  10705. * Performs memory copies from source buffers specified in \p srcs to destination buffers specified in \p dsts.
  10706. * The size of each copy is specified in \p sizes. All three arrays must be of the same length as specified
  10707. * by \p count. Since there are no ordering guarantees for copies within a batch, specifying any dependent copies
  10708. * within a batch will result in undefined behavior.
  10709. *
  10710. * Every copy in the batch has to be associated with a set of attributes specified in the \p attrs array.
  10711. * Each entry in this array can apply to more than one copy. This can be done by specifying in the \p attrsIdxs array,
  10712. * the index of the first copy that the corresponding entry in the \p attrs array applies to. Both \p attrs and
  10713. * \p attrsIdxs must be of the same length as specified by \p numAttrs. For example, if a batch has 10 copies listed
  10714. * in dst/src/sizes, the first 6 of which have one set of attributes and the remaining 4 another, then \p numAttrs
  10715. * will be 2, \p attrsIdxs will be {0, 6} and \p attrs will contains the two sets of attributes. Note that the first entry
  10716. * in \p attrsIdxs must always be 0. Also, each entry must be greater than the previous entry and the last entry should be
  10717. * less than \p count. Furthermore, \p numAttrs must be lesser than or equal to \p count.
  10718. *
  10719. * The ::CUmemcpyAttributes::srcAccessOrder indicates the source access ordering to be observed for copies associated
  10720. * with the attribute. If the source access order is set to ::CU_MEMCPY_SRC_ACCESS_ORDER_STREAM, then the source will
  10721. * be accessed in stream order. If the source access order is set to ::CU_MEMCPY_SRC_ACCESS_ORDER_DURING_API_CALL then
  10722. * it indicates that access to the source pointer can be out of stream order and all accesses must be complete before
  10723. * the API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior
  10724. * operations in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope
  10725. * that the source variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the
  10726. * need for the user to synchronize the stream after the API call. If the source access order is set to
  10727. * ::CU_MEMCPY_SRC_ACCESS_ORDER_ANY then it indicates that access to the source pointer can be out of stream order and the
  10728. * accesses can happen even after the API call returns. This flag is suited for host pointers allocated
  10729. * outside CUDA (ex., via malloc) when it's known that no prior operations in the stream can be accessing the memory.
  10730. * Specifying this flag allows the driver to optimize the copy on certain platforms. Each memcpy operation in the batch must
  10731. * have a valid ::CUmemcpyAttributes corresponding to it including the appropriate srcAccessOrder setting, otherwise the API
  10732. * will return ::CUDA_ERROR_INVALID_VALUE.
  10733. *
  10734. * The ::CUmemcpyAttributes::srcLocHint and ::CUmemcpyAttributes::dstLocHint allows applications to specify hint locations
  10735. * for operands of a copy when the operand doesn't have a fixed location. That is, these hints are
  10736. * only applicable for managed memory pointers on devices where ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS is true or
  10737. * system-allocated pageable memory on devices where ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS is true.
  10738. * For other cases, these hints are ignored.
  10739. *
  10740. * The ::CUmemcpyAttributes::flags field can be used to specify certain flags for copies. Setting the
  10741. * ::CU_MEMCPY_FLAG_PREFER_OVERLAP_WITH_COMPUTE flag indicates that the associated copies should preferably overlap with
  10742. * any compute work. Note that this flag is a hint and can be ignored depending on the platform and other parameters of the copy.
  10743. *
  10744. * If any error is encountered while parsing the batch, the index within the batch where the error was encountered
  10745. * will be returned in \p failIdx.
  10746. *
  10747. * \param dsts - Array of destination pointers.
  10748. * \param srcs - Array of memcpy source pointers.
  10749. * \param sizes - Array of sizes for memcpy operations.
  10750. * \param count - Size of \p dsts, \p srcs and \p sizes arrays
  10751. * \param attrs - Array of memcpy attributes.
  10752. * \param attrsIdxs - Array of indices to specify which copies each entry in the \p attrs array applies to.
  10753. The attributes specified in attrs[k] will be applied to copies starting from attrsIdxs[k]
  10754. through attrsIdxs[k+1] - 1. Also attrs[numAttrs-1] will apply to copies starting from
  10755. attrsIdxs[numAttrs-1] through count - 1.
  10756. * \param numAttrs - Size of \p attrs and \p attrsIdxs arrays.
  10757. * \param failIdx - Pointer to a location to return the index of the copy where a failure was encountered.
  10758. The value will be SIZE_MAX if the error doesn't pertain to any specific copy.
  10759. * \param hStream - The stream to enqueue the operations in. Must not be legacy NULL stream.
  10760. *
  10761. * \return
  10762. * ::CUDA_SUCCESS
  10763. * ::CUDA_ERROR_DEINITIALIZED
  10764. * ::CUDA_ERROR_NOT_INITIALIZED
  10765. * ::CUDA_ERROR_INVALID_VALUE
  10766. * \notefnerr
  10767. * \note_async
  10768. * \note_memcpy
  10769. */
  10770. CUresult CUDAAPI cuMemcpyBatchAsync(CUdeviceptr *dsts, CUdeviceptr *srcs, size_t *sizes, size_t count,
  10771. CUmemcpyAttributes *attrs, size_t *attrsIdxs, size_t numAttrs,
  10772. size_t *failIdx, CUstream hStream);
  10773. /**
  10774. * \brief Performs a batch of 3D memory copies asynchronously.
  10775. *
  10776. * Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a
  10777. * batch are not guaranteed to execute in any specific order. Note that this means specifying any dependent
  10778. * copies within a batch will result in undefined behavior.
  10779. *
  10780. * Performs memory copies as specified in the \p opList array. The length of this array is specified in \p numOps.
  10781. * Each entry in this array describes a copy operation. This includes among other things, the source and destination
  10782. * operands for the copy as specified in ::CUDA_MEMCPY3D_BATCH_OP::src and ::CUDA_MEMCPY3D_BATCH_OP::dst respectively.
  10783. * The source and destination operands of a copy can either be a pointer or a CUDA array. The width, height and depth
  10784. * of a copy is specified in ::CUDA_MEMCPY3D_BATCH_OP::extent. The width, height and depth of a copy are specified in
  10785. * elements and must not be zero. For pointer-to-pointer copies, the element size is considered to be 1. For pointer
  10786. * to CUDA array or vice versa copies, the element size is determined by the CUDA array. For CUDA array to CUDA array copies,
  10787. * the element size of the two CUDA arrays must match.
  10788. *
  10789. * For a given operand, if ::CUmemcpy3DOperand::type is specified as ::CU_MEMCPY_OPERAND_TYPE_POINTER, then
  10790. * ::CUmemcpy3DOperand::op::ptr will be used. The ::CUmemcpy3DOperand::op::ptr::ptr field must contain the pointer where
  10791. * the copy should begin. The ::CUmemcpy3DOperand::op::ptr::rowLength field specifies the length of each row in elements and
  10792. * must either be zero or be greater than or equal to the width of the copy specified in ::CUDA_MEMCPY3D_BATCH_OP::extent::width.
  10793. * The ::CUmemcpy3DOperand::op::ptr::layerHeight field specifies the height of each layer and must either be zero or be greater than
  10794. * or equal to the height of the copy specified in ::CUDA_MEMCPY3D_BATCH_OP::extent::height. When either of these values is zero,
  10795. * that aspect of the operand is considered to be tightly packed according to the copy extent. For managed memory pointers on devices where
  10796. * ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS is true or system-allocated pageable memory on devices where
  10797. * ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS is true, the ::CUmemcpy3DOperand::op::ptr::locHint field can be used to hint
  10798. * the location of the operand.
  10799. *
  10800. * If an operand's type is specified as ::CU_MEMCPY_OPERAND_TYPE_ARRAY, then ::CUmemcpy3DOperand::op::array will be used.
  10801. * The ::CUmemcpy3DOperand::op::array::array field specifies the CUDA array and ::CUmemcpy3DOperand::op::array::offset specifies
  10802. * the 3D offset into that array where the copy begins.
  10803. *
  10804. * The ::CUmemcpyAttributes::srcAccessOrder indicates the source access ordering to be observed for copies associated
  10805. * with the attribute. If the source access order is set to ::CU_MEMCPY_SRC_ACCESS_ORDER_STREAM, then the source will
  10806. * be accessed in stream order. If the source access order is set to ::CU_MEMCPY_SRC_ACCESS_ORDER_DURING_API_CALL then
  10807. * it indicates that access to the source pointer can be out of stream order and all accesses must be complete before
  10808. * the API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior
  10809. * operations in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope
  10810. * that the source variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the
  10811. * need for the user to synchronize the stream after the API call. If the source access order is set to
  10812. * ::CU_MEMCPY_SRC_ACCESS_ORDER_ANY then it indicates that access to the source pointer can be out of stream order and the
  10813. * accesses can happen even after the API call returns. This flag is suited for host pointers allocated
  10814. * outside CUDA (ex., via malloc) when it's known that no prior operations in the stream can be accessing the memory.
  10815. * Specifying this flag allows the driver to optimize the copy on certain platforms. Each memcopy operation in \p opList must
  10816. * have a valid srcAccessOrder setting, otherwise this API will return ::CUDA_ERROR_INVALID_VALUE.
  10817. *
  10818. * The ::CUmemcpyAttributes::flags field can be used to specify certain flags for copies. Setting the
  10819. * ::CU_MEMCPY_FLAG_PREFER_OVERLAP_WITH_COMPUTE flag indicates that the associated copies should preferably overlap with
  10820. * any compute work. Note that this flag is a hint and can be ignored depending on the platform and other parameters of the copy.
  10821. *
  10822. * If any error is encountered while parsing the batch, the index within the batch where the error was encountered
  10823. * will be returned in \p failIdx.
  10824. *
  10825. * \param numOps - Total number of memcpy operations.
  10826. * \param opList - Array of size \p numOps containing the actual memcpy operations.
  10827. * \param failIdx - Pointer to a location to return the index of the copy where a failure was encountered.
  10828. * The value will be SIZE_MAX if the error doesn't pertain to any specific copy.
  10829. * \param flags - Flags for future use, must be zero now.
  10830. * \param hStream - The stream to enqueue the operations in. Must not be default NULL stream.
  10831. *
  10832. * \return
  10833. * ::CUDA_SUCCESS
  10834. * ::CUDA_ERROR_DEINITIALIZED
  10835. * ::CUDA_ERROR_NOT_INITIALIZED
  10836. * ::CUDA_ERROR_INVALID_VALUE
  10837. * \notefnerr
  10838. * \note_async
  10839. * \note_memcpy
  10840. */
  10841. CUresult CUDAAPI cuMemcpy3DBatchAsync(size_t numOps, CUDA_MEMCPY3D_BATCH_OP *opList,
  10842. size_t *failIdx, unsigned long long flags, CUstream hStream);
  10843. /**
  10844. * \brief Initializes device memory
  10845. *
  10846. * Sets the memory range of \p N 8-bit values to the specified value
  10847. * \p uc.
  10848. *
  10849. * \param dstDevice - Destination device pointer
  10850. * \param uc - Value to set
  10851. * \param N - Number of elements
  10852. *
  10853. * \return
  10854. * ::CUDA_SUCCESS,
  10855. * ::CUDA_ERROR_DEINITIALIZED,
  10856. * ::CUDA_ERROR_NOT_INITIALIZED,
  10857. * ::CUDA_ERROR_INVALID_CONTEXT,
  10858. * ::CUDA_ERROR_INVALID_VALUE
  10859. * \notefnerr
  10860. * \note_memset
  10861. *
  10862. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10863. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10864. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10865. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10866. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10867. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10868. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10869. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10870. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10871. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10872. * ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10873. * ::cuMemsetD32, ::cuMemsetD32Async,
  10874. * ::cudaMemset
  10875. */
  10876. CUresult CUDAAPI cuMemsetD8(CUdeviceptr dstDevice, unsigned char uc, size_t N);
  10877. /**
  10878. * \brief Initializes device memory
  10879. *
  10880. * Sets the memory range of \p N 16-bit values to the specified value
  10881. * \p us. The \p dstDevice pointer must be two byte aligned.
  10882. *
  10883. * \param dstDevice - Destination device pointer
  10884. * \param us - Value to set
  10885. * \param N - Number of elements
  10886. *
  10887. * \return
  10888. * ::CUDA_SUCCESS,
  10889. * ::CUDA_ERROR_DEINITIALIZED,
  10890. * ::CUDA_ERROR_NOT_INITIALIZED,
  10891. * ::CUDA_ERROR_INVALID_CONTEXT,
  10892. * ::CUDA_ERROR_INVALID_VALUE
  10893. * \notefnerr
  10894. * \note_memset
  10895. *
  10896. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10897. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10898. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10899. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10900. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10901. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10902. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10903. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10904. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10905. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10906. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16Async,
  10907. * ::cuMemsetD32, ::cuMemsetD32Async,
  10908. * ::cudaMemset
  10909. */
  10910. CUresult CUDAAPI cuMemsetD16(CUdeviceptr dstDevice, unsigned short us, size_t N);
  10911. /**
  10912. * \brief Initializes device memory
  10913. *
  10914. * Sets the memory range of \p N 32-bit values to the specified value
  10915. * \p ui. The \p dstDevice pointer must be four byte aligned.
  10916. *
  10917. * \param dstDevice - Destination device pointer
  10918. * \param ui - Value to set
  10919. * \param N - Number of elements
  10920. *
  10921. * \return
  10922. * ::CUDA_SUCCESS,
  10923. * ::CUDA_ERROR_DEINITIALIZED,
  10924. * ::CUDA_ERROR_NOT_INITIALIZED,
  10925. * ::CUDA_ERROR_INVALID_CONTEXT,
  10926. * ::CUDA_ERROR_INVALID_VALUE
  10927. * \notefnerr
  10928. * \note_memset
  10929. *
  10930. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10931. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10932. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10933. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10934. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10935. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10936. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10937. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10938. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  10939. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10940. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10941. * ::cuMemsetD32Async,
  10942. * ::cudaMemset
  10943. */
  10944. CUresult CUDAAPI cuMemsetD32(CUdeviceptr dstDevice, unsigned int ui, size_t N);
  10945. /**
  10946. * \brief Initializes device memory
  10947. *
  10948. * Sets the 2D memory range of \p Width 8-bit values to the specified value
  10949. * \p uc. \p Height specifies the number of rows to set, and \p dstPitch
  10950. * specifies the number of bytes between each row. This function performs
  10951. * fastest when the pitch is one that has been passed back by
  10952. * ::cuMemAllocPitch().
  10953. *
  10954. * \param dstDevice - Destination device pointer
  10955. * \param dstPitch - Pitch of destination device pointer(Unused if \p Height is 1)
  10956. * \param uc - Value to set
  10957. * \param Width - Width of row
  10958. * \param Height - Number of rows
  10959. *
  10960. * \return
  10961. * ::CUDA_SUCCESS,
  10962. * ::CUDA_ERROR_DEINITIALIZED,
  10963. * ::CUDA_ERROR_NOT_INITIALIZED,
  10964. * ::CUDA_ERROR_INVALID_CONTEXT,
  10965. * ::CUDA_ERROR_INVALID_VALUE
  10966. * \notefnerr
  10967. * \note_memset
  10968. *
  10969. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  10970. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  10971. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  10972. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  10973. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  10974. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  10975. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  10976. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  10977. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8Async,
  10978. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  10979. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  10980. * ::cuMemsetD32, ::cuMemsetD32Async,
  10981. * ::cudaMemset2D
  10982. */
  10983. CUresult CUDAAPI cuMemsetD2D8(CUdeviceptr dstDevice, size_t dstPitch, unsigned char uc, size_t Width, size_t Height);
  10984. /**
  10985. * \brief Initializes device memory
  10986. *
  10987. * Sets the 2D memory range of \p Width 16-bit values to the specified value
  10988. * \p us. \p Height specifies the number of rows to set, and \p dstPitch
  10989. * specifies the number of bytes between each row. The \p dstDevice pointer
  10990. * and \p dstPitch offset must be two byte aligned. This function performs
  10991. * fastest when the pitch is one that has been passed back by
  10992. * ::cuMemAllocPitch().
  10993. *
  10994. * \param dstDevice - Destination device pointer
  10995. * \param dstPitch - Pitch of destination device pointer(Unused if \p Height is 1)
  10996. * \param us - Value to set
  10997. * \param Width - Width of row
  10998. * \param Height - Number of rows
  10999. *
  11000. * \return
  11001. * ::CUDA_SUCCESS,
  11002. * ::CUDA_ERROR_DEINITIALIZED,
  11003. * ::CUDA_ERROR_NOT_INITIALIZED,
  11004. * ::CUDA_ERROR_INVALID_CONTEXT,
  11005. * ::CUDA_ERROR_INVALID_VALUE
  11006. * \notefnerr
  11007. * \note_memset
  11008. *
  11009. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11010. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11011. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11012. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11013. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11014. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11015. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11016. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11017. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  11018. * ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  11019. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  11020. * ::cuMemsetD32, ::cuMemsetD32Async,
  11021. * ::cudaMemset2D
  11022. */
  11023. CUresult CUDAAPI cuMemsetD2D16(CUdeviceptr dstDevice, size_t dstPitch, unsigned short us, size_t Width, size_t Height);
  11024. /**
  11025. * \brief Initializes device memory
  11026. *
  11027. * Sets the 2D memory range of \p Width 32-bit values to the specified value
  11028. * \p ui. \p Height specifies the number of rows to set, and \p dstPitch
  11029. * specifies the number of bytes between each row. The \p dstDevice pointer
  11030. * and \p dstPitch offset must be four byte aligned. This function performs
  11031. * fastest when the pitch is one that has been passed back by
  11032. * ::cuMemAllocPitch().
  11033. *
  11034. * \param dstDevice - Destination device pointer
  11035. * \param dstPitch - Pitch of destination device pointer(Unused if \p Height is 1)
  11036. * \param ui - Value to set
  11037. * \param Width - Width of row
  11038. * \param Height - Number of rows
  11039. *
  11040. * \return
  11041. * ::CUDA_SUCCESS,
  11042. * ::CUDA_ERROR_DEINITIALIZED,
  11043. * ::CUDA_ERROR_NOT_INITIALIZED,
  11044. * ::CUDA_ERROR_INVALID_CONTEXT,
  11045. * ::CUDA_ERROR_INVALID_VALUE
  11046. * \notefnerr
  11047. * \note_memset
  11048. *
  11049. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11050. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11051. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11052. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11053. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11054. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11055. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11056. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11057. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  11058. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32Async,
  11059. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  11060. * ::cuMemsetD32, ::cuMemsetD32Async,
  11061. * ::cudaMemset2D
  11062. */
  11063. CUresult CUDAAPI cuMemsetD2D32(CUdeviceptr dstDevice, size_t dstPitch, unsigned int ui, size_t Width, size_t Height);
  11064. /**
  11065. * \brief Sets device memory
  11066. *
  11067. * Sets the memory range of \p N 8-bit values to the specified value
  11068. * \p uc.
  11069. *
  11070. * \param dstDevice - Destination device pointer
  11071. * \param uc - Value to set
  11072. * \param N - Number of elements
  11073. * \param hStream - Stream identifier
  11074. *
  11075. * \return
  11076. * ::CUDA_SUCCESS,
  11077. * ::CUDA_ERROR_DEINITIALIZED,
  11078. * ::CUDA_ERROR_NOT_INITIALIZED,
  11079. * ::CUDA_ERROR_INVALID_CONTEXT,
  11080. * ::CUDA_ERROR_INVALID_VALUE
  11081. * \notefnerr
  11082. * \note_memset
  11083. * \note_null_stream
  11084. *
  11085. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11086. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11087. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11088. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11089. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11090. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11091. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11092. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11093. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  11094. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  11095. * ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD16Async,
  11096. * ::cuMemsetD32, ::cuMemsetD32Async,
  11097. * ::cudaMemsetAsync
  11098. */
  11099. CUresult CUDAAPI cuMemsetD8Async(CUdeviceptr dstDevice, unsigned char uc, size_t N, CUstream hStream);
  11100. /**
  11101. * \brief Sets device memory
  11102. *
  11103. * Sets the memory range of \p N 16-bit values to the specified value
  11104. * \p us. The \p dstDevice pointer must be two byte aligned.
  11105. *
  11106. * \param dstDevice - Destination device pointer
  11107. * \param us - Value to set
  11108. * \param N - Number of elements
  11109. * \param hStream - Stream identifier
  11110. *
  11111. * \return
  11112. * ::CUDA_SUCCESS,
  11113. * ::CUDA_ERROR_DEINITIALIZED,
  11114. * ::CUDA_ERROR_NOT_INITIALIZED,
  11115. * ::CUDA_ERROR_INVALID_CONTEXT,
  11116. * ::CUDA_ERROR_INVALID_VALUE
  11117. * \notefnerr
  11118. * \note_memset
  11119. * \note_null_stream
  11120. *
  11121. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11122. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11123. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11124. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11125. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11126. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11127. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11128. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11129. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  11130. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  11131. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16,
  11132. * ::cuMemsetD32, ::cuMemsetD32Async,
  11133. * ::cudaMemsetAsync
  11134. */
  11135. CUresult CUDAAPI cuMemsetD16Async(CUdeviceptr dstDevice, unsigned short us, size_t N, CUstream hStream);
  11136. /**
  11137. * \brief Sets device memory
  11138. *
  11139. * Sets the memory range of \p N 32-bit values to the specified value
  11140. * \p ui. The \p dstDevice pointer must be four byte aligned.
  11141. *
  11142. * \param dstDevice - Destination device pointer
  11143. * \param ui - Value to set
  11144. * \param N - Number of elements
  11145. * \param hStream - Stream identifier
  11146. *
  11147. * \return
  11148. * ::CUDA_SUCCESS,
  11149. * ::CUDA_ERROR_DEINITIALIZED,
  11150. * ::CUDA_ERROR_NOT_INITIALIZED,
  11151. * ::CUDA_ERROR_INVALID_CONTEXT,
  11152. * ::CUDA_ERROR_INVALID_VALUE
  11153. * \notefnerr
  11154. * \note_memset
  11155. * \note_null_stream
  11156. *
  11157. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11158. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11159. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11160. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11161. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11162. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11163. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11164. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11165. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  11166. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  11167. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async, ::cuMemsetD32,
  11168. * ::cudaMemsetAsync
  11169. */
  11170. CUresult CUDAAPI cuMemsetD32Async(CUdeviceptr dstDevice, unsigned int ui, size_t N, CUstream hStream);
  11171. /**
  11172. * \brief Sets device memory
  11173. *
  11174. * Sets the 2D memory range of \p Width 8-bit values to the specified value
  11175. * \p uc. \p Height specifies the number of rows to set, and \p dstPitch
  11176. * specifies the number of bytes between each row. This function performs
  11177. * fastest when the pitch is one that has been passed back by
  11178. * ::cuMemAllocPitch().
  11179. *
  11180. * \param dstDevice - Destination device pointer
  11181. * \param dstPitch - Pitch of destination device pointer(Unused if \p Height is 1)
  11182. * \param uc - Value to set
  11183. * \param Width - Width of row
  11184. * \param Height - Number of rows
  11185. * \param hStream - Stream identifier
  11186. *
  11187. * \return
  11188. * ::CUDA_SUCCESS,
  11189. * ::CUDA_ERROR_DEINITIALIZED,
  11190. * ::CUDA_ERROR_NOT_INITIALIZED,
  11191. * ::CUDA_ERROR_INVALID_CONTEXT,
  11192. * ::CUDA_ERROR_INVALID_VALUE
  11193. * \notefnerr
  11194. * \note_memset
  11195. * \note_null_stream
  11196. *
  11197. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11198. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11199. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11200. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11201. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11202. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11203. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11204. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11205. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8,
  11206. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  11207. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  11208. * ::cuMemsetD32, ::cuMemsetD32Async,
  11209. * ::cudaMemset2DAsync
  11210. */
  11211. CUresult CUDAAPI cuMemsetD2D8Async(CUdeviceptr dstDevice, size_t dstPitch, unsigned char uc, size_t Width, size_t Height, CUstream hStream);
  11212. /**
  11213. * \brief Sets device memory
  11214. *
  11215. * Sets the 2D memory range of \p Width 16-bit values to the specified value
  11216. * \p us. \p Height specifies the number of rows to set, and \p dstPitch
  11217. * specifies the number of bytes between each row. The \p dstDevice pointer
  11218. * and \p dstPitch offset must be two byte aligned. This function performs
  11219. * fastest when the pitch is one that has been passed back by
  11220. * ::cuMemAllocPitch().
  11221. *
  11222. * \param dstDevice - Destination device pointer
  11223. * \param dstPitch - Pitch of destination device pointer(Unused if \p Height is 1)
  11224. * \param us - Value to set
  11225. * \param Width - Width of row
  11226. * \param Height - Number of rows
  11227. * \param hStream - Stream identifier
  11228. *
  11229. * \return
  11230. * ::CUDA_SUCCESS,
  11231. * ::CUDA_ERROR_DEINITIALIZED,
  11232. * ::CUDA_ERROR_NOT_INITIALIZED,
  11233. * ::CUDA_ERROR_INVALID_CONTEXT,
  11234. * ::CUDA_ERROR_INVALID_VALUE
  11235. * \notefnerr
  11236. * \note_memset
  11237. * \note_null_stream
  11238. *
  11239. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11240. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11241. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11242. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11243. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11244. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11245. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11246. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11247. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  11248. * ::cuMemsetD2D16, ::cuMemsetD2D32, ::cuMemsetD2D32Async,
  11249. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  11250. * ::cuMemsetD32, ::cuMemsetD32Async,
  11251. * ::cudaMemset2DAsync
  11252. */
  11253. CUresult CUDAAPI cuMemsetD2D16Async(CUdeviceptr dstDevice, size_t dstPitch, unsigned short us, size_t Width, size_t Height, CUstream hStream);
  11254. /**
  11255. * \brief Sets device memory
  11256. *
  11257. * Sets the 2D memory range of \p Width 32-bit values to the specified value
  11258. * \p ui. \p Height specifies the number of rows to set, and \p dstPitch
  11259. * specifies the number of bytes between each row. The \p dstDevice pointer
  11260. * and \p dstPitch offset must be four byte aligned. This function performs
  11261. * fastest when the pitch is one that has been passed back by
  11262. * ::cuMemAllocPitch().
  11263. *
  11264. * \param dstDevice - Destination device pointer
  11265. * \param dstPitch - Pitch of destination device pointer(Unused if \p Height is 1)
  11266. * \param ui - Value to set
  11267. * \param Width - Width of row
  11268. * \param Height - Number of rows
  11269. * \param hStream - Stream identifier
  11270. *
  11271. * \return
  11272. * ::CUDA_SUCCESS,
  11273. * ::CUDA_ERROR_DEINITIALIZED,
  11274. * ::CUDA_ERROR_NOT_INITIALIZED,
  11275. * ::CUDA_ERROR_INVALID_CONTEXT,
  11276. * ::CUDA_ERROR_INVALID_VALUE
  11277. * \notefnerr
  11278. * \note_memset
  11279. * \note_null_stream
  11280. *
  11281. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11282. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11283. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11284. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11285. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11286. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11287. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11288. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11289. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D8Async,
  11290. * ::cuMemsetD2D16, ::cuMemsetD2D16Async, ::cuMemsetD2D32,
  11291. * ::cuMemsetD8, ::cuMemsetD8Async, ::cuMemsetD16, ::cuMemsetD16Async,
  11292. * ::cuMemsetD32, ::cuMemsetD32Async,
  11293. * ::cudaMemset2DAsync
  11294. */
  11295. CUresult CUDAAPI cuMemsetD2D32Async(CUdeviceptr dstDevice, size_t dstPitch, unsigned int ui, size_t Width, size_t Height, CUstream hStream);
  11296. /**
  11297. * \brief Creates a 1D or 2D CUDA array
  11298. *
  11299. * Creates a CUDA array according to the ::CUDA_ARRAY_DESCRIPTOR structure
  11300. * \p pAllocateArray and returns a handle to the new CUDA array in \p *pHandle.
  11301. * The ::CUDA_ARRAY_DESCRIPTOR is defined as:
  11302. *
  11303. * \code
  11304. typedef struct {
  11305. unsigned int Width;
  11306. unsigned int Height;
  11307. CUarray_format Format;
  11308. unsigned int NumChannels;
  11309. } CUDA_ARRAY_DESCRIPTOR;
  11310. * \endcode
  11311. * where:
  11312. *
  11313. * - \p Width, and \p Height are the width, and height of the CUDA array (in
  11314. * elements); the CUDA array is one-dimensional if height is 0, two-dimensional
  11315. * otherwise;
  11316. * - ::Format specifies the format of the elements; ::CUarray_format is
  11317. * defined as:
  11318. * \code
  11319. typedef enum CUarray_format_enum {
  11320. CU_AD_FORMAT_UNSIGNED_INT8 = 0x01,
  11321. CU_AD_FORMAT_UNSIGNED_INT16 = 0x02,
  11322. CU_AD_FORMAT_UNSIGNED_INT32 = 0x03,
  11323. CU_AD_FORMAT_SIGNED_INT8 = 0x08,
  11324. CU_AD_FORMAT_SIGNED_INT16 = 0x09,
  11325. CU_AD_FORMAT_SIGNED_INT32 = 0x0a,
  11326. CU_AD_FORMAT_HALF = 0x10,
  11327. CU_AD_FORMAT_FLOAT = 0x20,
  11328. CU_AD_FORMAT_NV12 = 0xb0,
  11329. CU_AD_FORMAT_UNORM_INT8X1 = 0xc0,
  11330. CU_AD_FORMAT_UNORM_INT8X2 = 0xc1,
  11331. CU_AD_FORMAT_UNORM_INT8X4 = 0xc2,
  11332. CU_AD_FORMAT_UNORM_INT16X1 = 0xc3,
  11333. CU_AD_FORMAT_UNORM_INT16X2 = 0xc4,
  11334. CU_AD_FORMAT_UNORM_INT16X4 = 0xc5,
  11335. CU_AD_FORMAT_SNORM_INT8X1 = 0xc6,
  11336. CU_AD_FORMAT_SNORM_INT8X2 = 0xc7,
  11337. CU_AD_FORMAT_SNORM_INT8X4 = 0xc8,
  11338. CU_AD_FORMAT_SNORM_INT16X1 = 0xc9,
  11339. CU_AD_FORMAT_SNORM_INT16X2 = 0xca,
  11340. CU_AD_FORMAT_SNORM_INT16X4 = 0xcb,
  11341. CU_AD_FORMAT_BC1_UNORM = 0x91,
  11342. CU_AD_FORMAT_BC1_UNORM_SRGB = 0x92,
  11343. CU_AD_FORMAT_BC2_UNORM = 0x93,
  11344. CU_AD_FORMAT_BC2_UNORM_SRGB = 0x94,
  11345. CU_AD_FORMAT_BC3_UNORM = 0x95,
  11346. CU_AD_FORMAT_BC3_UNORM_SRGB = 0x96,
  11347. CU_AD_FORMAT_BC4_UNORM = 0x97,
  11348. CU_AD_FORMAT_BC4_SNORM = 0x98,
  11349. CU_AD_FORMAT_BC5_UNORM = 0x99,
  11350. CU_AD_FORMAT_BC5_SNORM = 0x9a,
  11351. CU_AD_FORMAT_BC6H_UF16 = 0x9b,
  11352. CU_AD_FORMAT_BC6H_SF16 = 0x9c,
  11353. CU_AD_FORMAT_BC7_UNORM = 0x9d,
  11354. CU_AD_FORMAT_BC7_UNORM_SRGB = 0x9e,
  11355. CU_AD_FORMAT_P010 = 0x9f,
  11356. CU_AD_FORMAT_P016 = 0xa1,
  11357. CU_AD_FORMAT_NV16 = 0xa2,
  11358. CU_AD_FORMAT_P210 = 0xa3,
  11359. CU_AD_FORMAT_P216 = 0xa4,
  11360. CU_AD_FORMAT_YUY2 = 0xa5,
  11361. CU_AD_FORMAT_Y210 = 0xa6,
  11362. CU_AD_FORMAT_Y216 = 0xa7,
  11363. CU_AD_FORMAT_AYUV = 0xa8,
  11364. CU_AD_FORMAT_Y410 = 0xa9,
  11365. CU_AD_FORMAT_Y416 = 0xb1,
  11366. CU_AD_FORMAT_Y444_PLANAR8 = 0xb2,
  11367. CU_AD_FORMAT_Y444_PLANAR10 = 0xb3,
  11368. CU_AD_FORMAT_YUV444_8bit_SemiPlanar = 0xb4,
  11369. CU_AD_FORMAT_YUV444_16bit_SemiPlanar = 0xb5,
  11370. CU_AD_FORMAT_UNORM_INT_101010_2 = 0x50,
  11371. } CUarray_format;
  11372. * \endcode
  11373. * - \p NumChannels specifies the number of packed components per CUDA array
  11374. * element; it may be 1, 2, or 4;
  11375. *
  11376. * Here are examples of CUDA array descriptions:
  11377. *
  11378. * Description for a CUDA array of 2048 floats:
  11379. * \code
  11380. CUDA_ARRAY_DESCRIPTOR desc;
  11381. desc.Format = CU_AD_FORMAT_FLOAT;
  11382. desc.NumChannels = 1;
  11383. desc.Width = 2048;
  11384. desc.Height = 1;
  11385. * \endcode
  11386. *
  11387. * Description for a 64 x 64 CUDA array of floats:
  11388. * \code
  11389. CUDA_ARRAY_DESCRIPTOR desc;
  11390. desc.Format = CU_AD_FORMAT_FLOAT;
  11391. desc.NumChannels = 1;
  11392. desc.Width = 64;
  11393. desc.Height = 64;
  11394. * \endcode
  11395. *
  11396. * Description for a \p width x \p height CUDA array of 64-bit, 4x16-bit
  11397. * float16's:
  11398. * \code
  11399. CUDA_ARRAY_DESCRIPTOR desc;
  11400. desc.Format = CU_AD_FORMAT_HALF;
  11401. desc.NumChannels = 4;
  11402. desc.Width = width;
  11403. desc.Height = height;
  11404. * \endcode
  11405. *
  11406. * Description for a \p width x \p height CUDA array of 16-bit elements, each
  11407. * of which is two 8-bit unsigned chars:
  11408. * \code
  11409. CUDA_ARRAY_DESCRIPTOR arrayDesc;
  11410. desc.Format = CU_AD_FORMAT_UNSIGNED_INT8;
  11411. desc.NumChannels = 2;
  11412. desc.Width = width;
  11413. desc.Height = height;
  11414. * \endcode
  11415. *
  11416. * \param pHandle - Returned array
  11417. * \param pAllocateArray - Array descriptor
  11418. *
  11419. * \return
  11420. * ::CUDA_SUCCESS,
  11421. * ::CUDA_ERROR_DEINITIALIZED,
  11422. * ::CUDA_ERROR_NOT_INITIALIZED,
  11423. * ::CUDA_ERROR_INVALID_CONTEXT,
  11424. * ::CUDA_ERROR_INVALID_VALUE,
  11425. * ::CUDA_ERROR_OUT_OF_MEMORY,
  11426. * ::CUDA_ERROR_UNKNOWN
  11427. * \notefnerr
  11428. *
  11429. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor,
  11430. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11431. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11432. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11433. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11434. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11435. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11436. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11437. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  11438. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  11439. * ::cudaMallocArray
  11440. */
  11441. CUresult CUDAAPI cuArrayCreate(CUarray *pHandle, const CUDA_ARRAY_DESCRIPTOR *pAllocateArray);
  11442. /**
  11443. * \brief Get a 1D or 2D CUDA array descriptor
  11444. *
  11445. * Returns in \p *pArrayDescriptor a descriptor containing information on the
  11446. * format and dimensions of the CUDA array \p hArray. It is useful for
  11447. * subroutines that have been passed a CUDA array, but need to know the CUDA
  11448. * array parameters for validation or other purposes.
  11449. *
  11450. * \param pArrayDescriptor - Returned array descriptor
  11451. * \param hArray - Array to get descriptor of
  11452. *
  11453. * \return
  11454. * ::CUDA_SUCCESS,
  11455. * ::CUDA_ERROR_DEINITIALIZED,
  11456. * ::CUDA_ERROR_NOT_INITIALIZED,
  11457. * ::CUDA_ERROR_INVALID_CONTEXT,
  11458. * ::CUDA_ERROR_INVALID_VALUE,
  11459. * ::CUDA_ERROR_INVALID_HANDLE
  11460. * \notefnerr
  11461. *
  11462. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11463. * ::cuArrayDestroy, ::cuMemAlloc, ::cuMemAllocHost,
  11464. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11465. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11466. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11467. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11468. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11469. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11470. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  11471. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  11472. * ::cudaArrayGetInfo
  11473. */
  11474. CUresult CUDAAPI cuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR *pArrayDescriptor, CUarray hArray);
  11475. /**
  11476. * \brief Returns the layout properties of a sparse CUDA array
  11477. *
  11478. * Returns the layout properties of a sparse CUDA array in \p sparseProperties
  11479. * If the CUDA array is not allocated with flag ::CUDA_ARRAY3D_SPARSE
  11480. * ::CUDA_ERROR_INVALID_VALUE will be returned.
  11481. *
  11482. * If the returned value in ::CUDA_ARRAY_SPARSE_PROPERTIES::flags contains ::CU_ARRAY_SPARSE_PROPERTIES_SINGLE_MIPTAIL,
  11483. * then ::CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize represents the total size of the array. Otherwise, it will be zero.
  11484. * Also, the returned value in ::CUDA_ARRAY_SPARSE_PROPERTIES::miptailFirstLevel is always zero.
  11485. * Note that the \p array must have been allocated using ::cuArrayCreate or ::cuArray3DCreate. For CUDA arrays obtained
  11486. * using ::cuMipmappedArrayGetLevel, ::CUDA_ERROR_INVALID_VALUE will be returned. Instead, ::cuMipmappedArrayGetSparseProperties
  11487. * must be used to obtain the sparse properties of the entire CUDA mipmapped array to which \p array belongs to.
  11488. *
  11489. * \return
  11490. * ::CUDA_SUCCESS
  11491. * ::CUDA_ERROR_INVALID_VALUE
  11492. *
  11493. * \param[out] sparseProperties - Pointer to ::CUDA_ARRAY_SPARSE_PROPERTIES
  11494. * \param[in] array - CUDA array to get the sparse properties of
  11495. * \sa ::cuMipmappedArrayGetSparseProperties, ::cuMemMapArrayAsync
  11496. */
  11497. CUresult CUDAAPI cuArrayGetSparseProperties(CUDA_ARRAY_SPARSE_PROPERTIES *sparseProperties, CUarray array);
  11498. /**
  11499. * \brief Returns the layout properties of a sparse CUDA mipmapped array
  11500. *
  11501. * Returns the sparse array layout properties in \p sparseProperties
  11502. * If the CUDA mipmapped array is not allocated with flag ::CUDA_ARRAY3D_SPARSE
  11503. * ::CUDA_ERROR_INVALID_VALUE will be returned.
  11504. *
  11505. * For non-layered CUDA mipmapped arrays, ::CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize returns the
  11506. * size of the mip tail region. The mip tail region includes all mip levels whose width, height or depth
  11507. * is less than that of the tile.
  11508. * For layered CUDA mipmapped arrays, if ::CUDA_ARRAY_SPARSE_PROPERTIES::flags contains ::CU_ARRAY_SPARSE_PROPERTIES_SINGLE_MIPTAIL,
  11509. * then ::CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize specifies the size of the mip tail of all layers combined.
  11510. * Otherwise, ::CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize specifies mip tail size per layer.
  11511. * The returned value of ::CUDA_ARRAY_SPARSE_PROPERTIES::miptailFirstLevel is valid only if ::CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize is non-zero.
  11512. *
  11513. * \return
  11514. * ::CUDA_SUCCESS
  11515. * ::CUDA_ERROR_INVALID_VALUE
  11516. *
  11517. * \param[out] sparseProperties - Pointer to ::CUDA_ARRAY_SPARSE_PROPERTIES
  11518. * \param[in] mipmap - CUDA mipmapped array to get the sparse properties of
  11519. * \sa ::cuArrayGetSparseProperties, ::cuMemMapArrayAsync
  11520. */
  11521. CUresult CUDAAPI cuMipmappedArrayGetSparseProperties(CUDA_ARRAY_SPARSE_PROPERTIES *sparseProperties, CUmipmappedArray mipmap);
  11522. /**
  11523. * \brief Returns the memory requirements of a CUDA array
  11524. *
  11525. * Returns the memory requirements of a CUDA array in \p memoryRequirements
  11526. * If the CUDA array is not allocated with flag ::CUDA_ARRAY3D_DEFERRED_MAPPING
  11527. * ::CUDA_ERROR_INVALID_VALUE will be returned.
  11528. *
  11529. * The returned value in ::CUDA_ARRAY_MEMORY_REQUIREMENTS::size
  11530. * represents the total size of the CUDA array.
  11531. * The returned value in ::CUDA_ARRAY_MEMORY_REQUIREMENTS::alignment
  11532. * represents the alignment necessary for mapping the CUDA array.
  11533. *
  11534. * \return
  11535. * ::CUDA_SUCCESS
  11536. * ::CUDA_ERROR_INVALID_VALUE
  11537. *
  11538. * \param[out] memoryRequirements - Pointer to ::CUDA_ARRAY_MEMORY_REQUIREMENTS
  11539. * \param[in] array - CUDA array to get the memory requirements of
  11540. * \param[in] device - Device to get the memory requirements for
  11541. * \sa ::cuMipmappedArrayGetMemoryRequirements, ::cuMemMapArrayAsync
  11542. */
  11543. CUresult CUDAAPI cuArrayGetMemoryRequirements(CUDA_ARRAY_MEMORY_REQUIREMENTS *memoryRequirements, CUarray array, CUdevice device);
  11544. /**
  11545. * \brief Returns the memory requirements of a CUDA mipmapped array
  11546. *
  11547. * Returns the memory requirements of a CUDA mipmapped array in \p memoryRequirements
  11548. * If the CUDA mipmapped array is not allocated with flag ::CUDA_ARRAY3D_DEFERRED_MAPPING
  11549. * ::CUDA_ERROR_INVALID_VALUE will be returned.
  11550. *
  11551. * The returned value in ::CUDA_ARRAY_MEMORY_REQUIREMENTS::size
  11552. * represents the total size of the CUDA mipmapped array.
  11553. * The returned value in ::CUDA_ARRAY_MEMORY_REQUIREMENTS::alignment
  11554. * represents the alignment necessary for mapping the CUDA mipmapped
  11555. * array.
  11556. *
  11557. * \return
  11558. * ::CUDA_SUCCESS
  11559. * ::CUDA_ERROR_INVALID_VALUE
  11560. *
  11561. * \param[out] memoryRequirements - Pointer to ::CUDA_ARRAY_MEMORY_REQUIREMENTS
  11562. * \param[in] mipmap - CUDA mipmapped array to get the memory requirements of
  11563. * \param[in] device - Device to get the memory requirements for
  11564. * \sa ::cuArrayGetMemoryRequirements, ::cuMemMapArrayAsync
  11565. */
  11566. CUresult CUDAAPI cuMipmappedArrayGetMemoryRequirements(CUDA_ARRAY_MEMORY_REQUIREMENTS *memoryRequirements, CUmipmappedArray mipmap, CUdevice device);
  11567. /**
  11568. * \brief Gets a CUDA array plane from a CUDA array
  11569. *
  11570. * Returns in \p pPlaneArray a CUDA array that represents a single format plane
  11571. * of the CUDA array \p hArray.
  11572. *
  11573. * If \p planeIdx is greater than the maximum number of planes in this array or if the array does
  11574. * not have a multi-planar format e.g: ::CU_AD_FORMAT_NV12, then ::CUDA_ERROR_INVALID_VALUE is returned.
  11575. *
  11576. * Note that if the \p hArray has format ::CU_AD_FORMAT_NV12, then passing in 0 for \p planeIdx returns
  11577. * a CUDA array of the same size as \p hArray but with one channel and ::CU_AD_FORMAT_UNSIGNED_INT8 as its format.
  11578. * If 1 is passed for \p planeIdx, then the returned CUDA array has half the height and width
  11579. * of \p hArray with two channels and ::CU_AD_FORMAT_UNSIGNED_INT8 as its format.
  11580. *
  11581. * \param pPlaneArray - Returned CUDA array referenced by the \p planeIdx
  11582. * \param hArray - Multiplanar CUDA array
  11583. * \param planeIdx - Plane index
  11584. *
  11585. * \return
  11586. * ::CUDA_SUCCESS,
  11587. * ::CUDA_ERROR_DEINITIALIZED,
  11588. * ::CUDA_ERROR_NOT_INITIALIZED,
  11589. * ::CUDA_ERROR_INVALID_CONTEXT,
  11590. * ::CUDA_ERROR_INVALID_VALUE,
  11591. * ::CUDA_ERROR_INVALID_HANDLE
  11592. * \notefnerr
  11593. *
  11594. * \sa
  11595. * ::cuArrayCreate,
  11596. * ::cudaArrayGetPlane
  11597. */
  11598. CUresult CUDAAPI cuArrayGetPlane(CUarray *pPlaneArray, CUarray hArray, unsigned int planeIdx);
  11599. /**
  11600. * \brief Destroys a CUDA array
  11601. *
  11602. * Destroys the CUDA array \p hArray.
  11603. *
  11604. * \param hArray - Array to destroy
  11605. *
  11606. * \return
  11607. * ::CUDA_SUCCESS,
  11608. * ::CUDA_ERROR_DEINITIALIZED,
  11609. * ::CUDA_ERROR_NOT_INITIALIZED,
  11610. * ::CUDA_ERROR_INVALID_CONTEXT,
  11611. * ::CUDA_ERROR_INVALID_HANDLE,
  11612. * ::CUDA_ERROR_ARRAY_IS_MAPPED,
  11613. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED
  11614. * \notefnerr
  11615. *
  11616. * \sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11617. * ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11618. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11619. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11620. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11621. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11622. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11623. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11624. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  11625. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  11626. * ::cudaFreeArray
  11627. */
  11628. CUresult CUDAAPI cuArrayDestroy(CUarray hArray);
  11629. /**
  11630. * \brief Creates a 3D CUDA array
  11631. *
  11632. * Creates a CUDA array according to the ::CUDA_ARRAY3D_DESCRIPTOR structure
  11633. * \p pAllocateArray and returns a handle to the new CUDA array in \p *pHandle.
  11634. * The ::CUDA_ARRAY3D_DESCRIPTOR is defined as:
  11635. *
  11636. * \code
  11637. typedef struct {
  11638. unsigned int Width;
  11639. unsigned int Height;
  11640. unsigned int Depth;
  11641. CUarray_format Format;
  11642. unsigned int NumChannels;
  11643. unsigned int Flags;
  11644. } CUDA_ARRAY3D_DESCRIPTOR;
  11645. * \endcode
  11646. * where:
  11647. *
  11648. * - \p Width, \p Height, and \p Depth are the width, height, and depth of the
  11649. * CUDA array (in elements); the following types of CUDA arrays can be allocated:
  11650. * - A 1D array is allocated if \p Height and \p Depth extents are both zero.
  11651. * - A 2D array is allocated if only \p Depth extent is zero.
  11652. * - A 3D array is allocated if all three extents are non-zero.
  11653. * - A 1D layered CUDA array is allocated if only \p Height is zero and the
  11654. * ::CUDA_ARRAY3D_LAYERED flag is set. Each layer is a 1D array. The number
  11655. * of layers is determined by the depth extent.
  11656. * - A 2D layered CUDA array is allocated if all three extents are non-zero and
  11657. * the ::CUDA_ARRAY3D_LAYERED flag is set. Each layer is a 2D array. The number
  11658. * of layers is determined by the depth extent.
  11659. * - A cubemap CUDA array is allocated if all three extents are non-zero and the
  11660. * ::CUDA_ARRAY3D_CUBEMAP flag is set. \p Width must be equal to \p Height, and
  11661. * \p Depth must be six. A cubemap is a special type of 2D layered CUDA array,
  11662. * where the six layers represent the six faces of a cube. The order of the six
  11663. * layers in memory is the same as that listed in ::CUarray_cubemap_face.
  11664. * - A cubemap layered CUDA array is allocated if all three extents are non-zero,
  11665. * and both, ::CUDA_ARRAY3D_CUBEMAP and ::CUDA_ARRAY3D_LAYERED flags are set.
  11666. * \p Width must be equal to \p Height, and \p Depth must be a multiple of six.
  11667. * A cubemap layered CUDA array is a special type of 2D layered CUDA array that
  11668. * consists of a collection of cubemaps. The first six layers represent the first
  11669. * cubemap, the next six layers form the second cubemap, and so on.
  11670. *
  11671. * - ::Format specifies the format of the elements; ::CUarray_format is
  11672. * defined as:
  11673. * \code
  11674. typedef enum CUarray_format_enum {
  11675. CU_AD_FORMAT_UNSIGNED_INT8 = 0x01,
  11676. CU_AD_FORMAT_UNSIGNED_INT16 = 0x02,
  11677. CU_AD_FORMAT_UNSIGNED_INT32 = 0x03,
  11678. CU_AD_FORMAT_SIGNED_INT8 = 0x08,
  11679. CU_AD_FORMAT_SIGNED_INT16 = 0x09,
  11680. CU_AD_FORMAT_SIGNED_INT32 = 0x0a,
  11681. CU_AD_FORMAT_HALF = 0x10,
  11682. CU_AD_FORMAT_FLOAT = 0x20,
  11683. CU_AD_FORMAT_NV12 = 0xb0,
  11684. CU_AD_FORMAT_UNORM_INT8X1 = 0xc0,
  11685. CU_AD_FORMAT_UNORM_INT8X2 = 0xc1,
  11686. CU_AD_FORMAT_UNORM_INT8X4 = 0xc2,
  11687. CU_AD_FORMAT_UNORM_INT16X1 = 0xc3,
  11688. CU_AD_FORMAT_UNORM_INT16X2 = 0xc4,
  11689. CU_AD_FORMAT_UNORM_INT16X4 = 0xc5,
  11690. CU_AD_FORMAT_SNORM_INT8X1 = 0xc6,
  11691. CU_AD_FORMAT_SNORM_INT8X2 = 0xc7,
  11692. CU_AD_FORMAT_SNORM_INT8X4 = 0xc8,
  11693. CU_AD_FORMAT_SNORM_INT16X1 = 0xc9,
  11694. CU_AD_FORMAT_SNORM_INT16X2 = 0xca,
  11695. CU_AD_FORMAT_SNORM_INT16X4 = 0xcb,
  11696. CU_AD_FORMAT_BC1_UNORM = 0x91,
  11697. CU_AD_FORMAT_BC1_UNORM_SRGB = 0x92,
  11698. CU_AD_FORMAT_BC2_UNORM = 0x93,
  11699. CU_AD_FORMAT_BC2_UNORM_SRGB = 0x94,
  11700. CU_AD_FORMAT_BC3_UNORM = 0x95,
  11701. CU_AD_FORMAT_BC3_UNORM_SRGB = 0x96,
  11702. CU_AD_FORMAT_BC4_UNORM = 0x97,
  11703. CU_AD_FORMAT_BC4_SNORM = 0x98,
  11704. CU_AD_FORMAT_BC5_UNORM = 0x99,
  11705. CU_AD_FORMAT_BC5_SNORM = 0x9a,
  11706. CU_AD_FORMAT_BC6H_UF16 = 0x9b,
  11707. CU_AD_FORMAT_BC6H_SF16 = 0x9c,
  11708. CU_AD_FORMAT_BC7_UNORM = 0x9d,
  11709. CU_AD_FORMAT_BC7_UNORM_SRGB = 0x9e,
  11710. CU_AD_FORMAT_P010 = 0x9f,
  11711. CU_AD_FORMAT_P016 = 0xa1,
  11712. CU_AD_FORMAT_NV16 = 0xa2,
  11713. CU_AD_FORMAT_P210 = 0xa3,
  11714. CU_AD_FORMAT_P216 = 0xa4,
  11715. CU_AD_FORMAT_YUY2 = 0xa5,
  11716. CU_AD_FORMAT_Y210 = 0xa6,
  11717. CU_AD_FORMAT_Y216 = 0xa7,
  11718. CU_AD_FORMAT_AYUV = 0xa8,
  11719. CU_AD_FORMAT_Y410 = 0xa9,
  11720. CU_AD_FORMAT_Y416 = 0xb1,
  11721. CU_AD_FORMAT_Y444_PLANAR8 = 0xb2,
  11722. CU_AD_FORMAT_Y444_PLANAR10 = 0xb3,
  11723. CU_AD_FORMAT_YUV444_8bit_SemiPlanar = 0xb4,
  11724. CU_AD_FORMAT_YUV444_16bit_SemiPlanar = 0xb5,
  11725. CU_AD_FORMAT_UNORM_INT_101010_2 = 0x50,
  11726. } CUarray_format;
  11727. * \endcode
  11728. *
  11729. * - \p NumChannels specifies the number of packed components per CUDA array
  11730. * element; it may be 1, 2, or 4;
  11731. *
  11732. * - ::Flags may be set to
  11733. * - ::CUDA_ARRAY3D_LAYERED to enable creation of layered CUDA arrays. If this flag is set,
  11734. * \p Depth specifies the number of layers, not the depth of a 3D array.
  11735. * - ::CUDA_ARRAY3D_SURFACE_LDST to enable surface references to be bound to the CUDA array.
  11736. * If this flag is not set, ::cuSurfRefSetArray will fail when attempting to bind the CUDA array
  11737. * to a surface reference.
  11738. * - ::CUDA_ARRAY3D_CUBEMAP to enable creation of cubemaps. If this flag is set, \p Width must be
  11739. * equal to \p Height, and \p Depth must be six. If the ::CUDA_ARRAY3D_LAYERED flag is also set,
  11740. * then \p Depth must be a multiple of six.
  11741. * - ::CUDA_ARRAY3D_TEXTURE_GATHER to indicate that the CUDA array will be used for texture gather.
  11742. * Texture gather can only be performed on 2D CUDA arrays.
  11743. *
  11744. * \p Width, \p Height and \p Depth must meet certain size requirements as listed in the following table.
  11745. * All values are specified in elements. Note that for brevity's sake, the full name of the device attribute
  11746. * is not specified. For ex., TEXTURE1D_WIDTH refers to the device attribute
  11747. * ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH.
  11748. *
  11749. * Note that 2D CUDA arrays have different size requirements if the ::CUDA_ARRAY3D_TEXTURE_GATHER flag
  11750. * is set. \p Width and \p Height must not be greater than ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH
  11751. * and ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT respectively, in that case.
  11752. *
  11753. * <table>
  11754. * <tr><td><b>CUDA array type</b></td>
  11755. * <td><b>Valid extents that must always be met<br>{(width range in elements), (height range),
  11756. * (depth range)}</b></td>
  11757. * <td><b>Valid extents with CUDA_ARRAY3D_SURFACE_LDST set<br>
  11758. * {(width range in elements), (height range), (depth range)}</b></td></tr>
  11759. * <tr><td>1D</td>
  11760. * <td><small>{ (1,TEXTURE1D_WIDTH), 0, 0 }</small></td>
  11761. * <td><small>{ (1,SURFACE1D_WIDTH), 0, 0 }</small></td></tr>
  11762. * <tr><td>2D</td>
  11763. * <td><small>{ (1,TEXTURE2D_WIDTH), (1,TEXTURE2D_HEIGHT), 0 }</small></td>
  11764. * <td><small>{ (1,SURFACE2D_WIDTH), (1,SURFACE2D_HEIGHT), 0 }</small></td></tr>
  11765. * <tr><td>3D</td>
  11766. * <td><small>{ (1,TEXTURE3D_WIDTH), (1,TEXTURE3D_HEIGHT), (1,TEXTURE3D_DEPTH) }
  11767. * <br>OR<br>{ (1,TEXTURE3D_WIDTH_ALTERNATE), (1,TEXTURE3D_HEIGHT_ALTERNATE),
  11768. * (1,TEXTURE3D_DEPTH_ALTERNATE) }</small></td>
  11769. * <td><small>{ (1,SURFACE3D_WIDTH), (1,SURFACE3D_HEIGHT),
  11770. * (1,SURFACE3D_DEPTH) }</small></td></tr>
  11771. * <tr><td>1D Layered</td>
  11772. * <td><small>{ (1,TEXTURE1D_LAYERED_WIDTH), 0,
  11773. * (1,TEXTURE1D_LAYERED_LAYERS) }</small></td>
  11774. * <td><small>{ (1,SURFACE1D_LAYERED_WIDTH), 0,
  11775. * (1,SURFACE1D_LAYERED_LAYERS) }</small></td></tr>
  11776. * <tr><td>2D Layered</td>
  11777. * <td><small>{ (1,TEXTURE2D_LAYERED_WIDTH), (1,TEXTURE2D_LAYERED_HEIGHT),
  11778. * (1,TEXTURE2D_LAYERED_LAYERS) }</small></td>
  11779. * <td><small>{ (1,SURFACE2D_LAYERED_WIDTH), (1,SURFACE2D_LAYERED_HEIGHT),
  11780. * (1,SURFACE2D_LAYERED_LAYERS) }</small></td></tr>
  11781. * <tr><td>Cubemap</td>
  11782. * <td><small>{ (1,TEXTURECUBEMAP_WIDTH), (1,TEXTURECUBEMAP_WIDTH), 6 }</small></td>
  11783. * <td><small>{ (1,SURFACECUBEMAP_WIDTH),
  11784. * (1,SURFACECUBEMAP_WIDTH), 6 }</small></td></tr>
  11785. * <tr><td>Cubemap Layered</td>
  11786. * <td><small>{ (1,TEXTURECUBEMAP_LAYERED_WIDTH), (1,TEXTURECUBEMAP_LAYERED_WIDTH),
  11787. * (1,TEXTURECUBEMAP_LAYERED_LAYERS) }</small></td>
  11788. * <td><small>{ (1,SURFACECUBEMAP_LAYERED_WIDTH), (1,SURFACECUBEMAP_LAYERED_WIDTH),
  11789. * (1,SURFACECUBEMAP_LAYERED_LAYERS) }</small></td></tr>
  11790. * </table>
  11791. *
  11792. * Here are examples of CUDA array descriptions:
  11793. *
  11794. * Description for a CUDA array of 2048 floats:
  11795. * \code
  11796. CUDA_ARRAY3D_DESCRIPTOR desc;
  11797. desc.Format = CU_AD_FORMAT_FLOAT;
  11798. desc.NumChannels = 1;
  11799. desc.Width = 2048;
  11800. desc.Height = 0;
  11801. desc.Depth = 0;
  11802. * \endcode
  11803. *
  11804. * Description for a 64 x 64 CUDA array of floats:
  11805. * \code
  11806. CUDA_ARRAY3D_DESCRIPTOR desc;
  11807. desc.Format = CU_AD_FORMAT_FLOAT;
  11808. desc.NumChannels = 1;
  11809. desc.Width = 64;
  11810. desc.Height = 64;
  11811. desc.Depth = 0;
  11812. * \endcode
  11813. *
  11814. * Description for a \p width x \p height x \p depth CUDA array of 64-bit,
  11815. * 4x16-bit float16's:
  11816. * \code
  11817. CUDA_ARRAY3D_DESCRIPTOR desc;
  11818. desc.Format = CU_AD_FORMAT_HALF;
  11819. desc.NumChannels = 4;
  11820. desc.Width = width;
  11821. desc.Height = height;
  11822. desc.Depth = depth;
  11823. * \endcode
  11824. *
  11825. * \param pHandle - Returned array
  11826. * \param pAllocateArray - 3D array descriptor
  11827. *
  11828. * \return
  11829. * ::CUDA_SUCCESS,
  11830. * ::CUDA_ERROR_DEINITIALIZED,
  11831. * ::CUDA_ERROR_NOT_INITIALIZED,
  11832. * ::CUDA_ERROR_INVALID_CONTEXT,
  11833. * ::CUDA_ERROR_INVALID_VALUE,
  11834. * ::CUDA_ERROR_OUT_OF_MEMORY,
  11835. * ::CUDA_ERROR_UNKNOWN
  11836. * \notefnerr
  11837. *
  11838. * \sa ::cuArray3DGetDescriptor, ::cuArrayCreate,
  11839. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11840. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11841. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11842. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11843. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11844. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11845. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11846. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  11847. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  11848. * ::cudaMalloc3DArray
  11849. */
  11850. CUresult CUDAAPI cuArray3DCreate(CUarray *pHandle, const CUDA_ARRAY3D_DESCRIPTOR *pAllocateArray);
  11851. /**
  11852. * \brief Get a 3D CUDA array descriptor
  11853. *
  11854. * Returns in \p *pArrayDescriptor a descriptor containing information on the
  11855. * format and dimensions of the CUDA array \p hArray. It is useful for
  11856. * subroutines that have been passed a CUDA array, but need to know the CUDA
  11857. * array parameters for validation or other purposes.
  11858. *
  11859. * This function may be called on 1D and 2D arrays, in which case the \p Height
  11860. * and/or \p Depth members of the descriptor struct will be set to 0.
  11861. *
  11862. * \param pArrayDescriptor - Returned 3D array descriptor
  11863. * \param hArray - 3D array to get descriptor of
  11864. *
  11865. * \return
  11866. * ::CUDA_SUCCESS,
  11867. * ::CUDA_ERROR_DEINITIALIZED,
  11868. * ::CUDA_ERROR_NOT_INITIALIZED,
  11869. * ::CUDA_ERROR_INVALID_CONTEXT,
  11870. * ::CUDA_ERROR_INVALID_VALUE,
  11871. * ::CUDA_ERROR_INVALID_HANDLE,
  11872. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED
  11873. * \notefnerr
  11874. *
  11875. * \sa ::cuArray3DCreate, ::cuArrayCreate,
  11876. * ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost,
  11877. * ::cuMemAllocPitch, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned,
  11878. * ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD,
  11879. * ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync,
  11880. * ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync,
  11881. * ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost,
  11882. * ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc,
  11883. * ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16,
  11884. * ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32,
  11885. * ::cudaArrayGetInfo
  11886. */
  11887. CUresult CUDAAPI cuArray3DGetDescriptor(CUDA_ARRAY3D_DESCRIPTOR *pArrayDescriptor, CUarray hArray);
  11888. /**
  11889. * \brief Creates a CUDA mipmapped array
  11890. *
  11891. * Creates a CUDA mipmapped array according to the ::CUDA_ARRAY3D_DESCRIPTOR structure
  11892. * \p pMipmappedArrayDesc and returns a handle to the new CUDA mipmapped array in \p *pHandle.
  11893. * \p numMipmapLevels specifies the number of mipmap levels to be allocated. This value is
  11894. * clamped to the range [1, 1 + floor(log2(max(width, height, depth)))].
  11895. *
  11896. * The ::CUDA_ARRAY3D_DESCRIPTOR is defined as:
  11897. *
  11898. * \code
  11899. typedef struct {
  11900. unsigned int Width;
  11901. unsigned int Height;
  11902. unsigned int Depth;
  11903. CUarray_format Format;
  11904. unsigned int NumChannels;
  11905. unsigned int Flags;
  11906. } CUDA_ARRAY3D_DESCRIPTOR;
  11907. * \endcode
  11908. * where:
  11909. *
  11910. * - \p Width, \p Height, and \p Depth are the width, height, and depth of the
  11911. * CUDA array (in elements); the following types of CUDA arrays can be allocated:
  11912. * - A 1D mipmapped array is allocated if \p Height and \p Depth extents are both zero.
  11913. * - A 2D mipmapped array is allocated if only \p Depth extent is zero.
  11914. * - A 3D mipmapped array is allocated if all three extents are non-zero.
  11915. * - A 1D layered CUDA mipmapped array is allocated if only \p Height is zero and the
  11916. * ::CUDA_ARRAY3D_LAYERED flag is set. Each layer is a 1D array. The number
  11917. * of layers is determined by the depth extent.
  11918. * - A 2D layered CUDA mipmapped array is allocated if all three extents are non-zero and
  11919. * the ::CUDA_ARRAY3D_LAYERED flag is set. Each layer is a 2D array. The number
  11920. * of layers is determined by the depth extent.
  11921. * - A cubemap CUDA mipmapped array is allocated if all three extents are non-zero and the
  11922. * ::CUDA_ARRAY3D_CUBEMAP flag is set. \p Width must be equal to \p Height, and
  11923. * \p Depth must be six. A cubemap is a special type of 2D layered CUDA array,
  11924. * where the six layers represent the six faces of a cube. The order of the six
  11925. * layers in memory is the same as that listed in ::CUarray_cubemap_face.
  11926. * - A cubemap layered CUDA mipmapped array is allocated if all three extents are non-zero,
  11927. * and both, ::CUDA_ARRAY3D_CUBEMAP and ::CUDA_ARRAY3D_LAYERED flags are set.
  11928. * \p Width must be equal to \p Height, and \p Depth must be a multiple of six.
  11929. * A cubemap layered CUDA array is a special type of 2D layered CUDA array that
  11930. * consists of a collection of cubemaps. The first six layers represent the first
  11931. * cubemap, the next six layers form the second cubemap, and so on.
  11932. *
  11933. * - ::Format specifies the format of the elements; ::CUarray_format is
  11934. * defined as:
  11935. * \code
  11936. typedef enum CUarray_format_enum {
  11937. CU_AD_FORMAT_UNSIGNED_INT8 = 0x01,
  11938. CU_AD_FORMAT_UNSIGNED_INT16 = 0x02,
  11939. CU_AD_FORMAT_UNSIGNED_INT32 = 0x03,
  11940. CU_AD_FORMAT_SIGNED_INT8 = 0x08,
  11941. CU_AD_FORMAT_SIGNED_INT16 = 0x09,
  11942. CU_AD_FORMAT_SIGNED_INT32 = 0x0a,
  11943. CU_AD_FORMAT_HALF = 0x10,
  11944. CU_AD_FORMAT_FLOAT = 0x20,
  11945. CU_AD_FORMAT_NV12 = 0xb0,
  11946. CU_AD_FORMAT_UNORM_INT8X1 = 0xc0,
  11947. CU_AD_FORMAT_UNORM_INT8X2 = 0xc1,
  11948. CU_AD_FORMAT_UNORM_INT8X4 = 0xc2,
  11949. CU_AD_FORMAT_UNORM_INT16X1 = 0xc3,
  11950. CU_AD_FORMAT_UNORM_INT16X2 = 0xc4,
  11951. CU_AD_FORMAT_UNORM_INT16X4 = 0xc5,
  11952. CU_AD_FORMAT_SNORM_INT8X1 = 0xc6,
  11953. CU_AD_FORMAT_SNORM_INT8X2 = 0xc7,
  11954. CU_AD_FORMAT_SNORM_INT8X4 = 0xc8,
  11955. CU_AD_FORMAT_SNORM_INT16X1 = 0xc9,
  11956. CU_AD_FORMAT_SNORM_INT16X2 = 0xca,
  11957. CU_AD_FORMAT_SNORM_INT16X4 = 0xcb,
  11958. CU_AD_FORMAT_BC1_UNORM = 0x91,
  11959. CU_AD_FORMAT_BC1_UNORM_SRGB = 0x92,
  11960. CU_AD_FORMAT_BC2_UNORM = 0x93,
  11961. CU_AD_FORMAT_BC2_UNORM_SRGB = 0x94,
  11962. CU_AD_FORMAT_BC3_UNORM = 0x95,
  11963. CU_AD_FORMAT_BC3_UNORM_SRGB = 0x96,
  11964. CU_AD_FORMAT_BC4_UNORM = 0x97,
  11965. CU_AD_FORMAT_BC4_SNORM = 0x98,
  11966. CU_AD_FORMAT_BC5_UNORM = 0x99,
  11967. CU_AD_FORMAT_BC5_SNORM = 0x9a,
  11968. CU_AD_FORMAT_BC6H_UF16 = 0x9b,
  11969. CU_AD_FORMAT_BC6H_SF16 = 0x9c,
  11970. CU_AD_FORMAT_BC7_UNORM = 0x9d,
  11971. CU_AD_FORMAT_BC7_UNORM_SRGB = 0x9e,
  11972. CU_AD_FORMAT_P010 = 0x9f,
  11973. CU_AD_FORMAT_P016 = 0xa1,
  11974. CU_AD_FORMAT_NV16 = 0xa2,
  11975. CU_AD_FORMAT_P210 = 0xa3,
  11976. CU_AD_FORMAT_P216 = 0xa4,
  11977. CU_AD_FORMAT_YUY2 = 0xa5,
  11978. CU_AD_FORMAT_Y210 = 0xa6,
  11979. CU_AD_FORMAT_Y216 = 0xa7,
  11980. CU_AD_FORMAT_AYUV = 0xa8,
  11981. CU_AD_FORMAT_Y410 = 0xa9,
  11982. CU_AD_FORMAT_Y416 = 0xb1,
  11983. CU_AD_FORMAT_Y444_PLANAR8 = 0xb2,
  11984. CU_AD_FORMAT_Y444_PLANAR10 = 0xb3,
  11985. CU_AD_FORMAT_YUV444_8bit_SemiPlanar = 0xb4,
  11986. CU_AD_FORMAT_YUV444_16bit_SemiPlanar = 0xb5,
  11987. CU_AD_FORMAT_UNORM_INT_101010_2 = 0x50,
  11988. } CUarray_format;
  11989. * \endcode
  11990. *
  11991. * - \p NumChannels specifies the number of packed components per CUDA array
  11992. * element; it may be 1, 2, or 4;
  11993. *
  11994. * - ::Flags may be set to
  11995. * - ::CUDA_ARRAY3D_LAYERED to enable creation of layered CUDA mipmapped arrays. If this flag is set,
  11996. * \p Depth specifies the number of layers, not the depth of a 3D array.
  11997. * - ::CUDA_ARRAY3D_SURFACE_LDST to enable surface references to be bound to individual mipmap levels of
  11998. * the CUDA mipmapped array. If this flag is not set, ::cuSurfRefSetArray will fail when attempting to
  11999. * bind a mipmap level of the CUDA mipmapped array to a surface reference.
  12000. * - ::CUDA_ARRAY3D_CUBEMAP to enable creation of mipmapped cubemaps. If this flag is set, \p Width must be
  12001. * equal to \p Height, and \p Depth must be six. If the ::CUDA_ARRAY3D_LAYERED flag is also set,
  12002. * then \p Depth must be a multiple of six.
  12003. * - ::CUDA_ARRAY3D_TEXTURE_GATHER to indicate that the CUDA mipmapped array will be used for texture gather.
  12004. * Texture gather can only be performed on 2D CUDA mipmapped arrays.
  12005. *
  12006. * \p Width, \p Height and \p Depth must meet certain size requirements as listed in the following table.
  12007. * All values are specified in elements. Note that for brevity's sake, the full name of the device attribute
  12008. * is not specified. For ex., TEXTURE1D_MIPMAPPED_WIDTH refers to the device attribute
  12009. * ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH.
  12010. *
  12011. * <table>
  12012. * <tr><td><b>CUDA array type</b></td>
  12013. * <td><b>Valid extents that must always be met<br>{(width range in elements), (height range),
  12014. * (depth range)}</b></td>
  12015. * <td><b>Valid extents with CUDA_ARRAY3D_SURFACE_LDST set<br>
  12016. * {(width range in elements), (height range), (depth range)}</b></td></tr>
  12017. * <tr><td>1D</td>
  12018. * <td><small>{ (1,TEXTURE1D_MIPMAPPED_WIDTH), 0, 0 }</small></td>
  12019. * <td><small>{ (1,SURFACE1D_WIDTH), 0, 0 }</small></td></tr>
  12020. * <tr><td>2D</td>
  12021. * <td><small>{ (1,TEXTURE2D_MIPMAPPED_WIDTH), (1,TEXTURE2D_MIPMAPPED_HEIGHT), 0 }</small></td>
  12022. * <td><small>{ (1,SURFACE2D_WIDTH), (1,SURFACE2D_HEIGHT), 0 }</small></td></tr>
  12023. * <tr><td>3D</td>
  12024. * <td><small>{ (1,TEXTURE3D_WIDTH), (1,TEXTURE3D_HEIGHT), (1,TEXTURE3D_DEPTH) }
  12025. * <br>OR<br>{ (1,TEXTURE3D_WIDTH_ALTERNATE), (1,TEXTURE3D_HEIGHT_ALTERNATE),
  12026. * (1,TEXTURE3D_DEPTH_ALTERNATE) }</small></td>
  12027. * <td><small>{ (1,SURFACE3D_WIDTH), (1,SURFACE3D_HEIGHT),
  12028. * (1,SURFACE3D_DEPTH) }</small></td></tr>
  12029. * <tr><td>1D Layered</td>
  12030. * <td><small>{ (1,TEXTURE1D_LAYERED_WIDTH), 0,
  12031. * (1,TEXTURE1D_LAYERED_LAYERS) }</small></td>
  12032. * <td><small>{ (1,SURFACE1D_LAYERED_WIDTH), 0,
  12033. * (1,SURFACE1D_LAYERED_LAYERS) }</small></td></tr>
  12034. * <tr><td>2D Layered</td>
  12035. * <td><small>{ (1,TEXTURE2D_LAYERED_WIDTH), (1,TEXTURE2D_LAYERED_HEIGHT),
  12036. * (1,TEXTURE2D_LAYERED_LAYERS) }</small></td>
  12037. * <td><small>{ (1,SURFACE2D_LAYERED_WIDTH), (1,SURFACE2D_LAYERED_HEIGHT),
  12038. * (1,SURFACE2D_LAYERED_LAYERS) }</small></td></tr>
  12039. * <tr><td>Cubemap</td>
  12040. * <td><small>{ (1,TEXTURECUBEMAP_WIDTH), (1,TEXTURECUBEMAP_WIDTH), 6 }</small></td>
  12041. * <td><small>{ (1,SURFACECUBEMAP_WIDTH),
  12042. * (1,SURFACECUBEMAP_WIDTH), 6 }</small></td></tr>
  12043. * <tr><td>Cubemap Layered</td>
  12044. * <td><small>{ (1,TEXTURECUBEMAP_LAYERED_WIDTH), (1,TEXTURECUBEMAP_LAYERED_WIDTH),
  12045. * (1,TEXTURECUBEMAP_LAYERED_LAYERS) }</small></td>
  12046. * <td><small>{ (1,SURFACECUBEMAP_LAYERED_WIDTH), (1,SURFACECUBEMAP_LAYERED_WIDTH),
  12047. * (1,SURFACECUBEMAP_LAYERED_LAYERS) }</small></td></tr>
  12048. * </table>
  12049. *
  12050. *
  12051. * \param pHandle - Returned mipmapped array
  12052. * \param pMipmappedArrayDesc - mipmapped array descriptor
  12053. * \param numMipmapLevels - Number of mipmap levels
  12054. *
  12055. * \return
  12056. * ::CUDA_SUCCESS,
  12057. * ::CUDA_ERROR_DEINITIALIZED,
  12058. * ::CUDA_ERROR_NOT_INITIALIZED,
  12059. * ::CUDA_ERROR_INVALID_CONTEXT,
  12060. * ::CUDA_ERROR_INVALID_VALUE,
  12061. * ::CUDA_ERROR_OUT_OF_MEMORY,
  12062. * ::CUDA_ERROR_UNKNOWN
  12063. * \notefnerr
  12064. *
  12065. * \sa
  12066. * ::cuMipmappedArrayDestroy,
  12067. * ::cuMipmappedArrayGetLevel,
  12068. * ::cuArrayCreate,
  12069. * ::cudaMallocMipmappedArray
  12070. */
  12071. CUresult CUDAAPI cuMipmappedArrayCreate(CUmipmappedArray *pHandle, const CUDA_ARRAY3D_DESCRIPTOR *pMipmappedArrayDesc, unsigned int numMipmapLevels);
  12072. /**
  12073. * \brief Gets a mipmap level of a CUDA mipmapped array
  12074. *
  12075. * Returns in \p *pLevelArray a CUDA array that represents a single mipmap level
  12076. * of the CUDA mipmapped array \p hMipmappedArray.
  12077. *
  12078. * If \p level is greater than the maximum number of levels in this mipmapped array,
  12079. * ::CUDA_ERROR_INVALID_VALUE is returned.
  12080. *
  12081. * \param pLevelArray - Returned mipmap level CUDA array
  12082. * \param hMipmappedArray - CUDA mipmapped array
  12083. * \param level - Mipmap level
  12084. *
  12085. * \return
  12086. * ::CUDA_SUCCESS,
  12087. * ::CUDA_ERROR_DEINITIALIZED,
  12088. * ::CUDA_ERROR_NOT_INITIALIZED,
  12089. * ::CUDA_ERROR_INVALID_CONTEXT,
  12090. * ::CUDA_ERROR_INVALID_VALUE,
  12091. * ::CUDA_ERROR_INVALID_HANDLE
  12092. * \notefnerr
  12093. *
  12094. * \sa
  12095. * ::cuMipmappedArrayCreate,
  12096. * ::cuMipmappedArrayDestroy,
  12097. * ::cuArrayCreate,
  12098. * ::cudaGetMipmappedArrayLevel
  12099. */
  12100. CUresult CUDAAPI cuMipmappedArrayGetLevel(CUarray *pLevelArray, CUmipmappedArray hMipmappedArray, unsigned int level);
  12101. /**
  12102. * \brief Destroys a CUDA mipmapped array
  12103. *
  12104. * Destroys the CUDA mipmapped array \p hMipmappedArray.
  12105. *
  12106. * \param hMipmappedArray - Mipmapped array to destroy
  12107. *
  12108. * \return
  12109. * ::CUDA_SUCCESS,
  12110. * ::CUDA_ERROR_DEINITIALIZED,
  12111. * ::CUDA_ERROR_NOT_INITIALIZED,
  12112. * ::CUDA_ERROR_INVALID_CONTEXT,
  12113. * ::CUDA_ERROR_INVALID_HANDLE,
  12114. * ::CUDA_ERROR_ARRAY_IS_MAPPED,
  12115. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED
  12116. * \notefnerr
  12117. *
  12118. * \sa
  12119. * ::cuMipmappedArrayCreate,
  12120. * ::cuMipmappedArrayGetLevel,
  12121. * ::cuArrayCreate,
  12122. * ::cudaFreeMipmappedArray
  12123. */
  12124. CUresult CUDAAPI cuMipmappedArrayDestroy(CUmipmappedArray hMipmappedArray);
  12125. /**
  12126. * \brief Retrieve handle for an address range
  12127. *
  12128. * Get a handle of the specified type to an address range. The address range
  12129. * must have been obtained by a prior call to either ::cuMemAlloc or ::cuMemAddressReserve.
  12130. * If the address range was obtained via ::cuMemAddressReserve, it must also be fully mapped via ::cuMemMap.
  12131. * The address range must have been obtained by a prior call to either ::cuMemAllocHost or
  12132. * ::cuMemHostAlloc on Tegra.
  12133. *
  12134. * Users must ensure the \p dptr and \p size are aligned to the host page size.
  12135. *
  12136. * When requesting CUmemRangeHandleType::CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD,
  12137. * users are expected to query for dma_buf support for the platform
  12138. * by using ::CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED device attribute before calling
  12139. * this API. The \p handle will be interpreted as a pointer to an integer to store the dma_buf file descriptor.
  12140. * Users must ensure the entire address range is backed and mapped when
  12141. * the address range is allocated by ::cuMemAddressReserve. All the physical
  12142. * allocations backing the address range must be resident on the same device and
  12143. * have identical allocation properties. Users are also expected to retrieve a
  12144. * new handle every time the underlying physical allocation(s) corresponding
  12145. * to a previously queried VA range are changed.
  12146. *
  12147. * For CUmemRangeHandleType::CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD, users may set
  12148. * flags to ::CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE. Which when set on a
  12149. * supported platform, will give a DMA_BUF handle mapped via PCIE BAR1 or will
  12150. * return an error otherwise.
  12151. *
  12152. * \param[out] handle - Pointer to the location where the returned handle will be stored.
  12153. * \param[in] dptr - Pointer to a valid CUDA device allocation. Must be aligned to host page size.
  12154. * \param[in] size - Length of the address range. Must be aligned to host page size.
  12155. * \param[in] handleType - Type of handle requested (defines type and size of the \p handle output parameter)
  12156. * \param[in] flags - When requesting CUmemRangeHandleType::CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD the value could be
  12157. * ::CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE, otherwise 0.
  12158. *
  12159. * \return
  12160. * CUDA_SUCCESS
  12161. * CUDA_ERROR_INVALID_VALUE
  12162. * CUDA_ERROR_NOT_SUPPORTED
  12163. */
  12164. CUresult CUDAAPI cuMemGetHandleForAddressRange(void *handle, CUdeviceptr dptr, size_t size, CUmemRangeHandleType handleType, unsigned long long flags);
  12165. /**
  12166. * \brief Bitmasks for CU_DEVICE_ATTRIBUTE_MEM_DECOMPRESS_ALGORITHM_MASK.
  12167. */
  12168. typedef enum CUmemDecompressAlgorithm_enum {
  12169. CU_MEM_DECOMPRESS_UNSUPPORTED = 0, /**< Decompression is unsupported. */
  12170. CU_MEM_DECOMPRESS_ALGORITHM_DEFLATE = 1<<0, /**< Deflate is supported. */
  12171. CU_MEM_DECOMPRESS_ALGORITHM_SNAPPY = 1<<1 /**< Snappy is supported. */
  12172. } CUmemDecompressAlgorithm;
  12173. /**
  12174. * \brief Structure describing the parameters that compose a single
  12175. * decompression operation.
  12176. */
  12177. typedef struct CUmemDecompressParams_st {
  12178. /** The number of bytes to be read and decompressed from
  12179. * ::CUmemDecompressParams_st.src. */
  12180. size_t srcNumBytes;
  12181. /** The number of bytes that the decompression operation will be expected to
  12182. * write to ::CUmemDecompressParams_st.dst. This value is optional; if
  12183. * present, it may be used by the CUDA driver as a heuristic for scheduling
  12184. * the individual decompression operations. */
  12185. size_t dstNumBytes;
  12186. /** After the decompression operation has completed, the actual number of
  12187. * bytes written to ::CUmemDecompressParams.dst will be recorded as a 32-bit
  12188. * unsigned integer in the memory at this address. */
  12189. cuuint32_t *dstActBytes;
  12190. /** Pointer to a buffer of at least ::CUmemDecompressParams_st.srcNumBytes
  12191. * compressed bytes. */
  12192. const void *src;
  12193. /** Pointer to a buffer where the decompressed data will be written. The
  12194. * number of bytes written to this location will be recorded in the memory
  12195. * pointed to by ::CUmemDecompressParams_st.dstActBytes */
  12196. void *dst;
  12197. /** The decompression algorithm to use. */
  12198. CUmemDecompressAlgorithm algo;
  12199. /* These bytes are unused and must be zeroed. This ensures compatibility if
  12200. * additional fields are added in the future. */
  12201. unsigned char padding[20];
  12202. } CUmemDecompressParams;
  12203. /**
  12204. * \brief Submit a batch of \p count independent decompression operations.
  12205. *
  12206. * \details Each of the \p count decompression operations is described by a
  12207. * single entry in the \p paramsArray array. Once the batch has been
  12208. * submitted, the function will return, and decompression will happen
  12209. * asynchronously w.r.t. the CPU. To the work completion tracking
  12210. * mechanisms in the CUDA driver, the batch will be considered a single
  12211. * unit of work and processed according to stream semantics, i.e., it
  12212. * is not possible to query the completion of individual decompression
  12213. * operations within a batch.
  12214. *
  12215. * The memory pointed to by each of ::CUmemDecompressParams.src,
  12216. * ::CUmemDecompressParams.dst, and ::CUmemDecompressParams.dstActBytes,
  12217. * must be capable of usage with the hardware decompress feature. That
  12218. * is, for each of said pointers, the pointer attribute
  12219. * ::CU_POINTER_ATTRIBUTE_IS_MEM_DECOMPRESS_CAPABLE should give a
  12220. * non-zero value. To ensure this, the memory backing the pointers
  12221. * should have been allocated using one of the following CUDA memory
  12222. * allocators:
  12223. * * ::cuMemAlloc()
  12224. * * ::cuMemCreate() with the usage flag ::CU_MEM_CREATE_USAGE_HW_DECOMPRESS
  12225. * * ::cuMemAllocFromPoolAsync() from a pool that was created with
  12226. * the usage flag ::CU_MEM_POOL_CREATE_USAGE_HW_DECOMPRESS
  12227. * Additionally, ::CUmemDecompressParams.src, ::CUmemDecompressParams.dst,
  12228. * and ::CUmemDecompressParams.dstActBytes, must all be accessible from
  12229. * the device associated with the context where \p stream was created.
  12230. * For information on how to ensure this, see the documentation for the
  12231. * allocator of interest.
  12232. *
  12233. * \param[in] paramsArray The array of structures describing the independent
  12234. * decompression operations.
  12235. * \param[in] count The number of entries in \p paramsArray array.
  12236. * \param[in] flags Must be 0.
  12237. * \param[out] errorIndex The index into \p paramsArray of the decompression
  12238. * operation for which the error returned by this
  12239. * function pertains to. If \p index is SIZE_MAX and
  12240. * the value returned is not ::CUDA_SUCCESS, then the
  12241. * error returned by this function should be considered
  12242. * a general error that does not pertain to a
  12243. * particular decompression operation. May be \p NULL,
  12244. * in which case, no index will be recorded in the
  12245. * event of error.
  12246. * \param[in] stream The stream where the work will be enqueued.
  12247. *
  12248. * \return
  12249. * ::CUDA_SUCCESS,
  12250. * ::CUDA_ERROR_DEINITIALIZED,
  12251. * ::CUDA_ERROR_NOT_INITIALIZED,
  12252. * ::CUDA_ERROR_INVALID_CONTEXT,
  12253. * ::CUDA_ERROR_INVALID_VALUE,
  12254. * ::CUDA_ERROR_INVALID_HANDLE
  12255. * \notefnerr
  12256. * \note_async
  12257. * \note_null_stream
  12258. *
  12259. * \sa ::cuMemAlloc, ::cuMemPoolCreate, ::cuMemAllocFromPoolAsync
  12260. */
  12261. CUresult CUDAAPI cuMemBatchDecompressAsync(
  12262. CUmemDecompressParams *paramsArray,
  12263. size_t count,
  12264. unsigned int flags,
  12265. size_t *errorIndex,
  12266. CUstream stream
  12267. );
  12268. /** @} */ /* END CUDA_MEM */
  12269. /**
  12270. * \defgroup CUDA_VA Virtual Memory Management
  12271. *
  12272. * ___MANBRIEF___ virtual memory management functions of the low-level CUDA driver API
  12273. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  12274. *
  12275. * This section describes the virtual memory management functions of the low-level CUDA
  12276. * driver application programming interface.
  12277. *
  12278. * @{
  12279. */
  12280. /**
  12281. * \brief Allocate an address range reservation.
  12282. *
  12283. * Reserves a virtual address range based on the given parameters, giving
  12284. * the starting address of the range in \p ptr. This API requires a system that
  12285. * supports UVA. The size and address parameters must be a multiple of the
  12286. * host page size and the alignment must be a power of two or zero for default
  12287. * alignment.
  12288. *
  12289. * \param[out] ptr - Resulting pointer to start of virtual address range allocated
  12290. * \param[in] size - Size of the reserved virtual address range requested
  12291. * \param[in] alignment - Alignment of the reserved virtual address range requested
  12292. * \param[in] addr - Fixed starting address range requested
  12293. * \param[in] flags - Currently unused, must be zero
  12294. * \return
  12295. * ::CUDA_SUCCESS,
  12296. * ::CUDA_ERROR_INVALID_VALUE,
  12297. * ::CUDA_ERROR_OUT_OF_MEMORY,
  12298. * ::CUDA_ERROR_NOT_INITIALIZED,
  12299. * ::CUDA_ERROR_DEINITIALIZED,
  12300. * ::CUDA_ERROR_NOT_PERMITTED,
  12301. * ::CUDA_ERROR_NOT_SUPPORTED
  12302. *
  12303. * \sa ::cuMemAddressFree
  12304. */
  12305. CUresult CUDAAPI cuMemAddressReserve(CUdeviceptr *ptr, size_t size, size_t alignment, CUdeviceptr addr, unsigned long long flags);
  12306. /**
  12307. * \brief Free an address range reservation.
  12308. *
  12309. * Frees a virtual address range reserved by cuMemAddressReserve. The size
  12310. * must match what was given to memAddressReserve and the ptr given must
  12311. * match what was returned from memAddressReserve.
  12312. *
  12313. * \param[in] ptr - Starting address of the virtual address range to free
  12314. * \param[in] size - Size of the virtual address region to free
  12315. * \return
  12316. * ::CUDA_SUCCESS,
  12317. * ::CUDA_ERROR_INVALID_VALUE,
  12318. * ::CUDA_ERROR_NOT_INITIALIZED,
  12319. * ::CUDA_ERROR_DEINITIALIZED,
  12320. * ::CUDA_ERROR_NOT_PERMITTED,
  12321. * ::CUDA_ERROR_NOT_SUPPORTED
  12322. *
  12323. * \sa ::cuMemAddressReserve
  12324. */
  12325. CUresult CUDAAPI cuMemAddressFree(CUdeviceptr ptr, size_t size);
  12326. /**
  12327. * \brief Create a CUDA memory handle representing a memory allocation of a given size described by the given properties
  12328. *
  12329. * This creates a memory allocation on the target device specified through the
  12330. * \p prop structure. The created allocation will not have any device or host
  12331. * mappings. The generic memory \p handle for the allocation can be
  12332. * mapped to the address space of calling process via ::cuMemMap. This handle
  12333. * cannot be transmitted directly to other processes (see
  12334. * ::cuMemExportToShareableHandle). On Windows, the caller must also pass
  12335. * an LPSECURITYATTRIBUTE in \p prop to be associated with this handle which
  12336. * limits or allows access to this handle for a recipient process (see
  12337. * ::CUmemAllocationProp::win32HandleMetaData for more). The \p size of this
  12338. * allocation must be a multiple of the the value given via
  12339. * ::cuMemGetAllocationGranularity with the ::CU_MEM_ALLOC_GRANULARITY_MINIMUM
  12340. * flag.
  12341. * To create a CPU allocation targeting a specific host NUMA node, applications must
  12342. * set ::CUmemAllocationProp::CUmemLocation::type to ::CU_MEM_LOCATION_TYPE_HOST_NUMA and
  12343. * ::CUmemAllocationProp::CUmemLocation::id must specify the NUMA ID of the CPU.
  12344. * On systems where NUMA is not available ::CUmemAllocationProp::CUmemLocation::id must be set to 0.
  12345. * Specifying ::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT or ::CU_MEM_LOCATION_TYPE_HOST as the
  12346. * ::CUmemLocation::type will result in ::CUDA_ERROR_INVALID_VALUE.
  12347. *
  12348. * Applications that intend to use ::CU_MEM_HANDLE_TYPE_FABRIC based memory sharing must ensure:
  12349. * (1) `nvidia-caps-imex-channels` character device is created by the driver and is listed under /proc/devices
  12350. * (2) have at least one IMEX channel file accessible by the user launching the application.
  12351. *
  12352. * When exporter and importer CUDA processes have been granted access to the same IMEX channel, they can securely
  12353. * share memory.
  12354. *
  12355. * The IMEX channel security model works on a per user basis. Which means all processes under a user can share
  12356. * memory if the user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX
  12357. * channel is required for each user.
  12358. *
  12359. * These channel files exist in /dev/nvidia-caps-imex-channels/channel* and can be created using standard OS
  12360. * native calls like mknod on Linux. For example: To create channel0 with the major number from /proc/devices
  12361. * users can execute the following command: `mknod /dev/nvidia-caps-imex-channels/channel0 c <major number> 0`
  12362. *
  12363. * If ::CUmemAllocationProp::allocFlags::usage contains ::CU_MEM_CREATE_USAGE_TILE_POOL flag then
  12364. * the memory allocation is intended only to be used as backing tile pool for sparse CUDA arrays
  12365. * and sparse CUDA mipmapped arrays.
  12366. * (see ::cuMemMapArrayAsync).
  12367. *
  12368. * \param[out] handle - Value of handle returned. All operations on this allocation are to be performed using this handle.
  12369. * \param[in] size - Size of the allocation requested
  12370. * \param[in] prop - Properties of the allocation to create.
  12371. * \param[in] flags - flags for future use, must be zero now.
  12372. * \return
  12373. * ::CUDA_SUCCESS,
  12374. * ::CUDA_ERROR_INVALID_VALUE,
  12375. * ::CUDA_ERROR_OUT_OF_MEMORY,
  12376. * ::CUDA_ERROR_INVALID_DEVICE,
  12377. * ::CUDA_ERROR_NOT_INITIALIZED,
  12378. * ::CUDA_ERROR_DEINITIALIZED,
  12379. * ::CUDA_ERROR_NOT_PERMITTED,
  12380. * ::CUDA_ERROR_NOT_SUPPORTED
  12381. * \notefnerr
  12382. *
  12383. * \sa ::cuMemRelease, ::cuMemExportToShareableHandle, ::cuMemImportFromShareableHandle
  12384. */
  12385. CUresult CUDAAPI cuMemCreate(CUmemGenericAllocationHandle *handle, size_t size, const CUmemAllocationProp *prop, unsigned long long flags);
  12386. /**
  12387. * \brief Release a memory handle representing a memory allocation which was previously allocated through cuMemCreate.
  12388. *
  12389. * Frees the memory that was allocated on a device through cuMemCreate.
  12390. *
  12391. * The memory allocation will be freed when all outstanding mappings to the memory
  12392. * are unmapped and when all outstanding references to the handle (including it's
  12393. * shareable counterparts) are also released. The generic memory handle can be
  12394. * freed when there are still outstanding mappings made with this handle. Each
  12395. * time a recipient process imports a shareable handle, it needs to pair it with
  12396. * ::cuMemRelease for the handle to be freed. If \p handle is not a valid handle
  12397. * the behavior is undefined.
  12398. *
  12399. * \param[in] handle Value of handle which was returned previously by cuMemCreate.
  12400. * \return
  12401. * ::CUDA_SUCCESS,
  12402. * ::CUDA_ERROR_INVALID_VALUE,
  12403. * ::CUDA_ERROR_NOT_INITIALIZED,
  12404. * ::CUDA_ERROR_DEINITIALIZED,
  12405. * ::CUDA_ERROR_NOT_PERMITTED,
  12406. * ::CUDA_ERROR_NOT_SUPPORTED
  12407. * \notefnerr
  12408. *
  12409. * \sa ::cuMemCreate
  12410. */
  12411. CUresult CUDAAPI cuMemRelease(CUmemGenericAllocationHandle handle);
  12412. /**
  12413. * \brief Maps an allocation handle to a reserved virtual address range.
  12414. *
  12415. * Maps bytes of memory represented by \p handle starting from byte \p offset to
  12416. * \p size to address range [\p addr, \p addr + \p size]. This range must be an
  12417. * address reservation previously reserved with ::cuMemAddressReserve, and
  12418. * \p offset + \p size must be less than the size of the memory allocation.
  12419. * Both \p ptr, \p size, and \p offset must be a multiple of the value given via
  12420. * ::cuMemGetAllocationGranularity with the ::CU_MEM_ALLOC_GRANULARITY_MINIMUM flag.
  12421. * If \p handle represents a multicast object, \p ptr, \p size and \p offset must
  12422. * be aligned to the value returned by ::cuMulticastGetGranularity with the flag
  12423. * ::CU_MULTICAST_MINIMUM_GRANULARITY. For best performance however, it is
  12424. * recommended that \p ptr, \p size and \p offset be aligned to the value
  12425. * returned by ::cuMulticastGetGranularity with the flag
  12426. * ::CU_MULTICAST_RECOMMENDED_GRANULARITY.
  12427. *
  12428. * Please note calling ::cuMemMap does not make the address accessible,
  12429. * the caller needs to update accessibility of a contiguous mapped VA
  12430. * range by calling ::cuMemSetAccess.
  12431. *
  12432. * Once a recipient process obtains a shareable memory handle
  12433. * from ::cuMemImportFromShareableHandle, the process must
  12434. * use ::cuMemMap to map the memory into its address ranges before
  12435. * setting accessibility with ::cuMemSetAccess.
  12436. *
  12437. * ::cuMemMap can only create mappings on VA range reservations
  12438. * that are not currently mapped.
  12439. *
  12440. * \param[in] ptr - Address where memory will be mapped.
  12441. * \param[in] size - Size of the memory mapping.
  12442. * \param[in] offset - Offset into the memory represented by
  12443. * - \p handle from which to start mapping
  12444. * - Note: currently must be zero.
  12445. * \param[in] handle - Handle to a shareable memory
  12446. * \param[in] flags - flags for future use, must be zero now.
  12447. * \return
  12448. * ::CUDA_SUCCESS,
  12449. * ::CUDA_ERROR_INVALID_VALUE,
  12450. * ::CUDA_ERROR_INVALID_DEVICE,
  12451. * ::CUDA_ERROR_OUT_OF_MEMORY,
  12452. * ::CUDA_ERROR_NOT_INITIALIZED,
  12453. * ::CUDA_ERROR_DEINITIALIZED,
  12454. * ::CUDA_ERROR_NOT_PERMITTED,
  12455. * ::CUDA_ERROR_NOT_SUPPORTED
  12456. * \notefnerr
  12457. *
  12458. * \sa ::cuMemUnmap, ::cuMemSetAccess, ::cuMemCreate, ::cuMemAddressReserve, ::cuMemImportFromShareableHandle
  12459. */
  12460. CUresult CUDAAPI cuMemMap(CUdeviceptr ptr, size_t size, size_t offset, CUmemGenericAllocationHandle handle, unsigned long long flags);
  12461. /**
  12462. * \brief Maps or unmaps subregions of sparse CUDA arrays and sparse CUDA mipmapped arrays
  12463. *
  12464. * Performs map or unmap operations on subregions of sparse CUDA arrays and sparse CUDA mipmapped arrays.
  12465. * Each operation is specified by a ::CUarrayMapInfo entry in the \p mapInfoList array of size \p count.
  12466. * The structure ::CUarrayMapInfo is defined as follow:
  12467. \code
  12468. typedef struct CUarrayMapInfo_st {
  12469. CUresourcetype resourceType;
  12470. union {
  12471. CUmipmappedArray mipmap;
  12472. CUarray array;
  12473. } resource;
  12474. CUarraySparseSubresourceType subresourceType;
  12475. union {
  12476. struct {
  12477. unsigned int level;
  12478. unsigned int layer;
  12479. unsigned int offsetX;
  12480. unsigned int offsetY;
  12481. unsigned int offsetZ;
  12482. unsigned int extentWidth;
  12483. unsigned int extentHeight;
  12484. unsigned int extentDepth;
  12485. } sparseLevel;
  12486. struct {
  12487. unsigned int layer;
  12488. unsigned long long offset;
  12489. unsigned long long size;
  12490. } miptail;
  12491. } subresource;
  12492. CUmemOperationType memOperationType;
  12493. CUmemHandleType memHandleType;
  12494. union {
  12495. CUmemGenericAllocationHandle memHandle;
  12496. } memHandle;
  12497. unsigned long long offset;
  12498. unsigned int deviceBitMask;
  12499. unsigned int flags;
  12500. unsigned int reserved[2];
  12501. } CUarrayMapInfo;
  12502. \endcode
  12503. *
  12504. * where ::CUarrayMapInfo::resourceType specifies the type of resource to be operated on.
  12505. * If ::CUarrayMapInfo::resourceType is set to ::CUresourcetype::CU_RESOURCE_TYPE_ARRAY then
  12506. * ::CUarrayMapInfo::resource::array must be set to a valid sparse CUDA array handle.
  12507. * The CUDA array must be either a 2D, 2D layered or 3D CUDA array and must have been allocated using
  12508. * ::cuArrayCreate or ::cuArray3DCreate with the flag ::CUDA_ARRAY3D_SPARSE
  12509. * or ::CUDA_ARRAY3D_DEFERRED_MAPPING.
  12510. * For CUDA arrays obtained using ::cuMipmappedArrayGetLevel, ::CUDA_ERROR_INVALID_VALUE will be returned.
  12511. * If ::CUarrayMapInfo::resourceType is set to ::CUresourcetype::CU_RESOURCE_TYPE_MIPMAPPED_ARRAY
  12512. * then ::CUarrayMapInfo::resource::mipmap must be set to a valid sparse CUDA mipmapped array handle.
  12513. * The CUDA mipmapped array must be either a 2D, 2D layered or 3D CUDA mipmapped array and must have been
  12514. * allocated using ::cuMipmappedArrayCreate with the flag ::CUDA_ARRAY3D_SPARSE
  12515. * or ::CUDA_ARRAY3D_DEFERRED_MAPPING.
  12516. *
  12517. * ::CUarrayMapInfo::subresourceType specifies the type of subresource within the resource.
  12518. * ::CUarraySparseSubresourceType_enum is defined as:
  12519. \code
  12520. typedef enum CUarraySparseSubresourceType_enum {
  12521. CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_SPARSE_LEVEL = 0,
  12522. CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_MIPTAIL = 1
  12523. } CUarraySparseSubresourceType;
  12524. \endcode
  12525. *
  12526. * where ::CUarraySparseSubresourceType::CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_SPARSE_LEVEL indicates a
  12527. * sparse-miplevel which spans at least one tile in every dimension. The remaining miplevels which
  12528. * are too small to span at least one tile in any dimension constitute the mip tail region as indicated by
  12529. * ::CUarraySparseSubresourceType::CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_MIPTAIL subresource type.
  12530. *
  12531. * If ::CUarrayMapInfo::subresourceType is set to ::CUarraySparseSubresourceType::CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_SPARSE_LEVEL
  12532. * then ::CUarrayMapInfo::subresource::sparseLevel struct must contain valid array subregion offsets and extents.
  12533. * The ::CUarrayMapInfo::subresource::sparseLevel::offsetX, ::CUarrayMapInfo::subresource::sparseLevel::offsetY
  12534. * and ::CUarrayMapInfo::subresource::sparseLevel::offsetZ must specify valid X, Y and Z offsets respectively.
  12535. * The ::CUarrayMapInfo::subresource::sparseLevel::extentWidth, ::CUarrayMapInfo::subresource::sparseLevel::extentHeight
  12536. * and ::CUarrayMapInfo::subresource::sparseLevel::extentDepth must specify valid width, height and depth extents respectively.
  12537. * These offsets and extents must be aligned to the corresponding tile dimension.
  12538. * For CUDA mipmapped arrays ::CUarrayMapInfo::subresource::sparseLevel::level must specify a valid mip level index. Otherwise,
  12539. * must be zero.
  12540. * For layered CUDA arrays and layered CUDA mipmapped arrays ::CUarrayMapInfo::subresource::sparseLevel::layer must specify a valid layer index. Otherwise,
  12541. * must be zero.
  12542. * ::CUarrayMapInfo::subresource::sparseLevel::offsetZ must be zero and ::CUarrayMapInfo::subresource::sparseLevel::extentDepth
  12543. * must be set to 1 for 2D and 2D layered CUDA arrays and CUDA mipmapped arrays.
  12544. * Tile extents can be obtained by calling ::cuArrayGetSparseProperties and ::cuMipmappedArrayGetSparseProperties
  12545. *
  12546. * If ::CUarrayMapInfo::subresourceType is set to ::CUarraySparseSubresourceType::CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_MIPTAIL
  12547. * then ::CUarrayMapInfo::subresource::miptail struct must contain valid mip tail offset in
  12548. * ::CUarrayMapInfo::subresource::miptail::offset and size in ::CUarrayMapInfo::subresource::miptail::size.
  12549. * Both, mip tail offset and mip tail size must be aligned to the tile size.
  12550. * For layered CUDA mipmapped arrays which don't have the flag ::CU_ARRAY_SPARSE_PROPERTIES_SINGLE_MIPTAIL set in ::CUDA_ARRAY_SPARSE_PROPERTIES::flags
  12551. * as returned by ::cuMipmappedArrayGetSparseProperties, ::CUarrayMapInfo::subresource::miptail::layer must specify a valid layer index.
  12552. * Otherwise, must be zero.
  12553. *
  12554. * If ::CUarrayMapInfo::resource::array or ::CUarrayMapInfo::resource::mipmap was created with ::CUDA_ARRAY3D_DEFERRED_MAPPING
  12555. * flag set the ::CUarrayMapInfo::subresourceType and the contents of ::CUarrayMapInfo::subresource will be ignored.
  12556. *
  12557. * ::CUarrayMapInfo::memOperationType specifies the type of operation. ::CUmemOperationType is defined as:
  12558. \code
  12559. typedef enum CUmemOperationType_enum {
  12560. CU_MEM_OPERATION_TYPE_MAP = 1,
  12561. CU_MEM_OPERATION_TYPE_UNMAP = 2
  12562. } CUmemOperationType;
  12563. \endcode
  12564. * If ::CUarrayMapInfo::memOperationType is set to ::CUmemOperationType::CU_MEM_OPERATION_TYPE_MAP then the subresource
  12565. * will be mapped onto the tile pool memory specified by ::CUarrayMapInfo::memHandle at offset ::CUarrayMapInfo::offset.
  12566. * The tile pool allocation has to be created by specifying the ::CU_MEM_CREATE_USAGE_TILE_POOL flag when calling ::cuMemCreate. Also,
  12567. * ::CUarrayMapInfo::memHandleType must be set to ::CUmemHandleType::CU_MEM_HANDLE_TYPE_GENERIC.
  12568. *
  12569. * If ::CUarrayMapInfo::memOperationType is set to ::CUmemOperationType::CU_MEM_OPERATION_TYPE_UNMAP then an unmapping operation
  12570. * is performed. ::CUarrayMapInfo::memHandle must be NULL.
  12571. *
  12572. * ::CUarrayMapInfo::deviceBitMask specifies the list of devices that must map or unmap physical memory.
  12573. * Currently, this mask must have exactly one bit set, and the corresponding device must match the device associated with the stream.
  12574. * If ::CUarrayMapInfo::memOperationType is set to ::CUmemOperationType::CU_MEM_OPERATION_TYPE_MAP, the device must also match
  12575. * the device associated with the tile pool memory allocation as specified by ::CUarrayMapInfo::memHandle.
  12576. *
  12577. * ::CUarrayMapInfo::flags and ::CUarrayMapInfo::reserved[] are unused and must be set to zero.
  12578. *
  12579. * \return
  12580. * ::CUDA_SUCCESS,
  12581. * ::CUDA_ERROR_INVALID_VALUE,
  12582. * ::CUDA_ERROR_INVALID_HANDLE
  12583. *
  12584. * \param[in] mapInfoList - List of ::CUarrayMapInfo
  12585. * \param[in] count - Count of ::CUarrayMapInfo in \p mapInfoList
  12586. * \param[in] hStream - Stream identifier for the stream to use for map or unmap operations
  12587. *
  12588. * \sa ::cuMipmappedArrayCreate, ::cuArrayCreate, ::cuArray3DCreate, ::cuMemCreate, ::cuArrayGetSparseProperties, ::cuMipmappedArrayGetSparseProperties
  12589. */
  12590. CUresult CUDAAPI cuMemMapArrayAsync(CUarrayMapInfo *mapInfoList, unsigned int count, CUstream hStream);
  12591. /**
  12592. * \brief Unmap the backing memory of a given address range.
  12593. *
  12594. * The range must be the entire contiguous address range that was mapped to. In
  12595. * other words, ::cuMemUnmap cannot unmap a sub-range of an address range mapped
  12596. * by ::cuMemCreate / ::cuMemMap. Any backing memory allocations will be freed
  12597. * if there are no existing mappings and there are no unreleased memory handles.
  12598. *
  12599. * When ::cuMemUnmap returns successfully the address range is converted to an
  12600. * address reservation and can be used for a future calls to ::cuMemMap. Any new
  12601. * mapping to this virtual address will need to have access granted through
  12602. * ::cuMemSetAccess, as all mappings start with no accessibility setup.
  12603. *
  12604. * \param[in] ptr - Starting address for the virtual address range to unmap
  12605. * \param[in] size - Size of the virtual address range to unmap
  12606. * \returns
  12607. * ::CUDA_SUCCESS,
  12608. * ::CUDA_ERROR_INVALID_VALUE,
  12609. * ::CUDA_ERROR_NOT_INITIALIZED,
  12610. * ::CUDA_ERROR_DEINITIALIZED,
  12611. * ::CUDA_ERROR_NOT_PERMITTED,
  12612. * ::CUDA_ERROR_NOT_SUPPORTED
  12613. * \notefnerr
  12614. * \note_sync
  12615. *
  12616. * \sa ::cuMemCreate, ::cuMemAddressReserve
  12617. */
  12618. CUresult CUDAAPI cuMemUnmap(CUdeviceptr ptr, size_t size);
  12619. /**
  12620. * \brief Set the access flags for each location specified in \p desc for the given virtual address range
  12621. *
  12622. * Given the virtual address range via \p ptr and \p size, and the locations
  12623. * in the array given by \p desc and \p count, set the access flags for the
  12624. * target locations. The range must be a fully mapped address range
  12625. * containing all allocations created by ::cuMemMap / ::cuMemCreate.
  12626. * Users cannot specify ::CU_MEM_LOCATION_TYPE_HOST_NUMA accessibility for allocations created on with other location types.
  12627. * Note: When ::CUmemAccessDesc::CUmemLocation::type is ::CU_MEM_LOCATION_TYPE_HOST_NUMA, ::CUmemAccessDesc::CUmemLocation::id
  12628. * is ignored.
  12629. * When setting the access flags for a virtual address range mapping a multicast
  12630. * object, \p ptr and \p size must be aligned to the value returned by
  12631. * ::cuMulticastGetGranularity with the flag ::CU_MULTICAST_MINIMUM_GRANULARITY.
  12632. * For best performance however, it is recommended that \p ptr and \p size be
  12633. * aligned to the value returned by ::cuMulticastGetGranularity with the flag
  12634. * ::CU_MULTICAST_RECOMMENDED_GRANULARITY.
  12635. *
  12636. * \param[in] ptr - Starting address for the virtual address range
  12637. * \param[in] size - Length of the virtual address range
  12638. * \param[in] desc - Array of ::CUmemAccessDesc that describe how to change the
  12639. * - mapping for each location specified
  12640. * \param[in] count - Number of ::CUmemAccessDesc in \p desc
  12641. * \returns
  12642. * ::CUDA_SUCCESS,
  12643. * ::CUDA_ERROR_INVALID_VALUE,
  12644. * ::CUDA_ERROR_INVALID_DEVICE,
  12645. * ::CUDA_ERROR_NOT_SUPPORTED
  12646. * \notefnerr
  12647. * \note_sync
  12648. *
  12649. * \sa ::cuMemSetAccess, ::cuMemCreate, :cuMemMap
  12650. */
  12651. CUresult CUDAAPI cuMemSetAccess(CUdeviceptr ptr, size_t size, const CUmemAccessDesc *desc, size_t count);
  12652. /**
  12653. * \brief Get the access \p flags set for the given \p location and \p ptr
  12654. *
  12655. * \param[out] flags - Flags set for this location
  12656. * \param[in] location - Location in which to check the flags for
  12657. * \param[in] ptr - Address in which to check the access flags for
  12658. * \returns
  12659. * ::CUDA_SUCCESS,
  12660. * ::CUDA_ERROR_INVALID_VALUE,
  12661. * ::CUDA_ERROR_INVALID_DEVICE,
  12662. * ::CUDA_ERROR_NOT_INITIALIZED,
  12663. * ::CUDA_ERROR_DEINITIALIZED,
  12664. * ::CUDA_ERROR_NOT_PERMITTED,
  12665. * ::CUDA_ERROR_NOT_SUPPORTED
  12666. *
  12667. * \sa ::cuMemSetAccess
  12668. */
  12669. CUresult CUDAAPI cuMemGetAccess(unsigned long long *flags, const CUmemLocation *location, CUdeviceptr ptr);
  12670. /**
  12671. * \brief Exports an allocation to a requested shareable handle type
  12672. *
  12673. * Given a CUDA memory handle, create a shareable memory
  12674. * allocation handle that can be used to share the memory with other
  12675. * processes. The recipient process can convert the shareable handle back into a
  12676. * CUDA memory handle using ::cuMemImportFromShareableHandle and map
  12677. * it with ::cuMemMap. The implementation of what this handle is and how it
  12678. * can be transferred is defined by the requested handle type in \p handleType
  12679. *
  12680. * Once all shareable handles are closed and the allocation is released, the allocated
  12681. * memory referenced will be released back to the OS and uses of the CUDA handle afterward
  12682. * will lead to undefined behavior.
  12683. *
  12684. * This API can also be used in conjunction with other APIs (e.g. Vulkan, OpenGL)
  12685. * that support importing memory from the shareable type
  12686. *
  12687. * \param[out] shareableHandle - Pointer to the location in which to store the requested handle type
  12688. * \param[in] handle - CUDA handle for the memory allocation
  12689. * \param[in] handleType - Type of shareable handle requested (defines type and size of the \p shareableHandle output parameter)
  12690. * \param[in] flags - Reserved, must be zero
  12691. * \returns
  12692. * ::CUDA_SUCCESS,
  12693. * ::CUDA_ERROR_INVALID_VALUE,
  12694. * ::CUDA_ERROR_NOT_INITIALIZED,
  12695. * ::CUDA_ERROR_DEINITIALIZED,
  12696. * ::CUDA_ERROR_NOT_PERMITTED,
  12697. * ::CUDA_ERROR_NOT_SUPPORTED
  12698. *
  12699. * \sa ::cuMemImportFromShareableHandle
  12700. */
  12701. CUresult CUDAAPI cuMemExportToShareableHandle(void *shareableHandle, CUmemGenericAllocationHandle handle, CUmemAllocationHandleType handleType, unsigned long long flags);
  12702. /**
  12703. * \brief Imports an allocation from a requested shareable handle type.
  12704. *
  12705. * If the current process cannot support the memory described by this shareable
  12706. * handle, this API will error as ::CUDA_ERROR_NOT_SUPPORTED.
  12707. *
  12708. * If \p shHandleType is ::CU_MEM_HANDLE_TYPE_FABRIC and the importer process has not been
  12709. * granted access to the same IMEX channel as the exporter process, this API will error
  12710. * as ::CUDA_ERROR_NOT_PERMITTED.
  12711. *
  12712. * \note Importing shareable handles exported from some graphics APIs(VUlkan, OpenGL, etc)
  12713. * created on devices under an SLI group may not be supported, and thus this API will
  12714. * return CUDA_ERROR_NOT_SUPPORTED.
  12715. * There is no guarantee that the contents of \p handle will be the same CUDA memory handle
  12716. * for the same given OS shareable handle, or the same underlying allocation.
  12717. *
  12718. * \param[out] handle - CUDA Memory handle for the memory allocation.
  12719. * \param[in] osHandle - Shareable Handle representing the memory allocation that is to be imported.
  12720. * \param[in] shHandleType - handle type of the exported handle ::CUmemAllocationHandleType.
  12721. * \returns
  12722. * ::CUDA_SUCCESS,
  12723. * ::CUDA_ERROR_INVALID_VALUE,
  12724. * ::CUDA_ERROR_NOT_INITIALIZED,
  12725. * ::CUDA_ERROR_DEINITIALIZED,
  12726. * ::CUDA_ERROR_NOT_PERMITTED,
  12727. * ::CUDA_ERROR_NOT_SUPPORTED
  12728. *
  12729. * \sa ::cuMemExportToShareableHandle, ::cuMemMap, ::cuMemRelease
  12730. */
  12731. CUresult CUDAAPI cuMemImportFromShareableHandle(CUmemGenericAllocationHandle *handle, void *osHandle, CUmemAllocationHandleType shHandleType);
  12732. /**
  12733. * \brief Calculates either the minimal or recommended granularity
  12734. *
  12735. * Calculates either the minimal or recommended granularity
  12736. * for a given allocation specification and returns it in granularity. This
  12737. * granularity can be used as a multiple for alignment, size, or address mapping.
  12738. *
  12739. * \param[out] granularity Returned granularity.
  12740. * \param[in] prop Property for which to determine the granularity for
  12741. * \param[in] option Determines which granularity to return
  12742. * \returns
  12743. * ::CUDA_SUCCESS,
  12744. * ::CUDA_ERROR_INVALID_VALUE,
  12745. * ::CUDA_ERROR_NOT_INITIALIZED,
  12746. * ::CUDA_ERROR_DEINITIALIZED,
  12747. * ::CUDA_ERROR_NOT_PERMITTED,
  12748. * ::CUDA_ERROR_NOT_SUPPORTED
  12749. *
  12750. * \sa ::cuMemCreate, ::cuMemMap
  12751. */
  12752. CUresult CUDAAPI cuMemGetAllocationGranularity(size_t *granularity, const CUmemAllocationProp *prop, CUmemAllocationGranularity_flags option);
  12753. /**
  12754. * \brief Retrieve the contents of the property structure defining properties for this handle
  12755. *
  12756. * \param[out] prop - Pointer to a properties structure which will hold the information about this handle
  12757. * \param[in] handle - Handle which to perform the query on
  12758. * \returns
  12759. * ::CUDA_SUCCESS,
  12760. * ::CUDA_ERROR_INVALID_VALUE,
  12761. * ::CUDA_ERROR_NOT_INITIALIZED,
  12762. * ::CUDA_ERROR_DEINITIALIZED,
  12763. * ::CUDA_ERROR_NOT_PERMITTED,
  12764. * ::CUDA_ERROR_NOT_SUPPORTED
  12765. *
  12766. * \sa ::cuMemCreate, ::cuMemImportFromShareableHandle
  12767. */
  12768. CUresult CUDAAPI cuMemGetAllocationPropertiesFromHandle(CUmemAllocationProp *prop, CUmemGenericAllocationHandle handle);
  12769. /**
  12770. * \brief Given an address \p addr, returns the allocation handle of the backing memory allocation.
  12771. *
  12772. * The handle is guaranteed to be the same handle value used to map the memory. If the address
  12773. * requested is not mapped, the function will fail. The returned handle must be released with
  12774. * corresponding number of calls to ::cuMemRelease.
  12775. *
  12776. * \note The address \p addr, can be any address in a range previously mapped
  12777. * by ::cuMemMap, and not necessarily the start address.
  12778. *
  12779. * \param[out] handle CUDA Memory handle for the backing memory allocation.
  12780. * \param[in] addr Memory address to query, that has been mapped previously.
  12781. * \returns
  12782. * ::CUDA_SUCCESS,
  12783. * ::CUDA_ERROR_INVALID_VALUE,
  12784. * ::CUDA_ERROR_NOT_INITIALIZED,
  12785. * ::CUDA_ERROR_DEINITIALIZED,
  12786. * ::CUDA_ERROR_NOT_PERMITTED,
  12787. * ::CUDA_ERROR_NOT_SUPPORTED
  12788. *
  12789. * \sa ::cuMemCreate, ::cuMemRelease, ::cuMemMap
  12790. */
  12791. CUresult CUDAAPI cuMemRetainAllocationHandle(CUmemGenericAllocationHandle *handle, void *addr);
  12792. /** @} */ /* END CUDA_VA */
  12793. /**
  12794. * \defgroup CUDA_MALLOC_ASYNC Stream Ordered Memory Allocator
  12795. *
  12796. * ___MANBRIEF___ Functions for performing allocation and free operations in stream order.
  12797. * Functions for controlling the behavior of the underlying allocator.
  12798. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  12799. *
  12800. * This section describes the stream ordered memory allocator exposed by the
  12801. * low-level CUDA driver application programming interface.
  12802. *
  12803. * @{
  12804. *
  12805. * \section CUDA_MALLOC_ASYNC_overview overview
  12806. *
  12807. * The asynchronous allocator allows the user to allocate and free in stream order.
  12808. * All asynchronous accesses of the allocation must happen between
  12809. * the stream executions of the allocation and the free. If the memory is accessed
  12810. * outside of the promised stream order, a use before allocation / use after free error
  12811. * will cause undefined behavior.
  12812. *
  12813. * The allocator is free to reallocate the memory as long as it can guarantee
  12814. * that compliant memory accesses will not overlap temporally.
  12815. * The allocator may refer to internal stream ordering as well as inter-stream dependencies
  12816. * (such as CUDA events and null stream dependencies) when establishing the temporal guarantee.
  12817. * The allocator may also insert inter-stream dependencies to establish the temporal guarantee.
  12818. *
  12819. * \section CUDA_MALLOC_ASYNC_support Supported Platforms
  12820. *
  12821. * Whether or not a device supports the integrated stream ordered memory allocator
  12822. * may be queried by calling ::cuDeviceGetAttribute() with the device attribute
  12823. * ::CU_DEVICE_ATTRIBUTE_MEMORY_POOLS_SUPPORTED
  12824. */
  12825. /**
  12826. * \brief Frees memory with stream ordered semantics
  12827. *
  12828. * Inserts a free operation into \p hStream.
  12829. * The allocation must not be accessed after stream execution reaches the free.
  12830. * After this API returns, accessing the memory from any subsequent work launched on the GPU
  12831. * or querying its pointer attributes results in undefined behavior.
  12832. *
  12833. * \note During stream capture, this function results in the creation of a free node and
  12834. * must therefore be passed the address of a graph allocation.
  12835. *
  12836. * \param dptr - memory to free
  12837. * \param hStream - The stream establishing the stream ordering contract.
  12838. * \returns
  12839. * ::CUDA_SUCCESS,
  12840. * ::CUDA_ERROR_INVALID_VALUE,
  12841. * ::CUDA_ERROR_NOT_INITIALIZED,
  12842. * ::CUDA_ERROR_INVALID_CONTEXT (default stream specified with no current context),
  12843. * ::CUDA_ERROR_NOT_SUPPORTED
  12844. */
  12845. CUresult CUDAAPI cuMemFreeAsync(CUdeviceptr dptr, CUstream hStream);
  12846. /**
  12847. * \brief Allocates memory with stream ordered semantics
  12848. *
  12849. * Inserts an allocation operation into \p hStream.
  12850. * A pointer to the allocated memory is returned immediately in *dptr.
  12851. * The allocation must not be accessed until the the allocation operation completes.
  12852. * The allocation comes from the memory pool current to the stream's device.
  12853. *
  12854. * \note The default memory pool of a device contains device memory from that device.
  12855. * \note Basic stream ordering allows future work submitted into the same stream to use the allocation.
  12856. * Stream query, stream synchronize, and CUDA events can be used to guarantee that the allocation
  12857. * operation completes before work submitted in a separate stream runs.
  12858. * \note During stream capture, this function results in the creation of an allocation node. In this case,
  12859. * the allocation is owned by the graph instead of the memory pool. The memory pool's properties
  12860. * are used to set the node's creation parameters.
  12861. *
  12862. * \param[out] dptr - Returned device pointer
  12863. * \param[in] bytesize - Number of bytes to allocate
  12864. * \param[in] hStream - The stream establishing the stream ordering contract and the memory pool to allocate from
  12865. * \returns
  12866. * ::CUDA_SUCCESS,
  12867. * ::CUDA_ERROR_INVALID_VALUE,
  12868. * ::CUDA_ERROR_NOT_INITIALIZED,
  12869. * ::CUDA_ERROR_INVALID_CONTEXT (default stream specified with no current context),
  12870. * ::CUDA_ERROR_NOT_SUPPORTED,
  12871. * ::CUDA_ERROR_OUT_OF_MEMORY
  12872. *
  12873. * \sa ::cuMemAllocFromPoolAsync, ::cuMemFreeAsync, ::cuDeviceSetMemPool,
  12874. * ::cuDeviceGetDefaultMemPool, ::cuDeviceGetMemPool, ::cuMemPoolCreate,
  12875. * ::cuMemPoolSetAccess, ::cuMemPoolSetAttribute
  12876. */
  12877. CUresult CUDAAPI cuMemAllocAsync(CUdeviceptr *dptr, size_t bytesize, CUstream hStream);
  12878. /**
  12879. * \brief Tries to release memory back to the OS
  12880. *
  12881. * Releases memory back to the OS until the pool contains fewer than minBytesToKeep
  12882. * reserved bytes, or there is no more memory that the allocator can safely release.
  12883. * The allocator cannot release OS allocations that back outstanding asynchronous allocations.
  12884. * The OS allocations may happen at different granularity from the user allocations.
  12885. *
  12886. * \note: Allocations that have not been freed count as outstanding.
  12887. * \note: Allocations that have been asynchronously freed but whose completion has
  12888. * not been observed on the host (eg. by a synchronize) can count as outstanding.
  12889. *
  12890. * \param[in] pool - The memory pool to trim
  12891. * \param[in] minBytesToKeep - If the pool has less than minBytesToKeep reserved,
  12892. * the TrimTo operation is a no-op. Otherwise the pool will be guaranteed to have
  12893. * at least minBytesToKeep bytes reserved after the operation.
  12894. * \returns
  12895. * ::CUDA_SUCCESS,
  12896. * ::CUDA_ERROR_NOT_INITIALIZED,
  12897. * ::CUDA_ERROR_INVALID_VALUE
  12898. *
  12899. * \sa ::cuMemAllocAsync, ::cuMemFreeAsync, ::cuDeviceGetDefaultMemPool,
  12900. * ::cuDeviceGetMemPool, ::cuMemPoolCreate
  12901. */
  12902. CUresult CUDAAPI cuMemPoolTrimTo(CUmemoryPool pool, size_t minBytesToKeep);
  12903. /**
  12904. * \brief Sets attributes of a memory pool
  12905. *
  12906. * Supported attributes are:
  12907. * - ::CU_MEMPOOL_ATTR_RELEASE_THRESHOLD: (value type = cuuint64_t)
  12908. * Amount of reserved memory in bytes to hold onto before trying
  12909. * to release memory back to the OS. When more than the release
  12910. * threshold bytes of memory are held by the memory pool, the
  12911. * allocator will try to release memory back to the OS on the
  12912. * next call to stream, event or context synchronize. (default 0)
  12913. * - ::CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES: (value type = int)
  12914. * Allow ::cuMemAllocAsync to use memory asynchronously freed
  12915. * in another stream as long as a stream ordering dependency
  12916. * of the allocating stream on the free action exists.
  12917. * Cuda events and null stream interactions can create the required
  12918. * stream ordered dependencies. (default enabled)
  12919. * - ::CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC: (value type = int)
  12920. * Allow reuse of already completed frees when there is no dependency
  12921. * between the free and allocation. (default enabled)
  12922. * - ::CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES: (value type = int)
  12923. * Allow ::cuMemAllocAsync to insert new stream dependencies
  12924. * in order to establish the stream ordering required to reuse
  12925. * a piece of memory released by ::cuMemFreeAsync (default enabled).
  12926. * - ::CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH: (value type = cuuint64_t)
  12927. * Reset the high watermark that tracks the amount of backing memory that was
  12928. * allocated for the memory pool. It is illegal to set this attribute to a non-zero value.
  12929. * - ::CU_MEMPOOL_ATTR_USED_MEM_HIGH: (value type = cuuint64_t)
  12930. * Reset the high watermark that tracks the amount of used memory that was
  12931. * allocated for the memory pool.
  12932. *
  12933. * \param[in] pool - The memory pool to modify
  12934. * \param[in] attr - The attribute to modify
  12935. * \param[in] value - Pointer to the value to assign
  12936. *
  12937. * \returns
  12938. * ::CUDA_SUCCESS,
  12939. * ::CUDA_ERROR_INVALID_VALUE
  12940. *
  12941. * \sa ::cuMemAllocAsync, ::cuMemFreeAsync, ::cuDeviceGetDefaultMemPool,
  12942. * ::cuDeviceGetMemPool, ::cuMemPoolCreate
  12943. */
  12944. CUresult CUDAAPI cuMemPoolSetAttribute(CUmemoryPool pool, CUmemPool_attribute attr, void *value);
  12945. /**
  12946. * \brief Gets attributes of a memory pool
  12947. *
  12948. * Supported attributes are:
  12949. * - ::CU_MEMPOOL_ATTR_RELEASE_THRESHOLD: (value type = cuuint64_t)
  12950. * Amount of reserved memory in bytes to hold onto before trying
  12951. * to release memory back to the OS. When more than the release
  12952. * threshold bytes of memory are held by the memory pool, the
  12953. * allocator will try to release memory back to the OS on the
  12954. * next call to stream, event or context synchronize. (default 0)
  12955. * - ::CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES: (value type = int)
  12956. * Allow ::cuMemAllocAsync to use memory asynchronously freed
  12957. * in another stream as long as a stream ordering dependency
  12958. * of the allocating stream on the free action exists.
  12959. * Cuda events and null stream interactions can create the required
  12960. * stream ordered dependencies. (default enabled)
  12961. * - ::CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC: (value type = int)
  12962. * Allow reuse of already completed frees when there is no dependency
  12963. * between the free and allocation. (default enabled)
  12964. * - ::CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES: (value type = int)
  12965. * Allow ::cuMemAllocAsync to insert new stream dependencies
  12966. * in order to establish the stream ordering required to reuse
  12967. * a piece of memory released by ::cuMemFreeAsync (default enabled).
  12968. * - ::CU_MEMPOOL_ATTR_RESERVED_MEM_CURRENT: (value type = cuuint64_t)
  12969. * Amount of backing memory currently allocated for the mempool
  12970. * - ::CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH: (value type = cuuint64_t)
  12971. * High watermark of backing memory allocated for the mempool since the
  12972. * last time it was reset.
  12973. * - ::CU_MEMPOOL_ATTR_USED_MEM_CURRENT: (value type = cuuint64_t)
  12974. * Amount of memory from the pool that is currently in use by the application.
  12975. * - ::CU_MEMPOOL_ATTR_USED_MEM_HIGH: (value type = cuuint64_t)
  12976. * High watermark of the amount of memory from the pool that was in use by the application.
  12977. *
  12978. * \param[in] pool - The memory pool to get attributes of
  12979. * \param[in] attr - The attribute to get
  12980. * \param[out] value - Retrieved value
  12981. *
  12982. * \returns
  12983. * ::CUDA_SUCCESS,
  12984. * ::CUDA_ERROR_NOT_INITIALIZED,
  12985. * ::CUDA_ERROR_INVALID_VALUE
  12986. *
  12987. * \sa ::cuMemAllocAsync, ::cuMemFreeAsync, ::cuDeviceGetDefaultMemPool,
  12988. * ::cuDeviceGetMemPool, ::cuMemPoolCreate
  12989. */
  12990. CUresult CUDAAPI cuMemPoolGetAttribute(CUmemoryPool pool, CUmemPool_attribute attr, void *value);
  12991. /**
  12992. * \brief Controls visibility of pools between devices
  12993. *
  12994. * \param[in] pool - The pool being modified
  12995. * \param[in] map - Array of access descriptors. Each descriptor instructs the access to enable for a single gpu.
  12996. * \param[in] count - Number of descriptors in the map array.
  12997. *
  12998. * \returns
  12999. * ::CUDA_SUCCESS,
  13000. * ::CUDA_ERROR_NOT_INITIALIZED,
  13001. * ::CUDA_ERROR_INVALID_VALUE
  13002. *
  13003. * \sa ::cuMemAllocAsync, ::cuMemFreeAsync, ::cuDeviceGetDefaultMemPool,
  13004. * ::cuDeviceGetMemPool, ::cuMemPoolCreate
  13005. */
  13006. CUresult CUDAAPI cuMemPoolSetAccess(CUmemoryPool pool, const CUmemAccessDesc *map, size_t count);
  13007. /**
  13008. * \brief Returns the accessibility of a pool from a device
  13009. *
  13010. * Returns the accessibility of the pool's memory from the specified location.
  13011. *
  13012. * \param[out] flags - the accessibility of the pool from the specified location
  13013. * \param[in] memPool - the pool being queried
  13014. * \param[in] location - the location accessing the pool
  13015. *
  13016. * \sa ::cuMemAllocAsync, ::cuMemFreeAsync, ::cuDeviceGetDefaultMemPool,
  13017. * ::cuDeviceGetMemPool, ::cuMemPoolCreate
  13018. */
  13019. CUresult CUDAAPI cuMemPoolGetAccess(CUmemAccess_flags *flags, CUmemoryPool memPool, CUmemLocation *location);
  13020. /**
  13021. * \brief Creates a memory pool
  13022. *
  13023. * Creates a CUDA memory pool and returns the handle in \p pool. The \p poolProps determines
  13024. * the properties of the pool such as the backing device and IPC capabilities.
  13025. *
  13026. * To create a memory pool targeting a specific host NUMA node, applications must
  13027. * set ::CUmemPoolProps::CUmemLocation::type to ::CU_MEM_LOCATION_TYPE_HOST_NUMA and
  13028. * ::CUmemPoolProps::CUmemLocation::id must specify the NUMA ID of the host memory node.
  13029. * Specifying ::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT or ::CU_MEM_LOCATION_TYPE_HOST as the
  13030. * ::CUmemPoolProps::CUmemLocation::type will result in ::CUDA_ERROR_INVALID_VALUE.
  13031. * By default, the pool's memory will be accessible from the device it is allocated on.
  13032. * In the case of pools created with ::CU_MEM_LOCATION_TYPE_HOST_NUMA, their default accessibility
  13033. * will be from the host CPU.
  13034. * Applications can control the maximum size of the pool by specifying a non-zero value for ::CUmemPoolProps::maxSize.
  13035. * If set to 0, the maximum size of the pool will default to a system dependent value.
  13036. *
  13037. * Applications that intend to use ::CU_MEM_HANDLE_TYPE_FABRIC based memory sharing must ensure:
  13038. * (1) `nvidia-caps-imex-channels` character device is created by the driver and is listed under /proc/devices
  13039. * (2) have at least one IMEX channel file accessible by the user launching the application.
  13040. *
  13041. * When exporter and importer CUDA processes have been granted access to the same IMEX channel, they can securely
  13042. * share memory.
  13043. *
  13044. * The IMEX channel security model works on a per user basis. Which means all processes under a user can share
  13045. * memory if the user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX
  13046. * channel is required for each user.
  13047. *
  13048. * These channel files exist in /dev/nvidia-caps-imex-channels/channel* and can be created using standard OS
  13049. * native calls like mknod on Linux. For example: To create channel0 with the major number from /proc/devices
  13050. * users can execute the following command: `mknod /dev/nvidia-caps-imex-channels/channel0 c <major number> 0`
  13051. *
  13052. * \note Specifying CU_MEM_HANDLE_TYPE_NONE creates a memory pool that will not support IPC.
  13053. *
  13054. * \returns
  13055. * ::CUDA_SUCCESS,
  13056. * ::CUDA_ERROR_NOT_INITIALIZED,
  13057. * ::CUDA_ERROR_INVALID_VALUE,
  13058. * ::CUDA_ERROR_OUT_OF_MEMORY,
  13059. * ::CUDA_ERROR_NOT_PERMITTED
  13060. * ::CUDA_ERROR_NOT_SUPPORTED
  13061. *
  13062. * \sa ::cuDeviceSetMemPool, ::cuDeviceGetMemPool, ::cuDeviceGetDefaultMemPool,
  13063. * ::cuMemAllocFromPoolAsync, ::cuMemPoolExportToShareableHandle
  13064. */
  13065. CUresult CUDAAPI cuMemPoolCreate(CUmemoryPool *pool, const CUmemPoolProps *poolProps);
  13066. /**
  13067. * \brief Destroys the specified memory pool
  13068. *
  13069. * If any pointers obtained from this pool haven't been freed or
  13070. * the pool has free operations that haven't completed
  13071. * when ::cuMemPoolDestroy is invoked, the function will return immediately and the
  13072. * resources associated with the pool will be released automatically
  13073. * once there are no more outstanding allocations.
  13074. *
  13075. * Destroying the current mempool of a device sets the default mempool of
  13076. * that device as the current mempool for that device.
  13077. *
  13078. * \note A device's default memory pool cannot be destroyed.
  13079. *
  13080. * \returns
  13081. * ::CUDA_SUCCESS,
  13082. * ::CUDA_ERROR_INVALID_VALUE
  13083. *
  13084. * \sa ::cuMemFreeAsync, ::cuDeviceSetMemPool, ::cuDeviceGetMemPool,
  13085. * ::cuDeviceGetDefaultMemPool, ::cuMemPoolCreate
  13086. */
  13087. CUresult CUDAAPI cuMemPoolDestroy(CUmemoryPool pool);
  13088. /**
  13089. * \brief Allocates memory from a specified pool with stream ordered semantics.
  13090. *
  13091. * Inserts an allocation operation into \p hStream.
  13092. * A pointer to the allocated memory is returned immediately in *dptr.
  13093. * The allocation must not be accessed until the the allocation operation completes.
  13094. * The allocation comes from the specified memory pool.
  13095. *
  13096. * \note
  13097. * - The specified memory pool may be from a device different than that of the specified \p hStream.
  13098. *
  13099. * - Basic stream ordering allows future work submitted into the same stream to use the allocation.
  13100. * Stream query, stream synchronize, and CUDA events can be used to guarantee that the allocation
  13101. * operation completes before work submitted in a separate stream runs.
  13102. *
  13103. * \note During stream capture, this function results in the creation of an allocation node. In this case,
  13104. * the allocation is owned by the graph instead of the memory pool. The memory pool's properties
  13105. * are used to set the node's creation parameters.
  13106. *
  13107. * \param[out] dptr - Returned device pointer
  13108. * \param[in] bytesize - Number of bytes to allocate
  13109. * \param[in] pool - The pool to allocate from
  13110. * \param[in] hStream - The stream establishing the stream ordering semantic
  13111. *
  13112. * \returns
  13113. * ::CUDA_SUCCESS,
  13114. * ::CUDA_ERROR_INVALID_VALUE,
  13115. * ::CUDA_ERROR_NOT_INITIALIZED,
  13116. * ::CUDA_ERROR_INVALID_CONTEXT (default stream specified with no current context),
  13117. * ::CUDA_ERROR_NOT_SUPPORTED,
  13118. * ::CUDA_ERROR_OUT_OF_MEMORY
  13119. *
  13120. * \sa ::cuMemAllocAsync, ::cuMemFreeAsync, ::cuDeviceGetDefaultMemPool,
  13121. * ::cuDeviceGetMemPool, ::cuMemPoolCreate, ::cuMemPoolSetAccess,
  13122. * ::cuMemPoolSetAttribute
  13123. */
  13124. CUresult CUDAAPI cuMemAllocFromPoolAsync(CUdeviceptr *dptr, size_t bytesize, CUmemoryPool pool, CUstream hStream);
  13125. /**
  13126. * \brief Exports a memory pool to the requested handle type.
  13127. *
  13128. * Given an IPC capable mempool, create an OS handle to share the pool with another process.
  13129. * A recipient process can convert the shareable handle into a mempool with ::cuMemPoolImportFromShareableHandle.
  13130. * Individual pointers can then be shared with the ::cuMemPoolExportPointer and ::cuMemPoolImportPointer APIs.
  13131. * The implementation of what the shareable handle is and how it can be transferred is defined by the requested
  13132. * handle type.
  13133. *
  13134. * \note: To create an IPC capable mempool, create a mempool with a CUmemAllocationHandleType other than CU_MEM_HANDLE_TYPE_NONE.
  13135. *
  13136. * \param[out] handle_out - Returned OS handle
  13137. * \param[in] pool - pool to export
  13138. * \param[in] handleType - the type of handle to create
  13139. * \param[in] flags - must be 0
  13140. *
  13141. * \returns
  13142. * ::CUDA_SUCCESS,
  13143. * ::CUDA_ERROR_INVALID_VALUE,
  13144. * ::CUDA_ERROR_NOT_INITIALIZED,
  13145. * ::CUDA_ERROR_OUT_OF_MEMORY
  13146. *
  13147. * \sa ::cuMemPoolImportFromShareableHandle, ::cuMemPoolExportPointer,
  13148. * ::cuMemPoolImportPointer, ::cuMemAllocAsync, ::cuMemFreeAsync,
  13149. * ::cuDeviceGetDefaultMemPool, ::cuDeviceGetMemPool, ::cuMemPoolCreate,
  13150. * ::cuMemPoolSetAccess, ::cuMemPoolSetAttribute
  13151. */
  13152. CUresult CUDAAPI cuMemPoolExportToShareableHandle(void *handle_out, CUmemoryPool pool, CUmemAllocationHandleType handleType, unsigned long long flags);
  13153. /**
  13154. * \brief imports a memory pool from a shared handle.
  13155. *
  13156. * Specific allocations can be imported from the imported pool with cuMemPoolImportPointer.
  13157. *
  13158. * If \p handleType is ::CU_MEM_HANDLE_TYPE_FABRIC and the importer process has not been
  13159. * granted access to the same IMEX channel as the exporter process, this API will error
  13160. * as ::CUDA_ERROR_NOT_PERMITTED.
  13161. *
  13162. *
  13163. * \note Imported memory pools do not support creating new allocations.
  13164. * As such imported memory pools may not be used in cuDeviceSetMemPool
  13165. * or ::cuMemAllocFromPoolAsync calls.
  13166. *
  13167. * \param[out] pool_out - Returned memory pool
  13168. * \param[in] handle - OS handle of the pool to open
  13169. * \param[in] handleType - The type of handle being imported
  13170. * \param[in] flags - must be 0
  13171. *
  13172. * \returns
  13173. * ::CUDA_SUCCESS,
  13174. * ::CUDA_ERROR_INVALID_VALUE,
  13175. * ::CUDA_ERROR_NOT_INITIALIZED,
  13176. * ::CUDA_ERROR_OUT_OF_MEMORY
  13177. *
  13178. * \sa ::cuMemPoolExportToShareableHandle, ::cuMemPoolExportPointer, ::cuMemPoolImportPointer
  13179. */
  13180. CUresult CUDAAPI cuMemPoolImportFromShareableHandle(
  13181. CUmemoryPool *pool_out,
  13182. void *handle,
  13183. CUmemAllocationHandleType handleType,
  13184. unsigned long long flags);
  13185. /**
  13186. * \brief Export data to share a memory pool allocation between processes.
  13187. *
  13188. * Constructs \p shareData_out for sharing a specific allocation from an already shared memory pool.
  13189. * The recipient process can import the allocation with the ::cuMemPoolImportPointer api.
  13190. * The data is not a handle and may be shared through any IPC mechanism.
  13191. *
  13192. * \param[out] shareData_out - Returned export data
  13193. * \param[in] ptr - pointer to memory being exported
  13194. *
  13195. * \returns
  13196. * ::CUDA_SUCCESS,
  13197. * ::CUDA_ERROR_INVALID_VALUE,
  13198. * ::CUDA_ERROR_NOT_INITIALIZED,
  13199. * ::CUDA_ERROR_OUT_OF_MEMORY
  13200. *
  13201. * \sa ::cuMemPoolExportToShareableHandle, ::cuMemPoolImportFromShareableHandle, ::cuMemPoolImportPointer
  13202. */
  13203. CUresult CUDAAPI cuMemPoolExportPointer(CUmemPoolPtrExportData *shareData_out, CUdeviceptr ptr);
  13204. /**
  13205. * \brief Import a memory pool allocation from another process.
  13206. *
  13207. * Returns in \p ptr_out a pointer to the imported memory.
  13208. * The imported memory must not be accessed before the allocation operation completes
  13209. * in the exporting process. The imported memory must be freed from all importing processes before
  13210. * being freed in the exporting process. The pointer may be freed with cuMemFree
  13211. * or cuMemFreeAsync. If cuMemFreeAsync is used, the free must be completed
  13212. * on the importing process before the free operation on the exporting process.
  13213. *
  13214. * \note The cuMemFreeAsync api may be used in the exporting process before
  13215. * the cuMemFreeAsync operation completes in its stream as long as the
  13216. * cuMemFreeAsync in the exporting process specifies a stream with
  13217. * a stream dependency on the importing process's cuMemFreeAsync.
  13218. *
  13219. * \param[out] ptr_out - pointer to imported memory
  13220. * \param[in] pool - pool from which to import
  13221. * \param[in] shareData - data specifying the memory to import
  13222. *
  13223. * \returns
  13224. * ::CUDA_SUCCESS,
  13225. * ::CUDA_ERROR_INVALID_VALUE,
  13226. * ::CUDA_ERROR_NOT_INITIALIZED,
  13227. * ::CUDA_ERROR_OUT_OF_MEMORY
  13228. *
  13229. * \sa ::cuMemPoolExportToShareableHandle, ::cuMemPoolImportFromShareableHandle, ::cuMemPoolExportPointer
  13230. */
  13231. CUresult CUDAAPI cuMemPoolImportPointer(CUdeviceptr *ptr_out, CUmemoryPool pool, CUmemPoolPtrExportData *shareData);
  13232. /** @} */ /* END CUDA_MALLOC_ASYNC */
  13233. /**
  13234. * \defgroup CUDA_MULTICAST Multicast Object Management
  13235. *
  13236. * ___MANBRIEF___ Functions for creating multicast objects, adding devices to them and binding/unbinding memory
  13237. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  13238. *
  13239. * This section describes the CUDA multicast object operations exposed by the
  13240. * low-level CUDA driver application programming interface.
  13241. *
  13242. * @{
  13243. *
  13244. * \section CUDA_MULTICAST_overview overview
  13245. *
  13246. * A multicast object created via ::cuMulticastCreate enables certain memory
  13247. * operations to be broadcast to a team of devices. Devices can be added to a
  13248. * multicast object via ::cuMulticastAddDevice. Memory can be bound on each
  13249. * participating device via either ::cuMulticastBindMem or ::cuMulticastBindAddr.
  13250. * Multicast objects can be mapped into a device's virtual address space using
  13251. * the virtual memmory management APIs (see ::cuMemMap and ::cuMemSetAccess).
  13252. *
  13253. * \section CUDA_MULTICAST_support Supported Platforms
  13254. *
  13255. * Support for multicast on a specific device can be queried using the device
  13256. * attribute ::CU_DEVICE_ATTRIBUTE_MULTICAST_SUPPORTED
  13257. */
  13258. /**
  13259. * \brief Create a generic allocation handle representing a multicast object described by the given properties.
  13260. *
  13261. * This creates a multicast object as described by \p prop. The number of
  13262. * participating devices is specified by ::CUmulticastObjectProp::numDevices.
  13263. * Devices can be added to the multicast object via ::cuMulticastAddDevice.
  13264. * All participating devices must be added to the multicast object before memory
  13265. * can be bound to it. Memory is bound to the multicast object via either
  13266. * ::cuMulticastBindMem or ::cuMulticastBindAddr, and can be unbound via
  13267. * ::cuMulticastUnbind. The total amount of memory that can be bound per device
  13268. * is specified by :CUmulticastObjectProp::size. This size must be a multiple of
  13269. * the value returned by ::cuMulticastGetGranularity with the flag
  13270. * ::CU_MULTICAST_GRANULARITY_MINIMUM. For best performance however, the size
  13271. * should be aligned to the value returned by ::cuMulticastGetGranularity with
  13272. * the flag ::CU_MULTICAST_GRANULARITY_RECOMMENDED.
  13273. *
  13274. * After all participating devices have been added, multicast objects can also
  13275. * be mapped to a device's virtual address space using the virtual memory
  13276. * management APIs (see ::cuMemMap and ::cuMemSetAccess). Multicast objects can
  13277. * also be shared with other processes by requesting a shareable handle via
  13278. * ::cuMemExportToShareableHandle. Note that the desired types of shareable
  13279. * handles must be specified in the bitmask ::CUmulticastObjectProp::handleTypes.
  13280. * Multicast objects can be released using the virtual memory management API
  13281. * ::cuMemRelease.
  13282. *
  13283. * \param[out] mcHandle Value of handle returned.
  13284. * \param[in] prop Properties of the multicast object to create.
  13285. *
  13286. * \return
  13287. * ::CUDA_SUCCESS,
  13288. * ::CUDA_ERROR_INVALID_VALUE,
  13289. * ::CUDA_ERROR_OUT_OF_MEMORY,
  13290. * ::CUDA_ERROR_INVALID_DEVICE,
  13291. * ::CUDA_ERROR_NOT_INITIALIZED,
  13292. * ::CUDA_ERROR_DEINITIALIZED,
  13293. * ::CUDA_ERROR_NOT_PERMITTED,
  13294. * ::CUDA_ERROR_NOT_SUPPORTED
  13295. *
  13296. * \sa ::cuMulticastAddDevice, ::cuMulticastBindMem, ::cuMulticastBindAddr, ::cuMulticastUnbind
  13297. * \sa ::cuMemCreate, ::cuMemRelease, ::cuMemExportToShareableHandle, ::cuMemImportFromShareableHandle
  13298. */
  13299. CUresult CUDAAPI cuMulticastCreate(CUmemGenericAllocationHandle *mcHandle, const CUmulticastObjectProp *prop);
  13300. /**
  13301. * \brief Associate a device to a multicast object.
  13302. *
  13303. * Associates a device to a multicast object. The added device will be a part of
  13304. * the multicast team of size specified by CUmulticastObjectProp::numDevices
  13305. * during ::cuMulticastCreate.
  13306. * The association of the device to the multicast object is permanent during
  13307. * the life time of the multicast object.
  13308. * All devices must be added to the multicast team before any memory can be
  13309. * bound to any device in the team. Any calls to ::cuMulticastBindMem or
  13310. * ::cuMulticastBindAddr will block until all devices have been added.
  13311. * Similarly all devices must be added to the multicast team before a virtual
  13312. * address range can be mapped to the multicast object. A call to ::cuMemMap
  13313. * will block until all devices have been added.
  13314. *
  13315. * \param[in] mcHandle Handle representing a multicast object.
  13316. * \param[in] dev Device that will be associated to the multicast
  13317. * object.
  13318. *
  13319. * \return
  13320. * ::CUDA_SUCCESS,
  13321. * ::CUDA_ERROR_INVALID_VALUE,
  13322. * ::CUDA_ERROR_OUT_OF_MEMORY,
  13323. * ::CUDA_ERROR_INVALID_DEVICE,
  13324. * ::CUDA_ERROR_NOT_INITIALIZED,
  13325. * ::CUDA_ERROR_DEINITIALIZED,
  13326. * ::CUDA_ERROR_NOT_PERMITTED,
  13327. * ::CUDA_ERROR_NOT_SUPPORTED
  13328. *
  13329. * \sa ::cuMulticastCreate, ::cuMulticastBindMem, ::cuMulticastBindAddr
  13330. */
  13331. CUresult CUDAAPI cuMulticastAddDevice(CUmemGenericAllocationHandle mcHandle, CUdevice dev);
  13332. /**
  13333. * \brief Bind a memory allocation represented by a handle to a multicast object.
  13334. *
  13335. * Binds a memory allocation specified by \p memHandle and created via
  13336. * ::cuMemCreate to a multicast object represented by \p mcHandle and created
  13337. * via ::cuMulticastCreate. The intended \p size of the bind, the offset in the
  13338. * multicast range \p mcOffset as well as the offset in the memory \p memOffset
  13339. * must be a multiple of the value returned by ::cuMulticastGetGranularity with
  13340. * the flag ::CU_MULTICAST_GRANULARITY_MINIMUM. For best performance however,
  13341. * \p size, \p mcOffset and \p memOffset should be aligned to the granularity of
  13342. * the memory allocation(see ::cuMemGetAllocationGranularity) or to the value
  13343. * returned by ::cuMulticastGetGranularity with the flag
  13344. * ::CU_MULTICAST_GRANULARITY_RECOMMENDED.
  13345. *
  13346. * The \p size + \p memOffset cannot be larger than the size of the allocated
  13347. * memory. Similarly the \p size + \p mcOffset cannot be larger than the size
  13348. * of the multicast object.
  13349. * The memory allocation must have beeen created on one of the devices
  13350. * that was added to the multicast team via ::cuMulticastAddDevice.
  13351. * Externally shareable as well as imported multicast objects can be bound only
  13352. * to externally shareable memory.
  13353. * Note that this call will return CUDA_ERROR_OUT_OF_MEMORY if there are
  13354. * insufficient resources required to perform the bind. This call may also
  13355. * return CUDA_ERROR_SYSTEM_NOT_READY if the necessary system software is not
  13356. * initialized or running.
  13357. *
  13358. * \param[in] mcHandle Handle representing a multicast object.
  13359. * \param[in] mcOffset Offset into the multicast object for attachment.
  13360. * \param[in] memHandle Handle representing a memory allocation.
  13361. * \param[in] memOffset Offset into the memory for attachment.
  13362. * \param[in] size Size of the memory that will be bound to the
  13363. * multicast object.
  13364. * \param[in] flags Flags for future use, must be zero for now.
  13365. *
  13366. * \return
  13367. * ::CUDA_SUCCESS,
  13368. * ::CUDA_ERROR_INVALID_VALUE,
  13369. * ::CUDA_ERROR_INVALID_DEVICE,
  13370. * ::CUDA_ERROR_NOT_INITIALIZED,
  13371. * ::CUDA_ERROR_DEINITIALIZED,
  13372. * ::CUDA_ERROR_NOT_PERMITTED,
  13373. * ::CUDA_ERROR_NOT_SUPPORTED,
  13374. * ::CUDA_ERROR_OUT_OF_MEMORY,
  13375. * ::CUDA_ERROR_SYSTEM_NOT_READY
  13376. *
  13377. * \sa ::cuMulticastCreate, ::cuMulticastAddDevice, ::cuMemCreate
  13378. */
  13379. CUresult CUDAAPI cuMulticastBindMem(CUmemGenericAllocationHandle mcHandle, size_t mcOffset, CUmemGenericAllocationHandle memHandle, size_t memOffset, size_t size, unsigned long long flags);
  13380. /**
  13381. * \brief Bind a memory allocation represented by a virtual address to a multicast object.
  13382. *
  13383. * Binds a memory allocation specified by its mapped address \p memptr to a
  13384. * multicast object represented by \p mcHandle.
  13385. * The memory must have been allocated via ::cuMemCreate or ::cudaMallocAsync.
  13386. * The intended \p size of the bind, the offset in the multicast range
  13387. * \p mcOffset and \p memptr must be a multiple of the value returned by
  13388. * ::cuMulticastGetGranularity with the flag ::CU_MULTICAST_GRANULARITY_MINIMUM.
  13389. * For best performance however, \p size, \p mcOffset and \p memptr should be
  13390. * aligned to the value returned by ::cuMulticastGetGranularity with the flag
  13391. * ::CU_MULTICAST_GRANULARITY_RECOMMENDED.
  13392. *
  13393. * The \p size cannot be larger than the size of the allocated memory.
  13394. * Similarly the \p size + \p mcOffset cannot be larger than the total size
  13395. * of the multicast object.
  13396. * The memory allocation must have beeen created on one of the devices
  13397. * that was added to the multicast team via ::cuMulticastAddDevice.
  13398. * Externally shareable as well as imported multicast objects can be bound only
  13399. * to externally shareable memory.
  13400. * Note that this call will return CUDA_ERROR_OUT_OF_MEMORY if there are
  13401. * insufficient resources required to perform the bind. This call may also
  13402. * return CUDA_ERROR_SYSTEM_NOT_READY if the necessary system software is not
  13403. * initialized or running.
  13404. *
  13405. * \param[in] mcHandle Handle representing a multicast object.
  13406. * \param[in] mcOffset Offset into multicast va range for attachment.
  13407. * \param[in] memptr Virtual address of the memory allocation.
  13408. * \param[in] size Size of memory that will be bound to the
  13409. * multicast object.
  13410. * \param[in] flags Flags for future use, must be zero now.
  13411. *
  13412. * \return
  13413. * ::CUDA_SUCCESS,
  13414. * ::CUDA_ERROR_INVALID_VALUE,
  13415. * ::CUDA_ERROR_INVALID_DEVICE,
  13416. * ::CUDA_ERROR_NOT_INITIALIZED,
  13417. * ::CUDA_ERROR_DEINITIALIZED,
  13418. * ::CUDA_ERROR_NOT_PERMITTED,
  13419. * ::CUDA_ERROR_NOT_SUPPORTED,
  13420. * ::CUDA_ERROR_OUT_OF_MEMORY,
  13421. * ::CUDA_ERROR_SYSTEM_NOT_READY
  13422. *
  13423. * \sa ::cuMulticastCreate, ::cuMulticastAddDevice, ::cuMemCreate
  13424. */
  13425. CUresult CUDAAPI cuMulticastBindAddr(CUmemGenericAllocationHandle mcHandle, size_t mcOffset, CUdeviceptr memptr, size_t size, unsigned long long flags);
  13426. /**
  13427. * \brief Unbind any memory allocations bound to a multicast object at a given offset and upto a given size.
  13428. *
  13429. * Unbinds any memory allocations hosted on \p dev and bound to a multicast
  13430. * object at \p mcOffset and upto a given \p size.
  13431. * The intended \p size of the unbind and the offset in the multicast range
  13432. * ( \p mcOffset ) must be a multiple of the value returned by
  13433. * ::cuMulticastGetGranularity flag ::CU_MULTICAST_GRANULARITY_MINIMUM.
  13434. * The \p size + \p mcOffset cannot be larger than the total size of the
  13435. * multicast object.
  13436. *
  13437. * \note
  13438. * Warning:
  13439. * The \p mcOffset and the \p size must match the corresponding values specified
  13440. * during the bind call. Any other values may result in undefined behavior.
  13441. *
  13442. * \param[in] mcHandle Handle representing a multicast object.
  13443. * \param[in] dev Device that hosts the memory allocation.
  13444. * \param[in] mcOffset Offset into the multicast object.
  13445. * \param[in] size Desired size to unbind.
  13446. *
  13447. * \return
  13448. * ::CUDA_SUCCESS,
  13449. * ::CUDA_ERROR_INVALID_VALUE,
  13450. * ::CUDA_ERROR_INVALID_DEVICE,
  13451. * ::CUDA_ERROR_NOT_INITIALIZED,
  13452. * ::CUDA_ERROR_DEINITIALIZED,
  13453. * ::CUDA_ERROR_NOT_PERMITTED,
  13454. * ::CUDA_ERROR_NOT_SUPPORTED
  13455. *
  13456. * \sa ::cuMulticastBindMem, ::cuMulticastBindAddr
  13457. */
  13458. CUresult CUDAAPI cuMulticastUnbind(CUmemGenericAllocationHandle mcHandle, CUdevice dev, size_t mcOffset, size_t size);
  13459. /**
  13460. * \brief Calculates either the minimal or recommended granularity for multicast object
  13461. *
  13462. * Calculates either the minimal or recommended granularity for a given set of
  13463. * multicast object properties and returns it in granularity. This granularity
  13464. * can be used as a multiple for size, bind offsets and address mappings of the
  13465. * multicast object.
  13466. *
  13467. * \param[out] granularity Returned granularity.
  13468. * \param[in] prop Properties of the multicast object.
  13469. * \param[in] option Determines which granularity to return.
  13470. *
  13471. * \returns
  13472. * ::CUDA_SUCCESS,
  13473. * ::CUDA_ERROR_INVALID_VALUE,
  13474. * ::CUDA_ERROR_NOT_INITIALIZED,
  13475. * ::CUDA_ERROR_DEINITIALIZED,
  13476. * ::CUDA_ERROR_NOT_PERMITTED,
  13477. * ::CUDA_ERROR_NOT_SUPPORTED
  13478. *
  13479. * \sa ::cuMulticastCreate, ::cuMulticastBindMem, ::cuMulticastBindAddr, ::cuMulticastUnbind
  13480. */
  13481. CUresult CUDAAPI cuMulticastGetGranularity(size_t *granularity, const CUmulticastObjectProp *prop, CUmulticastGranularity_flags option);
  13482. /** @} */ /* END CUDA_MULTICAST */
  13483. /**
  13484. * \defgroup CUDA_UNIFIED Unified Addressing
  13485. *
  13486. * ___MANBRIEF___ unified addressing functions of the low-level CUDA driver
  13487. * API (___CURRENT_FILE___) ___ENDMANBRIEF___
  13488. *
  13489. * This section describes the unified addressing functions of the
  13490. * low-level CUDA driver application programming interface.
  13491. *
  13492. * @{
  13493. *
  13494. * \section CUDA_UNIFIED_overview Overview
  13495. *
  13496. * CUDA devices can share a unified address space with the host.
  13497. * For these devices there is no distinction between a device
  13498. * pointer and a host pointer -- the same pointer value may be
  13499. * used to access memory from the host program and from a kernel
  13500. * running on the device (with exceptions enumerated below).
  13501. *
  13502. * \section CUDA_UNIFIED_support Supported Platforms
  13503. *
  13504. * Whether or not a device supports unified addressing may be
  13505. * queried by calling ::cuDeviceGetAttribute() with the device
  13506. * attribute ::CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING.
  13507. *
  13508. * Unified addressing is automatically enabled in 64-bit processes
  13509. *
  13510. * \section CUDA_UNIFIED_lookup Looking Up Information from Pointer Values
  13511. *
  13512. * It is possible to look up information about the memory which backs a
  13513. * pointer value. For instance, one may want to know if a pointer points
  13514. * to host or device memory. As another example, in the case of device
  13515. * memory, one may want to know on which CUDA device the memory
  13516. * resides. These properties may be queried using the function
  13517. * ::cuPointerGetAttribute()
  13518. *
  13519. * Since pointers are unique, it is not necessary to specify information
  13520. * about the pointers specified to the various copy functions in the
  13521. * CUDA API. The function ::cuMemcpy() may be used to perform a copy
  13522. * between two pointers, ignoring whether they point to host or device
  13523. * memory (making ::cuMemcpyHtoD(), ::cuMemcpyDtoD(), and ::cuMemcpyDtoH()
  13524. * unnecessary for devices supporting unified addressing). For
  13525. * multidimensional copies, the memory type ::CU_MEMORYTYPE_UNIFIED may be
  13526. * used to specify that the CUDA driver should infer the location of the
  13527. * pointer from its value.
  13528. *
  13529. * \section CUDA_UNIFIED_automaphost Automatic Mapping of Host Allocated Host Memory
  13530. *
  13531. * All host memory allocated in all contexts using ::cuMemAllocHost() and
  13532. * ::cuMemHostAlloc() is always directly accessible from all contexts on
  13533. * all devices that support unified addressing. This is the case regardless
  13534. * of whether or not the flags ::CU_MEMHOSTALLOC_PORTABLE and
  13535. * ::CU_MEMHOSTALLOC_DEVICEMAP are specified.
  13536. *
  13537. * The pointer value through which allocated host memory may be accessed
  13538. * in kernels on all devices that support unified addressing is the same
  13539. * as the pointer value through which that memory is accessed on the host,
  13540. * so it is not necessary to call ::cuMemHostGetDevicePointer() to get the device
  13541. * pointer for these allocations.
  13542. *
  13543. * Note that this is not the case for memory allocated using the flag
  13544. * ::CU_MEMHOSTALLOC_WRITECOMBINED, as discussed below.
  13545. *
  13546. * \section CUDA_UNIFIED_autopeerregister Automatic Registration of Peer Memory
  13547. *
  13548. * Upon enabling direct access from a context that supports unified addressing
  13549. * to another peer context that supports unified addressing using
  13550. * ::cuCtxEnablePeerAccess() all memory allocated in the peer context using
  13551. * ::cuMemAlloc() and ::cuMemAllocPitch() will immediately be accessible
  13552. * by the current context. The device pointer value through
  13553. * which any peer memory may be accessed in the current context
  13554. * is the same pointer value through which that memory may be
  13555. * accessed in the peer context.
  13556. *
  13557. * \section CUDA_UNIFIED_exceptions Exceptions, Disjoint Addressing
  13558. *
  13559. * Not all memory may be accessed on devices through the same pointer
  13560. * value through which they are accessed on the host. These exceptions
  13561. * are host memory registered using ::cuMemHostRegister() and host memory
  13562. * allocated using the flag ::CU_MEMHOSTALLOC_WRITECOMBINED. For these
  13563. * exceptions, there exists a distinct host and device address for the
  13564. * memory. The device address is guaranteed to not overlap any valid host
  13565. * pointer range and is guaranteed to have the same value across all
  13566. * contexts that support unified addressing.
  13567. *
  13568. * This device address may be queried using ::cuMemHostGetDevicePointer()
  13569. * when a context using unified addressing is current. Either the host
  13570. * or the unified device pointer value may be used to refer to this memory
  13571. * through ::cuMemcpy() and similar functions using the
  13572. * ::CU_MEMORYTYPE_UNIFIED memory type.
  13573. *
  13574. */
  13575. /**
  13576. * \brief Returns information about a pointer
  13577. *
  13578. * The supported attributes are:
  13579. *
  13580. * - ::CU_POINTER_ATTRIBUTE_CONTEXT:
  13581. *
  13582. * Returns in \p *data the ::CUcontext in which \p ptr was allocated or
  13583. * registered.
  13584. * The type of \p data must be ::CUcontext *.
  13585. *
  13586. * If \p ptr was not allocated by, mapped by, or registered with
  13587. * a ::CUcontext which uses unified virtual addressing then
  13588. * ::CUDA_ERROR_INVALID_VALUE is returned.
  13589. *
  13590. * - ::CU_POINTER_ATTRIBUTE_MEMORY_TYPE:
  13591. *
  13592. * Returns in \p *data the physical memory type of the memory that
  13593. * \p ptr addresses as a ::CUmemorytype enumerated value.
  13594. * The type of \p data must be unsigned int.
  13595. *
  13596. * If \p ptr addresses device memory then \p *data is set to
  13597. * ::CU_MEMORYTYPE_DEVICE. The particular ::CUdevice on which the
  13598. * memory resides is the ::CUdevice of the ::CUcontext returned by the
  13599. * ::CU_POINTER_ATTRIBUTE_CONTEXT attribute of \p ptr.
  13600. *
  13601. * If \p ptr addresses host memory then \p *data is set to
  13602. * ::CU_MEMORYTYPE_HOST.
  13603. *
  13604. * If \p ptr was not allocated by, mapped by, or registered with
  13605. * a ::CUcontext which uses unified virtual addressing then
  13606. * ::CUDA_ERROR_INVALID_VALUE is returned.
  13607. *
  13608. * If the current ::CUcontext does not support unified virtual
  13609. * addressing then ::CUDA_ERROR_INVALID_CONTEXT is returned.
  13610. *
  13611. * - ::CU_POINTER_ATTRIBUTE_DEVICE_POINTER:
  13612. *
  13613. * Returns in \p *data the device pointer value through which
  13614. * \p ptr may be accessed by kernels running in the current
  13615. * ::CUcontext.
  13616. * The type of \p data must be CUdeviceptr *.
  13617. *
  13618. * If there exists no device pointer value through which
  13619. * kernels running in the current ::CUcontext may access
  13620. * \p ptr then ::CUDA_ERROR_INVALID_VALUE is returned.
  13621. *
  13622. * If there is no current ::CUcontext then
  13623. * ::CUDA_ERROR_INVALID_CONTEXT is returned.
  13624. *
  13625. * Except in the exceptional disjoint addressing cases discussed
  13626. * below, the value returned in \p *data will equal the input
  13627. * value \p ptr.
  13628. *
  13629. * - ::CU_POINTER_ATTRIBUTE_HOST_POINTER:
  13630. *
  13631. * Returns in \p *data the host pointer value through which
  13632. * \p ptr may be accessed by by the host program.
  13633. * The type of \p data must be void **.
  13634. * If there exists no host pointer value through which
  13635. * the host program may directly access \p ptr then
  13636. * ::CUDA_ERROR_INVALID_VALUE is returned.
  13637. *
  13638. * Except in the exceptional disjoint addressing cases discussed
  13639. * below, the value returned in \p *data will equal the input
  13640. * value \p ptr.
  13641. *
  13642. * - ::CU_POINTER_ATTRIBUTE_P2P_TOKENS:
  13643. *
  13644. * Returns in \p *data two tokens for use with the nv-p2p.h Linux
  13645. * kernel interface. \p data must be a struct of type
  13646. * CUDA_POINTER_ATTRIBUTE_P2P_TOKENS.
  13647. *
  13648. * \p ptr must be a pointer to memory obtained from :cuMemAlloc().
  13649. * Note that p2pToken and vaSpaceToken are only valid for the
  13650. * lifetime of the source allocation. A subsequent allocation at
  13651. * the same address may return completely different tokens.
  13652. * Querying this attribute has a side effect of setting the attribute
  13653. * ::CU_POINTER_ATTRIBUTE_SYNC_MEMOPS for the region of memory that
  13654. * \p ptr points to.
  13655. *
  13656. * - ::CU_POINTER_ATTRIBUTE_SYNC_MEMOPS:
  13657. *
  13658. * A boolean attribute which when set, ensures that synchronous memory operations
  13659. * initiated on the region of memory that \p ptr points to will always synchronize.
  13660. * See further documentation in the section titled "API synchronization behavior"
  13661. * to learn more about cases when synchronous memory operations can
  13662. * exhibit asynchronous behavior.
  13663. *
  13664. * - ::CU_POINTER_ATTRIBUTE_BUFFER_ID:
  13665. *
  13666. * Returns in \p *data a buffer ID which is guaranteed to be unique within the process.
  13667. * \p data must point to an unsigned long long.
  13668. *
  13669. * \p ptr must be a pointer to memory obtained from a CUDA memory allocation API.
  13670. * Every memory allocation from any of the CUDA memory allocation APIs will
  13671. * have a unique ID over a process lifetime. Subsequent allocations do not reuse IDs
  13672. * from previous freed allocations. IDs are only unique within a single process.
  13673. *
  13674. *
  13675. * - ::CU_POINTER_ATTRIBUTE_IS_MANAGED:
  13676. *
  13677. * Returns in \p *data a boolean that indicates whether the pointer points to
  13678. * managed memory or not.
  13679. *
  13680. * If \p ptr is not a valid CUDA pointer then ::CUDA_ERROR_INVALID_VALUE is returned.
  13681. *
  13682. * - ::CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL:
  13683. *
  13684. * Returns in \p *data an integer representing a device ordinal of a device against
  13685. * which the memory was allocated or registered.
  13686. *
  13687. * - ::CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE:
  13688. *
  13689. * Returns in \p *data a boolean that indicates if this pointer maps to
  13690. * an allocation that is suitable for ::cudaIpcGetMemHandle.
  13691. *
  13692. * - ::CU_POINTER_ATTRIBUTE_RANGE_START_ADDR:
  13693. *
  13694. * Returns in \p *data the starting address for the allocation referenced
  13695. * by the device pointer \p ptr. Note that this is not necessarily the
  13696. * address of the mapped region, but the address of the mappable address
  13697. * range \p ptr references (e.g. from ::cuMemAddressReserve).
  13698. *
  13699. * - ::CU_POINTER_ATTRIBUTE_RANGE_SIZE:
  13700. *
  13701. * Returns in \p *data the size for the allocation referenced by the device
  13702. * pointer \p ptr. Note that this is not necessarily the size of the mapped
  13703. * region, but the size of the mappable address range \p ptr references
  13704. * (e.g. from ::cuMemAddressReserve). To retrieve the size of the mapped
  13705. * region, see ::cuMemGetAddressRange
  13706. *
  13707. * - ::CU_POINTER_ATTRIBUTE_MAPPED:
  13708. *
  13709. * Returns in \p *data a boolean that indicates if this pointer is in a
  13710. * valid address range that is mapped to a backing allocation.
  13711. *
  13712. * - ::CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES:
  13713. *
  13714. * Returns a bitmask of the allowed handle types for an allocation that may
  13715. * be passed to ::cuMemExportToShareableHandle.
  13716. *
  13717. * - ::CU_POINTER_ATTRIBUTE_MEMPOOL_HANDLE:
  13718. *
  13719. * Returns in \p *data the handle to the mempool that the allocation was obtained from.
  13720. *
  13721. * - ::CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE:
  13722. *
  13723. * Returns in \p *data a boolean that indicates whether the pointer points
  13724. * to memory that is capable to be used for hardware accelerated
  13725. * decompression.
  13726. *
  13727. * \par
  13728. *
  13729. * Note that for most allocations in the unified virtual address space
  13730. * the host and device pointer for accessing the allocation will be the
  13731. * same. The exceptions to this are
  13732. * - user memory registered using ::cuMemHostRegister
  13733. * - host memory allocated using ::cuMemHostAlloc with the
  13734. * ::CU_MEMHOSTALLOC_WRITECOMBINED flag
  13735. * For these types of allocation there will exist separate, disjoint host
  13736. * and device addresses for accessing the allocation. In particular
  13737. * - The host address will correspond to an invalid unmapped device address
  13738. * (which will result in an exception if accessed from the device)
  13739. * - The device address will correspond to an invalid unmapped host address
  13740. * (which will result in an exception if accessed from the host).
  13741. * For these types of allocations, querying ::CU_POINTER_ATTRIBUTE_HOST_POINTER
  13742. * and ::CU_POINTER_ATTRIBUTE_DEVICE_POINTER may be used to retrieve the host
  13743. * and device addresses from either address.
  13744. *
  13745. * \param data - Returned pointer attribute value
  13746. * \param attribute - Pointer attribute to query
  13747. * \param ptr - Pointer
  13748. *
  13749. * \return
  13750. * ::CUDA_SUCCESS,
  13751. * ::CUDA_ERROR_DEINITIALIZED,
  13752. * ::CUDA_ERROR_NOT_INITIALIZED,
  13753. * ::CUDA_ERROR_INVALID_CONTEXT,
  13754. * ::CUDA_ERROR_INVALID_VALUE,
  13755. * ::CUDA_ERROR_INVALID_DEVICE
  13756. * \notefnerr
  13757. *
  13758. * \sa
  13759. * ::cuPointerSetAttribute,
  13760. * ::cuMemAlloc,
  13761. * ::cuMemFree,
  13762. * ::cuMemAllocHost,
  13763. * ::cuMemFreeHost,
  13764. * ::cuMemHostAlloc,
  13765. * ::cuMemHostRegister,
  13766. * ::cuMemHostUnregister,
  13767. * ::cudaPointerGetAttributes
  13768. */
  13769. CUresult CUDAAPI cuPointerGetAttribute(void *data, CUpointer_attribute attribute, CUdeviceptr ptr);
  13770. /**
  13771. * \brief Prefetches memory to the specified destination device
  13772. *
  13773. * Note there is a later version of this API, ::cuMemPrefetchAsync_v2. It will
  13774. * supplant this version in 13.0, which is retained for minor version compatibility.
  13775. *
  13776. * Prefetches memory to the specified destination device. \p devPtr is the
  13777. * base device pointer of the memory to be prefetched and \p dstDevice is the
  13778. * destination device. \p count specifies the number of bytes to copy. \p hStream
  13779. * is the stream in which the operation is enqueued. The memory range must refer
  13780. * to managed memory allocated via ::cuMemAllocManaged or declared via __managed__ variables
  13781. * or it may also refer to system-allocated memory on systems with non-zero
  13782. * CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS.
  13783. *
  13784. * Passing in CU_DEVICE_CPU for \p dstDevice will prefetch the data to host memory. If
  13785. * \p dstDevice is a GPU, then the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS
  13786. * must be non-zero. Additionally, \p hStream must be associated with a device that has a
  13787. * non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS.
  13788. *
  13789. * The start address and end address of the memory range will be rounded down and rounded up
  13790. * respectively to be aligned to CPU page size before the prefetch operation is enqueued
  13791. * in the stream.
  13792. *
  13793. * If no physical memory has been allocated for this region, then this memory region
  13794. * will be populated and mapped on the destination device. If there's insufficient
  13795. * memory to prefetch the desired region, the Unified Memory driver may evict pages from other
  13796. * ::cuMemAllocManaged allocations to host memory in order to make room. Device memory
  13797. * allocated using ::cuMemAlloc or ::cuArrayCreate will not be evicted.
  13798. *
  13799. * By default, any mappings to the previous location of the migrated pages are removed and
  13800. * mappings for the new location are only setup on \p dstDevice. The exact behavior however
  13801. * also depends on the settings applied to this memory range via ::cuMemAdvise as described
  13802. * below:
  13803. *
  13804. * If ::CU_MEM_ADVISE_SET_READ_MOSTLY was set on any subset of this memory range,
  13805. * then that subset will create a read-only copy of the pages on \p dstDevice.
  13806. *
  13807. * If ::CU_MEM_ADVISE_SET_PREFERRED_LOCATION was called on any subset of this memory
  13808. * range, then the pages will be migrated to \p dstDevice even if \p dstDevice is not the
  13809. * preferred location of any pages in the memory range.
  13810. *
  13811. * If ::CU_MEM_ADVISE_SET_ACCESSED_BY was called on any subset of this memory range,
  13812. * then mappings to those pages from all the appropriate processors are updated to
  13813. * refer to the new location if establishing such a mapping is possible. Otherwise,
  13814. * those mappings are cleared.
  13815. *
  13816. * Note that this API is not required for functionality and only serves to improve performance
  13817. * by allowing the application to migrate data to a suitable location before it is accessed.
  13818. * Memory accesses to this range are always coherent and are allowed even when the data is
  13819. * actively being migrated.
  13820. *
  13821. * Note that this function is asynchronous with respect to the host and all work
  13822. * on other devices.
  13823. *
  13824. * \param devPtr - Pointer to be prefetched
  13825. * \param count - Size in bytes
  13826. * \param dstDevice - Destination device to prefetch to
  13827. * \param hStream - Stream to enqueue prefetch operation
  13828. *
  13829. * \return
  13830. * ::CUDA_SUCCESS,
  13831. * ::CUDA_ERROR_INVALID_VALUE,
  13832. * ::CUDA_ERROR_INVALID_DEVICE
  13833. * \notefnerr
  13834. * \note_async
  13835. * \note_null_stream
  13836. *
  13837. * \sa ::cuMemcpy, ::cuMemcpyPeer, ::cuMemcpyAsync,
  13838. * ::cuMemcpy3DPeerAsync, ::cuMemAdvise, ::cuMemPrefetchAsync
  13839. * ::cudaMemPrefetchAsync_v2
  13840. */
  13841. CUresult CUDAAPI cuMemPrefetchAsync(CUdeviceptr devPtr, size_t count, CUdevice dstDevice, CUstream hStream);
  13842. /**
  13843. * \brief Prefetches memory to the specified destination location
  13844. *
  13845. * Prefetches memory to the specified destination location. \p devPtr is the
  13846. * base device pointer of the memory to be prefetched and \p location specifies the
  13847. * destination location. \p count specifies the number of bytes to copy. \p hStream
  13848. * is the stream in which the operation is enqueued. The memory range must refer
  13849. * to managed memory allocated via ::cuMemAllocManaged or declared via __managed__ variables.
  13850. *
  13851. * Specifying ::CU_MEM_LOCATION_TYPE_DEVICE for ::CUmemLocation::type will prefetch memory to GPU
  13852. * specified by device ordinal ::CUmemLocation::id which must have non-zero value for the device attribute
  13853. * ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS. Additionally, \p hStream must be associated with a device
  13854. * that has a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS.
  13855. * Specifying ::CU_MEM_LOCATION_TYPE_HOST as ::CUmemLocation::type will prefetch data to host memory.
  13856. * Applications can request prefetching memory to a specific host NUMA node by specifying
  13857. * ::CU_MEM_LOCATION_TYPE_HOST_NUMA for ::CUmemLocation::type and a valid host NUMA node id in ::CUmemLocation::id
  13858. * Users can also request prefetching memory to the host NUMA node closest to the current thread's CPU by specifying
  13859. * ::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT for ::CUmemLocation::type. Note when ::CUmemLocation::type is etiher
  13860. * ::CU_MEM_LOCATION_TYPE_HOST OR ::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT, ::CUmemLocation::id will be ignored.
  13861. *
  13862. * The start address and end address of the memory range will be rounded down and rounded up
  13863. * respectively to be aligned to CPU page size before the prefetch operation is enqueued
  13864. * in the stream.
  13865. *
  13866. * If no physical memory has been allocated for this region, then this memory region
  13867. * will be populated and mapped on the destination device. If there's insufficient
  13868. * memory to prefetch the desired region, the Unified Memory driver may evict pages from other
  13869. * ::cuMemAllocManaged allocations to host memory in order to make room. Device memory
  13870. * allocated using ::cuMemAlloc or ::cuArrayCreate will not be evicted.
  13871. *
  13872. * By default, any mappings to the previous location of the migrated pages are removed and
  13873. * mappings for the new location are only setup on the destination location. The exact behavior however
  13874. * also depends on the settings applied to this memory range via ::cuMemAdvise as described
  13875. * below:
  13876. *
  13877. * If ::CU_MEM_ADVISE_SET_READ_MOSTLY was set on any subset of this memory range,
  13878. * then that subset will create a read-only copy of the pages on destination location.
  13879. * If however the destination location is a host NUMA node, then any pages of that subset
  13880. * that are already in another host NUMA node will be transferred to the destination.
  13881. *
  13882. * If ::CU_MEM_ADVISE_SET_PREFERRED_LOCATION was called on any subset of this memory
  13883. * range, then the pages will be migrated to \p location even if \p location is not the
  13884. * preferred location of any pages in the memory range.
  13885. *
  13886. * If ::CU_MEM_ADVISE_SET_ACCESSED_BY was called on any subset of this memory range,
  13887. * then mappings to those pages from all the appropriate processors are updated to
  13888. * refer to the new location if establishing such a mapping is possible. Otherwise,
  13889. * those mappings are cleared.
  13890. *
  13891. * Note that this API is not required for functionality and only serves to improve performance
  13892. * by allowing the application to migrate data to a suitable location before it is accessed.
  13893. * Memory accesses to this range are always coherent and are allowed even when the data is
  13894. * actively being migrated.
  13895. *
  13896. * Note that this function is asynchronous with respect to the host and all work
  13897. * on other devices.
  13898. *
  13899. * \param devPtr - Pointer to be prefetched
  13900. * \param count - Size in bytes
  13901. * \param dstDevice - Destination device to prefetch to
  13902. * \param flags - flags for future use, must be zero now.
  13903. * \param hStream - Stream to enqueue prefetch operation
  13904. *
  13905. * \return
  13906. * ::CUDA_SUCCESS,
  13907. * ::CUDA_ERROR_INVALID_VALUE,
  13908. * ::CUDA_ERROR_INVALID_DEVICE
  13909. * \notefnerr
  13910. * \note_async
  13911. * \note_null_stream
  13912. *
  13913. * \sa ::cuMemcpy, ::cuMemcpyPeer, ::cuMemcpyAsync,
  13914. * ::cuMemcpy3DPeerAsync, ::cuMemAdvise, ::cuMemPrefetchAsync
  13915. * ::cudaMemPrefetchAsync_v2
  13916. */
  13917. CUresult CUDAAPI cuMemPrefetchAsync_v2(CUdeviceptr devPtr, size_t count, CUmemLocation location, unsigned int flags, CUstream hStream);
  13918. /**
  13919. * \brief Advise about the usage of a given memory range
  13920. *
  13921. * Note there is a later version of this API, ::cuMemAdvise_v2. It will
  13922. * supplant this version in 13.0, which is retained for minor version compatibility.
  13923. *
  13924. * Advise the Unified Memory subsystem about the usage pattern for the memory range
  13925. * starting at \p devPtr with a size of \p count bytes. The start address and end address of the memory
  13926. * range will be rounded down and rounded up respectively to be aligned to CPU page size before the
  13927. * advice is applied. The memory range must refer to managed memory allocated via ::cuMemAllocManaged
  13928. * or declared via __managed__ variables. The memory range could also refer to system-allocated pageable
  13929. * memory provided it represents a valid, host-accessible region of memory and all additional constraints
  13930. * imposed by \p advice as outlined below are also satisfied. Specifying an invalid system-allocated pageable
  13931. * memory range results in an error being returned.
  13932. *
  13933. * The \p advice parameter can take the following values:
  13934. * - ::CU_MEM_ADVISE_SET_READ_MOSTLY: This implies that the data is mostly going to be read
  13935. * from and only occasionally written to. Any read accesses from any processor to this region will create a
  13936. * read-only copy of at least the accessed pages in that processor's memory. Additionally, if ::cuMemPrefetchAsync
  13937. * is called on this region, it will create a read-only copy of the data on the destination processor.
  13938. * If any processor writes to this region, all copies of the corresponding page will be invalidated
  13939. * except for the one where the write occurred. The \p device argument is ignored for this advice.
  13940. * Note that for a page to be read-duplicated, the accessing processor must either be the CPU or a GPU
  13941. * that has a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS.
  13942. * Also, if a context is created on a device that does not have the device attribute
  13943. * ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS set, then read-duplication will not occur until
  13944. * all such contexts are destroyed.
  13945. * If the memory region refers to valid system-allocated pageable memory, then the accessing device must
  13946. * have a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS for a read-only
  13947. * copy to be created on that device. Note however that if the accessing device also has a non-zero value for the
  13948. * device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES, then setting this advice
  13949. * will not create a read-only copy when that device accesses this memory region.
  13950. *
  13951. * - ::CU_MEM_ADVISE_UNSET_READ_MOSTLY: Undoes the effect of ::CU_MEM_ADVISE_SET_READ_MOSTLY and also prevents the
  13952. * Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated
  13953. * copies of the data will be collapsed into a single copy. The location for the collapsed
  13954. * copy will be the preferred location if the page has a preferred location and one of the read-duplicated
  13955. * copies was resident at that location. Otherwise, the location chosen is arbitrary.
  13956. *
  13957. * - ::CU_MEM_ADVISE_SET_PREFERRED_LOCATION: This advice sets the preferred location for the
  13958. * data to be the memory belonging to \p device. Passing in CU_DEVICE_CPU for \p device sets the
  13959. * preferred location as host memory. If \p device is a GPU, then it must have a non-zero value for the
  13960. * device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS. Setting the preferred location
  13961. * does not cause data to migrate to that location immediately. Instead, it guides the migration policy
  13962. * when a fault occurs on that memory region. If the data is already in its preferred location and the
  13963. * faulting processor can establish a mapping without requiring the data to be migrated, then
  13964. * data migration will be avoided. On the other hand, if the data is not in its preferred location
  13965. * or if a direct mapping cannot be established, then it will be migrated to the processor accessing
  13966. * it. It is important to note that setting the preferred location does not prevent data prefetching
  13967. * done using ::cuMemPrefetchAsync.
  13968. * Having a preferred location can override the page thrash detection and resolution logic in the Unified
  13969. * Memory driver. Normally, if a page is detected to be constantly thrashing between for example host and device
  13970. * memory, the page may eventually be pinned to host memory by the Unified Memory driver. But
  13971. * if the preferred location is set as device memory, then the page will continue to thrash indefinitely.
  13972. * If ::CU_MEM_ADVISE_SET_READ_MOSTLY is also set on this memory region or any subset of it, then the
  13973. * policies associated with that advice will override the policies of this advice, unless read accesses from
  13974. * \p device will not result in a read-only copy being created on that device as outlined in description for
  13975. * the advice ::CU_MEM_ADVISE_SET_READ_MOSTLY.
  13976. * If the memory region refers to valid system-allocated pageable memory, then \p device must have a non-zero
  13977. * value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS.
  13978. *
  13979. * - ::CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION: Undoes the effect of ::CU_MEM_ADVISE_SET_PREFERRED_LOCATION
  13980. * and changes the preferred location to none.
  13981. *
  13982. * - ::CU_MEM_ADVISE_SET_ACCESSED_BY: This advice implies that the data will be accessed by \p device.
  13983. * Passing in ::CU_DEVICE_CPU for \p device will set the advice for the CPU. If \p device is a GPU, then
  13984. * the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS must be non-zero.
  13985. * This advice does not cause data migration and has no impact on the location of the data per se. Instead,
  13986. * it causes the data to always be mapped in the specified processor's page tables, as long as the
  13987. * location of the data permits a mapping to be established. If the data gets migrated for any reason,
  13988. * the mappings are updated accordingly.
  13989. * This advice is recommended in scenarios where data locality is not important, but avoiding faults is.
  13990. * Consider for example a system containing multiple GPUs with peer-to-peer access enabled, where the
  13991. * data located on one GPU is occasionally accessed by peer GPUs. In such scenarios, migrating data
  13992. * over to the other GPUs is not as important because the accesses are infrequent and the overhead of
  13993. * migration may be too high. But preventing faults can still help improve performance, and so having
  13994. * a mapping set up in advance is useful. Note that on CPU access of this data, the data may be migrated
  13995. * to host memory because the CPU typically cannot access device memory directly. Any GPU that had the
  13996. * ::CU_MEM_ADVISE_SET_ACCESSED_BY flag set for this data will now have its mapping updated to point to the
  13997. * page in host memory.
  13998. * If ::CU_MEM_ADVISE_SET_READ_MOSTLY is also set on this memory region or any subset of it, then the
  13999. * policies associated with that advice will override the policies of this advice. Additionally, if the
  14000. * preferred location of this memory region or any subset of it is also \p device, then the policies
  14001. * associated with ::CU_MEM_ADVISE_SET_PREFERRED_LOCATION will override the policies of this advice.
  14002. * If the memory region refers to valid system-allocated pageable memory, then \p device must have a non-zero
  14003. * value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS. Additionally, if \p device has
  14004. * a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES,
  14005. * then this call has no effect.
  14006. *
  14007. * - ::CU_MEM_ADVISE_UNSET_ACCESSED_BY: Undoes the effect of ::CU_MEM_ADVISE_SET_ACCESSED_BY. Any mappings to
  14008. * the data from \p device may be removed at any time causing accesses to result in non-fatal page faults.
  14009. * If the memory region refers to valid system-allocated pageable memory, then \p device must have a non-zero
  14010. * value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS. Additionally, if \p device has
  14011. * a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES,
  14012. * then this call has no effect.
  14013. *
  14014. * \param devPtr - Pointer to memory to set the advice for
  14015. * \param count - Size in bytes of the memory range
  14016. * \param advice - Advice to be applied for the specified memory range
  14017. * \param device - Device to apply the advice for
  14018. *
  14019. * \return
  14020. * ::CUDA_SUCCESS,
  14021. * ::CUDA_ERROR_INVALID_VALUE,
  14022. * ::CUDA_ERROR_INVALID_DEVICE
  14023. * \notefnerr
  14024. * \note_async
  14025. * \note_null_stream
  14026. *
  14027. * \sa ::cuMemcpy, ::cuMemcpyPeer, ::cuMemcpyAsync,
  14028. * ::cuMemcpy3DPeerAsync, ::cuMemPrefetchAsync, ::cuMemAdvise_v2
  14029. * ::cudaMemAdvise
  14030. */
  14031. CUresult CUDAAPI cuMemAdvise(CUdeviceptr devPtr, size_t count, CUmem_advise advice, CUdevice device);
  14032. /**
  14033. * \brief Advise about the usage of a given memory range
  14034. *
  14035. * Advise the Unified Memory subsystem about the usage pattern for the memory range
  14036. * starting at \p devPtr with a size of \p count bytes. The start address and end address of the memory
  14037. * range will be rounded down and rounded up respectively to be aligned to CPU page size before the
  14038. * advice is applied. The memory range must refer to managed memory allocated via ::cuMemAllocManaged
  14039. * or declared via __managed__ variables. The memory range could also refer to system-allocated pageable
  14040. * memory provided it represents a valid, host-accessible region of memory and all additional constraints
  14041. * imposed by \p advice as outlined below are also satisfied. Specifying an invalid system-allocated pageable
  14042. * memory range results in an error being returned.
  14043. *
  14044. * The \p advice parameter can take the following values:
  14045. * - ::CU_MEM_ADVISE_SET_READ_MOSTLY: This implies that the data is mostly going to be read
  14046. * from and only occasionally written to. Any read accesses from any processor to this region will create a
  14047. * read-only copy of at least the accessed pages in that processor's memory. Additionally, if ::cuMemPrefetchAsync
  14048. * or ::cuMemPrefetchAsync_v2 is called on this region, it will create a read-only copy of the data on the destination processor.
  14049. * If the target location for ::cuMemPrefetchAsync_v2 is a host NUMA node and a read-only copy already exists on
  14050. * another host NUMA node, that copy will be migrated to the targeted host NUMA node.
  14051. * If any processor writes to this region, all copies of the corresponding page will be invalidated
  14052. * except for the one where the write occurred. If the writing processor is the CPU and the preferred location of
  14053. * the page is a host NUMA node, then the page will also be migrated to that host NUMA node. The \p location argument is ignored for this advice.
  14054. * Note that for a page to be read-duplicated, the accessing processor must either be the CPU or a GPU
  14055. * that has a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS.
  14056. * Also, if a context is created on a device that does not have the device attribute
  14057. * ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS set, then read-duplication will not occur until
  14058. * all such contexts are destroyed.
  14059. * If the memory region refers to valid system-allocated pageable memory, then the accessing device must
  14060. * have a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS for a read-only
  14061. * copy to be created on that device. Note however that if the accessing device also has a non-zero value for the
  14062. * device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES, then setting this advice
  14063. * will not create a read-only copy when that device accesses this memory region.
  14064. *
  14065. * - ::CU_MEM_ADVISE_UNSET_READ_MOSTLY: Undoes the effect of ::CU_MEM_ADVISE_SET_READ_MOSTLY and also prevents the
  14066. * Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated
  14067. * copies of the data will be collapsed into a single copy. The location for the collapsed
  14068. * copy will be the preferred location if the page has a preferred location and one of the read-duplicated
  14069. * copies was resident at that location. Otherwise, the location chosen is arbitrary.
  14070. * Note: The \p location argument is ignored for this advice.
  14071. *
  14072. * - ::CU_MEM_ADVISE_SET_PREFERRED_LOCATION: This advice sets the preferred location for the
  14073. * data to be the memory belonging to \p location. When ::CUmemLocation::type is ::CU_MEM_LOCATION_TYPE_HOST,
  14074. * ::CUmemLocation::id is ignored and the preferred location is set to be host memory. To set the preferred location
  14075. * to a specific host NUMA node, applications must set ::CUmemLocation::type to ::CU_MEM_LOCATION_TYPE_HOST_NUMA and
  14076. * ::CUmemLocation::id must specify the NUMA ID of the host NUMA node. If ::CUmemLocation::type is set to ::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT,
  14077. * ::CUmemLocation::id will be ignored and the the host NUMA node closest to the calling thread's CPU will be used as the preferred location.
  14078. * If ::CUmemLocation::type is a ::CU_MEM_LOCATION_TYPE_DEVICE, then ::CUmemLocation::id must be a valid device ordinal
  14079. * and the device must have a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS.
  14080. * Setting the preferred location does not cause data to migrate to that location immediately. Instead, it guides the migration policy
  14081. * when a fault occurs on that memory region. If the data is already in its preferred location and the
  14082. * faulting processor can establish a mapping without requiring the data to be migrated, then
  14083. * data migration will be avoided. On the other hand, if the data is not in its preferred location
  14084. * or if a direct mapping cannot be established, then it will be migrated to the processor accessing
  14085. * it. It is important to note that setting the preferred location does not prevent data prefetching
  14086. * done using ::cuMemPrefetchAsync.
  14087. * Having a preferred location can override the page thrash detection and resolution logic in the Unified
  14088. * Memory driver. Normally, if a page is detected to be constantly thrashing between for example host and device
  14089. * memory, the page may eventually be pinned to host memory by the Unified Memory driver. But
  14090. * if the preferred location is set as device memory, then the page will continue to thrash indefinitely.
  14091. * If ::CU_MEM_ADVISE_SET_READ_MOSTLY is also set on this memory region or any subset of it, then the
  14092. * policies associated with that advice will override the policies of this advice, unless read accesses from
  14093. * \p location will not result in a read-only copy being created on that procesor as outlined in description for
  14094. * the advice ::CU_MEM_ADVISE_SET_READ_MOSTLY.
  14095. * If the memory region refers to valid system-allocated pageable memory, and ::CUmemLocation::type is CU_MEM_LOCATION_TYPE_DEVICE
  14096. * then ::CUmemLocation::id must be a valid device that has a non-zero alue for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS.
  14097. *
  14098. * - ::CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION: Undoes the effect of ::CU_MEM_ADVISE_SET_PREFERRED_LOCATION
  14099. * and changes the preferred location to none. The \p location argument is ignored for this advice.
  14100. *
  14101. * - ::CU_MEM_ADVISE_SET_ACCESSED_BY: This advice implies that the data will be accessed by processor \p location.
  14102. * The ::CUmemLocation::type must be either ::CU_MEM_LOCATION_TYPE_DEVICE with ::CUmemLocation::id representing a valid device
  14103. * ordinal or ::CU_MEM_LOCATION_TYPE_HOST and ::CUmemLocation::id will be ignored. All other location types are invalid.
  14104. * If ::CUmemLocation::id is a GPU, then the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS must be non-zero.
  14105. * This advice does not cause data migration and has no impact on the location of the data per se. Instead,
  14106. * it causes the data to always be mapped in the specified processor's page tables, as long as the
  14107. * location of the data permits a mapping to be established. If the data gets migrated for any reason,
  14108. * the mappings are updated accordingly.
  14109. * This advice is recommended in scenarios where data locality is not important, but avoiding faults is.
  14110. * Consider for example a system containing multiple GPUs with peer-to-peer access enabled, where the
  14111. * data located on one GPU is occasionally accessed by peer GPUs. In such scenarios, migrating data
  14112. * over to the other GPUs is not as important because the accesses are infrequent and the overhead of
  14113. * migration may be too high. But preventing faults can still help improve performance, and so having
  14114. * a mapping set up in advance is useful. Note that on CPU access of this data, the data may be migrated
  14115. * to host memory because the CPU typically cannot access device memory directly. Any GPU that had the
  14116. * ::CU_MEM_ADVISE_SET_ACCESSED_BY flag set for this data will now have its mapping updated to point to the
  14117. * page in host memory.
  14118. * If ::CU_MEM_ADVISE_SET_READ_MOSTLY is also set on this memory region or any subset of it, then the
  14119. * policies associated with that advice will override the policies of this advice. Additionally, if the
  14120. * preferred location of this memory region or any subset of it is also \p location, then the policies
  14121. * associated with ::CU_MEM_ADVISE_SET_PREFERRED_LOCATION will override the policies of this advice.
  14122. * If the memory region refers to valid system-allocated pageable memory, and ::CUmemLocation::type is ::CU_MEM_LOCATION_TYPE_DEVICE
  14123. * then device in ::CUmemLocation::id must have a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS.
  14124. * Additionally, if ::CUmemLocation::id has a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES,
  14125. * then this call has no effect.
  14126. *
  14127. * - ::CU_MEM_ADVISE_UNSET_ACCESSED_BY: Undoes the effect of ::CU_MEM_ADVISE_SET_ACCESSED_BY. Any mappings to
  14128. * the data from \p location may be removed at any time causing accesses to result in non-fatal page faults.
  14129. * If the memory region refers to valid system-allocated pageable memory, and ::CUmemLocation::type is ::CU_MEM_LOCATION_TYPE_DEVICE
  14130. * then device in ::CUmemLocation::id must have a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS.
  14131. * Additionally, if ::CUmemLocation::id has a non-zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES,
  14132. * then this call has no effect.
  14133. *
  14134. * \param devPtr - Pointer to memory to set the advice for
  14135. * \param count - Size in bytes of the memory range
  14136. * \param advice - Advice to be applied for the specified memory range
  14137. * \param location - location to apply the advice for
  14138. *
  14139. * \return
  14140. * ::CUDA_SUCCESS,
  14141. * ::CUDA_ERROR_INVALID_VALUE,
  14142. * ::CUDA_ERROR_INVALID_DEVICE
  14143. * \notefnerr
  14144. * \note_async
  14145. * \note_null_stream
  14146. *
  14147. * \sa ::cuMemcpy, ::cuMemcpyPeer, ::cuMemcpyAsync,
  14148. * ::cuMemcpy3DPeerAsync, ::cuMemPrefetchAsync, ::cuMemAdvise
  14149. * ::cudaMemAdvise
  14150. */
  14151. CUresult CUDAAPI cuMemAdvise_v2(CUdeviceptr devPtr, size_t count, CUmem_advise advice, CUmemLocation location);
  14152. /**
  14153. * \brief Query an attribute of a given memory range
  14154. *
  14155. * Query an attribute about the memory range starting at \p devPtr with a size of \p count bytes. The
  14156. * memory range must refer to managed memory allocated via ::cuMemAllocManaged or declared via
  14157. * __managed__ variables.
  14158. *
  14159. * The \p attribute parameter can take the following values:
  14160. * - ::CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY: If this attribute is specified, \p data will be interpreted
  14161. * as a 32-bit integer, and \p dataSize must be 4. The result returned will be 1 if all pages in the given
  14162. * memory range have read-duplication enabled, or 0 otherwise.
  14163. * - ::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION: If this attribute is specified, \p data will be
  14164. * interpreted as a 32-bit integer, and \p dataSize must be 4. The result returned will be a GPU device
  14165. * id if all pages in the memory range have that GPU as their preferred location, or it will be CU_DEVICE_CPU
  14166. * if all pages in the memory range have the CPU as their preferred location, or it will be CU_DEVICE_INVALID
  14167. * if either all the pages don't have the same preferred location or some of the pages don't have a
  14168. * preferred location at all. Note that the actual location of the pages in the memory range at the time of
  14169. * the query may be different from the preferred location.
  14170. * - ::CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY: If this attribute is specified, \p data will be interpreted
  14171. * as an array of 32-bit integers, and \p dataSize must be a non-zero multiple of 4. The result returned
  14172. * will be a list of device ids that had ::CU_MEM_ADVISE_SET_ACCESSED_BY set for that entire memory range.
  14173. * If any device does not have that advice set for the entire memory range, that device will not be included.
  14174. * If \p data is larger than the number of devices that have that advice set for that memory range,
  14175. * CU_DEVICE_INVALID will be returned in all the extra space provided. For ex., if \p dataSize is 12
  14176. * (i.e. \p data has 3 elements) and only device 0 has the advice set, then the result returned will be
  14177. * { 0, CU_DEVICE_INVALID, CU_DEVICE_INVALID }. If \p data is smaller than the number of devices that have
  14178. * that advice set, then only as many devices will be returned as can fit in the array. There is no
  14179. * guarantee on which specific devices will be returned, however.
  14180. * - ::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION: If this attribute is specified, \p data will be
  14181. * interpreted as a 32-bit integer, and \p dataSize must be 4. The result returned will be the last location
  14182. * to which all pages in the memory range were prefetched explicitly via ::cuMemPrefetchAsync. This will either be
  14183. * a GPU id or CU_DEVICE_CPU depending on whether the last location for prefetch was a GPU or the CPU
  14184. * respectively. If any page in the memory range was never explicitly prefetched or if all pages were not
  14185. * prefetched to the same location, CU_DEVICE_INVALID will be returned. Note that this simply returns the
  14186. * last location that the application requested to prefetch the memory range to. It gives no indication as to
  14187. * whether the prefetch operation to that location has completed or even begun.
  14188. * - ::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE: If this attribute is specified, \p data will be
  14189. * interpreted as a ::CUmemLocationType, and \p dataSize must be sizeof(CUmemLocationType). The ::CUmemLocationType returned will be
  14190. * ::CU_MEM_LOCATION_TYPE_DEVICE if all pages in the memory range have the same GPU as their preferred location, or ::CUmemLocationType
  14191. * will be ::CU_MEM_LOCATION_TYPE_HOST if all pages in the memory range have the CPU as their preferred location, or it will be ::CU_MEM_LOCATION_TYPE_HOST_NUMA
  14192. * if all the pages in the memory range have the same host NUMA node ID as their preferred location or it will be ::CU_MEM_LOCATION_TYPE_INVALID
  14193. * if either all the pages don't have the same preferred location or some of the pages don't have a preferred location at all.
  14194. * Note that the actual location type of the pages in the memory range at the time of the query may be different from the preferred location type.
  14195. * - ::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_ID: If this attribute is specified, \p data will be
  14196. * interpreted as a 32-bit integer, and \p dataSize must be 4. If the ::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE query for the same address range
  14197. * returns ::CU_MEM_LOCATION_TYPE_DEVICE, it will be a valid device ordinal or if it returns ::CU_MEM_LOCATION_TYPE_HOST_NUMA, it will be a valid host NUMA node ID
  14198. * or if it returns any other location type, the id should be ignored.
  14199. * - ::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE: If this attribute is specified, \p data will be
  14200. * interpreted as a ::CUmemLocationType, and \p dataSize must be sizeof(CUmemLocationType). The result returned will be the last location
  14201. * to which all pages in the memory range were prefetched explicitly via ::cuMemPrefetchAsync. The ::CUmemLocationType returned
  14202. * will be ::CU_MEM_LOCATION_TYPE_DEVICE if the last prefetch location was a GPU or ::CU_MEM_LOCATION_TYPE_HOST if it was the CPU or ::CU_MEM_LOCATION_TYPE_HOST_NUMA if
  14203. * the last prefetch location was a specific host NUMA node. If any page in the memory range was never explicitly prefetched or if all pages were not
  14204. * prefetched to the same location, ::CUmemLocationType will be ::CU_MEM_LOCATION_TYPE_INVALID.
  14205. * Note that this simply returns the last location type that the application requested to prefetch the memory range to. It gives no indication as to
  14206. * whether the prefetch operation to that location has completed or even begun.
  14207. * - ::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_ID: If this attribute is specified, \p data will be
  14208. * interpreted as a 32-bit integer, and \p dataSize must be 4. If the ::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE query for the same address range
  14209. * returns ::CU_MEM_LOCATION_TYPE_DEVICE, it will be a valid device ordinal or if it returns ::CU_MEM_LOCATION_TYPE_HOST_NUMA, it will be a valid host NUMA node ID
  14210. * or if it returns any other location type, the id should be ignored.
  14211. *
  14212. * \param data - A pointers to a memory location where the result
  14213. * of each attribute query will be written to.
  14214. * \param dataSize - Array containing the size of data
  14215. * \param attribute - The attribute to query
  14216. * \param devPtr - Start of the range to query
  14217. * \param count - Size of the range to query
  14218. *
  14219. * \return
  14220. * ::CUDA_SUCCESS,
  14221. * ::CUDA_ERROR_INVALID_VALUE,
  14222. * ::CUDA_ERROR_INVALID_DEVICE
  14223. * \notefnerr
  14224. * \note_async
  14225. * \note_null_stream
  14226. *
  14227. * \sa ::cuMemRangeGetAttributes, ::cuMemPrefetchAsync,
  14228. * ::cuMemAdvise,
  14229. * ::cudaMemRangeGetAttribute
  14230. */
  14231. CUresult CUDAAPI cuMemRangeGetAttribute(void *data, size_t dataSize, CUmem_range_attribute attribute, CUdeviceptr devPtr, size_t count);
  14232. /**
  14233. * \brief Query attributes of a given memory range.
  14234. *
  14235. * Query attributes of the memory range starting at \p devPtr with a size of \p count bytes. The
  14236. * memory range must refer to managed memory allocated via ::cuMemAllocManaged or declared via
  14237. * __managed__ variables. The \p attributes array will be interpreted to have \p numAttributes
  14238. * entries. The \p dataSizes array will also be interpreted to have \p numAttributes entries.
  14239. * The results of the query will be stored in \p data.
  14240. *
  14241. * The list of supported attributes are given below. Please refer to ::cuMemRangeGetAttribute for
  14242. * attribute descriptions and restrictions.
  14243. *
  14244. * - ::CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY
  14245. * - ::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION
  14246. * - ::CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY
  14247. * - ::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION
  14248. * - ::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE
  14249. * - ::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_ID
  14250. * - ::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE
  14251. * - ::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_ID
  14252. *
  14253. * \param data - A two-dimensional array containing pointers to memory
  14254. * locations where the result of each attribute query will be written to.
  14255. * \param dataSizes - Array containing the sizes of each result
  14256. * \param attributes - An array of attributes to query
  14257. * (numAttributes and the number of attributes in this array should match)
  14258. * \param numAttributes - Number of attributes to query
  14259. * \param devPtr - Start of the range to query
  14260. * \param count - Size of the range to query
  14261. *
  14262. * \return
  14263. * ::CUDA_SUCCESS,
  14264. * ::CUDA_ERROR_DEINITIALIZED,
  14265. * ::CUDA_ERROR_INVALID_CONTEXT,
  14266. * ::CUDA_ERROR_INVALID_VALUE,
  14267. * ::CUDA_ERROR_INVALID_DEVICE
  14268. * \notefnerr
  14269. *
  14270. * \sa ::cuMemRangeGetAttribute, ::cuMemAdvise,
  14271. * ::cuMemPrefetchAsync,
  14272. * ::cudaMemRangeGetAttributes
  14273. */
  14274. CUresult CUDAAPI cuMemRangeGetAttributes(void **data, size_t *dataSizes, CUmem_range_attribute *attributes, size_t numAttributes, CUdeviceptr devPtr, size_t count);
  14275. /**
  14276. * \brief Set attributes on a previously allocated memory region
  14277. *
  14278. * The supported attributes are:
  14279. *
  14280. * - ::CU_POINTER_ATTRIBUTE_SYNC_MEMOPS:
  14281. *
  14282. * A boolean attribute that can either be set (1) or unset (0). When set,
  14283. * the region of memory that \p ptr points to is guaranteed to always synchronize
  14284. * memory operations that are synchronous. If there are some previously initiated
  14285. * synchronous memory operations that are pending when this attribute is set, the
  14286. * function does not return until those memory operations are complete.
  14287. * See further documentation in the section titled "API synchronization behavior"
  14288. * to learn more about cases when synchronous memory operations can
  14289. * exhibit asynchronous behavior.
  14290. * \p value will be considered as a pointer to an unsigned integer to which this attribute is to be set.
  14291. *
  14292. * \param value - Pointer to memory containing the value to be set
  14293. * \param attribute - Pointer attribute to set
  14294. * \param ptr - Pointer to a memory region allocated using CUDA memory allocation APIs
  14295. *
  14296. * \return
  14297. * ::CUDA_SUCCESS,
  14298. * ::CUDA_ERROR_DEINITIALIZED,
  14299. * ::CUDA_ERROR_NOT_INITIALIZED,
  14300. * ::CUDA_ERROR_INVALID_CONTEXT,
  14301. * ::CUDA_ERROR_INVALID_VALUE,
  14302. * ::CUDA_ERROR_INVALID_DEVICE
  14303. * \notefnerr
  14304. *
  14305. * \sa ::cuPointerGetAttribute,
  14306. * ::cuPointerGetAttributes,
  14307. * ::cuMemAlloc,
  14308. * ::cuMemFree,
  14309. * ::cuMemAllocHost,
  14310. * ::cuMemFreeHost,
  14311. * ::cuMemHostAlloc,
  14312. * ::cuMemHostRegister,
  14313. * ::cuMemHostUnregister
  14314. */
  14315. CUresult CUDAAPI cuPointerSetAttribute(const void *value, CUpointer_attribute attribute, CUdeviceptr ptr);
  14316. /**
  14317. * \brief Returns information about a pointer.
  14318. *
  14319. * The supported attributes are (refer to ::cuPointerGetAttribute for attribute descriptions and restrictions):
  14320. *
  14321. * - ::CU_POINTER_ATTRIBUTE_CONTEXT
  14322. * - ::CU_POINTER_ATTRIBUTE_MEMORY_TYPE
  14323. * - ::CU_POINTER_ATTRIBUTE_DEVICE_POINTER
  14324. * - ::CU_POINTER_ATTRIBUTE_HOST_POINTER
  14325. * - ::CU_POINTER_ATTRIBUTE_SYNC_MEMOPS
  14326. * - ::CU_POINTER_ATTRIBUTE_BUFFER_ID
  14327. * - ::CU_POINTER_ATTRIBUTE_IS_MANAGED
  14328. * - ::CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL
  14329. * - ::CU_POINTER_ATTRIBUTE_RANGE_START_ADDR
  14330. * - ::CU_POINTER_ATTRIBUTE_RANGE_SIZE
  14331. * - ::CU_POINTER_ATTRIBUTE_MAPPED
  14332. * - ::CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE
  14333. * - ::CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES
  14334. * - ::CU_POINTER_ATTRIBUTE_MEMPOOL_HANDLE
  14335. * - ::CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE
  14336. *
  14337. * \param numAttributes - Number of attributes to query
  14338. * \param attributes - An array of attributes to query
  14339. * (numAttributes and the number of attributes in this array should match)
  14340. * \param data - A two-dimensional array containing pointers to memory
  14341. * locations where the result of each attribute query will be written to.
  14342. * \param ptr - Pointer to query
  14343. *
  14344. * Unlike ::cuPointerGetAttribute, this function will not return an error when the \p ptr
  14345. * encountered is not a valid CUDA pointer. Instead, the attributes are assigned default NULL values
  14346. * and CUDA_SUCCESS is returned.
  14347. *
  14348. * If \p ptr was not allocated by, mapped by, or registered with a ::CUcontext which uses UVA
  14349. * (Unified Virtual Addressing), ::CUDA_ERROR_INVALID_CONTEXT is returned.
  14350. *
  14351. * \return
  14352. * ::CUDA_SUCCESS,
  14353. * ::CUDA_ERROR_DEINITIALIZED,
  14354. * ::CUDA_ERROR_INVALID_CONTEXT,
  14355. * ::CUDA_ERROR_INVALID_VALUE,
  14356. * ::CUDA_ERROR_INVALID_DEVICE
  14357. * \notefnerr
  14358. *
  14359. * \sa
  14360. * ::cuPointerGetAttribute,
  14361. * ::cuPointerSetAttribute,
  14362. * ::cudaPointerGetAttributes
  14363. */
  14364. CUresult CUDAAPI cuPointerGetAttributes(unsigned int numAttributes, CUpointer_attribute *attributes, void **data, CUdeviceptr ptr);
  14365. /** @} */ /* END CUDA_UNIFIED */
  14366. /**
  14367. * \defgroup CUDA_STREAM Stream Management
  14368. *
  14369. * ___MANBRIEF___ stream management functions of the low-level CUDA driver API
  14370. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  14371. *
  14372. * This section describes the stream management functions of the low-level CUDA
  14373. * driver application programming interface.
  14374. *
  14375. * @{
  14376. */
  14377. /**
  14378. * \brief Create a stream
  14379. *
  14380. * Creates a stream and returns a handle in \p phStream. The \p Flags argument
  14381. * determines behaviors of the stream.
  14382. *
  14383. * Valid values for \p Flags are:
  14384. * - ::CU_STREAM_DEFAULT: Default stream creation flag.
  14385. * - ::CU_STREAM_NON_BLOCKING: Specifies that work running in the created
  14386. * stream may run concurrently with work in stream 0 (the NULL stream), and that
  14387. * the created stream should perform no implicit synchronization with stream 0.
  14388. *
  14389. * \param phStream - Returned newly created stream
  14390. * \param Flags - Parameters for stream creation
  14391. *
  14392. * \return
  14393. * ::CUDA_SUCCESS,
  14394. * ::CUDA_ERROR_DEINITIALIZED,
  14395. * ::CUDA_ERROR_NOT_INITIALIZED,
  14396. * ::CUDA_ERROR_INVALID_CONTEXT,
  14397. * ::CUDA_ERROR_INVALID_VALUE,
  14398. * ::CUDA_ERROR_OUT_OF_MEMORY
  14399. * \notefnerr
  14400. *
  14401. * \sa ::cuStreamDestroy,
  14402. * ::cuStreamCreateWithPriority,
  14403. * ::cuGreenCtxStreamCreate,
  14404. * ::cuStreamGetPriority,
  14405. * ::cuStreamGetFlags,
  14406. * ::cuStreamGetDevice
  14407. * ::cuStreamWaitEvent,
  14408. * ::cuStreamQuery,
  14409. * ::cuStreamSynchronize,
  14410. * ::cuStreamAddCallback,
  14411. * ::cudaStreamCreate,
  14412. * ::cudaStreamCreateWithFlags
  14413. */
  14414. CUresult CUDAAPI cuStreamCreate(CUstream *phStream, unsigned int Flags);
  14415. /**
  14416. * \brief Create a stream with the given priority
  14417. *
  14418. * Creates a stream with the specified priority and returns a handle in \p phStream.
  14419. * This affects the scheduling priority of work in the stream. Priorities provide a
  14420. * hint to preferentially run work with higher priority when possible, but do
  14421. * not preempt already-running work or provide any other functional guarantee on
  14422. * execution order.
  14423. *
  14424. * \p priority follows a convention where lower numbers represent higher priorities.
  14425. * '0' represents default priority. The range of meaningful numerical priorities can
  14426. * be queried using ::cuCtxGetStreamPriorityRange. If the specified priority is
  14427. * outside the numerical range returned by ::cuCtxGetStreamPriorityRange,
  14428. * it will automatically be clamped to the lowest or the highest number in the range.
  14429. *
  14430. * \param phStream - Returned newly created stream
  14431. * \param flags - Flags for stream creation. See ::cuStreamCreate for a list of
  14432. * valid flags
  14433. * \param priority - Stream priority. Lower numbers represent higher priorities.
  14434. * See ::cuCtxGetStreamPriorityRange for more information about
  14435. * meaningful stream priorities that can be passed.
  14436. *
  14437. * \return
  14438. * ::CUDA_SUCCESS,
  14439. * ::CUDA_ERROR_DEINITIALIZED,
  14440. * ::CUDA_ERROR_NOT_INITIALIZED,
  14441. * ::CUDA_ERROR_INVALID_CONTEXT,
  14442. * ::CUDA_ERROR_INVALID_VALUE,
  14443. * ::CUDA_ERROR_OUT_OF_MEMORY
  14444. * \notefnerr
  14445. *
  14446. * \note Stream priorities are supported only on GPUs
  14447. * with compute capability 3.5 or higher.
  14448. *
  14449. * \note In the current implementation, only compute kernels launched in
  14450. * priority streams are affected by the stream's priority. Stream priorities have
  14451. * no effect on host-to-device and device-to-host memory operations.
  14452. *
  14453. * \sa ::cuStreamDestroy,
  14454. * ::cuStreamCreate,
  14455. * ::cuGreenCtxStreamCreate,
  14456. * ::cuStreamGetPriority,
  14457. * ::cuCtxGetStreamPriorityRange,
  14458. * ::cuStreamGetFlags,
  14459. * ::cuStreamGetDevice
  14460. * ::cuStreamWaitEvent,
  14461. * ::cuStreamQuery,
  14462. * ::cuStreamSynchronize,
  14463. * ::cuStreamAddCallback,
  14464. * ::cudaStreamCreateWithPriority
  14465. */
  14466. CUresult CUDAAPI cuStreamCreateWithPriority(CUstream *phStream, unsigned int flags, int priority);
  14467. /**
  14468. * \brief Query the priority of a given stream
  14469. *
  14470. * Query the priority of a stream created using ::cuStreamCreate, ::cuStreamCreateWithPriority or ::cuGreenCtxStreamCreate
  14471. * and return the priority in \p priority. Note that if the stream was created with a
  14472. * priority outside the numerical range returned by ::cuCtxGetStreamPriorityRange,
  14473. * this function returns the clamped priority.
  14474. * See ::cuStreamCreateWithPriority for details about priority clamping.
  14475. *
  14476. * \param hStream - Handle to the stream to be queried
  14477. * \param priority - Pointer to a signed integer in which the stream's priority is returned
  14478. * \return
  14479. * ::CUDA_SUCCESS,
  14480. * ::CUDA_ERROR_DEINITIALIZED,
  14481. * ::CUDA_ERROR_NOT_INITIALIZED,
  14482. * ::CUDA_ERROR_INVALID_CONTEXT,
  14483. * ::CUDA_ERROR_INVALID_VALUE,
  14484. * ::CUDA_ERROR_INVALID_HANDLE,
  14485. * ::CUDA_ERROR_OUT_OF_MEMORY
  14486. * \notefnerr
  14487. *
  14488. * \sa ::cuStreamDestroy,
  14489. * ::cuStreamCreate,
  14490. * ::cuStreamCreateWithPriority,
  14491. * ::cuGreenCtxStreamCreate,
  14492. * ::cuCtxGetStreamPriorityRange,
  14493. * ::cuStreamGetFlags,
  14494. * ::cuStreamGetDevice
  14495. * ::cudaStreamGetPriority
  14496. */
  14497. CUresult CUDAAPI cuStreamGetPriority(CUstream hStream, int *priority);
  14498. /**
  14499. * \brief Returns the device handle of the stream
  14500. *
  14501. * Returns in \p *device the device handle of the stream
  14502. *
  14503. * \param hStream - Handle to the stream to be queried
  14504. * \param device - Returns the device to which a stream belongs
  14505. *
  14506. * \return
  14507. * ::CUDA_SUCCESS,
  14508. * ::CUDA_ERROR_DEINITIALIZED,
  14509. * ::CUDA_ERROR_NOT_INITIALIZED,
  14510. * ::CUDA_ERROR_INVALID_CONTEXT,
  14511. * ::CUDA_ERROR_INVALID_VALUE,
  14512. * ::CUDA_ERROR_INVALID_HANDLE,
  14513. * ::CUDA_ERROR_OUT_OF_MEMORY
  14514. * \notefnerr
  14515. *
  14516. * \sa
  14517. * ::cuStreamDestroy,
  14518. * ::cuStreamCreate,
  14519. * ::cuGreenCtxStreamCreate,
  14520. * ::cuStreamGetFlags
  14521. */
  14522. CUresult CUDAAPI cuStreamGetDevice(CUstream hStream, CUdevice *device);
  14523. /**
  14524. * \brief Query the flags of a given stream
  14525. *
  14526. * Query the flags of a stream created using ::cuStreamCreate, ::cuStreamCreateWithPriority or ::cuGreenCtxStreamCreate
  14527. * and return the flags in \p flags.
  14528. *
  14529. * \param hStream - Handle to the stream to be queried
  14530. * \param flags - Pointer to an unsigned integer in which the stream's flags are returned
  14531. * The value returned in \p flags is a logical 'OR' of all flags that
  14532. * were used while creating this stream. See ::cuStreamCreate for the list
  14533. * of valid flags
  14534. * \return
  14535. * ::CUDA_SUCCESS,
  14536. * ::CUDA_ERROR_DEINITIALIZED,
  14537. * ::CUDA_ERROR_NOT_INITIALIZED,
  14538. * ::CUDA_ERROR_INVALID_CONTEXT,
  14539. * ::CUDA_ERROR_INVALID_VALUE,
  14540. * ::CUDA_ERROR_INVALID_HANDLE,
  14541. * ::CUDA_ERROR_OUT_OF_MEMORY
  14542. * \notefnerr
  14543. *
  14544. * \sa ::cuStreamDestroy,
  14545. * ::cuStreamCreate,
  14546. * ::cuGreenCtxStreamCreate,
  14547. * ::cuStreamGetPriority,
  14548. * ::cudaStreamGetFlags
  14549. * ::cuStreamGetDevice
  14550. */
  14551. CUresult CUDAAPI cuStreamGetFlags(CUstream hStream, unsigned int *flags);
  14552. /**
  14553. * \brief Returns the unique Id associated with the stream handle supplied
  14554. *
  14555. * Returns in \p streamId the unique Id which is associated with the given stream handle.
  14556. * The Id is unique for the life of the program.
  14557. *
  14558. * The stream handle \p hStream can refer to any of the following:
  14559. * <ul>
  14560. * <li>a stream created via any of the CUDA driver APIs such as ::cuStreamCreate
  14561. * and ::cuStreamCreateWithPriority, or their runtime API equivalents such as
  14562. * ::cudaStreamCreate, ::cudaStreamCreateWithFlags and ::cudaStreamCreateWithPriority.
  14563. * Passing an invalid handle will result in undefined behavior.</li>
  14564. * <li>any of the special streams such as the NULL stream, ::CU_STREAM_LEGACY and
  14565. * ::CU_STREAM_PER_THREAD. The runtime API equivalents of these are also accepted,
  14566. * which are NULL, ::cudaStreamLegacy and ::cudaStreamPerThread respectively.</li>
  14567. * </ul>
  14568. *
  14569. * \param hStream - Handle to the stream to be queried
  14570. * \param streamId - Pointer to store the Id of the stream
  14571. *
  14572. * \return
  14573. * ::CUDA_SUCCESS,
  14574. * ::CUDA_ERROR_INVALID_VALUE,
  14575. * ::CUDA_ERROR_INVALID_HANDLE
  14576. * \notefnerr
  14577. *
  14578. * \sa ::cuStreamDestroy,
  14579. * ::cuStreamCreate,
  14580. * ::cuStreamGetPriority,
  14581. * ::cudaStreamGetId
  14582. */
  14583. CUresult CUDAAPI cuStreamGetId(CUstream hStream, unsigned long long *streamId);
  14584. /**
  14585. * \brief Query the context associated with a stream
  14586. *
  14587. * Returns the CUDA context that the stream is associated with.
  14588. *
  14589. * Note there is a later version of this API, ::cuStreamGetCtx_v2. It will
  14590. * supplant this version in CUDA 13.0. It is recommended to use ::cuStreamGetCtx_v2
  14591. * till then as this version will return ::CUDA_ERROR_NOT_SUPPORTED for streams created via the API ::cuGreenCtxStreamCreate.
  14592. *
  14593. * The stream handle \p hStream can refer to any of the following:
  14594. * <ul>
  14595. * <li>a stream created via any of the CUDA driver APIs such as ::cuStreamCreate
  14596. * and ::cuStreamCreateWithPriority, or their runtime API equivalents such as
  14597. * ::cudaStreamCreate, ::cudaStreamCreateWithFlags and ::cudaStreamCreateWithPriority.
  14598. * The returned context is the context that was active in the calling thread when the
  14599. * stream was created. Passing an invalid handle will result in undefined behavior.</li>
  14600. * <li>any of the special streams such as the NULL stream, ::CU_STREAM_LEGACY and
  14601. * ::CU_STREAM_PER_THREAD. The runtime API equivalents of these are also accepted,
  14602. * which are NULL, ::cudaStreamLegacy and ::cudaStreamPerThread respectively.
  14603. * Specifying any of the special handles will return the context current to the
  14604. * calling thread. If no context is current to the calling thread,
  14605. * ::CUDA_ERROR_INVALID_CONTEXT is returned.</li>
  14606. * </ul>
  14607. *
  14608. * \param hStream - Handle to the stream to be queried
  14609. * \param pctx - Returned context associated with the stream
  14610. *
  14611. * \return
  14612. * ::CUDA_SUCCESS,
  14613. * ::CUDA_ERROR_DEINITIALIZED,
  14614. * ::CUDA_ERROR_NOT_INITIALIZED,
  14615. * ::CUDA_ERROR_INVALID_CONTEXT,
  14616. * ::CUDA_ERROR_INVALID_HANDLE,
  14617. * ::CUDA_ERROR_NOT_SUPPORTED
  14618. * \notefnerr
  14619. *
  14620. * \sa ::cuStreamDestroy,
  14621. * ::cuStreamCreateWithPriority,
  14622. * ::cuStreamGetPriority,
  14623. * ::cuStreamGetFlags,
  14624. * ::cuStreamGetDevice
  14625. * ::cuStreamWaitEvent,
  14626. * ::cuStreamQuery,
  14627. * ::cuStreamSynchronize,
  14628. * ::cuStreamAddCallback,
  14629. * ::cudaStreamCreate,
  14630. * ::cuStreamGetCtx_v2,
  14631. * ::cudaStreamCreateWithFlags
  14632. */
  14633. CUresult CUDAAPI cuStreamGetCtx(CUstream hStream, CUcontext *pctx);
  14634. /**
  14635. * \brief Query the contexts associated with a stream
  14636. *
  14637. * Returns the contexts that the stream is associated with.
  14638. *
  14639. * If the stream is associated with a green context, the API returns the green context in \p pGreenCtx
  14640. * and the primary context of the associated device in \p pCtx.
  14641. *
  14642. * If the stream is associated with a regular context, the API returns the regular context in \p pCtx
  14643. * and NULL in \p pGreenCtx.
  14644. *
  14645. * The stream handle \p hStream can refer to any of the following:
  14646. * <ul>
  14647. * <li>a stream created via any of the CUDA driver APIs such as ::cuStreamCreate,
  14648. * ::cuStreamCreateWithPriority and ::cuGreenCtxStreamCreate, or their runtime API equivalents such as
  14649. * ::cudaStreamCreate, ::cudaStreamCreateWithFlags and ::cudaStreamCreateWithPriority.
  14650. * Passing an invalid handle will result in undefined behavior.</li>
  14651. * <li>any of the special streams such as the NULL stream, ::CU_STREAM_LEGACY and
  14652. * ::CU_STREAM_PER_THREAD. The runtime API equivalents of these are also accepted,
  14653. * which are NULL, ::cudaStreamLegacy and ::cudaStreamPerThread respectively.
  14654. * If any of the special handles are specified, the API will operate on the context current to the
  14655. * calling thread. If a green context (that was converted via ::cuCtxFromGreenCtx() before setting it current)
  14656. * is current to the calling thread, the API will return the green context in \p pGreenCtx
  14657. * and the primary context of the associated device in \p pCtx. If a regular context is current,
  14658. * the API returns the regular context in \p pCtx and NULL in \p pGreenCtx.
  14659. * Note that specifying ::CU_STREAM_PER_THREAD or ::cudaStreamPerThread will return ::CUDA_ERROR_INVALID_HANDLE
  14660. * if a green context is current to the calling thread.
  14661. * If no context is current to the calling thread, ::CUDA_ERROR_INVALID_CONTEXT is returned.</li>
  14662. * </ul>
  14663. *
  14664. * \param hStream - Handle to the stream to be queried
  14665. * \param pCtx - Returned regular context associated with the stream
  14666. * \param pGreenCtx - Returned green context if the stream is associated with a green context or NULL if not
  14667. *
  14668. * \return
  14669. * ::CUDA_SUCCESS,
  14670. * ::CUDA_ERROR_DEINITIALIZED,
  14671. * ::CUDA_ERROR_NOT_INITIALIZED,
  14672. * ::CUDA_ERROR_INVALID_CONTEXT,
  14673. * ::CUDA_ERROR_INVALID_HANDLE
  14674. * \notefnerr
  14675. *
  14676. * \sa ::cuStreamDestroy,
  14677. * ::cuStreamCreate
  14678. * ::cuStreamCreateWithPriority,
  14679. * ::cuGreenCtxStreamCreate,
  14680. * ::cuStreamGetPriority,
  14681. * ::cuStreamGetFlags,
  14682. * ::cuStreamGetDevice
  14683. * ::cuStreamWaitEvent,
  14684. * ::cuStreamQuery,
  14685. * ::cuStreamSynchronize,
  14686. * ::cuStreamAddCallback,
  14687. * ::cudaStreamCreate,
  14688. * ::cudaStreamCreateWithFlags,
  14689. */
  14690. CUresult CUDAAPI cuStreamGetCtx_v2(CUstream hStream, CUcontext *pCtx, CUgreenCtx *pGreenCtx);
  14691. /**
  14692. * \brief Make a compute stream wait on an event
  14693. *
  14694. * Makes all future work submitted to \p hStream wait for all work captured in
  14695. * \p hEvent. See ::cuEventRecord() for details on what is captured by an event.
  14696. * The synchronization will be performed efficiently on the device when applicable.
  14697. * \p hEvent may be from a different context or device than \p hStream.
  14698. *
  14699. * flags include:
  14700. * - ::CU_EVENT_WAIT_DEFAULT: Default event creation flag.
  14701. * - ::CU_EVENT_WAIT_EXTERNAL: Event is captured in the graph as an external
  14702. * event node when performing stream capture. This flag is invalid outside
  14703. * of stream capture.
  14704. *
  14705. * \param hStream - Stream to wait
  14706. * \param hEvent - Event to wait on (may not be NULL)
  14707. * \param Flags - See ::CUevent_capture_flags
  14708. *
  14709. * \return
  14710. * ::CUDA_SUCCESS,
  14711. * ::CUDA_ERROR_DEINITIALIZED,
  14712. * ::CUDA_ERROR_NOT_INITIALIZED,
  14713. * ::CUDA_ERROR_INVALID_CONTEXT,
  14714. * ::CUDA_ERROR_INVALID_HANDLE,
  14715. * \note_null_stream
  14716. * \notefnerr
  14717. *
  14718. * \sa ::cuStreamCreate,
  14719. * ::cuEventRecord,
  14720. * ::cuStreamQuery,
  14721. * ::cuStreamSynchronize,
  14722. * ::cuStreamAddCallback,
  14723. * ::cuStreamDestroy,
  14724. * ::cudaStreamWaitEvent
  14725. */
  14726. CUresult CUDAAPI cuStreamWaitEvent(CUstream hStream, CUevent hEvent, unsigned int Flags);
  14727. /**
  14728. * \brief Add a callback to a compute stream
  14729. *
  14730. * \note This function is slated for eventual deprecation and removal. If
  14731. * you do not require the callback to execute in case of a device error,
  14732. * consider using ::cuLaunchHostFunc. Additionally, this function is not
  14733. * supported with ::cuStreamBeginCapture and ::cuStreamEndCapture, unlike
  14734. * ::cuLaunchHostFunc.
  14735. *
  14736. * Adds a callback to be called on the host after all currently enqueued
  14737. * items in the stream have completed. For each
  14738. * cuStreamAddCallback call, the callback will be executed exactly once.
  14739. * The callback will block later work in the stream until it is finished.
  14740. *
  14741. * The callback may be passed ::CUDA_SUCCESS or an error code. In the event
  14742. * of a device error, all subsequently executed callbacks will receive an
  14743. * appropriate ::CUresult.
  14744. *
  14745. * Callbacks must not make any CUDA API calls. Attempting to use a CUDA API
  14746. * will result in ::CUDA_ERROR_NOT_PERMITTED. Callbacks must not perform any
  14747. * synchronization that may depend on outstanding device work or other callbacks
  14748. * that are not mandated to run earlier. Callbacks without a mandated order
  14749. * (in independent streams) execute in undefined order and may be serialized.
  14750. *
  14751. * For the purposes of Unified Memory, callback execution makes a number of
  14752. * guarantees:
  14753. * <ul>
  14754. * <li>The callback stream is considered idle for the duration of the
  14755. * callback. Thus, for example, a callback may always use memory attached
  14756. * to the callback stream.</li>
  14757. * <li>The start of execution of a callback has the same effect as
  14758. * synchronizing an event recorded in the same stream immediately prior to
  14759. * the callback. It thus synchronizes streams which have been "joined"
  14760. * prior to the callback.</li>
  14761. * <li>Adding device work to any stream does not have the effect of making
  14762. * the stream active until all preceding host functions and stream callbacks
  14763. * have executed. Thus, for
  14764. * example, a callback might use global attached memory even if work has
  14765. * been added to another stream, if the work has been ordered behind the
  14766. * callback with an event.</li>
  14767. * <li>Completion of a callback does not cause a stream to become
  14768. * active except as described above. The callback stream will remain idle
  14769. * if no device work follows the callback, and will remain idle across
  14770. * consecutive callbacks without device work in between. Thus, for example,
  14771. * stream synchronization can be done by signaling from a callback at the
  14772. * end of the stream.</li>
  14773. * </ul>
  14774. *
  14775. * \param hStream - Stream to add callback to
  14776. * \param callback - The function to call once preceding stream operations are complete
  14777. * \param userData - User specified data to be passed to the callback function
  14778. * \param flags - Reserved for future use, must be 0
  14779. *
  14780. * \return
  14781. * ::CUDA_SUCCESS,
  14782. * ::CUDA_ERROR_DEINITIALIZED,
  14783. * ::CUDA_ERROR_NOT_INITIALIZED,
  14784. * ::CUDA_ERROR_INVALID_CONTEXT,
  14785. * ::CUDA_ERROR_INVALID_HANDLE,
  14786. * ::CUDA_ERROR_NOT_SUPPORTED
  14787. * \note_null_stream
  14788. * \notefnerr
  14789. *
  14790. * \sa ::cuStreamCreate,
  14791. * ::cuStreamQuery,
  14792. * ::cuStreamSynchronize,
  14793. * ::cuStreamWaitEvent,
  14794. * ::cuStreamDestroy,
  14795. * ::cuMemAllocManaged,
  14796. * ::cuStreamAttachMemAsync,
  14797. * ::cuLaunchHostFunc,
  14798. * ::cudaStreamAddCallback
  14799. */
  14800. CUresult CUDAAPI cuStreamAddCallback(CUstream hStream, CUstreamCallback callback, void *userData, unsigned int flags);
  14801. /**
  14802. * \brief Begins graph capture on a stream
  14803. *
  14804. * Begin graph capture on \p hStream. When a stream is in capture mode, all operations
  14805. * pushed into the stream will not be executed, but will instead be captured into
  14806. * a graph, which will be returned via ::cuStreamEndCapture. Capture may not be initiated
  14807. * if \p stream is CU_STREAM_LEGACY. Capture must be ended on the same stream in which
  14808. * it was initiated, and it may only be initiated if the stream is not already in capture
  14809. * mode. The capture mode may be queried via ::cuStreamIsCapturing. A unique id
  14810. * representing the capture sequence may be queried via ::cuStreamGetCaptureInfo.
  14811. *
  14812. * If \p mode is not ::CU_STREAM_CAPTURE_MODE_RELAXED, ::cuStreamEndCapture must be
  14813. * called on this stream from the same thread.
  14814. *
  14815. * \param hStream - Stream in which to initiate capture
  14816. * \param mode - Controls the interaction of this capture sequence with other API
  14817. * calls that are potentially unsafe. For more details see
  14818. * ::cuThreadExchangeStreamCaptureMode.
  14819. *
  14820. * \note Kernels captured using this API must not use texture and surface references.
  14821. * Reading or writing through any texture or surface reference is undefined
  14822. * behavior. This restriction does not apply to texture and surface objects.
  14823. *
  14824. * \return
  14825. * ::CUDA_SUCCESS,
  14826. * ::CUDA_ERROR_DEINITIALIZED,
  14827. * ::CUDA_ERROR_NOT_INITIALIZED,
  14828. * ::CUDA_ERROR_INVALID_VALUE
  14829. * \notefnerr
  14830. *
  14831. * \sa
  14832. * ::cuStreamCreate,
  14833. * ::cuStreamIsCapturing,
  14834. * ::cuStreamEndCapture,
  14835. * ::cuThreadExchangeStreamCaptureMode
  14836. */
  14837. CUresult CUDAAPI cuStreamBeginCapture(CUstream hStream, CUstreamCaptureMode mode);
  14838. /**
  14839. * \brief Begins graph capture on a stream to an existing graph
  14840. *
  14841. * Begin graph capture on \p hStream, placing new nodes into an existing graph. When a stream is
  14842. * in capture mode, all operations pushed into the stream will not be executed, but will instead
  14843. * be captured into \p hGraph. The graph will not be instantiable until the user calls
  14844. * ::cuStreamEndCapture.
  14845. *
  14846. * Capture may not be initiated if \p stream is CU_STREAM_LEGACY. Capture must be ended on the
  14847. * same stream in which it was initiated, and it may only be initiated if the stream is not
  14848. * already in capture mode. The capture mode may be queried via ::cuStreamIsCapturing. A unique id
  14849. * representing the capture sequence may be queried via ::cuStreamGetCaptureInfo.
  14850. *
  14851. * If \p mode is not ::CU_STREAM_CAPTURE_MODE_RELAXED, ::cuStreamEndCapture must be
  14852. * called on this stream from the same thread.
  14853. *
  14854. * \param hStream - Stream in which to initiate capture.
  14855. * \param hGraph - Graph to capture into.
  14856. * \param dependencies - Dependencies of the first node captured in the stream. Can be NULL if numDependencies is 0.
  14857. * \param dependencyData - Optional array of data associated with each dependency.
  14858. * \param numDependencies - Number of dependencies.
  14859. * \param mode - Controls the interaction of this capture sequence with other API
  14860. * calls that are potentially unsafe. For more details see
  14861. * ::cuThreadExchangeStreamCaptureMode.
  14862. *
  14863. * \note Kernels captured using this API must not use texture and surface references.
  14864. * Reading or writing through any texture or surface reference is undefined
  14865. * behavior. This restriction does not apply to texture and surface objects.
  14866. *
  14867. * \return
  14868. * ::CUDA_SUCCESS,
  14869. * ::CUDA_ERROR_DEINITIALIZED,
  14870. * ::CUDA_ERROR_NOT_INITIALIZED,
  14871. * ::CUDA_ERROR_INVALID_VALUE
  14872. * \notefnerr
  14873. *
  14874. * \sa
  14875. * ::cuStreamBeginCapture,
  14876. * ::cuStreamCreate,
  14877. * ::cuStreamIsCapturing,
  14878. * ::cuStreamEndCapture,
  14879. * ::cuThreadExchangeStreamCaptureMode,
  14880. * ::cuGraphAddNode,
  14881. */
  14882. CUresult CUDAAPI cuStreamBeginCaptureToGraph(CUstream hStream, CUgraph hGraph, const CUgraphNode *dependencies, const CUgraphEdgeData *dependencyData, size_t numDependencies, CUstreamCaptureMode mode);
  14883. /**
  14884. * \brief Swaps the stream capture interaction mode for a thread
  14885. *
  14886. * Sets the calling thread's stream capture interaction mode to the value contained
  14887. * in \p *mode, and overwrites \p *mode with the previous mode for the thread. To
  14888. * facilitate deterministic behavior across function or module boundaries, callers
  14889. * are encouraged to use this API in a push-pop fashion: \code
  14890. CUstreamCaptureMode mode = desiredMode;
  14891. cuThreadExchangeStreamCaptureMode(&mode);
  14892. ...
  14893. cuThreadExchangeStreamCaptureMode(&mode); // restore previous mode
  14894. * \endcode
  14895. *
  14896. * During stream capture (see ::cuStreamBeginCapture), some actions, such as a call
  14897. * to ::cudaMalloc, may be unsafe. In the case of ::cudaMalloc, the operation is
  14898. * not enqueued asynchronously to a stream, and is not observed by stream capture.
  14899. * Therefore, if the sequence of operations captured via ::cuStreamBeginCapture
  14900. * depended on the allocation being replayed whenever the graph is launched, the
  14901. * captured graph would be invalid.
  14902. *
  14903. * Therefore, stream capture places restrictions on API calls that can be made within
  14904. * or concurrently to a ::cuStreamBeginCapture-::cuStreamEndCapture sequence. This
  14905. * behavior can be controlled via this API and flags to ::cuStreamBeginCapture.
  14906. *
  14907. * A thread's mode is one of the following:
  14908. * - \p CU_STREAM_CAPTURE_MODE_GLOBAL: This is the default mode. If the local thread has
  14909. * an ongoing capture sequence that was not initiated with
  14910. * \p CU_STREAM_CAPTURE_MODE_RELAXED at \p cuStreamBeginCapture, or if any other thread
  14911. * has a concurrent capture sequence initiated with \p CU_STREAM_CAPTURE_MODE_GLOBAL,
  14912. * this thread is prohibited from potentially unsafe API calls.
  14913. * - \p CU_STREAM_CAPTURE_MODE_THREAD_LOCAL: If the local thread has an ongoing capture
  14914. * sequence not initiated with \p CU_STREAM_CAPTURE_MODE_RELAXED, it is prohibited
  14915. * from potentially unsafe API calls. Concurrent capture sequences in other threads
  14916. * are ignored.
  14917. * - \p CU_STREAM_CAPTURE_MODE_RELAXED: The local thread is not prohibited from potentially
  14918. * unsafe API calls. Note that the thread is still prohibited from API calls which
  14919. * necessarily conflict with stream capture, for example, attempting ::cuEventQuery
  14920. * on an event that was last recorded inside a capture sequence.
  14921. *
  14922. * \param mode - Pointer to mode value to swap with the current mode
  14923. *
  14924. * \return
  14925. * ::CUDA_SUCCESS,
  14926. * ::CUDA_ERROR_DEINITIALIZED,
  14927. * ::CUDA_ERROR_NOT_INITIALIZED,
  14928. * ::CUDA_ERROR_INVALID_VALUE
  14929. * \notefnerr
  14930. *
  14931. * \sa
  14932. * ::cuStreamBeginCapture
  14933. */
  14934. CUresult CUDAAPI cuThreadExchangeStreamCaptureMode(CUstreamCaptureMode *mode);
  14935. /**
  14936. * \brief Ends capture on a stream, returning the captured graph
  14937. *
  14938. * End capture on \p hStream, returning the captured graph via \p phGraph.
  14939. * Capture must have been initiated on \p hStream via a call to ::cuStreamBeginCapture.
  14940. * If capture was invalidated, due to a violation of the rules of stream capture, then
  14941. * a NULL graph will be returned.
  14942. *
  14943. * If the \p mode argument to ::cuStreamBeginCapture was not
  14944. * ::CU_STREAM_CAPTURE_MODE_RELAXED, this call must be from the same thread as
  14945. * ::cuStreamBeginCapture.
  14946. *
  14947. * \param hStream - Stream to query
  14948. * \param phGraph - The captured graph
  14949. *
  14950. * \return
  14951. * ::CUDA_SUCCESS,
  14952. * ::CUDA_ERROR_DEINITIALIZED,
  14953. * ::CUDA_ERROR_NOT_INITIALIZED,
  14954. * ::CUDA_ERROR_INVALID_VALUE,
  14955. * ::CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD
  14956. * \notefnerr
  14957. *
  14958. * \sa
  14959. * ::cuStreamCreate,
  14960. * ::cuStreamBeginCapture,
  14961. * ::cuStreamIsCapturing,
  14962. * ::cuGraphDestroy
  14963. */
  14964. CUresult CUDAAPI cuStreamEndCapture(CUstream hStream, CUgraph *phGraph);
  14965. /**
  14966. * \brief Returns a stream's capture status
  14967. *
  14968. * Return the capture status of \p hStream via \p captureStatus. After a successful
  14969. * call, \p *captureStatus will contain one of the following:
  14970. * - ::CU_STREAM_CAPTURE_STATUS_NONE: The stream is not capturing.
  14971. * - ::CU_STREAM_CAPTURE_STATUS_ACTIVE: The stream is capturing.
  14972. * - ::CU_STREAM_CAPTURE_STATUS_INVALIDATED: The stream was capturing but an error
  14973. * has invalidated the capture sequence. The capture sequence must be terminated
  14974. * with ::cuStreamEndCapture on the stream where it was initiated in order to
  14975. * continue using \p hStream.
  14976. *
  14977. * Note that, if this is called on ::CU_STREAM_LEGACY (the "null stream") while
  14978. * a blocking stream in the same context is capturing, it will return
  14979. * ::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT and \p *captureStatus is unspecified
  14980. * after the call. The blocking stream capture is not invalidated.
  14981. *
  14982. * When a blocking stream is capturing, the legacy stream is in an
  14983. * unusable state until the blocking stream capture is terminated. The legacy
  14984. * stream is not supported for stream capture, but attempted use would have an
  14985. * implicit dependency on the capturing stream(s).
  14986. *
  14987. * \param hStream - Stream to query
  14988. * \param captureStatus - Returns the stream's capture status
  14989. *
  14990. * \return
  14991. * ::CUDA_SUCCESS,
  14992. * ::CUDA_ERROR_DEINITIALIZED,
  14993. * ::CUDA_ERROR_NOT_INITIALIZED,
  14994. * ::CUDA_ERROR_INVALID_VALUE,
  14995. * ::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT
  14996. * \notefnerr
  14997. *
  14998. * \sa
  14999. * ::cuStreamCreate,
  15000. * ::cuStreamBeginCapture,
  15001. * ::cuStreamEndCapture
  15002. */
  15003. CUresult CUDAAPI cuStreamIsCapturing(CUstream hStream, CUstreamCaptureStatus *captureStatus);
  15004. /**
  15005. * \brief Query a stream's capture state
  15006. *
  15007. * Query stream state related to stream capture.
  15008. *
  15009. * If called on ::CU_STREAM_LEGACY (the "null stream") while a stream not created
  15010. * with ::CU_STREAM_NON_BLOCKING is capturing, returns ::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT.
  15011. *
  15012. * Valid data (other than capture status) is returned only if both of the following are true:
  15013. * - the call returns CUDA_SUCCESS
  15014. * - the returned capture status is ::CU_STREAM_CAPTURE_STATUS_ACTIVE
  15015. *
  15016. * \param hStream - The stream to query
  15017. * \param captureStatus_out - Location to return the capture status of the stream; required
  15018. * \param id_out - Optional location to return an id for the capture sequence, which is
  15019. * unique over the lifetime of the process
  15020. * \param graph_out - Optional location to return the graph being captured into. All
  15021. * operations other than destroy and node removal are permitted on the graph
  15022. * while the capture sequence is in progress. This API does not transfer
  15023. * ownership of the graph, which is transferred or destroyed at
  15024. * ::cuStreamEndCapture. Note that the graph handle may be invalidated before
  15025. * end of capture for certain errors. Nodes that are or become
  15026. * unreachable from the original stream at ::cuStreamEndCapture due to direct
  15027. * actions on the graph do not trigger ::CUDA_ERROR_STREAM_CAPTURE_UNJOINED.
  15028. * \param dependencies_out - Optional location to store a pointer to an array of nodes.
  15029. * The next node to be captured in the stream will depend on this set of nodes,
  15030. * absent operations such as event wait which modify this set. The array pointer
  15031. * is valid until the next API call which operates on the stream or until the
  15032. * capture is terminated. The node handles may be copied out and are valid until
  15033. * they or the graph is destroyed. The driver-owned array may also be passed
  15034. * directly to APIs that operate on the graph (not the stream) without copying.
  15035. * \param numDependencies_out - Optional location to store the size of the array
  15036. * returned in dependencies_out.
  15037. *
  15038. * \return
  15039. * ::CUDA_SUCCESS,
  15040. * ::CUDA_ERROR_INVALID_VALUE,
  15041. * ::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT
  15042. * \note_graph_thread_safety
  15043. * \notefnerr
  15044. *
  15045. * \sa
  15046. * ::cuStreamGetCaptureInfo_v3
  15047. * ::cuStreamBeginCapture,
  15048. * ::cuStreamIsCapturing,
  15049. * ::cuStreamUpdateCaptureDependencies
  15050. */
  15051. CUresult CUDAAPI cuStreamGetCaptureInfo(CUstream hStream, CUstreamCaptureStatus *captureStatus_out,
  15052. cuuint64_t *id_out, CUgraph *graph_out, const CUgraphNode **dependencies_out, size_t *numDependencies_out);
  15053. /**
  15054. * \brief Query a stream's capture state (12.3+)
  15055. *
  15056. * Query stream state related to stream capture.
  15057. *
  15058. * If called on ::CU_STREAM_LEGACY (the "null stream") while a stream not created
  15059. * with ::CU_STREAM_NON_BLOCKING is capturing, returns ::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT.
  15060. *
  15061. * Valid data (other than capture status) is returned only if both of the following are true:
  15062. * - the call returns CUDA_SUCCESS
  15063. * - the returned capture status is ::CU_STREAM_CAPTURE_STATUS_ACTIVE
  15064. *
  15065. * If \p edgeData_out is non-NULL then \p dependencies_out must be as well. If
  15066. * \p dependencies_out is non-NULL and \p edgeData_out is NULL, but there is non-zero edge
  15067. * data for one or more of the current stream dependencies, the call will return
  15068. * ::CUDA_ERROR_LOSSY_QUERY.
  15069. *
  15070. * \param hStream - The stream to query
  15071. * \param captureStatus_out - Location to return the capture status of the stream; required
  15072. * \param id_out - Optional location to return an id for the capture sequence, which is
  15073. * unique over the lifetime of the process
  15074. * \param graph_out - Optional location to return the graph being captured into. All
  15075. * operations other than destroy and node removal are permitted on the graph
  15076. * while the capture sequence is in progress. This API does not transfer
  15077. * ownership of the graph, which is transferred or destroyed at
  15078. * ::cuStreamEndCapture. Note that the graph handle may be invalidated before
  15079. * end of capture for certain errors. Nodes that are or become
  15080. * unreachable from the original stream at ::cuStreamEndCapture due to direct
  15081. * actions on the graph do not trigger ::CUDA_ERROR_STREAM_CAPTURE_UNJOINED.
  15082. * \param dependencies_out - Optional location to store a pointer to an array of nodes.
  15083. * The next node to be captured in the stream will depend on this set of nodes,
  15084. * absent operations such as event wait which modify this set. The array pointer
  15085. * is valid until the next API call which operates on the stream or until the
  15086. * capture is terminated. The node handles may be copied out and are valid until
  15087. * they or the graph is destroyed. The driver-owned array may also be passed
  15088. * directly to APIs that operate on the graph (not the stream) without copying.
  15089. * \param edgeData_out - Optional location to store a pointer to an array of graph edge
  15090. * data. This array parallels \c dependencies_out; the next node to be added
  15091. * has an edge to \c dependencies_out[i] with annotation \c edgeData_out[i] for
  15092. * each \c i. The array pointer is valid until the next API call which operates
  15093. * on the stream or until the capture is terminated.
  15094. * \param numDependencies_out - Optional location to store the size of the array
  15095. * returned in dependencies_out.
  15096. *
  15097. * \return
  15098. * ::CUDA_SUCCESS,
  15099. * ::CUDA_ERROR_INVALID_VALUE,
  15100. * ::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT,
  15101. * ::CUDA_ERROR_LOSSY_QUERY
  15102. * \note_graph_thread_safety
  15103. * \notefnerr
  15104. *
  15105. * \sa
  15106. * ::cuStreamGetCaptureInfo
  15107. * ::cuStreamBeginCapture,
  15108. * ::cuStreamIsCapturing,
  15109. * ::cuStreamUpdateCaptureDependencies
  15110. */
  15111. CUresult CUDAAPI cuStreamGetCaptureInfo_v3(CUstream hStream, CUstreamCaptureStatus *captureStatus_out,
  15112. cuuint64_t *id_out, CUgraph *graph_out, const CUgraphNode **dependencies_out,
  15113. const CUgraphEdgeData **edgeData_out, size_t *numDependencies_out);
  15114. /**
  15115. * \brief Update the set of dependencies in a capturing stream (11.3+)
  15116. *
  15117. * Modifies the dependency set of a capturing stream. The dependency set is the set
  15118. * of nodes that the next captured node in the stream will depend on.
  15119. *
  15120. * Valid flags are ::CU_STREAM_ADD_CAPTURE_DEPENDENCIES and
  15121. * ::CU_STREAM_SET_CAPTURE_DEPENDENCIES. These control whether the set passed to
  15122. * the API is added to the existing set or replaces it. A flags value of 0 defaults
  15123. * to ::CU_STREAM_ADD_CAPTURE_DEPENDENCIES.
  15124. *
  15125. * Nodes that are removed from the dependency set via this API do not result in
  15126. * ::CUDA_ERROR_STREAM_CAPTURE_UNJOINED if they are unreachable from the stream at
  15127. * ::cuStreamEndCapture.
  15128. *
  15129. * Returns ::CUDA_ERROR_ILLEGAL_STATE if the stream is not capturing.
  15130. *
  15131. * This API is new in CUDA 11.3. Developers requiring compatibility across minor
  15132. * versions to CUDA 11.0 should not use this API or provide a fallback.
  15133. *
  15134. * \param hStream - The stream to update
  15135. * \param dependencies - The set of dependencies to add
  15136. * \param numDependencies - The size of the dependencies array
  15137. * \param flags - See above
  15138. *
  15139. * \return
  15140. * ::CUDA_SUCCESS,
  15141. * ::CUDA_ERROR_INVALID_VALUE,
  15142. * ::CUDA_ERROR_ILLEGAL_STATE
  15143. *
  15144. * \sa
  15145. * ::cuStreamBeginCapture,
  15146. * ::cuStreamGetCaptureInfo,
  15147. */
  15148. CUresult CUDAAPI cuStreamUpdateCaptureDependencies(CUstream hStream, CUgraphNode *dependencies, size_t numDependencies, unsigned int flags);
  15149. /**
  15150. * \brief Update the set of dependencies in a capturing stream (12.3+)
  15151. *
  15152. * Modifies the dependency set of a capturing stream. The dependency set is the set
  15153. * of nodes that the next captured node in the stream will depend on along with the
  15154. * edge data for those dependencies.
  15155. *
  15156. * Valid flags are ::CU_STREAM_ADD_CAPTURE_DEPENDENCIES and
  15157. * ::CU_STREAM_SET_CAPTURE_DEPENDENCIES. These control whether the set passed to
  15158. * the API is added to the existing set or replaces it. A flags value of 0 defaults
  15159. * to ::CU_STREAM_ADD_CAPTURE_DEPENDENCIES.
  15160. *
  15161. * Nodes that are removed from the dependency set via this API do not result in
  15162. * ::CUDA_ERROR_STREAM_CAPTURE_UNJOINED if they are unreachable from the stream at
  15163. * ::cuStreamEndCapture.
  15164. *
  15165. * Returns ::CUDA_ERROR_ILLEGAL_STATE if the stream is not capturing.
  15166. *
  15167. * \param hStream - The stream to update
  15168. * \param dependencies - The set of dependencies to add
  15169. * \param dependencyData - Optional array of data associated with each dependency.
  15170. * \param numDependencies - The size of the dependencies array
  15171. * \param flags - See above
  15172. *
  15173. * \return
  15174. * ::CUDA_SUCCESS,
  15175. * ::CUDA_ERROR_INVALID_VALUE,
  15176. * ::CUDA_ERROR_ILLEGAL_STATE
  15177. *
  15178. * \sa
  15179. * ::cuStreamBeginCapture,
  15180. * ::cuStreamGetCaptureInfo,
  15181. */
  15182. CUresult CUDAAPI cuStreamUpdateCaptureDependencies_v2(CUstream hStream, CUgraphNode *dependencies,
  15183. const CUgraphEdgeData *dependencyData, size_t numDependencies, unsigned int flags);
  15184. /**
  15185. * \brief Attach memory to a stream asynchronously
  15186. *
  15187. * Enqueues an operation in \p hStream to specify stream association of
  15188. * \p length bytes of memory starting from \p dptr. This function is a
  15189. * stream-ordered operation, meaning that it is dependent on, and will
  15190. * only take effect when, previous work in stream has completed. Any
  15191. * previous association is automatically replaced.
  15192. *
  15193. * \p dptr must point to one of the following types of memories:
  15194. * - managed memory declared using the __managed__ keyword or allocated with
  15195. * ::cuMemAllocManaged.
  15196. * - a valid host-accessible region of system-allocated pageable memory. This
  15197. * type of memory may only be specified if the device associated with the
  15198. * stream reports a non-zero value for the device attribute
  15199. * ::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS.
  15200. *
  15201. * For managed allocations, \p length must be either zero or the entire
  15202. * allocation's size. Both indicate that the entire allocation's stream
  15203. * association is being changed. Currently, it is not possible to change stream
  15204. * association for a portion of a managed allocation.
  15205. *
  15206. * For pageable host allocations, \p length must be non-zero.
  15207. *
  15208. * The stream association is specified using \p flags which must be
  15209. * one of ::CUmemAttach_flags.
  15210. * If the ::CU_MEM_ATTACH_GLOBAL flag is specified, the memory can be accessed
  15211. * by any stream on any device.
  15212. * If the ::CU_MEM_ATTACH_HOST flag is specified, the program makes a guarantee
  15213. * that it won't access the memory on the device from any stream on a device that
  15214. * has a zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS.
  15215. * If the ::CU_MEM_ATTACH_SINGLE flag is specified and \p hStream is associated with
  15216. * a device that has a zero value for the device attribute ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS,
  15217. * the program makes a guarantee that it will only access the memory on the device
  15218. * from \p hStream. It is illegal to attach singly to the NULL stream, because the
  15219. * NULL stream is a virtual global stream and not a specific stream. An error will
  15220. * be returned in this case.
  15221. *
  15222. * When memory is associated with a single stream, the Unified Memory system will
  15223. * allow CPU access to this memory region so long as all operations in \p hStream
  15224. * have completed, regardless of whether other streams are active. In effect,
  15225. * this constrains exclusive ownership of the managed memory region by
  15226. * an active GPU to per-stream activity instead of whole-GPU activity.
  15227. *
  15228. * Accessing memory on the device from streams that are not associated with
  15229. * it will produce undefined results. No error checking is performed by the
  15230. * Unified Memory system to ensure that kernels launched into other streams
  15231. * do not access this region.
  15232. *
  15233. * It is a program's responsibility to order calls to ::cuStreamAttachMemAsync
  15234. * via events, synchronization or other means to ensure legal access to memory
  15235. * at all times. Data visibility and coherency will be changed appropriately
  15236. * for all kernels which follow a stream-association change.
  15237. *
  15238. * If \p hStream is destroyed while data is associated with it, the association is
  15239. * removed and the association reverts to the default visibility of the allocation
  15240. * as specified at ::cuMemAllocManaged. For __managed__ variables, the default
  15241. * association is always ::CU_MEM_ATTACH_GLOBAL. Note that destroying a stream is an
  15242. * asynchronous operation, and as a result, the change to default association won't
  15243. * happen until all work in the stream has completed.
  15244. *
  15245. * \param hStream - Stream in which to enqueue the attach operation
  15246. * \param dptr - Pointer to memory (must be a pointer to managed memory or
  15247. * to a valid host-accessible region of system-allocated
  15248. * pageable memory)
  15249. * \param length - Length of memory
  15250. * \param flags - Must be one of ::CUmemAttach_flags
  15251. *
  15252. * \return
  15253. * ::CUDA_SUCCESS,
  15254. * ::CUDA_ERROR_DEINITIALIZED,
  15255. * ::CUDA_ERROR_NOT_INITIALIZED,
  15256. * ::CUDA_ERROR_INVALID_CONTEXT,
  15257. * ::CUDA_ERROR_INVALID_HANDLE,
  15258. * ::CUDA_ERROR_NOT_SUPPORTED
  15259. * \note_null_stream
  15260. * \notefnerr
  15261. *
  15262. * \sa ::cuStreamCreate,
  15263. * ::cuStreamQuery,
  15264. * ::cuStreamSynchronize,
  15265. * ::cuStreamWaitEvent,
  15266. * ::cuStreamDestroy,
  15267. * ::cuMemAllocManaged,
  15268. * ::cudaStreamAttachMemAsync
  15269. */
  15270. CUresult CUDAAPI cuStreamAttachMemAsync(CUstream hStream, CUdeviceptr dptr, size_t length, unsigned int flags);
  15271. /**
  15272. * \brief Determine status of a compute stream
  15273. *
  15274. * Returns ::CUDA_SUCCESS if all operations in the stream specified by
  15275. * \p hStream have completed, or ::CUDA_ERROR_NOT_READY if not.
  15276. *
  15277. * For the purposes of Unified Memory, a return value of ::CUDA_SUCCESS
  15278. * is equivalent to having called ::cuStreamSynchronize().
  15279. *
  15280. * \param hStream - Stream to query status of
  15281. *
  15282. * \return
  15283. * ::CUDA_SUCCESS,
  15284. * ::CUDA_ERROR_DEINITIALIZED,
  15285. * ::CUDA_ERROR_NOT_INITIALIZED,
  15286. * ::CUDA_ERROR_INVALID_CONTEXT,
  15287. * ::CUDA_ERROR_INVALID_HANDLE,
  15288. * ::CUDA_ERROR_NOT_READY
  15289. * \note_null_stream
  15290. * \notefnerr
  15291. *
  15292. * \sa ::cuStreamCreate,
  15293. * ::cuStreamWaitEvent,
  15294. * ::cuStreamDestroy,
  15295. * ::cuStreamSynchronize,
  15296. * ::cuStreamAddCallback,
  15297. * ::cudaStreamQuery
  15298. */
  15299. CUresult CUDAAPI cuStreamQuery(CUstream hStream);
  15300. /**
  15301. * \brief Wait until a stream's tasks are completed
  15302. *
  15303. * Waits until the device has completed all operations in the stream specified
  15304. * by \p hStream. If the context was created with the
  15305. * ::CU_CTX_SCHED_BLOCKING_SYNC flag, the CPU thread will block until the
  15306. * stream is finished with all of its tasks.
  15307. *
  15308. * \param hStream - Stream to wait for
  15309. *
  15310. * \return
  15311. * ::CUDA_SUCCESS,
  15312. * ::CUDA_ERROR_DEINITIALIZED,
  15313. * ::CUDA_ERROR_NOT_INITIALIZED,
  15314. * ::CUDA_ERROR_INVALID_CONTEXT,
  15315. * ::CUDA_ERROR_INVALID_HANDLE
  15316. * \note_null_stream
  15317. * \notefnerr
  15318. *
  15319. * \sa ::cuStreamCreate,
  15320. * ::cuStreamDestroy,
  15321. * ::cuStreamWaitEvent,
  15322. * ::cuStreamQuery,
  15323. * ::cuStreamAddCallback,
  15324. * ::cudaStreamSynchronize
  15325. */
  15326. CUresult CUDAAPI cuStreamSynchronize(CUstream hStream);
  15327. /**
  15328. * \brief Destroys a stream
  15329. *
  15330. * Destroys the stream specified by \p hStream.
  15331. *
  15332. * In case the device is still doing work in the stream \p hStream
  15333. * when ::cuStreamDestroy() is called, the function will return immediately
  15334. * and the resources associated with \p hStream will be released automatically
  15335. * once the device has completed all work in \p hStream.
  15336. *
  15337. * \param hStream - Stream to destroy
  15338. *
  15339. * \return
  15340. * ::CUDA_SUCCESS,
  15341. * ::CUDA_ERROR_DEINITIALIZED,
  15342. * ::CUDA_ERROR_NOT_INITIALIZED,
  15343. * ::CUDA_ERROR_INVALID_CONTEXT,
  15344. * ::CUDA_ERROR_INVALID_VALUE,
  15345. * ::CUDA_ERROR_INVALID_HANDLE
  15346. * \notefnerr
  15347. *
  15348. * \sa ::cuStreamCreate,
  15349. * ::cuStreamWaitEvent,
  15350. * ::cuStreamQuery,
  15351. * ::cuStreamSynchronize,
  15352. * ::cuStreamAddCallback,
  15353. * ::cudaStreamDestroy
  15354. */
  15355. CUresult CUDAAPI cuStreamDestroy(CUstream hStream);
  15356. /**
  15357. * \brief Copies attributes from source stream to destination stream.
  15358. *
  15359. * Copies attributes from source stream \p src to destination stream \p dst.
  15360. * Both streams must have the same context.
  15361. *
  15362. * \param[out] dst Destination stream
  15363. * \param[in] src Source stream
  15364. * For list of attributes see ::CUstreamAttrID
  15365. *
  15366. * \return
  15367. * ::CUDA_SUCCESS,
  15368. * ::CUDA_ERROR_INVALID_VALUE
  15369. * \notefnerr
  15370. *
  15371. * \sa
  15372. * ::CUaccessPolicyWindow
  15373. */
  15374. CUresult CUDAAPI cuStreamCopyAttributes(CUstream dst, CUstream src);
  15375. /**
  15376. * \brief Queries stream attribute.
  15377. *
  15378. * Queries attribute \p attr from \p hStream and stores it in corresponding
  15379. * member of \p value_out.
  15380. *
  15381. * \param[in] hStream
  15382. * \param[in] attr
  15383. * \param[out] value_out
  15384. *
  15385. * \return
  15386. * ::CUDA_SUCCESS,
  15387. * ::CUDA_ERROR_INVALID_VALUE,
  15388. * ::CUDA_ERROR_INVALID_HANDLE
  15389. * \notefnerr
  15390. *
  15391. * \sa
  15392. * ::CUaccessPolicyWindow
  15393. */
  15394. CUresult CUDAAPI cuStreamGetAttribute(CUstream hStream, CUstreamAttrID attr,
  15395. CUstreamAttrValue *value_out);
  15396. /**
  15397. * \brief Sets stream attribute.
  15398. *
  15399. * Sets attribute \p attr on \p hStream from corresponding attribute of
  15400. * \p value. The updated attribute will be applied to subsequent work
  15401. * submitted to the stream. It will not affect previously submitted work.
  15402. *
  15403. * \param[out] hStream
  15404. * \param[in] attr
  15405. * \param[in] value
  15406. *
  15407. * \return
  15408. * ::CUDA_SUCCESS,
  15409. * ::CUDA_ERROR_INVALID_VALUE,
  15410. * ::CUDA_ERROR_INVALID_HANDLE
  15411. * \notefnerr
  15412. *
  15413. * \sa
  15414. * ::CUaccessPolicyWindow
  15415. */
  15416. CUresult CUDAAPI cuStreamSetAttribute(CUstream hStream, CUstreamAttrID attr,
  15417. const CUstreamAttrValue *value);
  15418. /** @} */ /* END CUDA_STREAM */
  15419. /**
  15420. * \defgroup CUDA_EVENT Event Management
  15421. *
  15422. * ___MANBRIEF___ event management functions of the low-level CUDA driver API
  15423. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  15424. *
  15425. * This section describes the event management functions of the low-level CUDA
  15426. * driver application programming interface.
  15427. *
  15428. * @{
  15429. */
  15430. /**
  15431. * \brief Creates an event
  15432. *
  15433. * Creates an event *phEvent for the current context with the flags specified via
  15434. * \p Flags. Valid flags include:
  15435. * - ::CU_EVENT_DEFAULT: Default event creation flag.
  15436. * - ::CU_EVENT_BLOCKING_SYNC: Specifies that the created event should use blocking
  15437. * synchronization. A CPU thread that uses ::cuEventSynchronize() to wait on
  15438. * an event created with this flag will block until the event has actually
  15439. * been recorded.
  15440. * - ::CU_EVENT_DISABLE_TIMING: Specifies that the created event does not need
  15441. * to record timing data. Events created with this flag specified and
  15442. * the ::CU_EVENT_BLOCKING_SYNC flag not specified will provide the best
  15443. * performance when used with ::cuStreamWaitEvent() and ::cuEventQuery().
  15444. * - ::CU_EVENT_INTERPROCESS: Specifies that the created event may be used as an
  15445. * interprocess event by ::cuIpcGetEventHandle(). ::CU_EVENT_INTERPROCESS must
  15446. * be specified along with ::CU_EVENT_DISABLE_TIMING.
  15447. *
  15448. * \param phEvent - Returns newly created event
  15449. * \param Flags - Event creation flags
  15450. *
  15451. * \return
  15452. * ::CUDA_SUCCESS,
  15453. * ::CUDA_ERROR_DEINITIALIZED,
  15454. * ::CUDA_ERROR_NOT_INITIALIZED,
  15455. * ::CUDA_ERROR_INVALID_CONTEXT,
  15456. * ::CUDA_ERROR_INVALID_VALUE,
  15457. * ::CUDA_ERROR_OUT_OF_MEMORY
  15458. * \notefnerr
  15459. *
  15460. * \sa
  15461. * ::cuEventRecord,
  15462. * ::cuEventQuery,
  15463. * ::cuEventSynchronize,
  15464. * ::cuEventDestroy,
  15465. * ::cuEventElapsedTime,
  15466. * ::cudaEventCreate,
  15467. * ::cudaEventCreateWithFlags
  15468. */
  15469. CUresult CUDAAPI cuEventCreate(CUevent *phEvent, unsigned int Flags);
  15470. /**
  15471. * \brief Records an event
  15472. *
  15473. * Captures in \p hEvent the contents of \p hStream at the time of this call.
  15474. * \p hEvent and \p hStream must be from the same context otherwise
  15475. * ::CUDA_ERROR_INVALID_HANDLE is returned.
  15476. * Calls such as ::cuEventQuery() or ::cuStreamWaitEvent() will then
  15477. * examine or wait for completion of the work that was captured. Uses of
  15478. * \p hStream after this call do not modify \p hEvent. See note on default
  15479. * stream behavior for what is captured in the default case.
  15480. *
  15481. * ::cuEventRecord() can be called multiple times on the same event and
  15482. * will overwrite the previously captured state. Other APIs such as
  15483. * ::cuStreamWaitEvent() use the most recently captured state at the time
  15484. * of the API call, and are not affected by later calls to
  15485. * ::cuEventRecord(). Before the first call to ::cuEventRecord(), an
  15486. * event represents an empty set of work, so for example ::cuEventQuery()
  15487. * would return ::CUDA_SUCCESS.
  15488. *
  15489. * \param hEvent - Event to record
  15490. * \param hStream - Stream to record event for
  15491. *
  15492. * \return
  15493. * ::CUDA_SUCCESS,
  15494. * ::CUDA_ERROR_DEINITIALIZED,
  15495. * ::CUDA_ERROR_NOT_INITIALIZED,
  15496. * ::CUDA_ERROR_INVALID_CONTEXT,
  15497. * ::CUDA_ERROR_INVALID_HANDLE,
  15498. * ::CUDA_ERROR_INVALID_VALUE
  15499. * \note_null_stream
  15500. * \notefnerr
  15501. *
  15502. * \sa ::cuEventCreate,
  15503. * ::cuEventQuery,
  15504. * ::cuEventSynchronize,
  15505. * ::cuStreamWaitEvent,
  15506. * ::cuEventDestroy,
  15507. * ::cuEventElapsedTime,
  15508. * ::cudaEventRecord,
  15509. * ::cuEventRecordWithFlags
  15510. */
  15511. CUresult CUDAAPI cuEventRecord(CUevent hEvent, CUstream hStream);
  15512. /**
  15513. * \brief Records an event
  15514. *
  15515. * Captures in \p hEvent the contents of \p hStream at the time of this call.
  15516. * \p hEvent and \p hStream must be from the same context otherwise
  15517. * ::CUDA_ERROR_INVALID_HANDLE is returned.
  15518. * Calls such as ::cuEventQuery() or ::cuStreamWaitEvent() will then
  15519. * examine or wait for completion of the work that was captured. Uses of
  15520. * \p hStream after this call do not modify \p hEvent. See note on default
  15521. * stream behavior for what is captured in the default case.
  15522. *
  15523. * ::cuEventRecordWithFlags() can be called multiple times on the same event and
  15524. * will overwrite the previously captured state. Other APIs such as
  15525. * ::cuStreamWaitEvent() use the most recently captured state at the time
  15526. * of the API call, and are not affected by later calls to
  15527. * ::cuEventRecordWithFlags(). Before the first call to ::cuEventRecordWithFlags(), an
  15528. * event represents an empty set of work, so for example ::cuEventQuery()
  15529. * would return ::CUDA_SUCCESS.
  15530. *
  15531. * flags include:
  15532. * - ::CU_EVENT_RECORD_DEFAULT: Default event creation flag.
  15533. * - ::CU_EVENT_RECORD_EXTERNAL: Event is captured in the graph as an external
  15534. * event node when performing stream capture. This flag is invalid outside
  15535. * of stream capture.
  15536. *
  15537. * \param hEvent - Event to record
  15538. * \param hStream - Stream to record event for
  15539. * \param flags - See ::CUevent_capture_flags
  15540. *
  15541. * \return
  15542. * ::CUDA_SUCCESS,
  15543. * ::CUDA_ERROR_DEINITIALIZED,
  15544. * ::CUDA_ERROR_NOT_INITIALIZED,
  15545. * ::CUDA_ERROR_INVALID_CONTEXT,
  15546. * ::CUDA_ERROR_INVALID_HANDLE,
  15547. * ::CUDA_ERROR_INVALID_VALUE
  15548. * \note_null_stream
  15549. * \notefnerr
  15550. *
  15551. * \sa ::cuEventCreate,
  15552. * ::cuEventQuery,
  15553. * ::cuEventSynchronize,
  15554. * ::cuStreamWaitEvent,
  15555. * ::cuEventDestroy,
  15556. * ::cuEventElapsedTime,
  15557. * ::cuEventRecord,
  15558. * ::cudaEventRecord
  15559. */
  15560. CUresult CUDAAPI cuEventRecordWithFlags(CUevent hEvent, CUstream hStream, unsigned int flags);
  15561. /**
  15562. * \brief Queries an event's status
  15563. *
  15564. * Queries the status of all work currently captured by \p hEvent. See
  15565. * ::cuEventRecord() for details on what is captured by an event.
  15566. *
  15567. * Returns ::CUDA_SUCCESS if all captured work has been completed, or
  15568. * ::CUDA_ERROR_NOT_READY if any captured work is incomplete.
  15569. *
  15570. * For the purposes of Unified Memory, a return value of ::CUDA_SUCCESS
  15571. * is equivalent to having called ::cuEventSynchronize().
  15572. *
  15573. * \param hEvent - Event to query
  15574. *
  15575. * \return
  15576. * ::CUDA_SUCCESS,
  15577. * ::CUDA_ERROR_DEINITIALIZED,
  15578. * ::CUDA_ERROR_NOT_INITIALIZED,
  15579. * ::CUDA_ERROR_INVALID_HANDLE,
  15580. * ::CUDA_ERROR_INVALID_VALUE,
  15581. * ::CUDA_ERROR_NOT_READY
  15582. * \notefnerr
  15583. *
  15584. * \sa ::cuEventCreate,
  15585. * ::cuEventRecord,
  15586. * ::cuEventSynchronize,
  15587. * ::cuEventDestroy,
  15588. * ::cuEventElapsedTime,
  15589. * ::cudaEventQuery
  15590. */
  15591. CUresult CUDAAPI cuEventQuery(CUevent hEvent);
  15592. /**
  15593. * \brief Waits for an event to complete
  15594. *
  15595. * Waits until the completion of all work currently captured in \p hEvent.
  15596. * See ::cuEventRecord() for details on what is captured by an event.
  15597. *
  15598. * Waiting for an event that was created with the ::CU_EVENT_BLOCKING_SYNC
  15599. * flag will cause the calling CPU thread to block until the event has
  15600. * been completed by the device. If the ::CU_EVENT_BLOCKING_SYNC flag has
  15601. * not been set, then the CPU thread will busy-wait until the event has
  15602. * been completed by the device.
  15603. *
  15604. * \param hEvent - Event to wait for
  15605. *
  15606. * \return
  15607. * ::CUDA_SUCCESS,
  15608. * ::CUDA_ERROR_DEINITIALIZED,
  15609. * ::CUDA_ERROR_NOT_INITIALIZED,
  15610. * ::CUDA_ERROR_INVALID_CONTEXT,
  15611. * ::CUDA_ERROR_INVALID_HANDLE
  15612. * \notefnerr
  15613. *
  15614. * \sa ::cuEventCreate,
  15615. * ::cuEventRecord,
  15616. * ::cuEventQuery,
  15617. * ::cuEventDestroy,
  15618. * ::cuEventElapsedTime,
  15619. * ::cudaEventSynchronize
  15620. */
  15621. CUresult CUDAAPI cuEventSynchronize(CUevent hEvent);
  15622. /**
  15623. * \brief Destroys an event
  15624. *
  15625. * Destroys the event specified by \p hEvent.
  15626. *
  15627. * An event may be destroyed before it is complete (i.e., while
  15628. * ::cuEventQuery() would return ::CUDA_ERROR_NOT_READY). In this case, the
  15629. * call does not block on completion of the event, and any associated
  15630. * resources will automatically be released asynchronously at completion.
  15631. *
  15632. * \param hEvent - Event to destroy
  15633. *
  15634. * \return
  15635. * ::CUDA_SUCCESS,
  15636. * ::CUDA_ERROR_DEINITIALIZED,
  15637. * ::CUDA_ERROR_NOT_INITIALIZED,
  15638. * ::CUDA_ERROR_INVALID_CONTEXT,
  15639. * ::CUDA_ERROR_INVALID_HANDLE
  15640. * \notefnerr
  15641. *
  15642. * \sa ::cuEventCreate,
  15643. * ::cuEventRecord,
  15644. * ::cuEventQuery,
  15645. * ::cuEventSynchronize,
  15646. * ::cuEventElapsedTime,
  15647. * ::cudaEventDestroy
  15648. */
  15649. CUresult CUDAAPI cuEventDestroy(CUevent hEvent);
  15650. /**
  15651. * \brief Computes the elapsed time between two events
  15652. *
  15653. * Computes the elapsed time between two events (in milliseconds with a
  15654. * resolution of around 0.5 microseconds).
  15655. *
  15656. * If either event was last recorded in a non-NULL stream, the resulting time
  15657. * may be greater than expected (even if both used the same stream handle). This
  15658. * happens because the ::cuEventRecord() operation takes place asynchronously
  15659. * and there is no guarantee that the measured latency is actually just between
  15660. * the two events. Any number of other different stream operations could execute
  15661. * in between the two measured events, thus altering the timing in a significant
  15662. * way.
  15663. *
  15664. * If ::cuEventRecord() has not been called on either event then
  15665. * ::CUDA_ERROR_INVALID_HANDLE is returned. If ::cuEventRecord() has been called
  15666. * on both events but one or both of them has not yet been completed (that is,
  15667. * ::cuEventQuery() would return ::CUDA_ERROR_NOT_READY on at least one of the
  15668. * events), ::CUDA_ERROR_NOT_READY is returned. If either event was created with
  15669. * the ::CU_EVENT_DISABLE_TIMING flag, then this function will return
  15670. * ::CUDA_ERROR_INVALID_HANDLE.
  15671. *
  15672. * Note there is a later version of this API, ::cuEventElapsedTime_v2. It will
  15673. * supplant this version in CUDA 13.0, which is retained for minor version compatibility.
  15674. *
  15675. * \param pMilliseconds - Time between \p hStart and \p hEnd in ms
  15676. * \param hStart - Starting event
  15677. * \param hEnd - Ending event
  15678. *
  15679. * \return
  15680. * ::CUDA_SUCCESS,
  15681. * ::CUDA_ERROR_DEINITIALIZED,
  15682. * ::CUDA_ERROR_NOT_INITIALIZED,
  15683. * ::CUDA_ERROR_INVALID_CONTEXT,
  15684. * ::CUDA_ERROR_INVALID_HANDLE,
  15685. * ::CUDA_ERROR_NOT_READY,
  15686. * ::CUDA_ERROR_UNKNOWN
  15687. * \notefnerr
  15688. *
  15689. * \sa ::cuEventCreate,
  15690. * ::cuEventRecord,
  15691. * ::cuEventQuery,
  15692. * ::cuEventSynchronize,
  15693. * ::cuEventDestroy,
  15694. * ::cudaEventElapsedTime
  15695. */
  15696. CUresult CUDAAPI cuEventElapsedTime(float *pMilliseconds, CUevent hStart, CUevent hEnd);
  15697. /**
  15698. * \brief Computes the elapsed time between two events
  15699. *
  15700. * Computes the elapsed time between two events (in milliseconds with a
  15701. * resolution of around 0.5 microseconds). Note this API is not guaranteed
  15702. * to return the latest errors for pending work. As such this API is intended to
  15703. * serve as an elapsed time calculation only and any polling for completion on the
  15704. * events to be compared should be done with ::cuEventQuery instead.
  15705. *
  15706. * If either event was last recorded in a non-NULL stream, the resulting time
  15707. * may be greater than expected (even if both used the same stream handle). This
  15708. * happens because the ::cuEventRecord() operation takes place asynchronously
  15709. * and there is no guarantee that the measured latency is actually just between
  15710. * the two events. Any number of other different stream operations could execute
  15711. * in between the two measured events, thus altering the timing in a significant
  15712. * way.
  15713. *
  15714. * If ::cuEventRecord() has not been called on either event then
  15715. * ::CUDA_ERROR_INVALID_HANDLE is returned. If ::cuEventRecord() has been called
  15716. * on both events but one or both of them has not yet been completed (that is,
  15717. * ::cuEventQuery() would return ::CUDA_ERROR_NOT_READY on at least one of the
  15718. * events), ::CUDA_ERROR_NOT_READY is returned. If either event was created with
  15719. * the ::CU_EVENT_DISABLE_TIMING flag, then this function will return
  15720. * ::CUDA_ERROR_INVALID_HANDLE.
  15721. *
  15722. * \param pMilliseconds - Time between \p hStart and \p hEnd in ms
  15723. * \param hStart - Starting event
  15724. * \param hEnd - Ending event
  15725. *
  15726. * \return
  15727. * ::CUDA_SUCCESS,
  15728. * ::CUDA_ERROR_DEINITIALIZED,
  15729. * ::CUDA_ERROR_NOT_INITIALIZED,
  15730. * ::CUDA_ERROR_INVALID_CONTEXT,
  15731. * ::CUDA_ERROR_INVALID_HANDLE,
  15732. * ::CUDA_ERROR_NOT_READY,
  15733. * ::CUDA_ERROR_UNKNOWN
  15734. * \notefnerr
  15735. *
  15736. * \sa ::cuEventCreate,
  15737. * ::cuEventRecord,
  15738. * ::cuEventQuery,
  15739. * ::cuEventSynchronize,
  15740. * ::cuEventDestroy,
  15741. * ::cudaEventElapsedTime
  15742. */
  15743. CUresult CUDAAPI cuEventElapsedTime_v2(float *pMilliseconds, CUevent hStart, CUevent hEnd);
  15744. /** @} */ /* END CUDA_EVENT */
  15745. /**
  15746. * \defgroup CUDA_EXTRES_INTEROP External Resource Interoperability
  15747. *
  15748. * ___MANBRIEF___ External resource interoperability functions of the low-level CUDA driver API
  15749. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  15750. *
  15751. * This section describes the external resource interoperability functions of the low-level CUDA
  15752. * driver application programming interface.
  15753. *
  15754. * @{
  15755. */
  15756. /**
  15757. * \brief Imports an external memory object
  15758. *
  15759. * Imports an externally allocated memory object and returns
  15760. * a handle to that in \p extMem_out.
  15761. *
  15762. * The properties of the handle being imported must be described in
  15763. * \p memHandleDesc. The ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC structure
  15764. * is defined as follows:
  15765. *
  15766. * \code
  15767. typedef struct CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st {
  15768. CUexternalMemoryHandleType type;
  15769. union {
  15770. int fd;
  15771. struct {
  15772. void *handle;
  15773. const void *name;
  15774. } win32;
  15775. const void *nvSciBufObject;
  15776. } handle;
  15777. unsigned long long size;
  15778. unsigned int flags;
  15779. } CUDA_EXTERNAL_MEMORY_HANDLE_DESC;
  15780. * \endcode
  15781. *
  15782. * where ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type specifies the type
  15783. * of handle being imported. ::CUexternalMemoryHandleType is
  15784. * defined as:
  15785. *
  15786. * \code
  15787. typedef enum CUexternalMemoryHandleType_enum {
  15788. CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD = 1,
  15789. CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32 = 2,
  15790. CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
  15791. CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP = 4,
  15792. CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE = 5,
  15793. CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE = 6,
  15794. CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT = 7,
  15795. CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF = 8,
  15796. } CUexternalMemoryHandleType;
  15797. * \endcode
  15798. *
  15799. * If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type is
  15800. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD, then
  15801. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::fd must be a valid
  15802. * file descriptor referencing a memory object. Ownership of
  15803. * the file descriptor is transferred to the CUDA driver when the
  15804. * handle is imported successfully. Performing any operations on the
  15805. * file descriptor after it is imported results in undefined behavior.
  15806. *
  15807. * If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type is
  15808. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32, then exactly one
  15809. * of ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle and
  15810. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name must not be
  15811. * NULL. If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle
  15812. * is not NULL, then it must represent a valid shared NT handle that
  15813. * references a memory object. Ownership of this handle is
  15814. * not transferred to CUDA after the import operation, so the
  15815. * application must release the handle using the appropriate system
  15816. * call. If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
  15817. * is not NULL, then it must point to a NULL-terminated array of
  15818. * UTF-16 characters that refers to a memory object.
  15819. *
  15820. * If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type is
  15821. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT, then
  15822. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle must
  15823. * be non-NULL and
  15824. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
  15825. * must be NULL. The handle specified must be a globally shared KMT
  15826. * handle. This handle does not hold a reference to the underlying
  15827. * object, and thus will be invalid when all references to the
  15828. * memory object are destroyed.
  15829. *
  15830. * If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type is
  15831. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP, then exactly one
  15832. * of ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle and
  15833. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name must not be
  15834. * NULL. If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle
  15835. * is not NULL, then it must represent a valid shared NT handle that
  15836. * is returned by ID3D12Device::CreateSharedHandle when referring to a
  15837. * ID3D12Heap object. This handle holds a reference to the underlying
  15838. * object. If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
  15839. * is not NULL, then it must point to a NULL-terminated array of
  15840. * UTF-16 characters that refers to a ID3D12Heap object.
  15841. *
  15842. * If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type is
  15843. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE, then exactly one
  15844. * of ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle and
  15845. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name must not be
  15846. * NULL. If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle
  15847. * is not NULL, then it must represent a valid shared NT handle that
  15848. * is returned by ID3D12Device::CreateSharedHandle when referring to a
  15849. * ID3D12Resource object. This handle holds a reference to the
  15850. * underlying object. If
  15851. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
  15852. * is not NULL, then it must point to a NULL-terminated array of
  15853. * UTF-16 characters that refers to a ID3D12Resource object.
  15854. *
  15855. * If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type is
  15856. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE, then
  15857. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle must
  15858. * represent a valid shared NT handle that is returned by
  15859. * IDXGIResource1::CreateSharedHandle when referring to a
  15860. * ID3D11Resource object. If
  15861. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
  15862. * is not NULL, then it must point to a NULL-terminated array of
  15863. * UTF-16 characters that refers to a ID3D11Resource object.
  15864. *
  15865. * If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type is
  15866. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT, then
  15867. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle must
  15868. * represent a valid shared KMT handle that is returned by
  15869. * IDXGIResource::GetSharedHandle when referring to a
  15870. * ID3D11Resource object and
  15871. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
  15872. * must be NULL.
  15873. *
  15874. * If ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type is
  15875. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF, then
  15876. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::nvSciBufObject must be non-NULL
  15877. * and reference a valid NvSciBuf object.
  15878. * If the NvSciBuf object imported into CUDA is also mapped by other drivers, then the
  15879. * application must use ::cuWaitExternalSemaphoresAsync or ::cuSignalExternalSemaphoresAsync
  15880. * as appropriate barriers to maintain coherence between CUDA and the other drivers.
  15881. * See ::CUDA_EXTERNAL_SEMAPHORE_SIGNAL_SKIP_NVSCIBUF_MEMSYNC and ::CUDA_EXTERNAL_SEMAPHORE_WAIT_SKIP_NVSCIBUF_MEMSYNC
  15882. * for memory synchronization.
  15883. *
  15884. *
  15885. * The size of the memory object must be specified in
  15886. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::size.
  15887. *
  15888. * Specifying the flag ::CUDA_EXTERNAL_MEMORY_DEDICATED in
  15889. * ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::flags indicates that the
  15890. * resource is a dedicated resource. The definition of what a
  15891. * dedicated resource is outside the scope of this extension.
  15892. * This flag must be set if ::CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type
  15893. * is one of the following:
  15894. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE
  15895. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE
  15896. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT
  15897. *
  15898. * \param extMem_out - Returned handle to an external memory object
  15899. * \param memHandleDesc - Memory import handle descriptor
  15900. *
  15901. * \return
  15902. * ::CUDA_SUCCESS,
  15903. * ::CUDA_ERROR_NOT_INITIALIZED,
  15904. * ::CUDA_ERROR_INVALID_VALUE,
  15905. * ::CUDA_ERROR_INVALID_HANDLE,
  15906. * ::CUDA_ERROR_OPERATING_SYSTEM
  15907. * \notefnerr
  15908. *
  15909. * \note If the Vulkan memory imported into CUDA is mapped on the CPU then the
  15910. * application must use vkInvalidateMappedMemoryRanges/vkFlushMappedMemoryRanges
  15911. * as well as appropriate Vulkan pipeline barriers to maintain coherence between
  15912. * CPU and GPU. For more information on these APIs, please refer to "Synchronization
  15913. * and Cache Control" chapter from Vulkan specification.
  15914. *
  15915. * \sa ::cuDestroyExternalMemory,
  15916. * ::cuExternalMemoryGetMappedBuffer,
  15917. * ::cuExternalMemoryGetMappedMipmappedArray
  15918. */
  15919. CUresult CUDAAPI cuImportExternalMemory(CUexternalMemory *extMem_out, const CUDA_EXTERNAL_MEMORY_HANDLE_DESC *memHandleDesc);
  15920. /**
  15921. * \brief Maps a buffer onto an imported memory object
  15922. *
  15923. * Maps a buffer onto an imported memory object and returns a device
  15924. * pointer in \p devPtr.
  15925. *
  15926. * The properties of the buffer being mapped must be described in
  15927. * \p bufferDesc. The ::CUDA_EXTERNAL_MEMORY_BUFFER_DESC structure is
  15928. * defined as follows:
  15929. *
  15930. * \code
  15931. typedef struct CUDA_EXTERNAL_MEMORY_BUFFER_DESC_st {
  15932. unsigned long long offset;
  15933. unsigned long long size;
  15934. unsigned int flags;
  15935. } CUDA_EXTERNAL_MEMORY_BUFFER_DESC;
  15936. * \endcode
  15937. *
  15938. * where ::CUDA_EXTERNAL_MEMORY_BUFFER_DESC::offset is the offset in
  15939. * the memory object where the buffer's base address is.
  15940. * ::CUDA_EXTERNAL_MEMORY_BUFFER_DESC::size is the size of the buffer.
  15941. * ::CUDA_EXTERNAL_MEMORY_BUFFER_DESC::flags must be zero.
  15942. *
  15943. * The offset and size have to be suitably aligned to match the
  15944. * requirements of the external API. Mapping two buffers whose ranges
  15945. * overlap may or may not result in the same virtual address being
  15946. * returned for the overlapped portion. In such cases, the application
  15947. * must ensure that all accesses to that region from the GPU are
  15948. * volatile. Otherwise writes made via one address are not guaranteed
  15949. * to be visible via the other address, even if they're issued by the
  15950. * same thread. It is recommended that applications map the combined
  15951. * range instead of mapping separate buffers and then apply the
  15952. * appropriate offsets to the returned pointer to derive the
  15953. * individual buffers.
  15954. *
  15955. * The returned pointer \p devPtr must be freed using ::cuMemFree.
  15956. *
  15957. * \param devPtr - Returned device pointer to buffer
  15958. * \param extMem - Handle to external memory object
  15959. * \param bufferDesc - Buffer descriptor
  15960. *
  15961. * \return
  15962. * ::CUDA_SUCCESS,
  15963. * ::CUDA_ERROR_NOT_INITIALIZED,
  15964. * ::CUDA_ERROR_INVALID_VALUE,
  15965. * ::CUDA_ERROR_INVALID_HANDLE
  15966. * \notefnerr
  15967. *
  15968. * \sa ::cuImportExternalMemory,
  15969. * ::cuDestroyExternalMemory,
  15970. * ::cuExternalMemoryGetMappedMipmappedArray
  15971. */
  15972. CUresult CUDAAPI cuExternalMemoryGetMappedBuffer(CUdeviceptr *devPtr, CUexternalMemory extMem, const CUDA_EXTERNAL_MEMORY_BUFFER_DESC *bufferDesc);
  15973. /**
  15974. * \brief Maps a CUDA mipmapped array onto an external memory object
  15975. *
  15976. * Maps a CUDA mipmapped array onto an external object and returns a
  15977. * handle to it in \p mipmap.
  15978. *
  15979. * The properties of the CUDA mipmapped array being mapped must be
  15980. * described in \p mipmapDesc. The structure
  15981. * ::CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC is defined as follows:
  15982. *
  15983. * \code
  15984. typedef struct CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_st {
  15985. unsigned long long offset;
  15986. CUDA_ARRAY3D_DESCRIPTOR arrayDesc;
  15987. unsigned int numLevels;
  15988. } CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC;
  15989. * \endcode
  15990. *
  15991. * where ::CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::offset is the
  15992. * offset in the memory object where the base level of the mipmap
  15993. * chain is.
  15994. * ::CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::arrayDesc describes
  15995. * the format, dimensions and type of the base level of the mipmap
  15996. * chain. For further details on these parameters, please refer to the
  15997. * documentation for ::cuMipmappedArrayCreate. Note that if the mipmapped
  15998. * array is bound as a color target in the graphics API, then the flag
  15999. * ::CUDA_ARRAY3D_COLOR_ATTACHMENT must be specified in
  16000. * ::CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::arrayDesc::Flags.
  16001. * ::CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::numLevels specifies
  16002. * the total number of levels in the mipmap chain.
  16003. *
  16004. * If \p extMem was imported from a handle of type ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF, then
  16005. * ::CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::numLevels must be equal to 1.
  16006. *
  16007. *
  16008. * The returned CUDA mipmapped array must be freed using ::cuMipmappedArrayDestroy.
  16009. *
  16010. * \param mipmap - Returned CUDA mipmapped array
  16011. * \param extMem - Handle to external memory object
  16012. * \param mipmapDesc - CUDA array descriptor
  16013. *
  16014. * \return
  16015. * ::CUDA_SUCCESS,
  16016. * ::CUDA_ERROR_NOT_INITIALIZED,
  16017. * ::CUDA_ERROR_INVALID_VALUE,
  16018. * ::CUDA_ERROR_INVALID_HANDLE
  16019. * \notefnerr
  16020. *
  16021. * \sa ::cuImportExternalMemory,
  16022. * ::cuDestroyExternalMemory,
  16023. * ::cuExternalMemoryGetMappedBuffer
  16024. */
  16025. CUresult CUDAAPI cuExternalMemoryGetMappedMipmappedArray(CUmipmappedArray *mipmap, CUexternalMemory extMem, const CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC *mipmapDesc);
  16026. /**
  16027. * \brief Destroys an external memory object.
  16028. *
  16029. * Destroys the specified external memory object. Any existing buffers
  16030. * and CUDA mipmapped arrays mapped onto this object must no longer be
  16031. * used and must be explicitly freed using ::cuMemFree and
  16032. * ::cuMipmappedArrayDestroy respectively.
  16033. *
  16034. * \param extMem - External memory object to be destroyed
  16035. *
  16036. * \return
  16037. * ::CUDA_SUCCESS,
  16038. * ::CUDA_ERROR_NOT_INITIALIZED,
  16039. * ::CUDA_ERROR_INVALID_HANDLE
  16040. * \notefnerr
  16041. *
  16042. * \sa ::cuImportExternalMemory,
  16043. * ::cuExternalMemoryGetMappedBuffer,
  16044. * ::cuExternalMemoryGetMappedMipmappedArray
  16045. */
  16046. CUresult CUDAAPI cuDestroyExternalMemory(CUexternalMemory extMem);
  16047. /**
  16048. * \brief Imports an external semaphore
  16049. *
  16050. * Imports an externally allocated synchronization object and returns
  16051. * a handle to that in \p extSem_out.
  16052. *
  16053. * The properties of the handle being imported must be described in
  16054. * \p semHandleDesc. The ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC is
  16055. * defined as follows:
  16056. *
  16057. * \code
  16058. typedef struct CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st {
  16059. CUexternalSemaphoreHandleType type;
  16060. union {
  16061. int fd;
  16062. struct {
  16063. void *handle;
  16064. const void *name;
  16065. } win32;
  16066. const void* NvSciSyncObj;
  16067. } handle;
  16068. unsigned int flags;
  16069. } CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC;
  16070. * \endcode
  16071. *
  16072. * where ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type specifies the type of
  16073. * handle being imported. ::CUexternalSemaphoreHandleType is defined
  16074. * as:
  16075. *
  16076. * \code
  16077. typedef enum CUexternalSemaphoreHandleType_enum {
  16078. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD = 1,
  16079. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32 = 2,
  16080. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
  16081. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE = 4,
  16082. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE = 5,
  16083. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC = 6,
  16084. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX = 7,
  16085. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT = 8,
  16086. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD = 9,
  16087. CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32 = 10
  16088. } CUexternalSemaphoreHandleType;
  16089. * \endcode
  16090. *
  16091. * If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type is
  16092. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD, then
  16093. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::fd must be a valid
  16094. * file descriptor referencing a synchronization object. Ownership of
  16095. * the file descriptor is transferred to the CUDA driver when the
  16096. * handle is imported successfully. Performing any operations on the
  16097. * file descriptor after it is imported results in undefined behavior.
  16098. *
  16099. * If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type is
  16100. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32, then exactly one
  16101. * of ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle and
  16102. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name must not be
  16103. * NULL. If
  16104. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle
  16105. * is not NULL, then it must represent a valid shared NT handle that
  16106. * references a synchronization object. Ownership of this handle is
  16107. * not transferred to CUDA after the import operation, so the
  16108. * application must release the handle using the appropriate system
  16109. * call. If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
  16110. * is not NULL, then it must name a valid synchronization object.
  16111. *
  16112. * If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type is
  16113. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT, then
  16114. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle must
  16115. * be non-NULL and
  16116. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
  16117. * must be NULL. The handle specified must be a globally shared KMT
  16118. * handle. This handle does not hold a reference to the underlying
  16119. * object, and thus will be invalid when all references to the
  16120. * synchronization object are destroyed.
  16121. *
  16122. * If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type is
  16123. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE, then exactly one
  16124. * of ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle and
  16125. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name must not be
  16126. * NULL. If
  16127. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle
  16128. * is not NULL, then it must represent a valid shared NT handle that
  16129. * is returned by ID3D12Device::CreateSharedHandle when referring to a
  16130. * ID3D12Fence object. This handle holds a reference to the underlying
  16131. * object. If
  16132. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
  16133. * is not NULL, then it must name a valid synchronization object that
  16134. * refers to a valid ID3D12Fence object.
  16135. *
  16136. * If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type is
  16137. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE, then
  16138. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle
  16139. * represents a valid shared NT handle that is returned by
  16140. * ID3D11Fence::CreateSharedHandle. If
  16141. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
  16142. * is not NULL, then it must name a valid synchronization object that
  16143. * refers to a valid ID3D11Fence object.
  16144. *
  16145. * If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type is
  16146. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC, then
  16147. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::nvSciSyncObj
  16148. * represents a valid NvSciSyncObj.
  16149. *
  16150. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX, then
  16151. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle
  16152. * represents a valid shared NT handle that
  16153. * is returned by IDXGIResource1::CreateSharedHandle when referring to
  16154. * a IDXGIKeyedMutex object. If
  16155. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
  16156. * is not NULL, then it must name a valid synchronization object that
  16157. * refers to a valid IDXGIKeyedMutex object.
  16158. *
  16159. * If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type is
  16160. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT, then
  16161. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle
  16162. * represents a valid shared KMT handle that
  16163. * is returned by IDXGIResource::GetSharedHandle when referring to
  16164. * a IDXGIKeyedMutex object and
  16165. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name must be NULL.
  16166. *
  16167. * If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type is
  16168. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD, then
  16169. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::fd must be a valid
  16170. * file descriptor referencing a synchronization object. Ownership of
  16171. * the file descriptor is transferred to the CUDA driver when the
  16172. * handle is imported successfully. Performing any operations on the
  16173. * file descriptor after it is imported results in undefined behavior.
  16174. *
  16175. * If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type is
  16176. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32, then exactly one
  16177. * of ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle and
  16178. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name must not be
  16179. * NULL. If
  16180. * ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle
  16181. * is not NULL, then it must represent a valid shared NT handle that
  16182. * references a synchronization object. Ownership of this handle is
  16183. * not transferred to CUDA after the import operation, so the
  16184. * application must release the handle using the appropriate system
  16185. * call. If ::CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
  16186. * is not NULL, then it must name a valid synchronization object.
  16187. *
  16188. * \param extSem_out - Returned handle to an external semaphore
  16189. * \param semHandleDesc - Semaphore import handle descriptor
  16190. *
  16191. * \return
  16192. * ::CUDA_SUCCESS,
  16193. * ::CUDA_ERROR_NOT_INITIALIZED,
  16194. * ::CUDA_ERROR_NOT_SUPPORTED,
  16195. * ::CUDA_ERROR_INVALID_HANDLE,
  16196. * ::CUDA_ERROR_OPERATING_SYSTEM
  16197. * \notefnerr
  16198. *
  16199. * \sa ::cuDestroyExternalSemaphore,
  16200. * ::cuSignalExternalSemaphoresAsync,
  16201. * ::cuWaitExternalSemaphoresAsync
  16202. */
  16203. CUresult CUDAAPI cuImportExternalSemaphore(CUexternalSemaphore *extSem_out, const CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC *semHandleDesc);
  16204. /**
  16205. * \brief Signals a set of external semaphore objects
  16206. *
  16207. * Enqueues a signal operation on a set of externally allocated
  16208. * semaphore object in the specified stream. The operations will be
  16209. * executed when all prior operations in the stream complete.
  16210. *
  16211. * The exact semantics of signaling a semaphore depends on the type of
  16212. * the object.
  16213. *
  16214. * If the semaphore object is any one of the following types:
  16215. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD,
  16216. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32,
  16217. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT
  16218. * then signaling the semaphore will set it to the signaled state.
  16219. *
  16220. * If the semaphore object is any one of the following types:
  16221. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE,
  16222. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE,
  16223. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD,
  16224. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32
  16225. * then the semaphore will be set to the value specified in
  16226. * ::CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS::params::fence::value.
  16227. *
  16228. * If the semaphore object is of the type ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC
  16229. * this API sets ::CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS::params::nvSciSync::fence
  16230. * to a value that can be used by subsequent waiters of the same NvSciSync object
  16231. * to order operations with those currently submitted in \p stream. Such an update
  16232. * will overwrite previous contents of
  16233. * ::CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS::params::nvSciSync::fence. By default,
  16234. * signaling such an external semaphore object causes appropriate memory synchronization
  16235. * operations to be performed over all external memory objects that are imported as
  16236. * ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF. This ensures that any subsequent accesses
  16237. * made by other importers of the same set of NvSciBuf memory object(s) are coherent.
  16238. * These operations can be skipped by specifying the flag
  16239. * ::CUDA_EXTERNAL_SEMAPHORE_SIGNAL_SKIP_NVSCIBUF_MEMSYNC, which can be used as a
  16240. * performance optimization when data coherency is not required. But specifying this
  16241. * flag in scenarios where data coherency is required results in undefined behavior.
  16242. * Also, for semaphore object of the type ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC,
  16243. * if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in
  16244. * ::cuDeviceGetNvSciSyncAttributes to CUDA_NVSCISYNC_ATTR_SIGNAL, this API will return
  16245. * CUDA_ERROR_NOT_SUPPORTED.
  16246. * NvSciSyncFence associated with semaphore object of the type
  16247. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC can be deterministic. For this the
  16248. * NvSciSyncAttrList used to create the semaphore object must have value of
  16249. * NvSciSyncAttrKey_RequireDeterministicFences key set to true. Deterministic fences
  16250. * allow users to enqueue a wait over the semaphore object even before corresponding
  16251. * signal is enqueued. For such a semaphore object, CUDA guarantees that each signal
  16252. * operation will increment the fence value by '1'. Users are expected to track count
  16253. * of signals enqueued on the semaphore object and insert waits accordingly. When such
  16254. * a semaphore object is signaled from multiple streams, due to concurrent stream
  16255. * execution, it is possible that the order in which the semaphore gets signaled is
  16256. * indeterministic. This could lead to waiters of the semaphore getting unblocked
  16257. * incorrectly. Users are expected to handle such situations, either by not using the
  16258. * same semaphore object with deterministic fence support enabled in different streams
  16259. * or by adding explicit dependency amongst such streams so that the semaphore is
  16260. * signaled in order.
  16261. *
  16262. * If the semaphore object is any one of the following types:
  16263. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX,
  16264. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT
  16265. * then the keyed mutex will be released with the key specified in
  16266. * ::CUDA_EXTERNAL_SEMAPHORE_PARAMS::params::keyedmutex::key.
  16267. *
  16268. * \param extSemArray - Set of external semaphores to be signaled
  16269. * \param paramsArray - Array of semaphore parameters
  16270. * \param numExtSems - Number of semaphores to signal
  16271. * \param stream - Stream to enqueue the signal operations in
  16272. *
  16273. * \return
  16274. * ::CUDA_SUCCESS,
  16275. * ::CUDA_ERROR_NOT_INITIALIZED,
  16276. * ::CUDA_ERROR_INVALID_HANDLE,
  16277. * ::CUDA_ERROR_NOT_SUPPORTED
  16278. * \notefnerr
  16279. *
  16280. * \sa ::cuImportExternalSemaphore,
  16281. * ::cuDestroyExternalSemaphore,
  16282. * ::cuWaitExternalSemaphoresAsync
  16283. */
  16284. CUresult CUDAAPI cuSignalExternalSemaphoresAsync(const CUexternalSemaphore *extSemArray, const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS *paramsArray, unsigned int numExtSems, CUstream stream);
  16285. /**
  16286. * \brief Waits on a set of external semaphore objects
  16287. *
  16288. * Enqueues a wait operation on a set of externally allocated
  16289. * semaphore object in the specified stream. The operations will be
  16290. * executed when all prior operations in the stream complete.
  16291. *
  16292. * The exact semantics of waiting on a semaphore depends on the type
  16293. * of the object.
  16294. *
  16295. * If the semaphore object is any one of the following types:
  16296. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD,
  16297. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32,
  16298. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT
  16299. * then waiting on the semaphore will wait until the semaphore reaches
  16300. * the signaled state. The semaphore will then be reset to the
  16301. * unsignaled state. Therefore for every signal operation, there can
  16302. * only be one wait operation.
  16303. *
  16304. * If the semaphore object is any one of the following types:
  16305. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE,
  16306. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE,
  16307. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD,
  16308. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32
  16309. * then waiting on the semaphore will wait until the value of the
  16310. * semaphore is greater than or equal to
  16311. * ::CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS::params::fence::value.
  16312. *
  16313. * If the semaphore object is of the type ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC
  16314. * then, waiting on the semaphore will wait until the
  16315. * ::CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS::params::nvSciSync::fence is signaled by the
  16316. * signaler of the NvSciSyncObj that was associated with this semaphore object.
  16317. * By default, waiting on such an external semaphore object causes appropriate
  16318. * memory synchronization operations to be performed over all external memory objects
  16319. * that are imported as ::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF. This ensures that
  16320. * any subsequent accesses made by other importers of the same set of NvSciBuf memory
  16321. * object(s) are coherent. These operations can be skipped by specifying the flag
  16322. * ::CUDA_EXTERNAL_SEMAPHORE_WAIT_SKIP_NVSCIBUF_MEMSYNC, which can be used as a
  16323. * performance optimization when data coherency is not required. But specifying this
  16324. * flag in scenarios where data coherency is required results in undefined behavior.
  16325. * Also, for semaphore object of the type ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC,
  16326. * if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in
  16327. * ::cuDeviceGetNvSciSyncAttributes to CUDA_NVSCISYNC_ATTR_WAIT, this API will return
  16328. * CUDA_ERROR_NOT_SUPPORTED.
  16329. *
  16330. * If the semaphore object is any one of the following types:
  16331. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX,
  16332. * ::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT
  16333. * then the keyed mutex will be acquired when it is released with the key
  16334. * specified in ::CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS::params::keyedmutex::key
  16335. * or until the timeout specified by
  16336. * ::CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS::params::keyedmutex::timeoutMs
  16337. * has lapsed. The timeout interval can either be a finite value
  16338. * specified in milliseconds or an infinite value. In case an infinite
  16339. * value is specified the timeout never elapses. The windows INFINITE
  16340. * macro must be used to specify infinite timeout.
  16341. *
  16342. * \param extSemArray - External semaphores to be waited on
  16343. * \param paramsArray - Array of semaphore parameters
  16344. * \param numExtSems - Number of semaphores to wait on
  16345. * \param stream - Stream to enqueue the wait operations in
  16346. *
  16347. * \return
  16348. * ::CUDA_SUCCESS,
  16349. * ::CUDA_ERROR_NOT_INITIALIZED,
  16350. * ::CUDA_ERROR_INVALID_HANDLE,
  16351. * ::CUDA_ERROR_NOT_SUPPORTED,
  16352. * ::CUDA_ERROR_TIMEOUT
  16353. * \notefnerr
  16354. *
  16355. * \sa ::cuImportExternalSemaphore,
  16356. * ::cuDestroyExternalSemaphore,
  16357. * ::cuSignalExternalSemaphoresAsync
  16358. */
  16359. CUresult CUDAAPI cuWaitExternalSemaphoresAsync(const CUexternalSemaphore *extSemArray, const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS *paramsArray, unsigned int numExtSems, CUstream stream);
  16360. /**
  16361. * \brief Destroys an external semaphore
  16362. *
  16363. * Destroys an external semaphore object and releases any references
  16364. * to the underlying resource. Any outstanding signals or waits must
  16365. * have completed before the semaphore is destroyed.
  16366. *
  16367. * \param extSem - External semaphore to be destroyed
  16368. *
  16369. * \return
  16370. * ::CUDA_SUCCESS,
  16371. * ::CUDA_ERROR_NOT_INITIALIZED,
  16372. * ::CUDA_ERROR_INVALID_HANDLE
  16373. * \notefnerr
  16374. *
  16375. * \sa ::cuImportExternalSemaphore,
  16376. * ::cuSignalExternalSemaphoresAsync,
  16377. * ::cuWaitExternalSemaphoresAsync
  16378. */
  16379. CUresult CUDAAPI cuDestroyExternalSemaphore(CUexternalSemaphore extSem);
  16380. /** @} */ /* END CUDA_EXTRES_INTEROP */
  16381. /**
  16382. * \defgroup CUDA_MEMOP Stream Memory Operations
  16383. *
  16384. * ___MANBRIEF___ Stream memory operations of the low-level CUDA driver API
  16385. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  16386. *
  16387. * This section describes the stream memory operations of the low-level CUDA
  16388. * driver application programming interface.
  16389. *
  16390. * Support for the ::CU_STREAM_WAIT_VALUE_NOR flag can be queried with
  16391. * ::CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_WAIT_VALUE_NOR_V2.
  16392. *
  16393. * Support for the ::cuStreamWriteValue64() and ::cuStreamWaitValue64()
  16394. * functions, as well as for the ::CU_STREAM_MEM_OP_WAIT_VALUE_64 and
  16395. * ::CU_STREAM_MEM_OP_WRITE_VALUE_64 flags, can be queried with
  16396. * ::CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS.
  16397. *
  16398. * Support for both ::CU_STREAM_WAIT_VALUE_FLUSH and
  16399. * ::CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES requires dedicated platform
  16400. * hardware features and can be queried with ::cuDeviceGetAttribute() and
  16401. * ::CU_DEVICE_ATTRIBUTE_CAN_FLUSH_REMOTE_WRITES.
  16402. *
  16403. * Note that all memory pointers passed as parameters to these operations
  16404. * are device pointers. Where necessary a device pointer should be
  16405. * obtained, for example with ::cuMemHostGetDevicePointer().
  16406. *
  16407. * None of the operations accepts pointers to managed memory buffers
  16408. * (::cuMemAllocManaged).
  16409. *
  16410. * \note
  16411. * Warning:
  16412. * Improper use of these APIs may deadlock the application. Synchronization
  16413. * ordering established through these APIs is not visible to CUDA. CUDA tasks
  16414. * that are (even indirectly) ordered by these APIs should also have that order
  16415. * expressed with CUDA-visible dependencies such as events. This ensures that
  16416. * the scheduler does not serialize them in an improper order.
  16417. *
  16418. * @{
  16419. */
  16420. /**
  16421. * \brief Wait on a memory location
  16422. *
  16423. * Enqueues a synchronization of the stream on the given memory location. Work
  16424. * ordered after the operation will block until the given condition on the
  16425. * memory is satisfied. By default, the condition is to wait for
  16426. * (int32_t)(*addr - value) >= 0, a cyclic greater-or-equal.
  16427. * Other condition types can be specified via \p flags.
  16428. *
  16429. * If the memory was registered via ::cuMemHostRegister(), the device pointer
  16430. * should be obtained with ::cuMemHostGetDevicePointer(). This function cannot
  16431. * be used with managed memory (::cuMemAllocManaged).
  16432. *
  16433. * Support for CU_STREAM_WAIT_VALUE_NOR can be queried with ::cuDeviceGetAttribute() and
  16434. * ::CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_WAIT_VALUE_NOR_V2.
  16435. *
  16436. * \note
  16437. * Warning:
  16438. * Improper use of this API may deadlock the application. Synchronization
  16439. * ordering established through this API is not visible to CUDA. CUDA tasks
  16440. * that are (even indirectly) ordered by this API should also have that order
  16441. * expressed with CUDA-visible dependencies such as events. This ensures that
  16442. * the scheduler does not serialize them in an improper order.
  16443. *
  16444. * \param stream The stream to synchronize on the memory location.
  16445. * \param addr The memory location to wait on.
  16446. * \param value The value to compare with the memory location.
  16447. * \param flags See ::CUstreamWaitValue_flags.
  16448. *
  16449. * \return
  16450. * ::CUDA_SUCCESS,
  16451. * ::CUDA_ERROR_INVALID_VALUE,
  16452. * ::CUDA_ERROR_NOT_SUPPORTED
  16453. * \notefnerr
  16454. *
  16455. * \sa ::cuStreamWaitValue64,
  16456. * ::cuStreamWriteValue32,
  16457. * ::cuStreamWriteValue64,
  16458. * ::cuStreamBatchMemOp,
  16459. * ::cuMemHostRegister,
  16460. * ::cuStreamWaitEvent
  16461. */
  16462. CUresult CUDAAPI cuStreamWaitValue32(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
  16463. /**
  16464. * \brief Wait on a memory location
  16465. *
  16466. * Enqueues a synchronization of the stream on the given memory location. Work
  16467. * ordered after the operation will block until the given condition on the
  16468. * memory is satisfied. By default, the condition is to wait for
  16469. * (int64_t)(*addr - value) >= 0, a cyclic greater-or-equal.
  16470. * Other condition types can be specified via \p flags.
  16471. *
  16472. * If the memory was registered via ::cuMemHostRegister(), the device pointer
  16473. * should be obtained with ::cuMemHostGetDevicePointer().
  16474. *
  16475. * Support for this can be queried with ::cuDeviceGetAttribute() and
  16476. * ::CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS.
  16477. *
  16478. * \note
  16479. * Warning:
  16480. * Improper use of this API may deadlock the application. Synchronization
  16481. * ordering established through this API is not visible to CUDA. CUDA tasks
  16482. * that are (even indirectly) ordered by this API should also have that order
  16483. * expressed with CUDA-visible dependencies such as events. This ensures that
  16484. * the scheduler does not serialize them in an improper order.
  16485. *
  16486. * \param stream The stream to synchronize on the memory location.
  16487. * \param addr The memory location to wait on.
  16488. * \param value The value to compare with the memory location.
  16489. * \param flags See ::CUstreamWaitValue_flags.
  16490. *
  16491. * \return
  16492. * ::CUDA_SUCCESS,
  16493. * ::CUDA_ERROR_INVALID_VALUE,
  16494. * ::CUDA_ERROR_NOT_SUPPORTED
  16495. * \notefnerr
  16496. *
  16497. * \sa ::cuStreamWaitValue32,
  16498. * ::cuStreamWriteValue32,
  16499. * ::cuStreamWriteValue64,
  16500. * ::cuStreamBatchMemOp,
  16501. * ::cuMemHostRegister,
  16502. * ::cuStreamWaitEvent
  16503. */
  16504. CUresult CUDAAPI cuStreamWaitValue64(CUstream stream, CUdeviceptr addr, cuuint64_t value, unsigned int flags);
  16505. /**
  16506. * \brief Write a value to memory
  16507. *
  16508. * Write a value to memory.
  16509. *
  16510. * If the memory was registered via ::cuMemHostRegister(), the device pointer
  16511. * should be obtained with ::cuMemHostGetDevicePointer(). This function cannot
  16512. * be used with managed memory (::cuMemAllocManaged).
  16513. *
  16514. * \param stream The stream to do the write in.
  16515. * \param addr The device address to write to.
  16516. * \param value The value to write.
  16517. * \param flags See ::CUstreamWriteValue_flags.
  16518. *
  16519. * \return
  16520. * ::CUDA_SUCCESS,
  16521. * ::CUDA_ERROR_INVALID_VALUE,
  16522. * ::CUDA_ERROR_NOT_SUPPORTED
  16523. * \notefnerr
  16524. *
  16525. * \sa ::cuStreamWriteValue64,
  16526. * ::cuStreamWaitValue32,
  16527. * ::cuStreamWaitValue64,
  16528. * ::cuStreamBatchMemOp,
  16529. * ::cuMemHostRegister,
  16530. * ::cuEventRecord
  16531. */
  16532. CUresult CUDAAPI cuStreamWriteValue32(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
  16533. /**
  16534. * \brief Write a value to memory
  16535. *
  16536. * Write a value to memory.
  16537. *
  16538. * If the memory was registered via ::cuMemHostRegister(), the device pointer
  16539. * should be obtained with ::cuMemHostGetDevicePointer().
  16540. *
  16541. * Support for this can be queried with ::cuDeviceGetAttribute() and
  16542. * ::CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS.
  16543. *
  16544. * \param stream The stream to do the write in.
  16545. * \param addr The device address to write to.
  16546. * \param value The value to write.
  16547. * \param flags See ::CUstreamWriteValue_flags.
  16548. *
  16549. * \return
  16550. * ::CUDA_SUCCESS,
  16551. * ::CUDA_ERROR_INVALID_VALUE,
  16552. * ::CUDA_ERROR_NOT_SUPPORTED
  16553. * \notefnerr
  16554. *
  16555. * \sa ::cuStreamWriteValue32,
  16556. * ::cuStreamWaitValue32,
  16557. * ::cuStreamWaitValue64,
  16558. * ::cuStreamBatchMemOp,
  16559. * ::cuMemHostRegister,
  16560. * ::cuEventRecord
  16561. */
  16562. CUresult CUDAAPI cuStreamWriteValue64(CUstream stream, CUdeviceptr addr, cuuint64_t value, unsigned int flags);
  16563. /**
  16564. * \brief Batch operations to synchronize the stream via memory operations
  16565. *
  16566. * This is a batch version of ::cuStreamWaitValue32() and ::cuStreamWriteValue32().
  16567. * Batching operations may avoid some performance overhead in both the API call
  16568. * and the device execution versus adding them to the stream in separate API
  16569. * calls. The operations are enqueued in the order they appear in the array.
  16570. *
  16571. * See ::CUstreamBatchMemOpType for the full set of supported operations, and
  16572. * ::cuStreamWaitValue32(), ::cuStreamWaitValue64(), ::cuStreamWriteValue32(),
  16573. * and ::cuStreamWriteValue64() for details of specific operations.
  16574. *
  16575. * See related APIs for details on querying support for specific operations.
  16576. *
  16577. * \note
  16578. * Warning:
  16579. * Improper use of this API may deadlock the application. Synchronization
  16580. * ordering established through this API is not visible to CUDA. CUDA tasks
  16581. * that are (even indirectly) ordered by this API should also have that order
  16582. * expressed with CUDA-visible dependencies such as events. This ensures that
  16583. * the scheduler does not serialize them in an improper order. For more
  16584. * information, see the Stream Memory Operations section in the programming
  16585. * guide(https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html).
  16586. *
  16587. * \param stream The stream to enqueue the operations in.
  16588. * \param count The number of operations in the array. Must be less than 256.
  16589. * \param paramArray The types and parameters of the individual operations.
  16590. * \param flags Reserved for future expansion; must be 0.
  16591. *
  16592. * \return
  16593. * ::CUDA_SUCCESS,
  16594. * ::CUDA_ERROR_INVALID_VALUE,
  16595. * ::CUDA_ERROR_NOT_SUPPORTED
  16596. * \notefnerr
  16597. *
  16598. * \sa ::cuStreamWaitValue32,
  16599. * ::cuStreamWaitValue64,
  16600. * ::cuStreamWriteValue32,
  16601. * ::cuStreamWriteValue64,
  16602. * ::cuMemHostRegister
  16603. */
  16604. CUresult CUDAAPI cuStreamBatchMemOp(CUstream stream, unsigned int count, CUstreamBatchMemOpParams *paramArray, unsigned int flags);
  16605. /** @} */ /* END CUDA_MEMOP */
  16606. /**
  16607. * \defgroup CUDA_EXEC Execution Control
  16608. *
  16609. * ___MANBRIEF___ execution control functions of the low-level CUDA driver API
  16610. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  16611. *
  16612. * This section describes the execution control functions of the low-level CUDA
  16613. * driver application programming interface.
  16614. *
  16615. * @{
  16616. */
  16617. /**
  16618. * \brief Returns information about a function
  16619. *
  16620. * Returns in \p *pi the integer value of the attribute \p attrib on the kernel
  16621. * given by \p hfunc. The supported attributes are:
  16622. * - ::CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK: The maximum number of threads
  16623. * per block, beyond which a launch of the function would fail. This number
  16624. * depends on both the function and the device on which the function is
  16625. * currently loaded.
  16626. * - ::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES: The size in bytes of
  16627. * statically-allocated shared memory per block required by this function.
  16628. * This does not include dynamically-allocated shared memory requested by
  16629. * the user at runtime.
  16630. * - ::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES: The size in bytes of user-allocated
  16631. * constant memory required by this function.
  16632. * - ::CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES: The size in bytes of local memory
  16633. * used by each thread of this function.
  16634. * - ::CU_FUNC_ATTRIBUTE_NUM_REGS: The number of registers used by each thread
  16635. * of this function.
  16636. * - ::CU_FUNC_ATTRIBUTE_PTX_VERSION: The PTX virtual architecture version for
  16637. * which the function was compiled. This value is the major PTX version * 10
  16638. * + the minor PTX version, so a PTX version 1.3 function would return the
  16639. * value 13. Note that this may return the undefined value of 0 for cubins
  16640. * compiled prior to CUDA 3.0.
  16641. * - ::CU_FUNC_ATTRIBUTE_BINARY_VERSION: The binary architecture version for
  16642. * which the function was compiled. This value is the major binary
  16643. * version * 10 + the minor binary version, so a binary version 1.3 function
  16644. * would return the value 13. Note that this will return a value of 10 for
  16645. * legacy cubins that do not have a properly-encoded binary architecture
  16646. * version.
  16647. * - ::CU_FUNC_CACHE_MODE_CA: The attribute to indicate whether the function has
  16648. * been compiled with user specified option "-Xptxas --dlcm=ca" set .
  16649. * - ::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES: The maximum size in bytes of
  16650. * dynamically-allocated shared memory.
  16651. * - ::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT: Preferred shared memory-L1
  16652. * cache split ratio in percent of total shared memory.
  16653. * - ::CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET: If this attribute is set, the
  16654. * kernel must launch with a valid cluster size specified.
  16655. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH: The required cluster width in
  16656. * blocks.
  16657. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT: The required cluster height in
  16658. * blocks.
  16659. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH: The required cluster depth in
  16660. * blocks.
  16661. * - ::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED: Indicates whether
  16662. * the function can be launched with non-portable cluster size. 1 is allowed,
  16663. * 0 is disallowed. A non-portable cluster size may only function on the
  16664. * specific SKUs the program is tested on. The launch might fail if the
  16665. * program is run on a different hardware platform. CUDA API provides
  16666. * cudaOccupancyMaxActiveClusters to assist with checking whether the desired
  16667. * size can be launched on the current device. A portable cluster size is
  16668. * guaranteed to be functional on all compute capabilities higher than the
  16669. * target compute capability. The portable cluster size for sm_90 is 8 blocks
  16670. * per cluster. This value may increase for future compute capabilities. The
  16671. * specific hardware unit may support higher cluster sizes that’s not
  16672. * guaranteed to be portable.
  16673. * - ::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE: The block
  16674. * scheduling policy of a function. The value type is CUclusterSchedulingPolicy.
  16675. *
  16676. * With a few execeptions, function attributes may also be queried on unloaded
  16677. * function handles returned from ::cuModuleEnumerateFunctions.
  16678. * ::CUDA_ERROR_FUNCTION_NOT_LOADED is returned if the attribute requires a fully
  16679. * loaded function but the function is not loaded. The loading state of a function
  16680. * may be queried using ::cuFuncIsloaded. ::cuFuncLoad may be called to explicitly
  16681. * load a function before querying the following attributes that require the function
  16682. * to be loaded:
  16683. * - ::CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK
  16684. * - ::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES
  16685. * - ::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES
  16686. *
  16687. * \param pi - Returned attribute value
  16688. * \param attrib - Attribute requested
  16689. * \param hfunc - Function to query attribute of
  16690. *
  16691. * \return
  16692. * ::CUDA_SUCCESS,
  16693. * ::CUDA_ERROR_DEINITIALIZED,
  16694. * ::CUDA_ERROR_NOT_INITIALIZED,
  16695. * ::CUDA_ERROR_INVALID_CONTEXT,
  16696. * ::CUDA_ERROR_INVALID_HANDLE,
  16697. * ::CUDA_ERROR_INVALID_VALUE,
  16698. * ::CUDA_ERROR_FUNCTION_NOT_LOADED
  16699. * \notefnerr
  16700. *
  16701. * \sa ::cuCtxGetCacheConfig,
  16702. * ::cuCtxSetCacheConfig,
  16703. * ::cuFuncSetCacheConfig,
  16704. * ::cuLaunchKernel,
  16705. * ::cudaFuncGetAttributes,
  16706. * ::cudaFuncSetAttribute,
  16707. * ::cuFuncIsLoaded,
  16708. * ::cuFuncLoad,
  16709. * ::cuKernelGetAttribute
  16710. */
  16711. CUresult CUDAAPI cuFuncGetAttribute(int *pi, CUfunction_attribute attrib, CUfunction hfunc);
  16712. /**
  16713. * \brief Sets information about a function
  16714. *
  16715. * This call sets the value of a specified attribute \p attrib on the kernel given
  16716. * by \p hfunc to an integer value specified by \p val
  16717. * This function returns CUDA_SUCCESS if the new value of the attribute could be
  16718. * successfully set. If the set fails, this call will return an error.
  16719. * Not all attributes can have values set. Attempting to set a value on a read-only
  16720. * attribute will result in an error (CUDA_ERROR_INVALID_VALUE)
  16721. *
  16722. * Supported attributes for the cuFuncSetAttribute call are:
  16723. * - ::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES: This maximum size in bytes of
  16724. * dynamically-allocated shared memory. The value should contain the requested
  16725. * maximum size of dynamically-allocated shared memory. The sum of this value and
  16726. * the function attribute ::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES cannot exceed the
  16727. * device attribute ::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN.
  16728. * The maximal size of requestable dynamic shared memory may differ by GPU
  16729. * architecture.
  16730. * - ::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT: On devices where the L1
  16731. * cache and shared memory use the same hardware resources, this sets the shared memory
  16732. * carveout preference, in percent of the total shared memory.
  16733. * See ::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR
  16734. * This is only a hint, and the driver can choose a different ratio if required to execute the function.
  16735. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH: The required cluster width in
  16736. * blocks. The width, height, and depth values must either all be 0 or all be
  16737. * positive. The validity of the cluster dimensions is checked at launch time.
  16738. * If the value is set during compile time, it cannot be set at runtime.
  16739. * Setting it at runtime will return CUDA_ERROR_NOT_PERMITTED.
  16740. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT: The required cluster height in
  16741. * blocks. The width, height, and depth values must either all be 0 or all be
  16742. * positive. The validity of the cluster dimensions is checked at launch time.
  16743. * If the value is set during compile time, it cannot be set at runtime.
  16744. * Setting it at runtime will return CUDA_ERROR_NOT_PERMITTED.
  16745. * - ::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH: The required cluster depth in
  16746. * blocks. The width, height, and depth values must either all be 0 or all be
  16747. * positive. The validity of the cluster dimensions is checked at launch time.
  16748. * If the value is set during compile time, it cannot be set at runtime.
  16749. * Setting it at runtime will return CUDA_ERROR_NOT_PERMITTED.
  16750. * - ::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED: Indicates whether
  16751. * the function can be launched with non-portable cluster size. 1 is allowed,
  16752. * 0 is disallowed.
  16753. * - ::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE: The block
  16754. * scheduling policy of a function. The value type is CUclusterSchedulingPolicy.
  16755. *
  16756. * \param hfunc - Function to query attribute of
  16757. * \param attrib - Attribute requested
  16758. * \param value - The value to set
  16759. *
  16760. * \return
  16761. * ::CUDA_SUCCESS,
  16762. * ::CUDA_ERROR_DEINITIALIZED,
  16763. * ::CUDA_ERROR_NOT_INITIALIZED,
  16764. * ::CUDA_ERROR_INVALID_CONTEXT,
  16765. * ::CUDA_ERROR_INVALID_HANDLE,
  16766. * ::CUDA_ERROR_INVALID_VALUE
  16767. * \notefnerr
  16768. *
  16769. * \sa ::cuCtxGetCacheConfig,
  16770. * ::cuCtxSetCacheConfig,
  16771. * ::cuFuncSetCacheConfig,
  16772. * ::cuLaunchKernel,
  16773. * ::cudaFuncGetAttributes,
  16774. * ::cudaFuncSetAttribute,
  16775. * ::cuKernelSetAttribute
  16776. */
  16777. CUresult CUDAAPI cuFuncSetAttribute(CUfunction hfunc, CUfunction_attribute attrib, int value);
  16778. /**
  16779. * \brief Sets the preferred cache configuration for a device function
  16780. *
  16781. * On devices where the L1 cache and shared memory use the same hardware
  16782. * resources, this sets through \p config the preferred cache configuration for
  16783. * the device function \p hfunc. This is only a preference. The driver will use
  16784. * the requested configuration if possible, but it is free to choose a different
  16785. * configuration if required to execute \p hfunc. Any context-wide preference
  16786. * set via ::cuCtxSetCacheConfig() will be overridden by this per-function
  16787. * setting unless the per-function setting is ::CU_FUNC_CACHE_PREFER_NONE. In
  16788. * that case, the current context-wide setting will be used.
  16789. *
  16790. * This setting does nothing on devices where the size of the L1 cache and
  16791. * shared memory are fixed.
  16792. *
  16793. * Launching a kernel with a different preference than the most recent
  16794. * preference setting may insert a device-side synchronization point.
  16795. *
  16796. *
  16797. * The supported cache configurations are:
  16798. * - ::CU_FUNC_CACHE_PREFER_NONE: no preference for shared memory or L1 (default)
  16799. * - ::CU_FUNC_CACHE_PREFER_SHARED: prefer larger shared memory and smaller L1 cache
  16800. * - ::CU_FUNC_CACHE_PREFER_L1: prefer larger L1 cache and smaller shared memory
  16801. * - ::CU_FUNC_CACHE_PREFER_EQUAL: prefer equal sized L1 cache and shared memory
  16802. *
  16803. * \param hfunc - Kernel to configure cache for
  16804. * \param config - Requested cache configuration
  16805. *
  16806. * \return
  16807. * ::CUDA_SUCCESS,
  16808. * ::CUDA_ERROR_INVALID_VALUE,
  16809. * ::CUDA_ERROR_DEINITIALIZED,
  16810. * ::CUDA_ERROR_NOT_INITIALIZED,
  16811. * ::CUDA_ERROR_INVALID_CONTEXT
  16812. * \notefnerr
  16813. *
  16814. * \sa ::cuCtxGetCacheConfig,
  16815. * ::cuCtxSetCacheConfig,
  16816. * ::cuFuncGetAttribute,
  16817. * ::cuLaunchKernel,
  16818. * ::cudaFuncSetCacheConfig,
  16819. * ::cuKernelSetCacheConfig
  16820. */
  16821. CUresult CUDAAPI cuFuncSetCacheConfig(CUfunction hfunc, CUfunc_cache config);
  16822. /**
  16823. * \brief Returns a module handle
  16824. *
  16825. * Returns in \p *hmod the handle of the module that function \p hfunc
  16826. * is located in. The lifetime of the module corresponds to the lifetime of
  16827. * the context it was loaded in or until the module is explicitly unloaded.
  16828. *
  16829. * The CUDA runtime manages its own modules loaded into the primary context.
  16830. * If the handle returned by this API refers to a module loaded by the CUDA runtime,
  16831. * calling ::cuModuleUnload() on that module will result in undefined behavior.
  16832. *
  16833. * \param hmod - Returned module handle
  16834. * \param hfunc - Function to retrieve module for
  16835. *
  16836. * \return
  16837. * ::CUDA_SUCCESS,
  16838. * ::CUDA_ERROR_DEINITIALIZED,
  16839. * ::CUDA_ERROR_NOT_INITIALIZED,
  16840. * ::CUDA_ERROR_INVALID_CONTEXT,
  16841. * ::CUDA_ERROR_INVALID_VALUE,
  16842. * ::CUDA_ERROR_NOT_FOUND
  16843. * \notefnerr
  16844. *
  16845. */
  16846. CUresult CUDAAPI cuFuncGetModule(CUmodule *hmod, CUfunction hfunc);
  16847. /**
  16848. * \brief Returns the function name for a ::CUfunction handle
  16849. *
  16850. * Returns in \p **name the function name associated with the function handle \p hfunc .
  16851. * The function name is returned as a null-terminated string. The returned name is only
  16852. * valid when the function handle is valid. If the module is unloaded or reloaded, one
  16853. * must call the API again to get the updated name. This API may return a mangled name if
  16854. * the function is not declared as having C linkage. If either \p **name or \p hfunc
  16855. * is NULL, ::CUDA_ERROR_INVALID_VALUE is returned.
  16856. *
  16857. * \param name - The returned name of the function
  16858. * \param hfunc - The function handle to retrieve the name for
  16859. *
  16860. * \return
  16861. * ::CUDA_SUCCESS,
  16862. * ::CUDA_ERROR_INVALID_VALUE,
  16863. * \notefnerr
  16864. *
  16865. */
  16866. CUresult CUDAAPI cuFuncGetName(const char **name, CUfunction hfunc);
  16867. /**
  16868. * \brief Returns the offset and size of a kernel parameter in the device-side parameter layout
  16869. *
  16870. * Queries the kernel parameter at \p paramIndex into \p func's list of parameters, and returns
  16871. * in \p paramOffset and \p paramSize the offset and size, respectively, where the parameter
  16872. * will reside in the device-side parameter layout. This information can be used to update kernel
  16873. * node parameters from the device via ::cudaGraphKernelNodeSetParam() and
  16874. * ::cudaGraphKernelNodeUpdatesApply(). \p paramIndex must be less than the number of parameters
  16875. * that \p func takes. \p paramSize can be set to NULL if only the parameter offset is desired.
  16876. *
  16877. * \param func - The function to query
  16878. * \param paramIndex - The parameter index to query
  16879. * \param paramOffset - Returns the offset into the device-side parameter layout at which the parameter resides
  16880. * \param paramSize - Optionally returns the size of the parameter in the device-side parameter layout
  16881. *
  16882. * \return
  16883. * ::CUDA_SUCCESS,
  16884. * ::CUDA_ERROR_INVALID_VALUE,
  16885. * \notefnerr
  16886. *
  16887. * \sa ::cuKernelGetParamInfo
  16888. */
  16889. CUresult CUDAAPI cuFuncGetParamInfo(CUfunction func, size_t paramIndex, size_t *paramOffset, size_t *paramSize);
  16890. typedef enum CUfunctionLoadingState_enum {
  16891. CU_FUNCTION_LOADING_STATE_UNLOADED = 0,
  16892. CU_FUNCTION_LOADING_STATE_LOADED = 1,
  16893. CU_FUNCTION_LOADING_STATE_MAX
  16894. } CUfunctionLoadingState;
  16895. /**
  16896. * \brief Returns if the function is loaded
  16897. *
  16898. * Returns in \p state the loading state of \p function.
  16899. *
  16900. * \param state - returned loading state
  16901. * \param function - the function to check
  16902. *
  16903. * \return
  16904. * ::CUDA_SUCCESS,
  16905. * ::CUDA_ERROR_INVALID_HANDLE,
  16906. * ::CUDA_ERROR_INVALID_VALUE
  16907. *
  16908. * \sa ::cuFuncLoad,
  16909. * ::cuModuleEnumerateFunctions
  16910. */
  16911. CUresult CUDAAPI cuFuncIsLoaded(CUfunctionLoadingState *state, CUfunction function);
  16912. /**
  16913. * \brief Loads a function
  16914. *
  16915. * Finalizes function loading for \p function. Calling this API with a
  16916. * fully loaded function has no effect.
  16917. *
  16918. * \param function - the function to load
  16919. *
  16920. * \return
  16921. * ::CUDA_SUCCESS,
  16922. * ::CUDA_ERROR_INVALID_HANDLE,
  16923. * ::CUDA_ERROR_INVALID_VALUE
  16924. *
  16925. * \sa ::cuModuleEnumerateFunctions,
  16926. * ::cuFuncIsLoaded
  16927. */
  16928. CUresult CUDAAPI cuFuncLoad(CUfunction function);
  16929. /**
  16930. * \brief Launches a CUDA function ::CUfunction or a CUDA kernel ::CUkernel
  16931. *
  16932. * Invokes the function ::CUfunction or the kernel ::CUkernel \p f
  16933. * on a \p gridDimX x \p gridDimY x \p gridDimZ grid of blocks.
  16934. * Each block contains \p blockDimX x \p blockDimY x
  16935. * \p blockDimZ threads.
  16936. *
  16937. * \p sharedMemBytes sets the amount of dynamic shared memory that will be
  16938. * available to each thread block.
  16939. *
  16940. * Kernel parameters to \p f can be specified in one of two ways:
  16941. *
  16942. * 1) Kernel parameters can be specified via \p kernelParams. If \p f
  16943. * has N parameters, then \p kernelParams needs to be an array of N
  16944. * pointers. Each of \p kernelParams[0] through \p kernelParams[N-1]
  16945. * must point to a region of memory from which the actual kernel
  16946. * parameter will be copied. The number of kernel parameters and their
  16947. * offsets and sizes do not need to be specified as that information is
  16948. * retrieved directly from the kernel's image.
  16949. *
  16950. * 2) Kernel parameters can also be packaged by the application into
  16951. * a single buffer that is passed in via the \p extra parameter.
  16952. * This places the burden on the application of knowing each kernel
  16953. * parameter's size and alignment/padding within the buffer. Here is
  16954. * an example of using the \p extra parameter in this manner:
  16955. * \code
  16956. size_t argBufferSize;
  16957. char argBuffer[256];
  16958. // populate argBuffer and argBufferSize
  16959. void *config[] = {
  16960. CU_LAUNCH_PARAM_BUFFER_POINTER, argBuffer,
  16961. CU_LAUNCH_PARAM_BUFFER_SIZE, &argBufferSize,
  16962. CU_LAUNCH_PARAM_END
  16963. };
  16964. status = cuLaunchKernel(f, gx, gy, gz, bx, by, bz, sh, s, NULL, config);
  16965. * \endcode
  16966. *
  16967. * The \p extra parameter exists to allow ::cuLaunchKernel to take
  16968. * additional less commonly used arguments. \p extra specifies a list of
  16969. * names of extra settings and their corresponding values. Each extra
  16970. * setting name is immediately followed by the corresponding value. The
  16971. * list must be terminated with either NULL or ::CU_LAUNCH_PARAM_END.
  16972. *
  16973. * - ::CU_LAUNCH_PARAM_END, which indicates the end of the \p extra
  16974. * array;
  16975. * - ::CU_LAUNCH_PARAM_BUFFER_POINTER, which specifies that the next
  16976. * value in \p extra will be a pointer to a buffer containing all
  16977. * the kernel parameters for launching kernel \p f;
  16978. * - ::CU_LAUNCH_PARAM_BUFFER_SIZE, which specifies that the next
  16979. * value in \p extra will be a pointer to a size_t containing the
  16980. * size of the buffer specified with ::CU_LAUNCH_PARAM_BUFFER_POINTER;
  16981. *
  16982. * The error ::CUDA_ERROR_INVALID_VALUE will be returned if kernel
  16983. * parameters are specified with both \p kernelParams and \p extra
  16984. * (i.e. both \p kernelParams and \p extra are non-NULL).
  16985. *
  16986. * Calling ::cuLaunchKernel() invalidates the persistent function state
  16987. * set through the following deprecated APIs:
  16988. * ::cuFuncSetBlockShape(),
  16989. * ::cuFuncSetSharedSize(),
  16990. * ::cuParamSetSize(),
  16991. * ::cuParamSeti(),
  16992. * ::cuParamSetf(),
  16993. * ::cuParamSetv().
  16994. *
  16995. * Note that to use ::cuLaunchKernel(), the kernel \p f must either have
  16996. * been compiled with toolchain version 3.2 or later so that it will
  16997. * contain kernel parameter information, or have no kernel parameters.
  16998. * If either of these conditions is not met, then ::cuLaunchKernel() will
  16999. * return ::CUDA_ERROR_INVALID_IMAGE.
  17000. *
  17001. * Note that the API can also be used to launch context-less kernel ::CUkernel
  17002. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  17003. * to the API by casting to ::CUfunction. Here, the context to launch
  17004. * the kernel on will either be taken from the specified stream \p hStream
  17005. * or the current context in case of NULL stream.
  17006. *
  17007. * \param f - Function ::CUfunction or Kernel ::CUkernel to launch
  17008. * \param gridDimX - Width of grid in blocks
  17009. * \param gridDimY - Height of grid in blocks
  17010. * \param gridDimZ - Depth of grid in blocks
  17011. * \param blockDimX - X dimension of each thread block
  17012. * \param blockDimY - Y dimension of each thread block
  17013. * \param blockDimZ - Z dimension of each thread block
  17014. * \param sharedMemBytes - Dynamic shared-memory size per thread block in bytes
  17015. * \param hStream - Stream identifier
  17016. * \param kernelParams - Array of pointers to kernel parameters
  17017. * \param extra - Extra options
  17018. *
  17019. * \return
  17020. * ::CUDA_SUCCESS,
  17021. * ::CUDA_ERROR_DEINITIALIZED,
  17022. * ::CUDA_ERROR_NOT_INITIALIZED,
  17023. * ::CUDA_ERROR_INVALID_CONTEXT,
  17024. * ::CUDA_ERROR_INVALID_HANDLE,
  17025. * ::CUDA_ERROR_INVALID_IMAGE,
  17026. * ::CUDA_ERROR_INVALID_VALUE,
  17027. * ::CUDA_ERROR_LAUNCH_FAILED,
  17028. * ::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
  17029. * ::CUDA_ERROR_LAUNCH_TIMEOUT,
  17030. * ::CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
  17031. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
  17032. * ::CUDA_ERROR_NOT_FOUND
  17033. * \note_null_stream
  17034. * \notefnerr
  17035. *
  17036. * \sa ::cuCtxGetCacheConfig,
  17037. * ::cuCtxSetCacheConfig,
  17038. * ::cuFuncSetCacheConfig,
  17039. * ::cuFuncGetAttribute,
  17040. * ::cudaLaunchKernel,
  17041. * ::cuLibraryGetKernel,
  17042. * ::cuKernelSetCacheConfig,
  17043. * ::cuKernelGetAttribute,
  17044. * ::cuKernelSetAttribute
  17045. */
  17046. CUresult CUDAAPI cuLaunchKernel(CUfunction f,
  17047. unsigned int gridDimX,
  17048. unsigned int gridDimY,
  17049. unsigned int gridDimZ,
  17050. unsigned int blockDimX,
  17051. unsigned int blockDimY,
  17052. unsigned int blockDimZ,
  17053. unsigned int sharedMemBytes,
  17054. CUstream hStream,
  17055. void **kernelParams,
  17056. void **extra);
  17057. /**
  17058. * \brief Launches a CUDA function ::CUfunction or a CUDA kernel ::CUkernel with launch-time configuration
  17059. *
  17060. * Invokes the function ::CUfunction or the kernel ::CUkernel \p f with the specified launch-time configuration
  17061. * \p config.
  17062. *
  17063. * The ::CUlaunchConfig structure is defined as:
  17064. *
  17065. * \code
  17066. * typedef struct CUlaunchConfig_st {
  17067. * unsigned int gridDimX;
  17068. * unsigned int gridDimY;
  17069. * unsigned int gridDimZ;
  17070. * unsigned int blockDimX;
  17071. * unsigned int blockDimY;
  17072. * unsigned int blockDimZ;
  17073. * unsigned int sharedMemBytes;
  17074. * CUstream hStream;
  17075. * CUlaunchAttribute *attrs;
  17076. * unsigned int numAttrs;
  17077. * } CUlaunchConfig;
  17078. * \endcode
  17079. *
  17080. * where:
  17081. * - ::CUlaunchConfig::gridDimX is the width of the grid in blocks.
  17082. * - ::CUlaunchConfig::gridDimY is the height of the grid in blocks.
  17083. * - ::CUlaunchConfig::gridDimZ is the depth of the grid in blocks.
  17084. * - ::CUlaunchConfig::blockDimX is the X dimension of each thread block.
  17085. * - ::CUlaunchConfig::blockDimX is the Y dimension of each thread block.
  17086. * - ::CUlaunchConfig::blockDimZ is the Z dimension of each thread block.
  17087. * - ::CUlaunchConfig::sharedMemBytes is the dynamic shared-memory size per
  17088. * thread block in bytes.
  17089. * - ::CUlaunchConfig::hStream is the handle to the stream to perform the launch
  17090. * in. The CUDA context associated with this stream must match that associated
  17091. * with function f.
  17092. * - ::CUlaunchConfig::attrs is an array of ::CUlaunchConfig::numAttrs
  17093. * continguous ::CUlaunchAttribute elements. The value of this pointer is not
  17094. * considered if ::CUlaunchConfig::numAttrs is zero. However, in that case, it
  17095. * is recommended to set the pointer to NULL.
  17096. * - ::CUlaunchConfig::numAttrs is the number of attributes populating the
  17097. * first ::CUlaunchConfig::numAttrs positions of the ::CUlaunchConfig::attrs
  17098. * array.
  17099. *
  17100. * Launch-time configuration is specified by adding entries to
  17101. * ::CUlaunchConfig::attrs. Each entry is an attribute ID and a corresponding
  17102. * attribute value.
  17103. *
  17104. * The ::CUlaunchAttribute structure is defined as:
  17105. * \code
  17106. * typedef struct CUlaunchAttribute_st {
  17107. * CUlaunchAttributeID id;
  17108. * CUlaunchAttributeValue value;
  17109. * } CUlaunchAttribute;
  17110. * \endcode
  17111. * where:
  17112. * - ::CUlaunchAttribute::id is a unique enum identifying the attribute.
  17113. * - ::CUlaunchAttribute::value is a union that hold the attribute value.
  17114. *
  17115. * An example of using the \p config parameter:
  17116. * \code
  17117. * CUlaunchAttribute coopAttr = {.id = CU_LAUNCH_ATTRIBUTE_COOPERATIVE,
  17118. * .value = 1};
  17119. * CUlaunchConfig config = {... // set block and grid dimensions
  17120. * .attrs = &coopAttr,
  17121. * .numAttrs = 1};
  17122. *
  17123. * cuLaunchKernelEx(&config, kernel, NULL, NULL);
  17124. * \endcode
  17125. *
  17126. * The ::CUlaunchAttributeID enum is defined as:
  17127. * \code
  17128. * typedef enum CUlaunchAttributeID_enum {
  17129. * CU_LAUNCH_ATTRIBUTE_IGNORE = 0,
  17130. * CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW = 1,
  17131. * CU_LAUNCH_ATTRIBUTE_COOPERATIVE = 2,
  17132. * CU_LAUNCH_ATTRIBUTE_SYNCHRONIZATION_POLICY = 3,
  17133. * CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION = 4,
  17134. * CU_LAUNCH_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE = 5,
  17135. * CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION = 6,
  17136. * CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT = 7,
  17137. * CU_LAUNCH_ATTRIBUTE_PRIORITY = 8,
  17138. * CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP = 9,
  17139. * CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN = 10,
  17140. * CU_LAUNCH_ATTRIBUTE_PREFERRED_CLUSTER_DIMENSION = 11,
  17141. * CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT = 12,
  17142. * CU_LAUNCH_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE = 13,
  17143. * } CUlaunchAttributeID;
  17144. * \endcode
  17145. *
  17146. * and the corresponding ::CUlaunchAttributeValue union as :
  17147. * \code
  17148. * typedef union CUlaunchAttributeValue_union {
  17149. * CUaccessPolicyWindow accessPolicyWindow;
  17150. * int cooperative;
  17151. * CUsynchronizationPolicy syncPolicy;
  17152. * struct {
  17153. * unsigned int x;
  17154. * unsigned int y;
  17155. * unsigned int z;
  17156. * } clusterDim;
  17157. * CUclusterSchedulingPolicy clusterSchedulingPolicyPreference;
  17158. * int programmaticStreamSerializationAllowed;
  17159. * struct {
  17160. * CUevent event;
  17161. * int flags;
  17162. * int triggerAtBlockStart;
  17163. * } programmaticEvent;
  17164. * int priority;
  17165. * CUlaunchMemSyncDomainMap memSyncDomainMap;
  17166. * CUlaunchMemSyncDomain memSyncDomain;
  17167. * struct {
  17168. * unsigned int x;
  17169. * unsigned int y;
  17170. * unsigned int z;
  17171. * } preferredClusterDim;
  17172. * struct {
  17173. * CUevent event;
  17174. * int flags;
  17175. * } launchCompletionEvent;
  17176. * struct {
  17177. * int deviceUpdatable;
  17178. * CUgraphDeviceNode devNode;
  17179. * } deviceUpdatableKernelNode;
  17180. * } CUlaunchAttributeValue;
  17181. * \endcode
  17182. *
  17183. * Setting ::CU_LAUNCH_ATTRIBUTE_COOPERATIVE to a non-zero value causes the
  17184. * kernel launch to be a cooperative launch, with exactly the same usage and
  17185. * semantics of ::cuLaunchCooperativeKernel.
  17186. *
  17187. * Setting ::CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION to a non-zero
  17188. * values causes the kernel to use programmatic means to resolve its stream
  17189. * dependency -- enabling the CUDA runtime to opportunistically allow the grid's
  17190. * execution to overlap with the previous kernel in the stream, if that kernel
  17191. * requests the overlap.
  17192. *
  17193. * ::CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT records an event along with the
  17194. * kernel launch. Event recorded through this launch attribute is guaranteed to
  17195. * only trigger after all block in the associated kernel trigger the event. A
  17196. * block can trigger the event through PTX launchdep.release or CUDA builtin
  17197. * function cudaTriggerProgrammaticLaunchCompletion(). A trigger can also be
  17198. * inserted at the beginning of each block's execution if triggerAtBlockStart is
  17199. * set to non-0. Note that dependents (including the CPU thread calling
  17200. * cuEventSynchronize()) are not guaranteed to observe the release precisely
  17201. * when it is released. For example, cuEventSynchronize() may only observe the
  17202. * event trigger long after the associated kernel has completed. This recording
  17203. * type is primarily meant for establishing programmatic dependency between
  17204. * device tasks. The event supplied must not be an interprocess or interop
  17205. * event. The event must disable timing (i.e. created with
  17206. * ::CU_EVENT_DISABLE_TIMING flag set).
  17207. *
  17208. * ::CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT records an event along with
  17209. * the kernel launch. Nominally, the event is triggered once all blocks of the
  17210. * kernel have begun execution. Currently this is a best effort. If a kernel B
  17211. * has a launch completion dependency on a kernel A, B may wait until A is
  17212. * complete. Alternatively, blocks of B may begin before all blocks of A have
  17213. * begun, for example:
  17214. *
  17215. * - If B can claim execution resources unavaiable to A, for example if they
  17216. * run on different GPUs.
  17217. * - If B is a higher priority than A.
  17218. *
  17219. * Exercise caution if such an ordering inversion could lead to deadlock. The
  17220. * event supplied must not be an interprocess or interop event. The event must
  17221. * disable timing (i.e. must be created with the ::CU_EVENT_DISABLE_TIMING flag
  17222. * set).
  17223. *
  17224. * Setting ::CU_LAUNCH_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE to 1
  17225. * on a captured launch causes the resulting kernel node to be device-updatable.
  17226. * This attribute is specific to graphs, and passing it to a launch in a
  17227. * non-capturing stream results in an error. Passing a value other than 0 or 1 is
  17228. * not allowed.
  17229. *
  17230. * On success, a handle will be returned via
  17231. * ::CUlaunchAttributeValue::deviceUpdatableKernelNode::devNode which can be passed
  17232. * to the various device-side update functions to update the node's kernel parameters
  17233. * from within another kernel. For more information on the types of device updates
  17234. * that can be made, as well as the relevant limitations thereof, see
  17235. * ::cudaGraphKernelNodeUpdatesApply.
  17236. *
  17237. * Kernel nodes which are device-updatable have additional restrictions compared to regular
  17238. * kernel nodes. Firstly, device-updatable nodes cannot be removed from their graph via
  17239. * ::cuGraphDestroyNode. Additionally, once opted-in to this functionality, a node cannot
  17240. * opt out, and any attempt to set the attribute to 0 will result in an error. Graphs
  17241. * containing one or more device-updatable node also do not allow multiple instantiation.
  17242. *
  17243. * ::CU_LAUNCH_ATTRIBUTE_PREFERRED_CLUSTER_DIMENSION allows the kernel launch to
  17244. * specify a preferred substitute cluster dimension. Blocks may be grouped
  17245. * according to either the dimensions specified with this attribute (grouped
  17246. * into a "preferred substitute cluster"), or the one specified with
  17247. * ::CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION attribute (grouped into a "regular
  17248. * cluster"). The cluster dimensions of a "preferred substitute cluster" shall
  17249. * be an integer multiple greater than zero of the regular cluster dimensions.
  17250. * The device will attempt - on a best-effort basis - to group thread blocks
  17251. * into preferred clusters over grouping them into regular clusters. When it
  17252. * deems necessary (primarily when the device temporarily runs out of physical
  17253. * resources to launch the larger preferred clusters), the device may switch to
  17254. * launch the regular clusters instead to attempt to utilize as much of the
  17255. * physical device resources as possible.
  17256. *
  17257. * Each type of cluster will have its enumeration / coordinate setup as if the
  17258. * grid consists solely of its type of cluster. For example, if the preferred
  17259. * substitute cluster dimensions double the regular cluster dimensions, there
  17260. * might be simultaneously a regular cluster indexed at (1,0,0), and a preferred
  17261. * cluster indexed at (1,0,0). In this example, the preferred substitute cluster
  17262. * (1,0,0) replaces regular clusters (2,0,0) and (3,0,0) and groups their
  17263. * blocks.
  17264. *
  17265. * This attribute will only take effect when a regular cluster dimension has
  17266. * been specified. The preferred substitute The preferred substitute cluster
  17267. * dimension must be an integer multiple greater than zero of the regular
  17268. * cluster dimension and must divide the grid. It must also be no more than
  17269. * `maxBlocksPerCluster`, if it is set in the kernel's `__launch_bounds__`.
  17270. * Otherwise it must be less than the maximum value the driver can support.
  17271. * Otherwise, setting this attribute to a value physically unable to fit on any
  17272. * particular device is permitted.
  17273. *
  17274. * The effect of other attributes is consistent with their effect when set via
  17275. * persistent APIs.
  17276. *
  17277. * See ::cuStreamSetAttribute for
  17278. * - ::CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW
  17279. * - ::CU_LAUNCH_ATTRIBUTE_SYNCHRONIZATION_POLICY
  17280. *
  17281. * See ::cuFuncSetAttribute for
  17282. * - ::CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION
  17283. * - ::CU_LAUNCH_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE
  17284. *
  17285. * Kernel parameters to \p f can be specified in the same ways that they can be
  17286. * using ::cuLaunchKernel.
  17287. *
  17288. * Note that the API can also be used to launch context-less kernel ::CUkernel
  17289. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  17290. * to the API by casting to ::CUfunction. Here, the context to launch
  17291. * the kernel on will either be taken from the specified stream ::CUlaunchConfig::hStream
  17292. * or the current context in case of NULL stream.
  17293. *
  17294. * \param config - Config to launch
  17295. * \param f - Function ::CUfunction or Kernel ::CUkernel to launch
  17296. * \param kernelParams - Array of pointers to kernel parameters
  17297. * \param extra - Extra options
  17298. *
  17299. * \return
  17300. * ::CUDA_SUCCESS,
  17301. * ::CUDA_ERROR_DEINITIALIZED,
  17302. * ::CUDA_ERROR_NOT_INITIALIZED,
  17303. * ::CUDA_ERROR_INVALID_CONTEXT,
  17304. * ::CUDA_ERROR_INVALID_HANDLE,
  17305. * ::CUDA_ERROR_INVALID_IMAGE,
  17306. * ::CUDA_ERROR_INVALID_VALUE,
  17307. * ::CUDA_ERROR_LAUNCH_FAILED,
  17308. * ::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
  17309. * ::CUDA_ERROR_LAUNCH_TIMEOUT,
  17310. * ::CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
  17311. * ::CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE,
  17312. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
  17313. * ::CUDA_ERROR_NOT_FOUND
  17314. * \note_null_stream
  17315. * \notefnerr
  17316. *
  17317. * \sa ::cuCtxGetCacheConfig,
  17318. * ::cuCtxSetCacheConfig,
  17319. * ::cuFuncSetCacheConfig,
  17320. * ::cuFuncGetAttribute,
  17321. * ::cudaLaunchKernel,
  17322. * ::cudaLaunchKernelEx,
  17323. * ::cuLibraryGetKernel,
  17324. * ::cuKernelSetCacheConfig,
  17325. * ::cuKernelGetAttribute,
  17326. * ::cuKernelSetAttribute
  17327. */
  17328. CUresult CUDAAPI cuLaunchKernelEx(const CUlaunchConfig *config,
  17329. CUfunction f,
  17330. void **kernelParams,
  17331. void **extra);
  17332. /**
  17333. * \brief Launches a CUDA function ::CUfunction or a CUDA kernel ::CUkernel where thread blocks
  17334. * can cooperate and synchronize as they execute
  17335. *
  17336. * Invokes the function ::CUfunction or the kernel ::CUkernel \p f on a \p gridDimX x \p gridDimY x \p gridDimZ
  17337. * grid of blocks. Each block contains \p blockDimX x \p blockDimY x
  17338. * \p blockDimZ threads.
  17339. *
  17340. * \p sharedMemBytes sets the amount of dynamic shared memory that will be
  17341. * available to each thread block.
  17342. *
  17343. * The device on which this kernel is invoked must have a non-zero value for
  17344. * the device attribute ::CU_DEVICE_ATTRIBUTE_COOPERATIVE_LAUNCH.
  17345. *
  17346. * The total number of blocks launched cannot exceed the maximum number of blocks per
  17347. * multiprocessor as returned by ::cuOccupancyMaxActiveBlocksPerMultiprocessor (or
  17348. * ::cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors
  17349. * as specified by the device attribute ::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT.
  17350. *
  17351. * The kernel cannot make use of CUDA dynamic parallelism.
  17352. *
  17353. * Kernel parameters must be specified via \p kernelParams. If \p f
  17354. * has N parameters, then \p kernelParams needs to be an array of N
  17355. * pointers. Each of \p kernelParams[0] through \p kernelParams[N-1]
  17356. * must point to a region of memory from which the actual kernel
  17357. * parameter will be copied. The number of kernel parameters and their
  17358. * offsets and sizes do not need to be specified as that information is
  17359. * retrieved directly from the kernel's image.
  17360. *
  17361. * Calling ::cuLaunchCooperativeKernel() sets persistent function state that is
  17362. * the same as function state set through ::cuLaunchKernel API
  17363. *
  17364. * When the kernel \p f is launched via ::cuLaunchCooperativeKernel(), the previous
  17365. * block shape, shared size and parameter info associated with \p f
  17366. * is overwritten.
  17367. *
  17368. * Note that to use ::cuLaunchCooperativeKernel(), the kernel \p f must either have
  17369. * been compiled with toolchain version 3.2 or later so that it will
  17370. * contain kernel parameter information, or have no kernel parameters.
  17371. * If either of these conditions is not met, then ::cuLaunchCooperativeKernel() will
  17372. * return ::CUDA_ERROR_INVALID_IMAGE.
  17373. *
  17374. * Note that the API can also be used to launch context-less kernel ::CUkernel
  17375. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  17376. * to the API by casting to ::CUfunction. Here, the context to launch
  17377. * the kernel on will either be taken from the specified stream \p hStream
  17378. * or the current context in case of NULL stream.
  17379. *
  17380. * \param f - Function ::CUfunction or Kernel ::CUkernel to launch
  17381. * \param gridDimX - Width of grid in blocks
  17382. * \param gridDimY - Height of grid in blocks
  17383. * \param gridDimZ - Depth of grid in blocks
  17384. * \param blockDimX - X dimension of each thread block
  17385. * \param blockDimY - Y dimension of each thread block
  17386. * \param blockDimZ - Z dimension of each thread block
  17387. * \param sharedMemBytes - Dynamic shared-memory size per thread block in bytes
  17388. * \param hStream - Stream identifier
  17389. * \param kernelParams - Array of pointers to kernel parameters
  17390. *
  17391. * \return
  17392. * ::CUDA_SUCCESS,
  17393. * ::CUDA_ERROR_DEINITIALIZED,
  17394. * ::CUDA_ERROR_NOT_INITIALIZED,
  17395. * ::CUDA_ERROR_INVALID_CONTEXT,
  17396. * ::CUDA_ERROR_INVALID_HANDLE,
  17397. * ::CUDA_ERROR_INVALID_IMAGE,
  17398. * ::CUDA_ERROR_INVALID_VALUE,
  17399. * ::CUDA_ERROR_LAUNCH_FAILED,
  17400. * ::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
  17401. * ::CUDA_ERROR_LAUNCH_TIMEOUT,
  17402. * ::CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
  17403. * ::CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE,
  17404. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
  17405. * ::CUDA_ERROR_NOT_FOUND
  17406. * \note_null_stream
  17407. * \notefnerr
  17408. *
  17409. * \sa ::cuCtxGetCacheConfig,
  17410. * ::cuCtxSetCacheConfig,
  17411. * ::cuFuncSetCacheConfig,
  17412. * ::cuFuncGetAttribute,
  17413. * ::cuLaunchCooperativeKernelMultiDevice,
  17414. * ::cudaLaunchCooperativeKernel,
  17415. * ::cuLibraryGetKernel,
  17416. * ::cuKernelSetCacheConfig,
  17417. * ::cuKernelGetAttribute,
  17418. * ::cuKernelSetAttribute
  17419. */
  17420. CUresult CUDAAPI cuLaunchCooperativeKernel(CUfunction f,
  17421. unsigned int gridDimX,
  17422. unsigned int gridDimY,
  17423. unsigned int gridDimZ,
  17424. unsigned int blockDimX,
  17425. unsigned int blockDimY,
  17426. unsigned int blockDimZ,
  17427. unsigned int sharedMemBytes,
  17428. CUstream hStream,
  17429. void **kernelParams);
  17430. /**
  17431. * \brief Launches CUDA functions on multiple devices where thread blocks can cooperate and synchronize as they execute
  17432. *
  17433. * \deprecated This function is deprecated as of CUDA 11.3.
  17434. *
  17435. * Invokes kernels as specified in the \p launchParamsList array where each element
  17436. * of the array specifies all the parameters required to perform a single kernel launch.
  17437. * These kernels can cooperate and synchronize as they execute. The size of the array is
  17438. * specified by \p numDevices.
  17439. *
  17440. * No two kernels can be launched on the same device. All the devices targeted by this
  17441. * multi-device launch must be identical. All devices must have a non-zero value for the
  17442. * device attribute ::CU_DEVICE_ATTRIBUTE_COOPERATIVE_MULTI_DEVICE_LAUNCH.
  17443. *
  17444. * All kernels launched must be identical with respect to the compiled code. Note that
  17445. * any __device__, __constant__ or __managed__ variables present in the module that owns
  17446. * the kernel launched on each device, are independently instantiated on every device.
  17447. * It is the application's responsibility to ensure these variables are initialized and
  17448. * used appropriately.
  17449. *
  17450. * The size of the grids as specified in blocks, the size of the blocks themselves
  17451. * and the amount of shared memory used by each thread block must also match across
  17452. * all launched kernels.
  17453. *
  17454. * The streams used to launch these kernels must have been created via either ::cuStreamCreate
  17455. * or ::cuStreamCreateWithPriority. The NULL stream or ::CU_STREAM_LEGACY or ::CU_STREAM_PER_THREAD
  17456. * cannot be used.
  17457. *
  17458. * The total number of blocks launched per kernel cannot exceed the maximum number of blocks
  17459. * per multiprocessor as returned by ::cuOccupancyMaxActiveBlocksPerMultiprocessor (or
  17460. * ::cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors
  17461. * as specified by the device attribute ::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT. Since the
  17462. * total number of blocks launched per device has to match across all devices, the maximum
  17463. * number of blocks that can be launched per device will be limited by the device with the
  17464. * least number of multiprocessors.
  17465. *
  17466. * The kernels cannot make use of CUDA dynamic parallelism.
  17467. *
  17468. * The ::CUDA_LAUNCH_PARAMS structure is defined as:
  17469. * \code
  17470. typedef struct CUDA_LAUNCH_PARAMS_st
  17471. {
  17472. CUfunction function;
  17473. unsigned int gridDimX;
  17474. unsigned int gridDimY;
  17475. unsigned int gridDimZ;
  17476. unsigned int blockDimX;
  17477. unsigned int blockDimY;
  17478. unsigned int blockDimZ;
  17479. unsigned int sharedMemBytes;
  17480. CUstream hStream;
  17481. void **kernelParams;
  17482. } CUDA_LAUNCH_PARAMS;
  17483. * \endcode
  17484. * where:
  17485. * - ::CUDA_LAUNCH_PARAMS::function specifies the kernel to be launched. All functions must
  17486. * be identical with respect to the compiled code.
  17487. * Note that you can also specify context-less kernel ::CUkernel by querying the handle
  17488. * using ::cuLibraryGetKernel() and then casting to ::CUfunction. In this case, the context to
  17489. * launch the kernel on be taken from the specified stream ::CUDA_LAUNCH_PARAMS::hStream.
  17490. * - ::CUDA_LAUNCH_PARAMS::gridDimX is the width of the grid in blocks. This must match across
  17491. * all kernels launched.
  17492. * - ::CUDA_LAUNCH_PARAMS::gridDimY is the height of the grid in blocks. This must match across
  17493. * all kernels launched.
  17494. * - ::CUDA_LAUNCH_PARAMS::gridDimZ is the depth of the grid in blocks. This must match across
  17495. * all kernels launched.
  17496. * - ::CUDA_LAUNCH_PARAMS::blockDimX is the X dimension of each thread block. This must match across
  17497. * all kernels launched.
  17498. * - ::CUDA_LAUNCH_PARAMS::blockDimX is the Y dimension of each thread block. This must match across
  17499. * all kernels launched.
  17500. * - ::CUDA_LAUNCH_PARAMS::blockDimZ is the Z dimension of each thread block. This must match across
  17501. * all kernels launched.
  17502. * - ::CUDA_LAUNCH_PARAMS::sharedMemBytes is the dynamic shared-memory size per thread block in bytes.
  17503. * This must match across all kernels launched.
  17504. * - ::CUDA_LAUNCH_PARAMS::hStream is the handle to the stream to perform the launch in. This cannot
  17505. * be the NULL stream or ::CU_STREAM_LEGACY or ::CU_STREAM_PER_THREAD. The CUDA context associated
  17506. * with this stream must match that associated with ::CUDA_LAUNCH_PARAMS::function.
  17507. * - ::CUDA_LAUNCH_PARAMS::kernelParams is an array of pointers to kernel parameters. If
  17508. * ::CUDA_LAUNCH_PARAMS::function has N parameters, then ::CUDA_LAUNCH_PARAMS::kernelParams
  17509. * needs to be an array of N pointers. Each of ::CUDA_LAUNCH_PARAMS::kernelParams[0] through
  17510. * ::CUDA_LAUNCH_PARAMS::kernelParams[N-1] must point to a region of memory from which the actual
  17511. * kernel parameter will be copied. The number of kernel parameters and their offsets and sizes
  17512. * do not need to be specified as that information is retrieved directly from the kernel's image.
  17513. *
  17514. * By default, the kernel won't begin execution on any GPU until all prior work in all the specified
  17515. * streams has completed. This behavior can be overridden by specifying the flag
  17516. * ::CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_PRE_LAUNCH_SYNC. When this flag is specified, each kernel
  17517. * will only wait for prior work in the stream corresponding to that GPU to complete before it begins
  17518. * execution.
  17519. *
  17520. * Similarly, by default, any subsequent work pushed in any of the specified streams will not begin
  17521. * execution until the kernels on all GPUs have completed. This behavior can be overridden by specifying
  17522. * the flag ::CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_POST_LAUNCH_SYNC. When this flag is specified,
  17523. * any subsequent work pushed in any of the specified streams will only wait for the kernel launched
  17524. * on the GPU corresponding to that stream to complete before it begins execution.
  17525. *
  17526. * Calling ::cuLaunchCooperativeKernelMultiDevice() sets persistent function state that is
  17527. * the same as function state set through ::cuLaunchKernel API when called individually for each
  17528. * element in \p launchParamsList.
  17529. *
  17530. * When kernels are launched via ::cuLaunchCooperativeKernelMultiDevice(), the previous
  17531. * block shape, shared size and parameter info associated with each ::CUDA_LAUNCH_PARAMS::function
  17532. * in \p launchParamsList is overwritten.
  17533. *
  17534. * Note that to use ::cuLaunchCooperativeKernelMultiDevice(), the kernels must either have
  17535. * been compiled with toolchain version 3.2 or later so that it will
  17536. * contain kernel parameter information, or have no kernel parameters.
  17537. * If either of these conditions is not met, then ::cuLaunchCooperativeKernelMultiDevice() will
  17538. * return ::CUDA_ERROR_INVALID_IMAGE.
  17539. *
  17540. * \param launchParamsList - List of launch parameters, one per device
  17541. * \param numDevices - Size of the \p launchParamsList array
  17542. * \param flags - Flags to control launch behavior
  17543. *
  17544. * \return
  17545. * ::CUDA_SUCCESS,
  17546. * ::CUDA_ERROR_DEINITIALIZED,
  17547. * ::CUDA_ERROR_NOT_INITIALIZED,
  17548. * ::CUDA_ERROR_INVALID_CONTEXT,
  17549. * ::CUDA_ERROR_INVALID_HANDLE,
  17550. * ::CUDA_ERROR_INVALID_IMAGE,
  17551. * ::CUDA_ERROR_INVALID_VALUE,
  17552. * ::CUDA_ERROR_LAUNCH_FAILED,
  17553. * ::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
  17554. * ::CUDA_ERROR_LAUNCH_TIMEOUT,
  17555. * ::CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
  17556. * ::CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE,
  17557. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED
  17558. * \note_null_stream
  17559. * \notefnerr
  17560. *
  17561. * \sa ::cuCtxGetCacheConfig,
  17562. * ::cuCtxSetCacheConfig,
  17563. * ::cuFuncSetCacheConfig,
  17564. * ::cuFuncGetAttribute,
  17565. * ::cuLaunchCooperativeKernel,
  17566. * ::cudaLaunchCooperativeKernelMultiDevice
  17567. */
  17568. __CUDA_DEPRECATED CUresult CUDAAPI cuLaunchCooperativeKernelMultiDevice(CUDA_LAUNCH_PARAMS *launchParamsList, unsigned int numDevices, unsigned int flags);
  17569. /**
  17570. * \brief Enqueues a host function call in a stream
  17571. *
  17572. * Enqueues a host function to run in a stream. The function will be called
  17573. * after currently enqueued work and will block work added after it.
  17574. *
  17575. * The host function must not make any CUDA API calls. Attempting to use a
  17576. * CUDA API may result in ::CUDA_ERROR_NOT_PERMITTED, but this is not required.
  17577. * The host function must not perform any synchronization that may depend on
  17578. * outstanding CUDA work not mandated to run earlier. Host functions without a
  17579. * mandated order (such as in independent streams) execute in undefined order
  17580. * and may be serialized.
  17581. *
  17582. * For the purposes of Unified Memory, execution makes a number of guarantees:
  17583. * <ul>
  17584. * <li>The stream is considered idle for the duration of the function's
  17585. * execution. Thus, for example, the function may always use memory attached
  17586. * to the stream it was enqueued in.</li>
  17587. * <li>The start of execution of the function has the same effect as
  17588. * synchronizing an event recorded in the same stream immediately prior to
  17589. * the function. It thus synchronizes streams which have been "joined"
  17590. * prior to the function.</li>
  17591. * <li>Adding device work to any stream does not have the effect of making
  17592. * the stream active until all preceding host functions and stream callbacks
  17593. * have executed. Thus, for
  17594. * example, a function might use global attached memory even if work has
  17595. * been added to another stream, if the work has been ordered behind the
  17596. * function call with an event.</li>
  17597. * <li>Completion of the function does not cause a stream to become
  17598. * active except as described above. The stream will remain idle
  17599. * if no device work follows the function, and will remain idle across
  17600. * consecutive host functions or stream callbacks without device work in
  17601. * between. Thus, for example,
  17602. * stream synchronization can be done by signaling from a host function at the
  17603. * end of the stream.</li>
  17604. * </ul>
  17605. *
  17606. * Note that, in contrast to ::cuStreamAddCallback, the function will not be
  17607. * called in the event of an error in the CUDA context.
  17608. *
  17609. * \param hStream - Stream to enqueue function call in
  17610. * \param fn - The function to call once preceding stream operations are complete
  17611. * \param userData - User-specified data to be passed to the function
  17612. *
  17613. * \return
  17614. * ::CUDA_SUCCESS,
  17615. * ::CUDA_ERROR_DEINITIALIZED,
  17616. * ::CUDA_ERROR_NOT_INITIALIZED,
  17617. * ::CUDA_ERROR_INVALID_CONTEXT,
  17618. * ::CUDA_ERROR_INVALID_HANDLE,
  17619. * ::CUDA_ERROR_NOT_SUPPORTED
  17620. * \note_null_stream
  17621. * \notefnerr
  17622. *
  17623. * \sa ::cuStreamCreate,
  17624. * ::cuStreamQuery,
  17625. * ::cuStreamSynchronize,
  17626. * ::cuStreamWaitEvent,
  17627. * ::cuStreamDestroy,
  17628. * ::cuMemAllocManaged,
  17629. * ::cuStreamAttachMemAsync,
  17630. * ::cuStreamAddCallback
  17631. */
  17632. CUresult CUDAAPI cuLaunchHostFunc(CUstream hStream, CUhostFn fn, void *userData);
  17633. /** @} */ /* END CUDA_EXEC */
  17634. /**
  17635. * \defgroup CUDA_EXEC_DEPRECATED Execution Control [DEPRECATED]
  17636. *
  17637. * ___MANBRIEF___ deprecated execution control functions of the low-level CUDA
  17638. * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  17639. *
  17640. * This section describes the deprecated execution control functions of the
  17641. * low-level CUDA driver application programming interface.
  17642. *
  17643. * @{
  17644. */
  17645. /**
  17646. * \brief Sets the block-dimensions for the function
  17647. *
  17648. * \deprecated
  17649. *
  17650. * Specifies the \p x, \p y, and \p z dimensions of the thread blocks that are
  17651. * created when the kernel given by \p hfunc is launched.
  17652. *
  17653. * \param hfunc - Kernel to specify dimensions of
  17654. * \param x - X dimension
  17655. * \param y - Y dimension
  17656. * \param z - Z dimension
  17657. *
  17658. * \return
  17659. * ::CUDA_SUCCESS,
  17660. * ::CUDA_ERROR_DEINITIALIZED,
  17661. * ::CUDA_ERROR_NOT_INITIALIZED,
  17662. * ::CUDA_ERROR_INVALID_CONTEXT,
  17663. * ::CUDA_ERROR_INVALID_HANDLE,
  17664. * ::CUDA_ERROR_INVALID_VALUE
  17665. * \notefnerr
  17666. *
  17667. * \sa ::cuFuncSetSharedSize,
  17668. * ::cuFuncSetCacheConfig,
  17669. * ::cuFuncGetAttribute,
  17670. * ::cuParamSetSize,
  17671. * ::cuParamSeti,
  17672. * ::cuParamSetf,
  17673. * ::cuParamSetv,
  17674. * ::cuLaunch,
  17675. * ::cuLaunchGrid,
  17676. * ::cuLaunchGridAsync,
  17677. * ::cuLaunchKernel
  17678. */
  17679. __CUDA_DEPRECATED CUresult CUDAAPI cuFuncSetBlockShape(CUfunction hfunc, int x, int y, int z);
  17680. /**
  17681. * \brief Sets the dynamic shared-memory size for the function
  17682. *
  17683. * \deprecated
  17684. *
  17685. * Sets through \p bytes the amount of dynamic shared memory that will be
  17686. * available to each thread block when the kernel given by \p hfunc is launched.
  17687. *
  17688. * \param hfunc - Kernel to specify dynamic shared-memory size for
  17689. * \param bytes - Dynamic shared-memory size per thread in bytes
  17690. *
  17691. * \return
  17692. * ::CUDA_SUCCESS,
  17693. * ::CUDA_ERROR_DEINITIALIZED,
  17694. * ::CUDA_ERROR_NOT_INITIALIZED,
  17695. * ::CUDA_ERROR_INVALID_CONTEXT,
  17696. * ::CUDA_ERROR_INVALID_HANDLE,
  17697. * ::CUDA_ERROR_INVALID_VALUE
  17698. * \notefnerr
  17699. *
  17700. * \sa ::cuFuncSetBlockShape,
  17701. * ::cuFuncSetCacheConfig,
  17702. * ::cuFuncGetAttribute,
  17703. * ::cuParamSetSize,
  17704. * ::cuParamSeti,
  17705. * ::cuParamSetf,
  17706. * ::cuParamSetv,
  17707. * ::cuLaunch,
  17708. * ::cuLaunchGrid,
  17709. * ::cuLaunchGridAsync,
  17710. * ::cuLaunchKernel
  17711. */
  17712. __CUDA_DEPRECATED CUresult CUDAAPI cuFuncSetSharedSize(CUfunction hfunc, unsigned int bytes);
  17713. /**
  17714. * \brief Sets the parameter size for the function
  17715. *
  17716. * \deprecated
  17717. *
  17718. * Sets through \p numbytes the total size in bytes needed by the function
  17719. * parameters of the kernel corresponding to \p hfunc.
  17720. *
  17721. * \param hfunc - Kernel to set parameter size for
  17722. * \param numbytes - Size of parameter list in bytes
  17723. *
  17724. * \return
  17725. * ::CUDA_SUCCESS,
  17726. * ::CUDA_ERROR_DEINITIALIZED,
  17727. * ::CUDA_ERROR_NOT_INITIALIZED,
  17728. * ::CUDA_ERROR_INVALID_CONTEXT,
  17729. * ::CUDA_ERROR_INVALID_VALUE
  17730. * \notefnerr
  17731. *
  17732. * \sa ::cuFuncSetBlockShape,
  17733. * ::cuFuncSetSharedSize,
  17734. * ::cuFuncGetAttribute,
  17735. * ::cuParamSetf,
  17736. * ::cuParamSeti,
  17737. * ::cuParamSetv,
  17738. * ::cuLaunch,
  17739. * ::cuLaunchGrid,
  17740. * ::cuLaunchGridAsync,
  17741. * ::cuLaunchKernel
  17742. */
  17743. __CUDA_DEPRECATED CUresult CUDAAPI cuParamSetSize(CUfunction hfunc, unsigned int numbytes);
  17744. /**
  17745. * \brief Adds an integer parameter to the function's argument list
  17746. *
  17747. * \deprecated
  17748. *
  17749. * Sets an integer parameter that will be specified the next time the
  17750. * kernel corresponding to \p hfunc will be invoked. \p offset is a byte offset.
  17751. *
  17752. * \param hfunc - Kernel to add parameter to
  17753. * \param offset - Offset to add parameter to argument list
  17754. * \param value - Value of parameter
  17755. *
  17756. * \return
  17757. * ::CUDA_SUCCESS,
  17758. * ::CUDA_ERROR_DEINITIALIZED,
  17759. * ::CUDA_ERROR_NOT_INITIALIZED,
  17760. * ::CUDA_ERROR_INVALID_CONTEXT,
  17761. * ::CUDA_ERROR_INVALID_VALUE
  17762. * \notefnerr
  17763. *
  17764. * \sa ::cuFuncSetBlockShape,
  17765. * ::cuFuncSetSharedSize,
  17766. * ::cuFuncGetAttribute,
  17767. * ::cuParamSetSize,
  17768. * ::cuParamSetf,
  17769. * ::cuParamSetv,
  17770. * ::cuLaunch,
  17771. * ::cuLaunchGrid,
  17772. * ::cuLaunchGridAsync,
  17773. * ::cuLaunchKernel
  17774. */
  17775. __CUDA_DEPRECATED CUresult CUDAAPI cuParamSeti(CUfunction hfunc, int offset, unsigned int value);
  17776. /**
  17777. * \brief Adds a floating-point parameter to the function's argument list
  17778. *
  17779. * \deprecated
  17780. *
  17781. * Sets a floating-point parameter that will be specified the next time the
  17782. * kernel corresponding to \p hfunc will be invoked. \p offset is a byte offset.
  17783. *
  17784. * \param hfunc - Kernel to add parameter to
  17785. * \param offset - Offset to add parameter to argument list
  17786. * \param value - Value of parameter
  17787. *
  17788. * \return
  17789. * ::CUDA_SUCCESS,
  17790. * ::CUDA_ERROR_DEINITIALIZED,
  17791. * ::CUDA_ERROR_NOT_INITIALIZED,
  17792. * ::CUDA_ERROR_INVALID_CONTEXT,
  17793. * ::CUDA_ERROR_INVALID_VALUE
  17794. * \notefnerr
  17795. *
  17796. * \sa ::cuFuncSetBlockShape,
  17797. * ::cuFuncSetSharedSize,
  17798. * ::cuFuncGetAttribute,
  17799. * ::cuParamSetSize,
  17800. * ::cuParamSeti,
  17801. * ::cuParamSetv,
  17802. * ::cuLaunch,
  17803. * ::cuLaunchGrid,
  17804. * ::cuLaunchGridAsync,
  17805. * ::cuLaunchKernel
  17806. */
  17807. __CUDA_DEPRECATED CUresult CUDAAPI cuParamSetf(CUfunction hfunc, int offset, float value);
  17808. /**
  17809. * \brief Adds arbitrary data to the function's argument list
  17810. *
  17811. * \deprecated
  17812. *
  17813. * Copies an arbitrary amount of data (specified in \p numbytes) from \p ptr
  17814. * into the parameter space of the kernel corresponding to \p hfunc. \p offset
  17815. * is a byte offset.
  17816. *
  17817. * \param hfunc - Kernel to add data to
  17818. * \param offset - Offset to add data to argument list
  17819. * \param ptr - Pointer to arbitrary data
  17820. * \param numbytes - Size of data to copy in bytes
  17821. *
  17822. * \return
  17823. * ::CUDA_SUCCESS,
  17824. * ::CUDA_ERROR_DEINITIALIZED,
  17825. * ::CUDA_ERROR_NOT_INITIALIZED,
  17826. * ::CUDA_ERROR_INVALID_CONTEXT,
  17827. * ::CUDA_ERROR_INVALID_VALUE
  17828. * \notefnerr
  17829. *
  17830. * \sa ::cuFuncSetBlockShape,
  17831. * ::cuFuncSetSharedSize,
  17832. * ::cuFuncGetAttribute,
  17833. * ::cuParamSetSize,
  17834. * ::cuParamSetf,
  17835. * ::cuParamSeti,
  17836. * ::cuLaunch,
  17837. * ::cuLaunchGrid,
  17838. * ::cuLaunchGridAsync,
  17839. * ::cuLaunchKernel
  17840. */
  17841. __CUDA_DEPRECATED CUresult CUDAAPI cuParamSetv(CUfunction hfunc, int offset, void *ptr, unsigned int numbytes);
  17842. /**
  17843. * \brief Launches a CUDA function
  17844. *
  17845. * \deprecated
  17846. *
  17847. * Invokes the kernel \p f on a 1 x 1 x 1 grid of blocks. The block
  17848. * contains the number of threads specified by a previous call to
  17849. * ::cuFuncSetBlockShape().
  17850. *
  17851. * The block shape, dynamic shared memory size, and parameter information
  17852. * must be set using
  17853. * ::cuFuncSetBlockShape(),
  17854. * ::cuFuncSetSharedSize(),
  17855. * ::cuParamSetSize(),
  17856. * ::cuParamSeti(),
  17857. * ::cuParamSetf(), and
  17858. * ::cuParamSetv()
  17859. * prior to calling this function.
  17860. *
  17861. * Launching a function via ::cuLaunchKernel() invalidates the function's
  17862. * block shape, dynamic shared memory size, and parameter information. After
  17863. * launching via cuLaunchKernel, this state must be re-initialized prior to
  17864. * calling this function. Failure to do so results in undefined behavior.
  17865. *
  17866. * \param f - Kernel to launch
  17867. *
  17868. * \return
  17869. * ::CUDA_SUCCESS,
  17870. * ::CUDA_ERROR_DEINITIALIZED,
  17871. * ::CUDA_ERROR_NOT_INITIALIZED,
  17872. * ::CUDA_ERROR_INVALID_CONTEXT,
  17873. * ::CUDA_ERROR_INVALID_VALUE,
  17874. * ::CUDA_ERROR_LAUNCH_FAILED,
  17875. * ::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
  17876. * ::CUDA_ERROR_LAUNCH_TIMEOUT,
  17877. * ::CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
  17878. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED
  17879. * \notefnerr
  17880. *
  17881. * \sa ::cuFuncSetBlockShape,
  17882. * ::cuFuncSetSharedSize,
  17883. * ::cuFuncGetAttribute,
  17884. * ::cuParamSetSize,
  17885. * ::cuParamSetf,
  17886. * ::cuParamSeti,
  17887. * ::cuParamSetv,
  17888. * ::cuLaunchGrid,
  17889. * ::cuLaunchGridAsync,
  17890. * ::cuLaunchKernel
  17891. */
  17892. __CUDA_DEPRECATED CUresult CUDAAPI cuLaunch(CUfunction f);
  17893. /**
  17894. * \brief Launches a CUDA function
  17895. *
  17896. * \deprecated
  17897. *
  17898. * Invokes the kernel \p f on a \p grid_width x \p grid_height grid of
  17899. * blocks. Each block contains the number of threads specified by a previous
  17900. * call to ::cuFuncSetBlockShape().
  17901. *
  17902. * The block shape, dynamic shared memory size, and parameter information
  17903. * must be set using
  17904. * ::cuFuncSetBlockShape(),
  17905. * ::cuFuncSetSharedSize(),
  17906. * ::cuParamSetSize(),
  17907. * ::cuParamSeti(),
  17908. * ::cuParamSetf(), and
  17909. * ::cuParamSetv()
  17910. * prior to calling this function.
  17911. *
  17912. * Launching a function via ::cuLaunchKernel() invalidates the function's
  17913. * block shape, dynamic shared memory size, and parameter information. After
  17914. * launching via cuLaunchKernel, this state must be re-initialized prior to
  17915. * calling this function. Failure to do so results in undefined behavior.
  17916. *
  17917. * \param f - Kernel to launch
  17918. * \param grid_width - Width of grid in blocks
  17919. * \param grid_height - Height of grid in blocks
  17920. *
  17921. * \return
  17922. * ::CUDA_SUCCESS,
  17923. * ::CUDA_ERROR_DEINITIALIZED,
  17924. * ::CUDA_ERROR_NOT_INITIALIZED,
  17925. * ::CUDA_ERROR_INVALID_CONTEXT,
  17926. * ::CUDA_ERROR_INVALID_VALUE,
  17927. * ::CUDA_ERROR_LAUNCH_FAILED,
  17928. * ::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
  17929. * ::CUDA_ERROR_LAUNCH_TIMEOUT,
  17930. * ::CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
  17931. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED
  17932. * \notefnerr
  17933. *
  17934. * \sa ::cuFuncSetBlockShape,
  17935. * ::cuFuncSetSharedSize,
  17936. * ::cuFuncGetAttribute,
  17937. * ::cuParamSetSize,
  17938. * ::cuParamSetf,
  17939. * ::cuParamSeti,
  17940. * ::cuParamSetv,
  17941. * ::cuLaunch,
  17942. * ::cuLaunchGridAsync,
  17943. * ::cuLaunchKernel
  17944. */
  17945. __CUDA_DEPRECATED CUresult CUDAAPI cuLaunchGrid(CUfunction f, int grid_width, int grid_height);
  17946. /**
  17947. * \brief Launches a CUDA function
  17948. *
  17949. * \deprecated
  17950. *
  17951. * Invokes the kernel \p f on a \p grid_width x \p grid_height grid of
  17952. * blocks. Each block contains the number of threads specified by a previous
  17953. * call to ::cuFuncSetBlockShape().
  17954. *
  17955. * The block shape, dynamic shared memory size, and parameter information
  17956. * must be set using
  17957. * ::cuFuncSetBlockShape(),
  17958. * ::cuFuncSetSharedSize(),
  17959. * ::cuParamSetSize(),
  17960. * ::cuParamSeti(),
  17961. * ::cuParamSetf(), and
  17962. * ::cuParamSetv()
  17963. * prior to calling this function.
  17964. *
  17965. * Launching a function via ::cuLaunchKernel() invalidates the function's
  17966. * block shape, dynamic shared memory size, and parameter information. After
  17967. * launching via cuLaunchKernel, this state must be re-initialized prior to
  17968. * calling this function. Failure to do so results in undefined behavior.
  17969. *
  17970. * \param f - Kernel to launch
  17971. * \param grid_width - Width of grid in blocks
  17972. * \param grid_height - Height of grid in blocks
  17973. * \param hStream - Stream identifier
  17974. *
  17975. * \return
  17976. * ::CUDA_SUCCESS,
  17977. * ::CUDA_ERROR_DEINITIALIZED,
  17978. * ::CUDA_ERROR_NOT_INITIALIZED,
  17979. * ::CUDA_ERROR_INVALID_CONTEXT,
  17980. * ::CUDA_ERROR_INVALID_HANDLE,
  17981. * ::CUDA_ERROR_INVALID_VALUE,
  17982. * ::CUDA_ERROR_LAUNCH_FAILED,
  17983. * ::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
  17984. * ::CUDA_ERROR_LAUNCH_TIMEOUT,
  17985. * ::CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
  17986. * ::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED
  17987. *
  17988. * \note In certain cases where cubins are created with no ABI (i.e., using \p ptxas \p --abi-compile \p no),
  17989. * this function may serialize kernel launches. The CUDA driver retains asynchronous behavior by
  17990. * growing the per-thread stack as needed per launch and not shrinking it afterwards.
  17991. *
  17992. * \note_null_stream
  17993. * \notefnerr
  17994. *
  17995. * \sa ::cuFuncSetBlockShape,
  17996. * ::cuFuncSetSharedSize,
  17997. * ::cuFuncGetAttribute,
  17998. * ::cuParamSetSize,
  17999. * ::cuParamSetf,
  18000. * ::cuParamSeti,
  18001. * ::cuParamSetv,
  18002. * ::cuLaunch,
  18003. * ::cuLaunchGrid,
  18004. * ::cuLaunchKernel
  18005. */
  18006. __CUDA_DEPRECATED CUresult CUDAAPI cuLaunchGridAsync(CUfunction f, int grid_width, int grid_height, CUstream hStream);
  18007. /**
  18008. * \brief Adds a texture-reference to the function's argument list
  18009. *
  18010. * \deprecated
  18011. *
  18012. * Makes the CUDA array or linear memory bound to the texture reference
  18013. * \p hTexRef available to a device program as a texture. In this version of
  18014. * CUDA, the texture-reference must be obtained via ::cuModuleGetTexRef() and
  18015. * the \p texunit parameter must be set to ::CU_PARAM_TR_DEFAULT.
  18016. *
  18017. * \param hfunc - Kernel to add texture-reference to
  18018. * \param texunit - Texture unit (must be ::CU_PARAM_TR_DEFAULT)
  18019. * \param hTexRef - Texture-reference to add to argument list
  18020. *
  18021. * \return
  18022. * ::CUDA_SUCCESS,
  18023. * ::CUDA_ERROR_DEINITIALIZED,
  18024. * ::CUDA_ERROR_NOT_INITIALIZED,
  18025. * ::CUDA_ERROR_INVALID_CONTEXT,
  18026. * ::CUDA_ERROR_INVALID_VALUE
  18027. * \notefnerr
  18028. */
  18029. __CUDA_DEPRECATED CUresult CUDAAPI cuParamSetTexRef(CUfunction hfunc, int texunit, CUtexref hTexRef);
  18030. /**
  18031. * \brief Sets the shared memory configuration for a device function.
  18032. *
  18033. * \deprecated
  18034. *
  18035. * On devices with configurable shared memory banks, this function will
  18036. * force all subsequent launches of the specified device function to have
  18037. * the given shared memory bank size configuration. On any given launch of the
  18038. * function, the shared memory configuration of the device will be temporarily
  18039. * changed if needed to suit the function's preferred configuration. Changes in
  18040. * shared memory configuration between subsequent launches of functions,
  18041. * may introduce a device side synchronization point.
  18042. *
  18043. * Any per-function setting of shared memory bank size set via
  18044. * ::cuFuncSetSharedMemConfig will override the context wide setting set with
  18045. * ::cuCtxSetSharedMemConfig.
  18046. *
  18047. * Changing the shared memory bank size will not increase shared memory usage
  18048. * or affect occupancy of kernels, but may have major effects on performance.
  18049. * Larger bank sizes will allow for greater potential bandwidth to shared memory,
  18050. * but will change what kinds of accesses to shared memory will result in bank
  18051. * conflicts.
  18052. *
  18053. * This function will do nothing on devices with fixed shared memory bank size.
  18054. *
  18055. * The supported bank configurations are:
  18056. * - ::CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE: use the context's shared memory
  18057. * configuration when launching this function.
  18058. * - ::CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE: set shared memory bank width to
  18059. * be natively four bytes when launching this function.
  18060. * - ::CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE: set shared memory bank width to
  18061. * be natively eight bytes when launching this function.
  18062. *
  18063. * \param hfunc - kernel to be given a shared memory config
  18064. * \param config - requested shared memory configuration
  18065. *
  18066. * \return
  18067. * ::CUDA_SUCCESS,
  18068. * ::CUDA_ERROR_INVALID_VALUE,
  18069. * ::CUDA_ERROR_DEINITIALIZED,
  18070. * ::CUDA_ERROR_NOT_INITIALIZED,
  18071. * ::CUDA_ERROR_INVALID_CONTEXT
  18072. * \notefnerr
  18073. *
  18074. * \sa ::cuCtxGetCacheConfig,
  18075. * ::cuCtxSetCacheConfig,
  18076. * ::cuCtxGetSharedMemConfig,
  18077. * ::cuCtxSetSharedMemConfig,
  18078. * ::cuFuncGetAttribute,
  18079. * ::cuLaunchKernel,
  18080. * ::cudaFuncSetSharedMemConfig
  18081. */
  18082. __CUDA_DEPRECATED CUresult CUDAAPI cuFuncSetSharedMemConfig(CUfunction hfunc, CUsharedconfig config);
  18083. /** @} */ /* END CUDA_EXEC_DEPRECATED */
  18084. /**
  18085. * \defgroup CUDA_GRAPH Graph Management
  18086. *
  18087. * ___MANBRIEF___ graph management functions of the low-level CUDA driver API
  18088. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  18089. *
  18090. * This section describes the graph management functions of the low-level CUDA
  18091. * driver application programming interface.
  18092. *
  18093. * @{
  18094. */
  18095. /**
  18096. * \brief Creates a graph
  18097. *
  18098. * Creates an empty graph, which is returned via \p phGraph.
  18099. *
  18100. * \param phGraph - Returns newly created graph
  18101. * \param flags - Graph creation flags, must be 0
  18102. *
  18103. * \return
  18104. * ::CUDA_SUCCESS,
  18105. * ::CUDA_ERROR_DEINITIALIZED,
  18106. * ::CUDA_ERROR_NOT_INITIALIZED,
  18107. * ::CUDA_ERROR_INVALID_VALUE,
  18108. * ::CUDA_ERROR_OUT_OF_MEMORY
  18109. * \note_graph_thread_safety
  18110. * \notefnerr
  18111. *
  18112. * \sa
  18113. * ::cuGraphAddChildGraphNode,
  18114. * ::cuGraphAddEmptyNode,
  18115. * ::cuGraphAddKernelNode,
  18116. * ::cuGraphAddHostNode,
  18117. * ::cuGraphAddMemcpyNode,
  18118. * ::cuGraphAddMemsetNode,
  18119. * ::cuGraphInstantiate,
  18120. * ::cuGraphDestroy,
  18121. * ::cuGraphGetNodes,
  18122. * ::cuGraphGetRootNodes,
  18123. * ::cuGraphGetEdges,
  18124. * ::cuGraphClone
  18125. */
  18126. CUresult CUDAAPI cuGraphCreate(CUgraph *phGraph, unsigned int flags);
  18127. /**
  18128. * \brief Creates a kernel execution node and adds it to a graph
  18129. *
  18130. * Creates a new kernel execution node and adds it to \p hGraph with \p numDependencies
  18131. * dependencies specified via \p dependencies and arguments specified in \p nodeParams.
  18132. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  18133. * at the root of the graph. \p dependencies may not have any duplicate entries.
  18134. * A handle to the new node will be returned in \p phGraphNode.
  18135. *
  18136. * The CUDA_KERNEL_NODE_PARAMS structure is defined as:
  18137. *
  18138. * \code
  18139. * typedef struct CUDA_KERNEL_NODE_PARAMS_st {
  18140. * CUfunction func;
  18141. * unsigned int gridDimX;
  18142. * unsigned int gridDimY;
  18143. * unsigned int gridDimZ;
  18144. * unsigned int blockDimX;
  18145. * unsigned int blockDimY;
  18146. * unsigned int blockDimZ;
  18147. * unsigned int sharedMemBytes;
  18148. * void **kernelParams;
  18149. * void **extra;
  18150. * CUkernel kern;
  18151. * CUcontext ctx;
  18152. * } CUDA_KERNEL_NODE_PARAMS;
  18153. * \endcode
  18154. *
  18155. * When the graph is launched, the node will invoke kernel \p func on a (\p gridDimX x
  18156. * \p gridDimY x \p gridDimZ) grid of blocks. Each block contains
  18157. * (\p blockDimX x \p blockDimY x \p blockDimZ) threads.
  18158. *
  18159. * \p sharedMemBytes sets the amount of dynamic shared memory that will be
  18160. * available to each thread block.
  18161. *
  18162. * Kernel parameters to \p func can be specified in one of two ways:
  18163. *
  18164. * 1) Kernel parameters can be specified via \p kernelParams. If the kernel has N
  18165. * parameters, then \p kernelParams needs to be an array of N pointers. Each pointer,
  18166. * from \p kernelParams[0] to \p kernelParams[N-1], points to the region of memory from which the actual
  18167. * parameter will be copied. The number of kernel parameters and their offsets and sizes do not need
  18168. * to be specified as that information is retrieved directly from the kernel's image.
  18169. *
  18170. * 2) Kernel parameters for non-cooperative kernels can also be packaged by the application into a single
  18171. * buffer that is passed in via \p extra. This places the burden on the application of knowing each
  18172. * kernel parameter's size and alignment/padding within the buffer. The \p extra parameter exists
  18173. * to allow this function to take additional less commonly used arguments. \p extra specifies
  18174. * a list of names of extra settings and their corresponding values. Each extra setting name is
  18175. * immediately followed by the corresponding value. The list must be terminated with either NULL or
  18176. * CU_LAUNCH_PARAM_END.
  18177. *
  18178. * - ::CU_LAUNCH_PARAM_END, which indicates the end of the \p extra
  18179. * array;
  18180. * - ::CU_LAUNCH_PARAM_BUFFER_POINTER, which specifies that the next
  18181. * value in \p extra will be a pointer to a buffer
  18182. * containing all the kernel parameters for launching kernel
  18183. * \p func;
  18184. * - ::CU_LAUNCH_PARAM_BUFFER_SIZE, which specifies that the next
  18185. * value in \p extra will be a pointer to a size_t
  18186. * containing the size of the buffer specified with
  18187. * ::CU_LAUNCH_PARAM_BUFFER_POINTER;
  18188. *
  18189. * The error ::CUDA_ERROR_INVALID_VALUE will be returned if kernel parameters are specified with both
  18190. * \p kernelParams and \p extra (i.e. both \p kernelParams and \p extra are non-NULL).
  18191. * ::CUDA_ERROR_INVALID_VALUE will be returned if \p extra is used for a cooperative kernel.
  18192. *
  18193. * The \p kernelParams or \p extra array, as well as the argument values it points to,
  18194. * are copied during this call.
  18195. *
  18196. * \note Kernels launched using graphs must not use texture and surface references. Reading or
  18197. * writing through any texture or surface reference is undefined behavior.
  18198. * This restriction does not apply to texture and surface objects.
  18199. *
  18200. * \param phGraphNode - Returns newly created node
  18201. * \param hGraph - Graph to which to add the node
  18202. * \param dependencies - Dependencies of the node
  18203. * \param numDependencies - Number of dependencies
  18204. * \param nodeParams - Parameters for the GPU execution node
  18205. *
  18206. * \return
  18207. * ::CUDA_SUCCESS,
  18208. * ::CUDA_ERROR_DEINITIALIZED,
  18209. * ::CUDA_ERROR_NOT_INITIALIZED,
  18210. * ::CUDA_ERROR_INVALID_VALUE
  18211. * \note_graph_thread_safety
  18212. * \notefnerr
  18213. *
  18214. * \sa
  18215. * ::cuGraphAddNode,
  18216. * ::cuLaunchKernel,
  18217. * ::cuLaunchCooperativeKernel,
  18218. * ::cuGraphKernelNodeGetParams,
  18219. * ::cuGraphKernelNodeSetParams,
  18220. * ::cuGraphCreate,
  18221. * ::cuGraphDestroyNode,
  18222. * ::cuGraphAddChildGraphNode,
  18223. * ::cuGraphAddEmptyNode,
  18224. * ::cuGraphAddHostNode,
  18225. * ::cuGraphAddMemcpyNode,
  18226. * ::cuGraphAddMemsetNode
  18227. */
  18228. CUresult CUDAAPI cuGraphAddKernelNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, const CUDA_KERNEL_NODE_PARAMS *nodeParams);
  18229. /**
  18230. * \brief Returns a kernel node's parameters
  18231. *
  18232. * Returns the parameters of kernel node \p hNode in \p nodeParams.
  18233. * The \p kernelParams or \p extra array returned in \p nodeParams,
  18234. * as well as the argument values it points to, are owned by the node.
  18235. * This memory remains valid until the node is destroyed or its
  18236. * parameters are modified, and should not be modified
  18237. * directly. Use ::cuGraphKernelNodeSetParams to update the
  18238. * parameters of this node.
  18239. *
  18240. * The params will contain either \p kernelParams or \p extra,
  18241. * according to which of these was most recently set on the node.
  18242. *
  18243. * \param hNode - Node to get the parameters for
  18244. * \param nodeParams - Pointer to return the parameters
  18245. *
  18246. * \return
  18247. * ::CUDA_SUCCESS,
  18248. * ::CUDA_ERROR_DEINITIALIZED,
  18249. * ::CUDA_ERROR_NOT_INITIALIZED,
  18250. * ::CUDA_ERROR_INVALID_VALUE
  18251. * \note_graph_thread_safety
  18252. * \notefnerr
  18253. *
  18254. * \sa
  18255. * ::cuLaunchKernel,
  18256. * ::cuGraphAddKernelNode,
  18257. * ::cuGraphKernelNodeSetParams
  18258. */
  18259. CUresult CUDAAPI cuGraphKernelNodeGetParams(CUgraphNode hNode, CUDA_KERNEL_NODE_PARAMS *nodeParams);
  18260. /**
  18261. * \brief Sets a kernel node's parameters
  18262. *
  18263. * Sets the parameters of kernel node \p hNode to \p nodeParams.
  18264. *
  18265. * \param hNode - Node to set the parameters for
  18266. * \param nodeParams - Parameters to copy
  18267. *
  18268. * \return
  18269. * ::CUDA_SUCCESS,
  18270. * ::CUDA_ERROR_INVALID_VALUE,
  18271. * ::CUDA_ERROR_INVALID_HANDLE,
  18272. * ::CUDA_ERROR_OUT_OF_MEMORY
  18273. * \note_graph_thread_safety
  18274. * \notefnerr
  18275. *
  18276. * \sa
  18277. * ::cuGraphNodeSetParams,
  18278. * ::cuLaunchKernel,
  18279. * ::cuGraphAddKernelNode,
  18280. * ::cuGraphKernelNodeGetParams
  18281. */
  18282. CUresult CUDAAPI cuGraphKernelNodeSetParams(CUgraphNode hNode, const CUDA_KERNEL_NODE_PARAMS *nodeParams);
  18283. /**
  18284. * \brief Creates a memcpy node and adds it to a graph
  18285. *
  18286. * Creates a new memcpy node and adds it to \p hGraph with \p numDependencies
  18287. * dependencies specified via \p dependencies.
  18288. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  18289. * at the root of the graph. \p dependencies may not have any duplicate entries.
  18290. * A handle to the new node will be returned in \p phGraphNode.
  18291. *
  18292. * When the graph is launched, the node will perform the memcpy described by \p copyParams.
  18293. * See ::cuMemcpy3D() for a description of the structure and its restrictions.
  18294. *
  18295. * Memcpy nodes have some additional restrictions with regards to managed memory, if the
  18296. * system contains at least one device which has a zero value for the device attribute
  18297. * ::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS. If one or more of the operands refer
  18298. * to managed memory, then using the memory type ::CU_MEMORYTYPE_UNIFIED is disallowed
  18299. * for those operand(s). The managed memory will be treated as residing on either the
  18300. * host or the device, depending on which memory type is specified.
  18301. *
  18302. * \param phGraphNode - Returns newly created node
  18303. * \param hGraph - Graph to which to add the node
  18304. * \param dependencies - Dependencies of the node
  18305. * \param numDependencies - Number of dependencies
  18306. * \param copyParams - Parameters for the memory copy
  18307. * \param ctx - Context on which to run the node
  18308. *
  18309. * \return
  18310. * ::CUDA_SUCCESS,
  18311. * ::CUDA_ERROR_DEINITIALIZED,
  18312. * ::CUDA_ERROR_NOT_INITIALIZED,
  18313. * ::CUDA_ERROR_INVALID_VALUE
  18314. * \note_graph_thread_safety
  18315. * \notefnerr
  18316. *
  18317. * \sa
  18318. * ::cuGraphAddNode,
  18319. * ::cuMemcpy3D,
  18320. * ::cuGraphMemcpyNodeGetParams,
  18321. * ::cuGraphMemcpyNodeSetParams,
  18322. * ::cuGraphCreate,
  18323. * ::cuGraphDestroyNode,
  18324. * ::cuGraphAddChildGraphNode,
  18325. * ::cuGraphAddEmptyNode,
  18326. * ::cuGraphAddKernelNode,
  18327. * ::cuGraphAddHostNode,
  18328. * ::cuGraphAddMemsetNode
  18329. */
  18330. CUresult CUDAAPI cuGraphAddMemcpyNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, const CUDA_MEMCPY3D *copyParams, CUcontext ctx);
  18331. /**
  18332. * \brief Returns a memcpy node's parameters
  18333. *
  18334. * Returns the parameters of memcpy node \p hNode in \p nodeParams.
  18335. *
  18336. * \param hNode - Node to get the parameters for
  18337. * \param nodeParams - Pointer to return the parameters
  18338. *
  18339. * \return
  18340. * ::CUDA_SUCCESS,
  18341. * ::CUDA_ERROR_DEINITIALIZED,
  18342. * ::CUDA_ERROR_NOT_INITIALIZED,
  18343. * ::CUDA_ERROR_INVALID_VALUE
  18344. * \note_graph_thread_safety
  18345. * \notefnerr
  18346. *
  18347. * \sa
  18348. * ::cuMemcpy3D,
  18349. * ::cuGraphAddMemcpyNode,
  18350. * ::cuGraphMemcpyNodeSetParams
  18351. */
  18352. CUresult CUDAAPI cuGraphMemcpyNodeGetParams(CUgraphNode hNode, CUDA_MEMCPY3D *nodeParams);
  18353. /**
  18354. * \brief Sets a memcpy node's parameters
  18355. *
  18356. * Sets the parameters of memcpy node \p hNode to \p nodeParams.
  18357. *
  18358. * \param hNode - Node to set the parameters for
  18359. * \param nodeParams - Parameters to copy
  18360. *
  18361. * \return
  18362. * ::CUDA_SUCCESS,
  18363. * ::CUDA_ERROR_DEINITIALIZED,
  18364. * ::CUDA_ERROR_NOT_INITIALIZED,
  18365. * ::CUDA_ERROR_INVALID_VALUE,
  18366. * \note_graph_thread_safety
  18367. * \notefnerr
  18368. *
  18369. * \sa
  18370. * ::cuGraphNodeSetParams,
  18371. * ::cuMemcpy3D,
  18372. * ::cuGraphAddMemcpyNode,
  18373. * ::cuGraphMemcpyNodeGetParams
  18374. */
  18375. CUresult CUDAAPI cuGraphMemcpyNodeSetParams(CUgraphNode hNode, const CUDA_MEMCPY3D *nodeParams);
  18376. /**
  18377. * \brief Creates a memset node and adds it to a graph
  18378. *
  18379. * Creates a new memset node and adds it to \p hGraph with \p numDependencies
  18380. * dependencies specified via \p dependencies.
  18381. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  18382. * at the root of the graph. \p dependencies may not have any duplicate entries.
  18383. * A handle to the new node will be returned in \p phGraphNode.
  18384. *
  18385. * The element size must be 1, 2, or 4 bytes.
  18386. * When the graph is launched, the node will perform the memset described by \p memsetParams.
  18387. *
  18388. * \param phGraphNode - Returns newly created node
  18389. * \param hGraph - Graph to which to add the node
  18390. * \param dependencies - Dependencies of the node
  18391. * \param numDependencies - Number of dependencies
  18392. * \param memsetParams - Parameters for the memory set
  18393. * \param ctx - Context on which to run the node
  18394. *
  18395. * \return
  18396. * ::CUDA_SUCCESS,
  18397. * ::CUDA_ERROR_DEINITIALIZED,
  18398. * ::CUDA_ERROR_NOT_INITIALIZED,
  18399. * ::CUDA_ERROR_INVALID_VALUE,
  18400. * ::CUDA_ERROR_INVALID_CONTEXT
  18401. * \note_graph_thread_safety
  18402. * \notefnerr
  18403. *
  18404. * \sa
  18405. * ::cuGraphAddNode,
  18406. * ::cuMemsetD2D32,
  18407. * ::cuGraphMemsetNodeGetParams,
  18408. * ::cuGraphMemsetNodeSetParams,
  18409. * ::cuGraphCreate,
  18410. * ::cuGraphDestroyNode,
  18411. * ::cuGraphAddChildGraphNode,
  18412. * ::cuGraphAddEmptyNode,
  18413. * ::cuGraphAddKernelNode,
  18414. * ::cuGraphAddHostNode,
  18415. * ::cuGraphAddMemcpyNode
  18416. */
  18417. CUresult CUDAAPI cuGraphAddMemsetNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, const CUDA_MEMSET_NODE_PARAMS *memsetParams, CUcontext ctx);
  18418. /**
  18419. * \brief Returns a memset node's parameters
  18420. *
  18421. * Returns the parameters of memset node \p hNode in \p nodeParams.
  18422. *
  18423. * \param hNode - Node to get the parameters for
  18424. * \param nodeParams - Pointer to return the parameters
  18425. *
  18426. * \return
  18427. * ::CUDA_SUCCESS,
  18428. * ::CUDA_ERROR_DEINITIALIZED,
  18429. * ::CUDA_ERROR_NOT_INITIALIZED,
  18430. * ::CUDA_ERROR_INVALID_VALUE
  18431. * \note_graph_thread_safety
  18432. * \notefnerr
  18433. *
  18434. * \sa
  18435. * ::cuMemsetD2D32,
  18436. * ::cuGraphAddMemsetNode,
  18437. * ::cuGraphMemsetNodeSetParams
  18438. */
  18439. CUresult CUDAAPI cuGraphMemsetNodeGetParams(CUgraphNode hNode, CUDA_MEMSET_NODE_PARAMS *nodeParams);
  18440. /**
  18441. * \brief Sets a memset node's parameters
  18442. *
  18443. * Sets the parameters of memset node \p hNode to \p nodeParams.
  18444. *
  18445. * \param hNode - Node to set the parameters for
  18446. * \param nodeParams - Parameters to copy
  18447. *
  18448. * \return
  18449. * ::CUDA_SUCCESS,
  18450. * ::CUDA_ERROR_DEINITIALIZED,
  18451. * ::CUDA_ERROR_NOT_INITIALIZED,
  18452. * ::CUDA_ERROR_INVALID_VALUE
  18453. * \note_graph_thread_safety
  18454. * \notefnerr
  18455. *
  18456. * \sa
  18457. * ::cuGraphNodeSetParams,
  18458. * ::cuMemsetD2D32,
  18459. * ::cuGraphAddMemsetNode,
  18460. * ::cuGraphMemsetNodeGetParams
  18461. */
  18462. CUresult CUDAAPI cuGraphMemsetNodeSetParams(CUgraphNode hNode, const CUDA_MEMSET_NODE_PARAMS *nodeParams);
  18463. /**
  18464. * \brief Creates a host execution node and adds it to a graph
  18465. *
  18466. * Creates a new CPU execution node and adds it to \p hGraph with \p numDependencies
  18467. * dependencies specified via \p dependencies and arguments specified in \p nodeParams.
  18468. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  18469. * at the root of the graph. \p dependencies may not have any duplicate entries.
  18470. * A handle to the new node will be returned in \p phGraphNode.
  18471. *
  18472. * When the graph is launched, the node will invoke the specified CPU function.
  18473. * Host nodes are not supported under MPS with pre-Volta GPUs.
  18474. *
  18475. * \param phGraphNode - Returns newly created node
  18476. * \param hGraph - Graph to which to add the node
  18477. * \param dependencies - Dependencies of the node
  18478. * \param numDependencies - Number of dependencies
  18479. * \param nodeParams - Parameters for the host node
  18480. *
  18481. * \return
  18482. * ::CUDA_SUCCESS,
  18483. * ::CUDA_ERROR_DEINITIALIZED,
  18484. * ::CUDA_ERROR_NOT_INITIALIZED,
  18485. * ::CUDA_ERROR_NOT_SUPPORTED,
  18486. * ::CUDA_ERROR_INVALID_VALUE
  18487. * \note_graph_thread_safety
  18488. * \notefnerr
  18489. *
  18490. * \sa
  18491. * ::cuGraphAddNode,
  18492. * ::cuLaunchHostFunc,
  18493. * ::cuGraphHostNodeGetParams,
  18494. * ::cuGraphHostNodeSetParams,
  18495. * ::cuGraphCreate,
  18496. * ::cuGraphDestroyNode,
  18497. * ::cuGraphAddChildGraphNode,
  18498. * ::cuGraphAddEmptyNode,
  18499. * ::cuGraphAddKernelNode,
  18500. * ::cuGraphAddMemcpyNode,
  18501. * ::cuGraphAddMemsetNode
  18502. */
  18503. CUresult CUDAAPI cuGraphAddHostNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, const CUDA_HOST_NODE_PARAMS *nodeParams);
  18504. /**
  18505. * \brief Returns a host node's parameters
  18506. *
  18507. * Returns the parameters of host node \p hNode in \p nodeParams.
  18508. *
  18509. * \param hNode - Node to get the parameters for
  18510. * \param nodeParams - Pointer to return the parameters
  18511. *
  18512. * \return
  18513. * ::CUDA_SUCCESS,
  18514. * ::CUDA_ERROR_DEINITIALIZED,
  18515. * ::CUDA_ERROR_NOT_INITIALIZED,
  18516. * ::CUDA_ERROR_INVALID_VALUE
  18517. * \note_graph_thread_safety
  18518. * \notefnerr
  18519. *
  18520. * \sa
  18521. * ::cuLaunchHostFunc,
  18522. * ::cuGraphAddHostNode,
  18523. * ::cuGraphHostNodeSetParams
  18524. */
  18525. CUresult CUDAAPI cuGraphHostNodeGetParams(CUgraphNode hNode, CUDA_HOST_NODE_PARAMS *nodeParams);
  18526. /**
  18527. * \brief Sets a host node's parameters
  18528. *
  18529. * Sets the parameters of host node \p hNode to \p nodeParams.
  18530. *
  18531. * \param hNode - Node to set the parameters for
  18532. * \param nodeParams - Parameters to copy
  18533. *
  18534. * \return
  18535. * ::CUDA_SUCCESS,
  18536. * ::CUDA_ERROR_DEINITIALIZED,
  18537. * ::CUDA_ERROR_NOT_INITIALIZED,
  18538. * ::CUDA_ERROR_INVALID_VALUE
  18539. * \note_graph_thread_safety
  18540. * \notefnerr
  18541. *
  18542. * \sa
  18543. * ::cuGraphNodeSetParams,
  18544. * ::cuLaunchHostFunc,
  18545. * ::cuGraphAddHostNode,
  18546. * ::cuGraphHostNodeGetParams
  18547. */
  18548. CUresult CUDAAPI cuGraphHostNodeSetParams(CUgraphNode hNode, const CUDA_HOST_NODE_PARAMS *nodeParams);
  18549. /**
  18550. * \brief Creates a child graph node and adds it to a graph
  18551. *
  18552. * Creates a new node which executes an embedded graph, and adds it to \p hGraph with
  18553. * \p numDependencies dependencies specified via \p dependencies.
  18554. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  18555. * at the root of the graph. \p dependencies may not have any duplicate entries.
  18556. * A handle to the new node will be returned in \p phGraphNode.
  18557. *
  18558. * If \p hGraph contains allocation or free nodes, this call will return an error.
  18559. *
  18560. * The node executes an embedded child graph. The child graph is cloned in this call.
  18561. *
  18562. * \param phGraphNode - Returns newly created node
  18563. * \param hGraph - Graph to which to add the node
  18564. * \param dependencies - Dependencies of the node
  18565. * \param numDependencies - Number of dependencies
  18566. * \param childGraph - The graph to clone into this node
  18567. *
  18568. * \return
  18569. * ::CUDA_SUCCESS,
  18570. * ::CUDA_ERROR_DEINITIALIZED,
  18571. * ::CUDA_ERROR_NOT_INITIALIZED,
  18572. * ::CUDA_ERROR_INVALID_VALUE,
  18573. * \note_graph_thread_safety
  18574. * \notefnerr
  18575. *
  18576. * \sa
  18577. * ::cuGraphAddNode,
  18578. * ::cuGraphChildGraphNodeGetGraph,
  18579. * ::cuGraphCreate,
  18580. * ::cuGraphDestroyNode,
  18581. * ::cuGraphAddEmptyNode,
  18582. * ::cuGraphAddKernelNode,
  18583. * ::cuGraphAddHostNode,
  18584. * ::cuGraphAddMemcpyNode,
  18585. * ::cuGraphAddMemsetNode,
  18586. * ::cuGraphClone
  18587. */
  18588. CUresult CUDAAPI cuGraphAddChildGraphNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, CUgraph childGraph);
  18589. /**
  18590. * \brief Gets a handle to the embedded graph of a child graph node
  18591. *
  18592. * Gets a handle to the embedded graph in a child graph node. This call
  18593. * does not clone the graph. Changes to the graph will be reflected in
  18594. * the node, and the node retains ownership of the graph.
  18595. *
  18596. * Allocation and free nodes cannot be added to the returned graph.
  18597. * Attempting to do so will return an error.
  18598. *
  18599. * \param hNode - Node to get the embedded graph for
  18600. * \param phGraph - Location to store a handle to the graph
  18601. *
  18602. * \return
  18603. * ::CUDA_SUCCESS,
  18604. * ::CUDA_ERROR_DEINITIALIZED,
  18605. * ::CUDA_ERROR_NOT_INITIALIZED,
  18606. * ::CUDA_ERROR_INVALID_VALUE,
  18607. * \note_graph_thread_safety
  18608. * \notefnerr
  18609. *
  18610. * \sa
  18611. * ::cuGraphAddChildGraphNode,
  18612. * ::cuGraphNodeFindInClone
  18613. */
  18614. CUresult CUDAAPI cuGraphChildGraphNodeGetGraph(CUgraphNode hNode, CUgraph *phGraph);
  18615. /**
  18616. * \brief Creates an empty node and adds it to a graph
  18617. *
  18618. * Creates a new node which performs no operation, and adds it to \p hGraph with
  18619. * \p numDependencies dependencies specified via \p dependencies.
  18620. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  18621. * at the root of the graph. \p dependencies may not have any duplicate entries.
  18622. * A handle to the new node will be returned in \p phGraphNode.
  18623. *
  18624. * An empty node performs no operation during execution, but can be used for
  18625. * transitive ordering. For example, a phased execution graph with 2 groups of n
  18626. * nodes with a barrier between them can be represented using an empty node and
  18627. * 2*n dependency edges, rather than no empty node and n^2 dependency edges.
  18628. *
  18629. * \param phGraphNode - Returns newly created node
  18630. * \param hGraph - Graph to which to add the node
  18631. * \param dependencies - Dependencies of the node
  18632. * \param numDependencies - Number of dependencies
  18633. *
  18634. * \return
  18635. * ::CUDA_SUCCESS,
  18636. * ::CUDA_ERROR_DEINITIALIZED,
  18637. * ::CUDA_ERROR_NOT_INITIALIZED,
  18638. * ::CUDA_ERROR_INVALID_VALUE,
  18639. * \note_graph_thread_safety
  18640. * \notefnerr
  18641. *
  18642. * \sa
  18643. * ::cuGraphAddNode,
  18644. * ::cuGraphCreate,
  18645. * ::cuGraphDestroyNode,
  18646. * ::cuGraphAddChildGraphNode,
  18647. * ::cuGraphAddKernelNode,
  18648. * ::cuGraphAddHostNode,
  18649. * ::cuGraphAddMemcpyNode,
  18650. * ::cuGraphAddMemsetNode
  18651. */
  18652. CUresult CUDAAPI cuGraphAddEmptyNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies);
  18653. /**
  18654. * \brief Creates an event record node and adds it to a graph
  18655. *
  18656. * Creates a new event record node and adds it to \p hGraph with \p numDependencies
  18657. * dependencies specified via \p dependencies and event specified in \p event.
  18658. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  18659. * at the root of the graph. \p dependencies may not have any duplicate entries.
  18660. * A handle to the new node will be returned in \p phGraphNode.
  18661. *
  18662. * Each launch of the graph will record \p event to capture execution of the
  18663. * node's dependencies.
  18664. *
  18665. * \param phGraphNode - Returns newly created node
  18666. * \param hGraph - Graph to which to add the node
  18667. * \param dependencies - Dependencies of the node
  18668. * \param numDependencies - Number of dependencies
  18669. * \param event - Event for the node
  18670. *
  18671. * \return
  18672. * ::CUDA_SUCCESS,
  18673. * ::CUDA_ERROR_DEINITIALIZED,
  18674. * ::CUDA_ERROR_NOT_INITIALIZED,
  18675. * ::CUDA_ERROR_NOT_SUPPORTED,
  18676. * ::CUDA_ERROR_INVALID_VALUE
  18677. * \note_graph_thread_safety
  18678. * \notefnerr
  18679. *
  18680. * \sa
  18681. * ::cuGraphAddNode,
  18682. * ::cuGraphAddEventWaitNode,
  18683. * ::cuEventRecordWithFlags,
  18684. * ::cuStreamWaitEvent,
  18685. * ::cuGraphCreate,
  18686. * ::cuGraphDestroyNode,
  18687. * ::cuGraphAddChildGraphNode,
  18688. * ::cuGraphAddEmptyNode,
  18689. * ::cuGraphAddKernelNode,
  18690. * ::cuGraphAddMemcpyNode,
  18691. * ::cuGraphAddMemsetNode
  18692. */
  18693. CUresult CUDAAPI cuGraphAddEventRecordNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, CUevent event);
  18694. /**
  18695. * \brief Returns the event associated with an event record node
  18696. *
  18697. * Returns the event of event record node \p hNode in \p event_out.
  18698. *
  18699. * \param hNode - Node to get the event for
  18700. * \param event_out - Pointer to return the event
  18701. *
  18702. * \return
  18703. * ::CUDA_SUCCESS,
  18704. * ::CUDA_ERROR_DEINITIALIZED,
  18705. * ::CUDA_ERROR_NOT_INITIALIZED,
  18706. * ::CUDA_ERROR_INVALID_VALUE
  18707. * \note_graph_thread_safety
  18708. * \notefnerr
  18709. *
  18710. * \sa
  18711. * ::cuGraphAddEventRecordNode,
  18712. * ::cuGraphEventRecordNodeSetEvent,
  18713. * ::cuGraphEventWaitNodeGetEvent,
  18714. * ::cuEventRecordWithFlags,
  18715. * ::cuStreamWaitEvent
  18716. */
  18717. CUresult CUDAAPI cuGraphEventRecordNodeGetEvent(CUgraphNode hNode, CUevent *event_out);
  18718. /**
  18719. * \brief Sets an event record node's event
  18720. *
  18721. * Sets the event of event record node \p hNode to \p event.
  18722. *
  18723. * \param hNode - Node to set the event for
  18724. * \param event - Event to use
  18725. *
  18726. * \return
  18727. * ::CUDA_SUCCESS,
  18728. * ::CUDA_ERROR_INVALID_VALUE,
  18729. * ::CUDA_ERROR_INVALID_HANDLE,
  18730. * ::CUDA_ERROR_OUT_OF_MEMORY
  18731. * \note_graph_thread_safety
  18732. * \notefnerr
  18733. *
  18734. * \sa
  18735. * ::cuGraphNodeSetParams,
  18736. * ::cuGraphAddEventRecordNode,
  18737. * ::cuGraphEventRecordNodeGetEvent,
  18738. * ::cuGraphEventWaitNodeSetEvent,
  18739. * ::cuEventRecordWithFlags,
  18740. * ::cuStreamWaitEvent
  18741. */
  18742. CUresult CUDAAPI cuGraphEventRecordNodeSetEvent(CUgraphNode hNode, CUevent event);
  18743. /**
  18744. * \brief Creates an event wait node and adds it to a graph
  18745. *
  18746. * Creates a new event wait node and adds it to \p hGraph with \p numDependencies
  18747. * dependencies specified via \p dependencies and event specified in \p event.
  18748. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  18749. * at the root of the graph. \p dependencies may not have any duplicate entries.
  18750. * A handle to the new node will be returned in \p phGraphNode.
  18751. *
  18752. * The graph node will wait for all work captured in \p event. See ::cuEventRecord()
  18753. * for details on what is captured by an event. \p event may be from a different context
  18754. * or device than the launch stream.
  18755. *
  18756. * \param phGraphNode - Returns newly created node
  18757. * \param hGraph - Graph to which to add the node
  18758. * \param dependencies - Dependencies of the node
  18759. * \param numDependencies - Number of dependencies
  18760. * \param event - Event for the node
  18761. *
  18762. * \return
  18763. * ::CUDA_SUCCESS,
  18764. * ::CUDA_ERROR_DEINITIALIZED,
  18765. * ::CUDA_ERROR_NOT_INITIALIZED,
  18766. * ::CUDA_ERROR_NOT_SUPPORTED,
  18767. * ::CUDA_ERROR_INVALID_VALUE
  18768. * \note_graph_thread_safety
  18769. * \notefnerr
  18770. *
  18771. * \sa
  18772. * ::cuGraphAddNode,
  18773. * ::cuGraphAddEventRecordNode,
  18774. * ::cuEventRecordWithFlags,
  18775. * ::cuStreamWaitEvent,
  18776. * ::cuGraphCreate,
  18777. * ::cuGraphDestroyNode,
  18778. * ::cuGraphAddChildGraphNode,
  18779. * ::cuGraphAddEmptyNode,
  18780. * ::cuGraphAddKernelNode,
  18781. * ::cuGraphAddMemcpyNode,
  18782. * ::cuGraphAddMemsetNode
  18783. */
  18784. CUresult CUDAAPI cuGraphAddEventWaitNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, CUevent event);
  18785. /**
  18786. * \brief Returns the event associated with an event wait node
  18787. *
  18788. * Returns the event of event wait node \p hNode in \p event_out.
  18789. *
  18790. * \param hNode - Node to get the event for
  18791. * \param event_out - Pointer to return the event
  18792. *
  18793. * \return
  18794. * ::CUDA_SUCCESS,
  18795. * ::CUDA_ERROR_DEINITIALIZED,
  18796. * ::CUDA_ERROR_NOT_INITIALIZED,
  18797. * ::CUDA_ERROR_INVALID_VALUE
  18798. * \note_graph_thread_safety
  18799. * \notefnerr
  18800. *
  18801. * \sa
  18802. * ::cuGraphAddEventWaitNode,
  18803. * ::cuGraphEventWaitNodeSetEvent,
  18804. * ::cuGraphEventRecordNodeGetEvent,
  18805. * ::cuEventRecordWithFlags,
  18806. * ::cuStreamWaitEvent
  18807. */
  18808. CUresult CUDAAPI cuGraphEventWaitNodeGetEvent(CUgraphNode hNode, CUevent *event_out);
  18809. /**
  18810. * \brief Sets an event wait node's event
  18811. *
  18812. * Sets the event of event wait node \p hNode to \p event.
  18813. *
  18814. * \param hNode - Node to set the event for
  18815. * \param event - Event to use
  18816. *
  18817. * \return
  18818. * ::CUDA_SUCCESS,
  18819. * ::CUDA_ERROR_INVALID_VALUE,
  18820. * ::CUDA_ERROR_INVALID_HANDLE,
  18821. * ::CUDA_ERROR_OUT_OF_MEMORY
  18822. * \note_graph_thread_safety
  18823. * \notefnerr
  18824. *
  18825. * \sa
  18826. * ::cuGraphNodeSetParams,
  18827. * ::cuGraphAddEventWaitNode,
  18828. * ::cuGraphEventWaitNodeGetEvent,
  18829. * ::cuGraphEventRecordNodeSetEvent,
  18830. * ::cuEventRecordWithFlags,
  18831. * ::cuStreamWaitEvent
  18832. */
  18833. CUresult CUDAAPI cuGraphEventWaitNodeSetEvent(CUgraphNode hNode, CUevent event);
  18834. /**
  18835. * \brief Creates an external semaphore signal node and adds it to a graph
  18836. *
  18837. * Creates a new external semaphore signal node and adds it to \p hGraph with \p
  18838. * numDependencies dependencies specified via \p dependencies and arguments specified
  18839. * in \p nodeParams. It is possible for \p numDependencies to be 0, in which case the
  18840. * node will be placed at the root of the graph. \p dependencies may not have any
  18841. * duplicate entries. A handle to the new node will be returned in \p phGraphNode.
  18842. *
  18843. * Performs a signal operation on a set of externally allocated semaphore objects
  18844. * when the node is launched. The operation(s) will occur after all of the node's
  18845. * dependencies have completed.
  18846. *
  18847. * \param phGraphNode - Returns newly created node
  18848. * \param hGraph - Graph to which to add the node
  18849. * \param dependencies - Dependencies of the node
  18850. * \param numDependencies - Number of dependencies
  18851. * \param nodeParams - Parameters for the node
  18852. *
  18853. * \return
  18854. * ::CUDA_SUCCESS,
  18855. * ::CUDA_ERROR_DEINITIALIZED,
  18856. * ::CUDA_ERROR_NOT_INITIALIZED,
  18857. * ::CUDA_ERROR_NOT_SUPPORTED,
  18858. * ::CUDA_ERROR_INVALID_VALUE
  18859. * \note_graph_thread_safety
  18860. * \notefnerr
  18861. *
  18862. * \sa
  18863. * ::cuGraphAddNode,
  18864. * ::cuGraphExternalSemaphoresSignalNodeGetParams,
  18865. * ::cuGraphExternalSemaphoresSignalNodeSetParams,
  18866. * ::cuGraphExecExternalSemaphoresSignalNodeSetParams,
  18867. * ::cuGraphAddExternalSemaphoresWaitNode,
  18868. * ::cuImportExternalSemaphore,
  18869. * ::cuSignalExternalSemaphoresAsync,
  18870. * ::cuWaitExternalSemaphoresAsync,
  18871. * ::cuGraphCreate,
  18872. * ::cuGraphDestroyNode,
  18873. * ::cuGraphAddEventRecordNode,
  18874. * ::cuGraphAddEventWaitNode,
  18875. * ::cuGraphAddChildGraphNode,
  18876. * ::cuGraphAddEmptyNode,
  18877. * ::cuGraphAddKernelNode,
  18878. * ::cuGraphAddMemcpyNode,
  18879. * ::cuGraphAddMemsetNode
  18880. */
  18881. CUresult CUDAAPI cuGraphAddExternalSemaphoresSignalNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS *nodeParams);
  18882. /**
  18883. * \brief Returns an external semaphore signal node's parameters
  18884. *
  18885. * Returns the parameters of an external semaphore signal node \p hNode in \p params_out.
  18886. * The \p extSemArray and \p paramsArray returned in \p params_out,
  18887. * are owned by the node. This memory remains valid until the node is destroyed or its
  18888. * parameters are modified, and should not be modified
  18889. * directly. Use ::cuGraphExternalSemaphoresSignalNodeSetParams to update the
  18890. * parameters of this node.
  18891. *
  18892. * \param hNode - Node to get the parameters for
  18893. * \param params_out - Pointer to return the parameters
  18894. *
  18895. * \return
  18896. * ::CUDA_SUCCESS,
  18897. * ::CUDA_ERROR_DEINITIALIZED,
  18898. * ::CUDA_ERROR_NOT_INITIALIZED,
  18899. * ::CUDA_ERROR_INVALID_VALUE
  18900. * \note_graph_thread_safety
  18901. * \notefnerr
  18902. *
  18903. * \sa
  18904. * ::cuLaunchKernel,
  18905. * ::cuGraphAddExternalSemaphoresSignalNode,
  18906. * ::cuGraphExternalSemaphoresSignalNodeSetParams,
  18907. * ::cuGraphAddExternalSemaphoresWaitNode,
  18908. * ::cuSignalExternalSemaphoresAsync,
  18909. * ::cuWaitExternalSemaphoresAsync
  18910. */
  18911. CUresult CUDAAPI cuGraphExternalSemaphoresSignalNodeGetParams(CUgraphNode hNode, CUDA_EXT_SEM_SIGNAL_NODE_PARAMS *params_out);
  18912. /**
  18913. * \brief Sets an external semaphore signal node's parameters
  18914. *
  18915. * Sets the parameters of an external semaphore signal node \p hNode to \p nodeParams.
  18916. *
  18917. * \param hNode - Node to set the parameters for
  18918. * \param nodeParams - Parameters to copy
  18919. *
  18920. * \return
  18921. * ::CUDA_SUCCESS,
  18922. * ::CUDA_ERROR_INVALID_VALUE,
  18923. * ::CUDA_ERROR_INVALID_HANDLE,
  18924. * ::CUDA_ERROR_OUT_OF_MEMORY
  18925. * \note_graph_thread_safety
  18926. * \notefnerr
  18927. *
  18928. * \sa
  18929. * ::cuGraphNodeSetParams,
  18930. * ::cuGraphAddExternalSemaphoresSignalNode,
  18931. * ::cuGraphExternalSemaphoresSignalNodeSetParams,
  18932. * ::cuGraphAddExternalSemaphoresWaitNode,
  18933. * ::cuSignalExternalSemaphoresAsync,
  18934. * ::cuWaitExternalSemaphoresAsync
  18935. */
  18936. CUresult CUDAAPI cuGraphExternalSemaphoresSignalNodeSetParams(CUgraphNode hNode, const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS *nodeParams);
  18937. /**
  18938. * \brief Creates an external semaphore wait node and adds it to a graph
  18939. *
  18940. * Creates a new external semaphore wait node and adds it to \p hGraph with \p numDependencies
  18941. * dependencies specified via \p dependencies and arguments specified in \p nodeParams.
  18942. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  18943. * at the root of the graph. \p dependencies may not have any duplicate entries. A handle
  18944. * to the new node will be returned in \p phGraphNode.
  18945. *
  18946. * Performs a wait operation on a set of externally allocated semaphore objects
  18947. * when the node is launched. The node's dependencies will not be launched until
  18948. * the wait operation has completed.
  18949. *
  18950. * \param phGraphNode - Returns newly created node
  18951. * \param hGraph - Graph to which to add the node
  18952. * \param dependencies - Dependencies of the node
  18953. * \param numDependencies - Number of dependencies
  18954. * \param nodeParams - Parameters for the node
  18955. *
  18956. * \return
  18957. * ::CUDA_SUCCESS,
  18958. * ::CUDA_ERROR_DEINITIALIZED,
  18959. * ::CUDA_ERROR_NOT_INITIALIZED,
  18960. * ::CUDA_ERROR_NOT_SUPPORTED,
  18961. * ::CUDA_ERROR_INVALID_VALUE
  18962. * \note_graph_thread_safety
  18963. * \notefnerr
  18964. *
  18965. * \sa
  18966. * ::cuGraphAddNode,
  18967. * ::cuGraphExternalSemaphoresWaitNodeGetParams,
  18968. * ::cuGraphExternalSemaphoresWaitNodeSetParams,
  18969. * ::cuGraphExecExternalSemaphoresWaitNodeSetParams,
  18970. * ::cuGraphAddExternalSemaphoresSignalNode,
  18971. * ::cuImportExternalSemaphore,
  18972. * ::cuSignalExternalSemaphoresAsync,
  18973. * ::cuWaitExternalSemaphoresAsync,
  18974. * ::cuGraphCreate,
  18975. * ::cuGraphDestroyNode,
  18976. * ::cuGraphAddEventRecordNode,
  18977. * ::cuGraphAddEventWaitNode,
  18978. * ::cuGraphAddChildGraphNode,
  18979. * ::cuGraphAddEmptyNode,
  18980. * ::cuGraphAddKernelNode,
  18981. * ::cuGraphAddMemcpyNode,
  18982. * ::cuGraphAddMemsetNode
  18983. */
  18984. CUresult CUDAAPI cuGraphAddExternalSemaphoresWaitNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, const CUDA_EXT_SEM_WAIT_NODE_PARAMS *nodeParams);
  18985. /**
  18986. * \brief Returns an external semaphore wait node's parameters
  18987. *
  18988. * Returns the parameters of an external semaphore wait node \p hNode in \p params_out.
  18989. * The \p extSemArray and \p paramsArray returned in \p params_out,
  18990. * are owned by the node. This memory remains valid until the node is destroyed or its
  18991. * parameters are modified, and should not be modified
  18992. * directly. Use ::cuGraphExternalSemaphoresSignalNodeSetParams to update the
  18993. * parameters of this node.
  18994. *
  18995. * \param hNode - Node to get the parameters for
  18996. * \param params_out - Pointer to return the parameters
  18997. *
  18998. * \return
  18999. * ::CUDA_SUCCESS,
  19000. * ::CUDA_ERROR_DEINITIALIZED,
  19001. * ::CUDA_ERROR_NOT_INITIALIZED,
  19002. * ::CUDA_ERROR_INVALID_VALUE
  19003. * \note_graph_thread_safety
  19004. * \notefnerr
  19005. *
  19006. * \sa
  19007. * ::cuLaunchKernel,
  19008. * ::cuGraphAddExternalSemaphoresWaitNode,
  19009. * ::cuGraphExternalSemaphoresWaitNodeSetParams,
  19010. * ::cuGraphAddExternalSemaphoresWaitNode,
  19011. * ::cuSignalExternalSemaphoresAsync,
  19012. * ::cuWaitExternalSemaphoresAsync
  19013. */
  19014. CUresult CUDAAPI cuGraphExternalSemaphoresWaitNodeGetParams(CUgraphNode hNode, CUDA_EXT_SEM_WAIT_NODE_PARAMS *params_out);
  19015. /**
  19016. * \brief Sets an external semaphore wait node's parameters
  19017. *
  19018. * Sets the parameters of an external semaphore wait node \p hNode to \p nodeParams.
  19019. *
  19020. * \param hNode - Node to set the parameters for
  19021. * \param nodeParams - Parameters to copy
  19022. *
  19023. * \return
  19024. * ::CUDA_SUCCESS,
  19025. * ::CUDA_ERROR_INVALID_VALUE,
  19026. * ::CUDA_ERROR_INVALID_HANDLE,
  19027. * ::CUDA_ERROR_OUT_OF_MEMORY
  19028. * \note_graph_thread_safety
  19029. * \notefnerr
  19030. *
  19031. * \sa
  19032. * ::cuGraphNodeSetParams,
  19033. * ::cuGraphAddExternalSemaphoresWaitNode,
  19034. * ::cuGraphExternalSemaphoresWaitNodeSetParams,
  19035. * ::cuGraphAddExternalSemaphoresWaitNode,
  19036. * ::cuSignalExternalSemaphoresAsync,
  19037. * ::cuWaitExternalSemaphoresAsync
  19038. */
  19039. CUresult CUDAAPI cuGraphExternalSemaphoresWaitNodeSetParams(CUgraphNode hNode, const CUDA_EXT_SEM_WAIT_NODE_PARAMS *nodeParams);
  19040. /**
  19041. * \brief Creates a batch memory operation node and adds it to a graph
  19042. *
  19043. * Creates a new batch memory operation node and adds it to \p hGraph with \p
  19044. * numDependencies dependencies specified via \p dependencies and arguments specified in \p nodeParams.
  19045. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  19046. * at the root of the graph. \p dependencies may not have any duplicate entries.
  19047. * A handle to the new node will be returned in \p phGraphNode.
  19048. *
  19049. * When the node is added, the paramArray inside \p nodeParams is copied and therefore it can be
  19050. * freed after the call returns.
  19051. *
  19052. * \note
  19053. * Warning:
  19054. * Improper use of this API may deadlock the application. Synchronization
  19055. * ordering established through this API is not visible to CUDA. CUDA tasks
  19056. * that are (even indirectly) ordered by this API should also have that order
  19057. * expressed with CUDA-visible dependencies such as events. This ensures that
  19058. * the scheduler does not serialize them in an improper order. For more
  19059. * information, see the Stream Memory Operations section in the programming
  19060. * guide(https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html).
  19061. *
  19062. * \param phGraphNode - Returns newly created node
  19063. * \param hGraph - Graph to which to add the node
  19064. * \param dependencies - Dependencies of the node
  19065. * \param numDependencies - Number of dependencies
  19066. * \param nodeParams - Parameters for the node
  19067. *
  19068. * \return
  19069. * ::CUDA_SUCCESS,
  19070. * ::CUDA_ERROR_DEINITIALIZED,
  19071. * ::CUDA_ERROR_NOT_INITIALIZED,
  19072. * ::CUDA_ERROR_NOT_SUPPORTED,
  19073. * ::CUDA_ERROR_INVALID_VALUE
  19074. * \note_graph_thread_safety
  19075. * \notefnerr
  19076. *
  19077. * \sa
  19078. * ::cuGraphAddNode,
  19079. * ::cuStreamBatchMemOp,
  19080. * ::cuStreamWaitValue32,
  19081. * ::cuStreamWriteValue32,
  19082. * ::cuStreamWaitValue64,
  19083. * ::cuStreamWriteValue64,
  19084. * ::cuGraphBatchMemOpNodeGetParams,
  19085. * ::cuGraphBatchMemOpNodeSetParams,
  19086. * ::cuGraphCreate,
  19087. * ::cuGraphDestroyNode,
  19088. * ::cuGraphAddChildGraphNode,
  19089. * ::cuGraphAddEmptyNode,
  19090. * ::cuGraphAddKernelNode,
  19091. * ::cuGraphAddMemcpyNode,
  19092. * ::cuGraphAddMemsetNode
  19093. */
  19094. CUresult CUDAAPI cuGraphAddBatchMemOpNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, const CUDA_BATCH_MEM_OP_NODE_PARAMS *nodeParams);
  19095. /**
  19096. * \brief Returns a batch mem op node's parameters
  19097. *
  19098. * Returns the parameters of batch mem op node \p hNode in \p nodeParams_out.
  19099. * The \p paramArray returned in \p nodeParams_out is owned by the node.
  19100. * This memory remains valid until the node is destroyed or its
  19101. * parameters are modified, and should not be modified
  19102. * directly. Use ::cuGraphBatchMemOpNodeSetParams to update the
  19103. * parameters of this node.
  19104. *
  19105. * \param hNode - Node to get the parameters for
  19106. * \param nodeParams_out - Pointer to return the parameters
  19107. *
  19108. * \return
  19109. * ::CUDA_SUCCESS,
  19110. * ::CUDA_ERROR_DEINITIALIZED,
  19111. * ::CUDA_ERROR_NOT_INITIALIZED,
  19112. * ::CUDA_ERROR_INVALID_VALUE
  19113. * \note_graph_thread_safety
  19114. * \notefnerr
  19115. *
  19116. * \sa
  19117. * ::cuStreamBatchMemOp,
  19118. * ::cuGraphAddBatchMemOpNode,
  19119. * ::cuGraphBatchMemOpNodeSetParams
  19120. */
  19121. CUresult CUDAAPI cuGraphBatchMemOpNodeGetParams(CUgraphNode hNode, CUDA_BATCH_MEM_OP_NODE_PARAMS *nodeParams_out);
  19122. /**
  19123. * \brief Sets a batch mem op node's parameters
  19124. *
  19125. * Sets the parameters of batch mem op node \p hNode to \p nodeParams.
  19126. *
  19127. * The paramArray inside \p nodeParams is copied and therefore it can be
  19128. * freed after the call returns.
  19129. *
  19130. * \param hNode - Node to set the parameters for
  19131. * \param nodeParams - Parameters to copy
  19132. *
  19133. * \return
  19134. * ::CUDA_SUCCESS,
  19135. * ::CUDA_ERROR_INVALID_VALUE,
  19136. * ::CUDA_ERROR_INVALID_HANDLE,
  19137. * ::CUDA_ERROR_OUT_OF_MEMORY
  19138. * \note_graph_thread_safety
  19139. * \notefnerr
  19140. *
  19141. * \sa
  19142. * ::cuGraphNodeSetParams,
  19143. * ::cuStreamBatchMemOp,
  19144. * ::cuGraphAddBatchMemOpNode,
  19145. * ::cuGraphBatchMemOpNodeGetParams
  19146. */
  19147. CUresult CUDAAPI cuGraphBatchMemOpNodeSetParams(CUgraphNode hNode, const CUDA_BATCH_MEM_OP_NODE_PARAMS *nodeParams);
  19148. /**
  19149. * \brief Sets the parameters for a batch mem op node in the given graphExec
  19150. *
  19151. * Sets the parameters of a batch mem op node in an executable graph \p hGraphExec.
  19152. * The node is identified by the corresponding node \p hNode in the
  19153. * non-executable graph, from which the executable graph was instantiated.
  19154. *
  19155. * The following fields on operations may be modified on an executable graph:
  19156. *
  19157. * op.waitValue.address
  19158. * op.waitValue.value[64]
  19159. * op.waitValue.flags bits corresponding to wait type (i.e. CU_STREAM_WAIT_VALUE_FLUSH bit cannot be modified)
  19160. * op.writeValue.address
  19161. * op.writeValue.value[64]
  19162. *
  19163. * Other fields, such as the context, count or type of operations, and other types of operations such as membars,
  19164. * may not be modified.
  19165. *
  19166. * \p hNode must not have been removed from the original graph.
  19167. *
  19168. * The modifications only affect future launches of \p hGraphExec. Already
  19169. * enqueued or running launches of \p hGraphExec are not affected by this call.
  19170. * \p hNode is also not modified by this call.
  19171. *
  19172. * The paramArray inside \p nodeParams is copied and therefore it can be
  19173. * freed after the call returns.
  19174. *
  19175. * \param hGraphExec - The executable graph in which to set the specified node
  19176. * \param hNode - Batch mem op node from the graph from which graphExec was instantiated
  19177. * \param nodeParams - Updated Parameters to set
  19178. *
  19179. * \return
  19180. * ::CUDA_SUCCESS,
  19181. * ::CUDA_ERROR_INVALID_VALUE,
  19182. * \note_graph_thread_safety
  19183. * \notefnerr
  19184. *
  19185. * \sa
  19186. * ::cuGraphExecNodeSetParams,
  19187. * ::cuStreamBatchMemOp,
  19188. * ::cuGraphAddBatchMemOpNode,
  19189. * ::cuGraphBatchMemOpNodeGetParams,
  19190. * ::cuGraphBatchMemOpNodeSetParams,
  19191. * ::cuGraphInstantiate
  19192. */
  19193. CUresult CUDAAPI cuGraphExecBatchMemOpNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_BATCH_MEM_OP_NODE_PARAMS *nodeParams);
  19194. /**
  19195. * \brief Creates an allocation node and adds it to a graph
  19196. *
  19197. * Creates a new allocation node and adds it to \p hGraph with \p numDependencies
  19198. * dependencies specified via \p dependencies and arguments specified in \p nodeParams.
  19199. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  19200. * at the root of the graph. \p dependencies may not have any duplicate entries. A handle
  19201. * to the new node will be returned in \p phGraphNode.
  19202. *
  19203. * \param phGraphNode - Returns newly created node
  19204. * \param hGraph - Graph to which to add the node
  19205. * \param dependencies - Dependencies of the node
  19206. * \param numDependencies - Number of dependencies
  19207. * \param nodeParams - Parameters for the node
  19208. *
  19209. * When ::cuGraphAddMemAllocNode creates an allocation node, it returns the address of the allocation in
  19210. * \p nodeParams.dptr. The allocation's address remains fixed across instantiations and launches.
  19211. *
  19212. * If the allocation is freed in the same graph, by creating a free node using ::cuGraphAddMemFreeNode,
  19213. * the allocation can be accessed by nodes ordered after the allocation node but before the free node.
  19214. * These allocations cannot be freed outside the owning graph, and they can only be freed once in the
  19215. * owning graph.
  19216. *
  19217. * If the allocation is not freed in the same graph, then it can be accessed not only by nodes in the
  19218. * graph which are ordered after the allocation node, but also by stream operations ordered after the
  19219. * graph's execution but before the allocation is freed.
  19220. *
  19221. * Allocations which are not freed in the same graph can be freed by:
  19222. * - passing the allocation to ::cuMemFreeAsync or ::cuMemFree;
  19223. * - launching a graph with a free node for that allocation; or
  19224. * - specifying ::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH during instantiation, which makes
  19225. * each launch behave as though it called ::cuMemFreeAsync for every unfreed allocation.
  19226. *
  19227. * It is not possible to free an allocation in both the owning graph and another graph. If the allocation
  19228. * is freed in the same graph, a free node cannot be added to another graph. If the allocation is freed
  19229. * in another graph, a free node can no longer be added to the owning graph.
  19230. *
  19231. * The following restrictions apply to graphs which contain allocation and/or memory free nodes:
  19232. * - Nodes and edges of the graph cannot be deleted.
  19233. * - The graph cannot be used in a child node.
  19234. * - Only one instantiation of the graph may exist at any point in time.
  19235. * - The graph cannot be cloned.
  19236. *
  19237. * \return
  19238. * ::CUDA_SUCCESS,
  19239. * ::CUDA_ERROR_DEINITIALIZED,
  19240. * ::CUDA_ERROR_NOT_INITIALIZED,
  19241. * ::CUDA_ERROR_NOT_SUPPORTED,
  19242. * ::CUDA_ERROR_INVALID_VALUE
  19243. * \note_graph_thread_safety
  19244. * \notefnerr
  19245. *
  19246. * \sa
  19247. * ::cuGraphAddNode,
  19248. * ::cuGraphAddMemFreeNode,
  19249. * ::cuGraphMemAllocNodeGetParams,
  19250. * ::cuDeviceGraphMemTrim,
  19251. * ::cuDeviceGetGraphMemAttribute,
  19252. * ::cuDeviceSetGraphMemAttribute,
  19253. * ::cuMemAllocAsync,
  19254. * ::cuMemFreeAsync,
  19255. * ::cuGraphCreate,
  19256. * ::cuGraphDestroyNode,
  19257. * ::cuGraphAddChildGraphNode,
  19258. * ::cuGraphAddEmptyNode,
  19259. * ::cuGraphAddEventRecordNode,
  19260. * ::cuGraphAddEventWaitNode,
  19261. * ::cuGraphAddExternalSemaphoresSignalNode,
  19262. * ::cuGraphAddExternalSemaphoresWaitNode,
  19263. * ::cuGraphAddKernelNode,
  19264. * ::cuGraphAddMemcpyNode,
  19265. * ::cuGraphAddMemsetNode
  19266. */
  19267. CUresult CUDAAPI cuGraphAddMemAllocNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, CUDA_MEM_ALLOC_NODE_PARAMS *nodeParams);
  19268. /**
  19269. * \brief Returns a memory alloc node's parameters
  19270. *
  19271. * Returns the parameters of a memory alloc node \p hNode in \p params_out.
  19272. * The \p poolProps and \p accessDescs returned in \p params_out, are owned by the
  19273. * node. This memory remains valid until the node is destroyed. The returned
  19274. * parameters must not be modified.
  19275. *
  19276. * \param hNode - Node to get the parameters for
  19277. * \param params_out - Pointer to return the parameters
  19278. *
  19279. * \return
  19280. * ::CUDA_SUCCESS,
  19281. * ::CUDA_ERROR_DEINITIALIZED,
  19282. * ::CUDA_ERROR_NOT_INITIALIZED,
  19283. * ::CUDA_ERROR_INVALID_VALUE
  19284. * \note_graph_thread_safety
  19285. * \notefnerr
  19286. *
  19287. * \sa
  19288. * ::cuGraphAddMemAllocNode,
  19289. * ::cuGraphMemFreeNodeGetParams
  19290. */
  19291. CUresult CUDAAPI cuGraphMemAllocNodeGetParams(CUgraphNode hNode, CUDA_MEM_ALLOC_NODE_PARAMS *params_out);
  19292. /**
  19293. * \brief Creates a memory free node and adds it to a graph
  19294. *
  19295. * Creates a new memory free node and adds it to \p hGraph with \p numDependencies
  19296. * dependencies specified via \p dependencies and arguments specified in \p nodeParams.
  19297. * It is possible for \p numDependencies to be 0, in which case the node will be placed
  19298. * at the root of the graph. \p dependencies may not have any duplicate entries. A handle
  19299. * to the new node will be returned in \p phGraphNode.
  19300. *
  19301. * \param phGraphNode - Returns newly created node
  19302. * \param hGraph - Graph to which to add the node
  19303. * \param dependencies - Dependencies of the node
  19304. * \param numDependencies - Number of dependencies
  19305. * \param dptr - Address of memory to free
  19306. *
  19307. * ::cuGraphAddMemFreeNode will return ::CUDA_ERROR_INVALID_VALUE if the user attempts to free:
  19308. * - an allocation twice in the same graph.
  19309. * - an address that was not returned by an allocation node.
  19310. * - an invalid address.
  19311. *
  19312. * The following restrictions apply to graphs which contain allocation and/or memory free nodes:
  19313. * - Nodes and edges of the graph cannot be deleted.
  19314. * - The graph cannot be used in a child node.
  19315. * - Only one instantiation of the graph may exist at any point in time.
  19316. * - The graph cannot be cloned.
  19317. *
  19318. * \return
  19319. * ::CUDA_SUCCESS,
  19320. * ::CUDA_ERROR_DEINITIALIZED,
  19321. * ::CUDA_ERROR_NOT_INITIALIZED,
  19322. * ::CUDA_ERROR_NOT_SUPPORTED,
  19323. * ::CUDA_ERROR_INVALID_VALUE
  19324. * \note_graph_thread_safety
  19325. * \notefnerr
  19326. *
  19327. * \sa
  19328. * ::cuGraphAddNode,
  19329. * ::cuGraphAddMemAllocNode,
  19330. * ::cuGraphMemFreeNodeGetParams,
  19331. * ::cuDeviceGraphMemTrim,
  19332. * ::cuDeviceGetGraphMemAttribute,
  19333. * ::cuDeviceSetGraphMemAttribute,
  19334. * ::cuMemAllocAsync,
  19335. * ::cuMemFreeAsync,
  19336. * ::cuGraphCreate,
  19337. * ::cuGraphDestroyNode,
  19338. * ::cuGraphAddChildGraphNode,
  19339. * ::cuGraphAddEmptyNode,
  19340. * ::cuGraphAddEventRecordNode,
  19341. * ::cuGraphAddEventWaitNode,
  19342. * ::cuGraphAddExternalSemaphoresSignalNode,
  19343. * ::cuGraphAddExternalSemaphoresWaitNode,
  19344. * ::cuGraphAddKernelNode,
  19345. * ::cuGraphAddMemcpyNode,
  19346. * ::cuGraphAddMemsetNode
  19347. */
  19348. CUresult CUDAAPI cuGraphAddMemFreeNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, CUdeviceptr dptr);
  19349. /**
  19350. * \brief Returns a memory free node's parameters
  19351. *
  19352. * Returns the address of a memory free node \p hNode in \p dptr_out.
  19353. *
  19354. * \param hNode - Node to get the parameters for
  19355. * \param dptr_out - Pointer to return the device address
  19356. *
  19357. * \return
  19358. * ::CUDA_SUCCESS,
  19359. * ::CUDA_ERROR_DEINITIALIZED,
  19360. * ::CUDA_ERROR_NOT_INITIALIZED,
  19361. * ::CUDA_ERROR_INVALID_VALUE
  19362. * \note_graph_thread_safety
  19363. * \notefnerr
  19364. *
  19365. * \sa
  19366. * ::cuGraphAddMemFreeNode,
  19367. * ::cuGraphMemAllocNodeGetParams
  19368. */
  19369. CUresult CUDAAPI cuGraphMemFreeNodeGetParams(CUgraphNode hNode, CUdeviceptr *dptr_out);
  19370. /**
  19371. * \brief Free unused memory that was cached on the specified device for use with graphs back to the OS.
  19372. *
  19373. * Blocks which are not in use by a graph that is either currently executing or scheduled to execute are
  19374. * freed back to the operating system.
  19375. *
  19376. * \param device - The device for which cached memory should be freed.
  19377. *
  19378. * \return
  19379. * ::CUDA_SUCCESS,
  19380. * ::CUDA_ERROR_INVALID_DEVICE
  19381. *
  19382. * \sa
  19383. * ::cuGraphAddMemAllocNode,
  19384. * ::cuGraphAddMemFreeNode,
  19385. * ::cuDeviceSetGraphMemAttribute,
  19386. * ::cuDeviceGetGraphMemAttribute
  19387. */
  19388. CUresult CUDAAPI cuDeviceGraphMemTrim(CUdevice device);
  19389. /**
  19390. * \brief Query asynchronous allocation attributes related to graphs
  19391. *
  19392. * Valid attributes are:
  19393. *
  19394. * - ::CU_GRAPH_MEM_ATTR_USED_MEM_CURRENT: Amount of memory, in bytes, currently associated with graphs
  19395. * - ::CU_GRAPH_MEM_ATTR_USED_MEM_HIGH: High watermark of memory, in bytes, associated with graphs since the
  19396. * last time it was reset. High watermark can only be reset to zero.
  19397. * - ::CU_GRAPH_MEM_ATTR_RESERVED_MEM_CURRENT: Amount of memory, in bytes, currently allocated for use by
  19398. * the CUDA graphs asynchronous allocator.
  19399. * - ::CU_GRAPH_MEM_ATTR_RESERVED_MEM_HIGH: High watermark of memory, in bytes, currently allocated for use by
  19400. * the CUDA graphs asynchronous allocator.
  19401. *
  19402. * \param device - Specifies the scope of the query
  19403. * \param attr - attribute to get
  19404. * \param value - retrieved value
  19405. *
  19406. * \return
  19407. * ::CUDA_SUCCESS,
  19408. * ::CUDA_ERROR_INVALID_DEVICE
  19409. *
  19410. * \sa
  19411. * ::cuDeviceSetGraphMemAttribute,
  19412. * ::cuGraphAddMemAllocNode,
  19413. * ::cuGraphAddMemFreeNode
  19414. */
  19415. CUresult CUDAAPI cuDeviceGetGraphMemAttribute(CUdevice device, CUgraphMem_attribute attr, void* value);
  19416. /**
  19417. * \brief Set asynchronous allocation attributes related to graphs
  19418. *
  19419. * Valid attributes are:
  19420. *
  19421. * - ::CU_GRAPH_MEM_ATTR_USED_MEM_HIGH: High watermark of memory, in bytes, associated with graphs since the
  19422. * last time it was reset. High watermark can only be reset to zero.
  19423. * - ::CU_GRAPH_MEM_ATTR_RESERVED_MEM_HIGH: High watermark of memory, in bytes, currently allocated for use by
  19424. * the CUDA graphs asynchronous allocator.
  19425. *
  19426. * \param device - Specifies the scope of the query
  19427. * \param attr - attribute to get
  19428. * \param value - pointer to value to set
  19429. *
  19430. * \return
  19431. * ::CUDA_SUCCESS,
  19432. * ::CUDA_ERROR_INVALID_DEVICE
  19433. *
  19434. * \sa
  19435. * ::cuDeviceGetGraphMemAttribute,
  19436. * ::cuGraphAddMemAllocNode,
  19437. * ::cuGraphAddMemFreeNode
  19438. */
  19439. CUresult CUDAAPI cuDeviceSetGraphMemAttribute(CUdevice device, CUgraphMem_attribute attr, void* value);
  19440. /**
  19441. * \brief Clones a graph
  19442. *
  19443. * This function creates a copy of \p originalGraph and returns it in \p phGraphClone.
  19444. * All parameters are copied into the cloned graph. The original graph may be modified
  19445. * after this call without affecting the clone.
  19446. *
  19447. * Child graph nodes in the original graph are recursively copied into the clone.
  19448. *
  19449. * \param phGraphClone - Returns newly created cloned graph
  19450. * \param originalGraph - Graph to clone
  19451. *
  19452. * \return
  19453. * ::CUDA_SUCCESS,
  19454. * ::CUDA_ERROR_INVALID_VALUE,
  19455. * ::CUDA_ERROR_OUT_OF_MEMORY
  19456. * \note_graph_thread_safety
  19457. * \notefnerr
  19458. *
  19459. * \sa
  19460. * ::cuGraphCreate,
  19461. * ::cuGraphNodeFindInClone
  19462. */
  19463. CUresult CUDAAPI cuGraphClone(CUgraph *phGraphClone, CUgraph originalGraph);
  19464. /**
  19465. * \brief Finds a cloned version of a node
  19466. *
  19467. * This function returns the node in \p hClonedGraph corresponding to \p hOriginalNode
  19468. * in the original graph.
  19469. *
  19470. * \p hClonedGraph must have been cloned from \p hOriginalGraph via ::cuGraphClone.
  19471. * \p hOriginalNode must have been in \p hOriginalGraph at the time of the call to
  19472. * ::cuGraphClone, and the corresponding cloned node in \p hClonedGraph must not have
  19473. * been removed. The cloned node is then returned via \p phClonedNode.
  19474. *
  19475. * \param phNode - Returns handle to the cloned node
  19476. * \param hOriginalNode - Handle to the original node
  19477. * \param hClonedGraph - Cloned graph to query
  19478. *
  19479. * \return
  19480. * ::CUDA_SUCCESS,
  19481. * ::CUDA_ERROR_INVALID_VALUE,
  19482. * \note_graph_thread_safety
  19483. * \notefnerr
  19484. *
  19485. * \sa
  19486. * ::cuGraphClone
  19487. */
  19488. CUresult CUDAAPI cuGraphNodeFindInClone(CUgraphNode *phNode, CUgraphNode hOriginalNode, CUgraph hClonedGraph);
  19489. /**
  19490. * \brief Returns a node's type
  19491. *
  19492. * Returns the node type of \p hNode in \p type.
  19493. *
  19494. * \param hNode - Node to query
  19495. * \param type - Pointer to return the node type
  19496. *
  19497. * \return
  19498. * ::CUDA_SUCCESS,
  19499. * ::CUDA_ERROR_DEINITIALIZED,
  19500. * ::CUDA_ERROR_NOT_INITIALIZED,
  19501. * ::CUDA_ERROR_INVALID_VALUE
  19502. * \note_graph_thread_safety
  19503. * \notefnerr
  19504. *
  19505. * \sa
  19506. * ::cuGraphGetNodes,
  19507. * ::cuGraphGetRootNodes,
  19508. * ::cuGraphChildGraphNodeGetGraph,
  19509. * ::cuGraphKernelNodeGetParams,
  19510. * ::cuGraphKernelNodeSetParams,
  19511. * ::cuGraphHostNodeGetParams,
  19512. * ::cuGraphHostNodeSetParams,
  19513. * ::cuGraphMemcpyNodeGetParams,
  19514. * ::cuGraphMemcpyNodeSetParams,
  19515. * ::cuGraphMemsetNodeGetParams,
  19516. * ::cuGraphMemsetNodeSetParams
  19517. */
  19518. CUresult CUDAAPI cuGraphNodeGetType(CUgraphNode hNode, CUgraphNodeType *type);
  19519. /**
  19520. * \brief Returns a graph's nodes
  19521. *
  19522. * Returns a list of \p hGraph's nodes. \p nodes may be NULL, in which case this
  19523. * function will return the number of nodes in \p numNodes. Otherwise,
  19524. * \p numNodes entries will be filled in. If \p numNodes is higher than the actual
  19525. * number of nodes, the remaining entries in \p nodes will be set to NULL, and the
  19526. * number of nodes actually obtained will be returned in \p numNodes.
  19527. *
  19528. * \param hGraph - Graph to query
  19529. * \param nodes - Pointer to return the nodes
  19530. * \param numNodes - See description
  19531. *
  19532. * \return
  19533. * ::CUDA_SUCCESS,
  19534. * ::CUDA_ERROR_DEINITIALIZED,
  19535. * ::CUDA_ERROR_NOT_INITIALIZED,
  19536. * ::CUDA_ERROR_INVALID_VALUE
  19537. * \note_graph_thread_safety
  19538. * \notefnerr
  19539. *
  19540. * \sa
  19541. * ::cuGraphCreate,
  19542. * ::cuGraphGetRootNodes,
  19543. * ::cuGraphGetEdges,
  19544. * ::cuGraphNodeGetType,
  19545. * ::cuGraphNodeGetDependencies,
  19546. * ::cuGraphNodeGetDependentNodes
  19547. */
  19548. CUresult CUDAAPI cuGraphGetNodes(CUgraph hGraph, CUgraphNode *nodes, size_t *numNodes);
  19549. /**
  19550. * \brief Returns a graph's root nodes
  19551. *
  19552. * Returns a list of \p hGraph's root nodes. \p rootNodes may be NULL, in which case this
  19553. * function will return the number of root nodes in \p numRootNodes. Otherwise,
  19554. * \p numRootNodes entries will be filled in. If \p numRootNodes is higher than the actual
  19555. * number of root nodes, the remaining entries in \p rootNodes will be set to NULL, and the
  19556. * number of nodes actually obtained will be returned in \p numRootNodes.
  19557. *
  19558. * \param hGraph - Graph to query
  19559. * \param rootNodes - Pointer to return the root nodes
  19560. * \param numRootNodes - See description
  19561. *
  19562. * \return
  19563. * ::CUDA_SUCCESS,
  19564. * ::CUDA_ERROR_DEINITIALIZED,
  19565. * ::CUDA_ERROR_NOT_INITIALIZED,
  19566. * ::CUDA_ERROR_INVALID_VALUE
  19567. * \note_graph_thread_safety
  19568. * \notefnerr
  19569. *
  19570. * \sa
  19571. * ::cuGraphCreate,
  19572. * ::cuGraphGetNodes,
  19573. * ::cuGraphGetEdges,
  19574. * ::cuGraphNodeGetType,
  19575. * ::cuGraphNodeGetDependencies,
  19576. * ::cuGraphNodeGetDependentNodes
  19577. */
  19578. CUresult CUDAAPI cuGraphGetRootNodes(CUgraph hGraph, CUgraphNode *rootNodes, size_t *numRootNodes);
  19579. /**
  19580. * \brief Returns a graph's dependency edges
  19581. *
  19582. * Returns a list of \p hGraph's dependency edges. Edges are returned via corresponding
  19583. * indices in \p from and \p to; that is, the node in \p to[i] has a dependency on the
  19584. * node in \p from[i]. \p from and \p to may both be NULL, in which
  19585. * case this function only returns the number of edges in \p numEdges. Otherwise,
  19586. * \p numEdges entries will be filled in. If \p numEdges is higher than the actual
  19587. * number of edges, the remaining entries in \p from and \p to will be set to NULL, and
  19588. * the number of edges actually returned will be written to \p numEdges.
  19589. *
  19590. * \param hGraph - Graph to get the edges from
  19591. * \param from - Location to return edge endpoints
  19592. * \param to - Location to return edge endpoints
  19593. * \param numEdges - See description
  19594. *
  19595. * \return
  19596. * ::CUDA_SUCCESS,
  19597. * ::CUDA_ERROR_DEINITIALIZED,
  19598. * ::CUDA_ERROR_NOT_INITIALIZED,
  19599. * ::CUDA_ERROR_INVALID_VALUE
  19600. * \note_graph_thread_safety
  19601. * \notefnerr
  19602. *
  19603. * \sa
  19604. * ::cuGraphGetNodes,
  19605. * ::cuGraphGetRootNodes,
  19606. * ::cuGraphAddDependencies,
  19607. * ::cuGraphRemoveDependencies,
  19608. * ::cuGraphNodeGetDependencies,
  19609. * ::cuGraphNodeGetDependentNodes
  19610. */
  19611. CUresult CUDAAPI cuGraphGetEdges(CUgraph hGraph, CUgraphNode *from, CUgraphNode *to, size_t *numEdges);
  19612. /**
  19613. * \brief Returns a graph's dependency edges (12.3+)
  19614. *
  19615. * Returns a list of \p hGraph's dependency edges. Edges are returned via corresponding
  19616. * indices in \p from, \p to and \p edgeData; that is, the node in \p to[i] has a
  19617. * dependency on the node in \p from[i] with data \p edgeData[i]. \p from and \p to may
  19618. * both be NULL, in which case this function only returns the number of edges in
  19619. * \p numEdges. Otherwise, \p numEdges entries will be filled in. If \p numEdges is higher
  19620. * than the actual number of edges, the remaining entries in \p from and \p to will be
  19621. * set to NULL, and the number of edges actually returned will be written to \p numEdges.
  19622. * \p edgeData may alone be NULL, in which case the edges must all have default (zeroed)
  19623. * edge data. Attempting a lossy query via NULL \p edgeData will result in
  19624. * ::CUDA_ERROR_LOSSY_QUERY. If \p edgeData is non-NULL then \p from and \p to must be
  19625. * as well.
  19626. *
  19627. * \param hGraph - Graph to get the edges from
  19628. * \param from - Location to return edge endpoints
  19629. * \param to - Location to return edge endpoints
  19630. * \param edgeData - Optional location to return edge data
  19631. * \param numEdges - See description
  19632. *
  19633. * \return
  19634. * ::CUDA_SUCCESS,
  19635. * ::CUDA_ERROR_LOSSY_QUERY,
  19636. * ::CUDA_ERROR_DEINITIALIZED,
  19637. * ::CUDA_ERROR_NOT_INITIALIZED,
  19638. * ::CUDA_ERROR_INVALID_VALUE
  19639. * \note_graph_thread_safety
  19640. * \notefnerr
  19641. *
  19642. * \sa
  19643. * ::cuGraphGetNodes,
  19644. * ::cuGraphGetRootNodes,
  19645. * ::cuGraphAddDependencies,
  19646. * ::cuGraphRemoveDependencies,
  19647. * ::cuGraphNodeGetDependencies,
  19648. * ::cuGraphNodeGetDependentNodes
  19649. */
  19650. CUresult CUDAAPI cuGraphGetEdges_v2(CUgraph hGraph, CUgraphNode *from, CUgraphNode *to, CUgraphEdgeData *edgeData, size_t *numEdges);
  19651. /**
  19652. * \brief Returns a node's dependencies
  19653. *
  19654. * Returns a list of \p node's dependencies. \p dependencies may be NULL, in which case this
  19655. * function will return the number of dependencies in \p numDependencies. Otherwise,
  19656. * \p numDependencies entries will be filled in. If \p numDependencies is higher than the actual
  19657. * number of dependencies, the remaining entries in \p dependencies will be set to NULL, and the
  19658. * number of nodes actually obtained will be returned in \p numDependencies.
  19659. *
  19660. * \param hNode - Node to query
  19661. * \param dependencies - Pointer to return the dependencies
  19662. * \param numDependencies - See description
  19663. *
  19664. * \return
  19665. * ::CUDA_SUCCESS,
  19666. * ::CUDA_ERROR_DEINITIALIZED,
  19667. * ::CUDA_ERROR_NOT_INITIALIZED,
  19668. * ::CUDA_ERROR_INVALID_VALUE
  19669. * \note_graph_thread_safety
  19670. * \notefnerr
  19671. *
  19672. * \sa
  19673. * ::cuGraphNodeGetDependentNodes,
  19674. * ::cuGraphGetNodes,
  19675. * ::cuGraphGetRootNodes,
  19676. * ::cuGraphGetEdges,
  19677. * ::cuGraphAddDependencies,
  19678. * ::cuGraphRemoveDependencies
  19679. */
  19680. CUresult CUDAAPI cuGraphNodeGetDependencies(CUgraphNode hNode, CUgraphNode *dependencies, size_t *numDependencies);
  19681. /**
  19682. * \brief Returns a node's dependencies (12.3+)
  19683. *
  19684. * Returns a list of \p node's dependencies. \p dependencies may be NULL, in which case this
  19685. * function will return the number of dependencies in \p numDependencies. Otherwise,
  19686. * \p numDependencies entries will be filled in. If \p numDependencies is higher than the actual
  19687. * number of dependencies, the remaining entries in \p dependencies will be set to NULL, and the
  19688. * number of nodes actually obtained will be returned in \p numDependencies.
  19689. *
  19690. * Note that if an edge has non-zero (non-default) edge data and \p edgeData is NULL,
  19691. * this API will return ::CUDA_ERROR_LOSSY_QUERY. If \p edgeData is non-NULL, then
  19692. * \p dependencies must be as well.
  19693. *
  19694. * \param hNode - Node to query
  19695. * \param dependencies - Pointer to return the dependencies
  19696. * \param edgeData - Optional array to return edge data for each dependency
  19697. * \param numDependencies - See description
  19698. *
  19699. * \return
  19700. * ::CUDA_SUCCESS,
  19701. * ::CUDA_ERROR_LOSSY_QUERY,
  19702. * ::CUDA_ERROR_DEINITIALIZED,
  19703. * ::CUDA_ERROR_NOT_INITIALIZED,
  19704. * ::CUDA_ERROR_INVALID_VALUE
  19705. * \note_graph_thread_safety
  19706. * \notefnerr
  19707. *
  19708. * \sa
  19709. * ::cuGraphNodeGetDependentNodes,
  19710. * ::cuGraphGetNodes,
  19711. * ::cuGraphGetRootNodes,
  19712. * ::cuGraphGetEdges,
  19713. * ::cuGraphAddDependencies,
  19714. * ::cuGraphRemoveDependencies
  19715. */
  19716. CUresult CUDAAPI cuGraphNodeGetDependencies_v2(CUgraphNode hNode, CUgraphNode *dependencies, CUgraphEdgeData *edgeData, size_t *numDependencies);
  19717. /**
  19718. * \brief Returns a node's dependent nodes
  19719. *
  19720. * Returns a list of \p node's dependent nodes. \p dependentNodes may be NULL, in which
  19721. * case this function will return the number of dependent nodes in \p numDependentNodes.
  19722. * Otherwise, \p numDependentNodes entries will be filled in. If \p numDependentNodes is
  19723. * higher than the actual number of dependent nodes, the remaining entries in
  19724. * \p dependentNodes will be set to NULL, and the number of nodes actually obtained will
  19725. * be returned in \p numDependentNodes.
  19726. *
  19727. * \param hNode - Node to query
  19728. * \param dependentNodes - Pointer to return the dependent nodes
  19729. * \param numDependentNodes - See description
  19730. *
  19731. * \return
  19732. * ::CUDA_SUCCESS,
  19733. * ::CUDA_ERROR_DEINITIALIZED,
  19734. * ::CUDA_ERROR_NOT_INITIALIZED,
  19735. * ::CUDA_ERROR_INVALID_VALUE
  19736. * \note_graph_thread_safety
  19737. * \notefnerr
  19738. *
  19739. * \sa
  19740. * ::cuGraphNodeGetDependencies,
  19741. * ::cuGraphGetNodes,
  19742. * ::cuGraphGetRootNodes,
  19743. * ::cuGraphGetEdges,
  19744. * ::cuGraphAddDependencies,
  19745. * ::cuGraphRemoveDependencies
  19746. */
  19747. CUresult CUDAAPI cuGraphNodeGetDependentNodes(CUgraphNode hNode, CUgraphNode *dependentNodes, size_t *numDependentNodes);
  19748. /**
  19749. * \brief Returns a node's dependent nodes (12.3+)
  19750. *
  19751. * Returns a list of \p node's dependent nodes. \p dependentNodes may be NULL, in which
  19752. * case this function will return the number of dependent nodes in \p numDependentNodes.
  19753. * Otherwise, \p numDependentNodes entries will be filled in. If \p numDependentNodes is
  19754. * higher than the actual number of dependent nodes, the remaining entries in
  19755. * \p dependentNodes will be set to NULL, and the number of nodes actually obtained will
  19756. * be returned in \p numDependentNodes.
  19757. *
  19758. * Note that if an edge has non-zero (non-default) edge data and \p edgeData is NULL,
  19759. * this API will return ::CUDA_ERROR_LOSSY_QUERY. If \p edgeData is non-NULL, then
  19760. * \p dependentNodes must be as well.
  19761. *
  19762. * \param hNode - Node to query
  19763. * \param dependentNodes - Pointer to return the dependent nodes
  19764. * \param edgeData - Optional pointer to return edge data for dependent nodes
  19765. * \param numDependentNodes - See description
  19766. *
  19767. * \return
  19768. * ::CUDA_SUCCESS,
  19769. * ::CUDA_ERROR_LOSSY_QUERY,
  19770. * ::CUDA_ERROR_DEINITIALIZED,
  19771. * ::CUDA_ERROR_NOT_INITIALIZED,
  19772. * ::CUDA_ERROR_INVALID_VALUE
  19773. * \note_graph_thread_safety
  19774. * \notefnerr
  19775. *
  19776. * \sa
  19777. * ::cuGraphNodeGetDependencies,
  19778. * ::cuGraphGetNodes,
  19779. * ::cuGraphGetRootNodes,
  19780. * ::cuGraphGetEdges,
  19781. * ::cuGraphAddDependencies,
  19782. * ::cuGraphRemoveDependencies
  19783. */
  19784. CUresult CUDAAPI cuGraphNodeGetDependentNodes_v2(CUgraphNode hNode, CUgraphNode *dependentNodes, CUgraphEdgeData *edgeData, size_t *numDependentNodes);
  19785. /**
  19786. * \brief Adds dependency edges to a graph
  19787. *
  19788. * The number of dependencies to be added is defined by \p numDependencies
  19789. * Elements in \p from and \p to at corresponding indices define a dependency.
  19790. * Each node in \p from and \p to must belong to \p hGraph.
  19791. *
  19792. * If \p numDependencies is 0, elements in \p from and \p to will be ignored.
  19793. * Specifying an existing dependency will return an error.
  19794. *
  19795. * \param hGraph - Graph to which dependencies are added
  19796. * \param from - Array of nodes that provide the dependencies
  19797. * \param to - Array of dependent nodes
  19798. * \param numDependencies - Number of dependencies to be added
  19799. *
  19800. * \return
  19801. * ::CUDA_SUCCESS,
  19802. * ::CUDA_ERROR_INVALID_VALUE
  19803. * \note_graph_thread_safety
  19804. * \notefnerr
  19805. *
  19806. * \sa
  19807. * ::cuGraphRemoveDependencies,
  19808. * ::cuGraphGetEdges,
  19809. * ::cuGraphNodeGetDependencies,
  19810. * ::cuGraphNodeGetDependentNodes
  19811. */
  19812. CUresult CUDAAPI cuGraphAddDependencies(CUgraph hGraph, const CUgraphNode *from, const CUgraphNode *to, size_t numDependencies);
  19813. /**
  19814. * \brief Adds dependency edges to a graph (12.3+)
  19815. *
  19816. * The number of dependencies to be added is defined by \p numDependencies
  19817. * Elements in \p from and \p to at corresponding indices define a dependency.
  19818. * Each node in \p from and \p to must belong to \p hGraph.
  19819. *
  19820. * If \p numDependencies is 0, elements in \p from and \p to will be ignored.
  19821. * Specifying an existing dependency will return an error.
  19822. *
  19823. * \param hGraph - Graph to which dependencies are added
  19824. * \param from - Array of nodes that provide the dependencies
  19825. * \param to - Array of dependent nodes
  19826. * \param edgeData - Optional array of edge data. If NULL, default (zeroed) edge data is assumed.
  19827. * \param numDependencies - Number of dependencies to be added
  19828. *
  19829. * \return
  19830. * ::CUDA_SUCCESS,
  19831. * ::CUDA_ERROR_INVALID_VALUE
  19832. * \note_graph_thread_safety
  19833. * \notefnerr
  19834. *
  19835. * \sa
  19836. * ::cuGraphRemoveDependencies,
  19837. * ::cuGraphGetEdges,
  19838. * ::cuGraphNodeGetDependencies,
  19839. * ::cuGraphNodeGetDependentNodes
  19840. */
  19841. CUresult CUDAAPI cuGraphAddDependencies_v2(CUgraph hGraph, const CUgraphNode *from, const CUgraphNode *to, const CUgraphEdgeData *edgeData, size_t numDependencies);
  19842. /**
  19843. * \brief Removes dependency edges from a graph
  19844. *
  19845. * The number of \p dependencies to be removed is defined by \p numDependencies.
  19846. * Elements in \p from and \p to at corresponding indices define a dependency.
  19847. * Each node in \p from and \p to must belong to \p hGraph.
  19848. *
  19849. * If \p numDependencies is 0, elements in \p from and \p to will be ignored.
  19850. * Specifying a non-existing dependency will return an error.
  19851. *
  19852. * Dependencies cannot be removed from graphs which contain allocation or free nodes.
  19853. * Any attempt to do so will return an error.
  19854. *
  19855. * \param hGraph - Graph from which to remove dependencies
  19856. * \param from - Array of nodes that provide the dependencies
  19857. * \param to - Array of dependent nodes
  19858. * \param numDependencies - Number of dependencies to be removed
  19859. *
  19860. * \return
  19861. * ::CUDA_SUCCESS,
  19862. * ::CUDA_ERROR_INVALID_VALUE
  19863. * \note_graph_thread_safety
  19864. * \notefnerr
  19865. *
  19866. * \sa
  19867. * ::cuGraphAddDependencies,
  19868. * ::cuGraphGetEdges,
  19869. * ::cuGraphNodeGetDependencies,
  19870. * ::cuGraphNodeGetDependentNodes
  19871. */
  19872. CUresult CUDAAPI cuGraphRemoveDependencies(CUgraph hGraph, const CUgraphNode *from, const CUgraphNode *to, size_t numDependencies);
  19873. /**
  19874. * \brief Removes dependency edges from a graph (12.3+)
  19875. *
  19876. * The number of \p dependencies to be removed is defined by \p numDependencies.
  19877. * Elements in \p from and \p to at corresponding indices define a dependency.
  19878. * Each node in \p from and \p to must belong to \p hGraph.
  19879. *
  19880. * If \p numDependencies is 0, elements in \p from and \p to will be ignored.
  19881. * Specifying an edge that does not exist in the graph, with data matching
  19882. * \p edgeData, results in an error. \p edgeData is nullable, which is equivalent
  19883. * to passing default (zeroed) data for each edge.
  19884. *
  19885. * Dependencies cannot be removed from graphs which contain allocation or free nodes.
  19886. * Any attempt to do so will return an error.
  19887. *
  19888. * \param hGraph - Graph from which to remove dependencies
  19889. * \param from - Array of nodes that provide the dependencies
  19890. * \param to - Array of dependent nodes
  19891. * \param edgeData - Optional array of edge data. If NULL, edge data is assumed to
  19892. * be default (zeroed).
  19893. * \param numDependencies - Number of dependencies to be removed
  19894. *
  19895. * \return
  19896. * ::CUDA_SUCCESS,
  19897. * ::CUDA_ERROR_INVALID_VALUE
  19898. * \note_graph_thread_safety
  19899. * \notefnerr
  19900. *
  19901. * \sa
  19902. * ::cuGraphAddDependencies,
  19903. * ::cuGraphGetEdges,
  19904. * ::cuGraphNodeGetDependencies,
  19905. * ::cuGraphNodeGetDependentNodes
  19906. */
  19907. CUresult CUDAAPI cuGraphRemoveDependencies_v2(CUgraph hGraph, const CUgraphNode *from, const CUgraphNode *to, const CUgraphEdgeData *edgeData, size_t numDependencies);
  19908. /**
  19909. * \brief Remove a node from the graph
  19910. *
  19911. * Removes \p hNode from its graph. This operation also severs any dependencies of other nodes
  19912. * on \p hNode and vice versa.
  19913. *
  19914. * Nodes which belong to a graph which contains allocation or free nodes cannot be destroyed.
  19915. * Any attempt to do so will return an error.
  19916. *
  19917. * \param hNode - Node to remove
  19918. *
  19919. * \return
  19920. * ::CUDA_SUCCESS,
  19921. * ::CUDA_ERROR_INVALID_VALUE
  19922. * \note_graph_thread_safety
  19923. * \notefnerr
  19924. *
  19925. * \sa
  19926. * ::cuGraphAddChildGraphNode,
  19927. * ::cuGraphAddEmptyNode,
  19928. * ::cuGraphAddKernelNode,
  19929. * ::cuGraphAddHostNode,
  19930. * ::cuGraphAddMemcpyNode,
  19931. * ::cuGraphAddMemsetNode
  19932. */
  19933. CUresult CUDAAPI cuGraphDestroyNode(CUgraphNode hNode);
  19934. /**
  19935. * \brief Creates an executable graph from a graph
  19936. *
  19937. * Instantiates \p hGraph as an executable graph. The graph is validated for any
  19938. * structural constraints or intra-node constraints which were not previously
  19939. * validated. If instantiation is successful, a handle to the instantiated graph
  19940. * is returned in \p phGraphExec.
  19941. *
  19942. * The \p flags parameter controls the behavior of instantiation and subsequent
  19943. * graph launches. Valid flags are:
  19944. *
  19945. * - ::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH, which configures a
  19946. * graph containing memory allocation nodes to automatically free any
  19947. * unfreed memory allocations before the graph is relaunched.
  19948. *
  19949. * - ::CUDA_GRAPH_INSTANTIATE_FLAG_DEVICE_LAUNCH, which configures the graph for launch
  19950. * from the device. If this flag is passed, the executable graph handle returned can be
  19951. * used to launch the graph from both the host and device. This flag can only be used
  19952. * on platforms which support unified addressing. This flag cannot be used in
  19953. * conjunction with ::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH.
  19954. *
  19955. * - ::CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY, which causes the graph
  19956. * to use the priorities from the per-node attributes rather than the priority
  19957. * of the launch stream during execution. Note that priorities are only available
  19958. * on kernel nodes, and are copied from stream priority during stream capture.
  19959. *
  19960. * If \p hGraph contains any allocation or free nodes, there can be at most one
  19961. * executable graph in existence for that graph at a time. An attempt to instantiate
  19962. * a second executable graph before destroying the first with ::cuGraphExecDestroy
  19963. * will result in an error.
  19964. * The same also applies if \p hGraph contains any device-updatable kernel nodes.
  19965. *
  19966. * If \p hGraph contains kernels which call device-side cudaGraphLaunch() from multiple
  19967. * contexts, this will result in an error.
  19968. *
  19969. * Graphs instantiated for launch on the device have additional restrictions which do not
  19970. * apply to host graphs:
  19971. *
  19972. * - The graph's nodes must reside on a single context.
  19973. * - The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes.
  19974. * - The graph cannot be empty and must contain at least one kernel, memcpy, or memset node.
  19975. * Operation-specific restrictions are outlined below.
  19976. * - Kernel nodes:
  19977. * - Use of CUDA Dynamic Parallelism is not permitted.
  19978. * - Cooperative launches are permitted as long as MPS is not in use.
  19979. * - Memcpy nodes:
  19980. * - Only copies involving device memory and/or pinned device-mapped host memory are permitted.
  19981. * - Copies involving CUDA arrays are not permitted.
  19982. * - Both operands must be accessible from the current context, and the current context must
  19983. * match the context of other nodes in the graph.
  19984. *
  19985. * \param phGraphExec - Returns instantiated graph
  19986. * \param hGraph - Graph to instantiate
  19987. * \param flags - Flags to control instantiation. See ::CUgraphInstantiate_flags.
  19988. *
  19989. * \return
  19990. * ::CUDA_SUCCESS,
  19991. * ::CUDA_ERROR_DEINITIALIZED,
  19992. * ::CUDA_ERROR_NOT_INITIALIZED,
  19993. * ::CUDA_ERROR_INVALID_VALUE
  19994. * \note_graph_thread_safety
  19995. * \notefnerr
  19996. *
  19997. * \sa
  19998. * ::cuGraphInstantiate,
  19999. * ::cuGraphCreate,
  20000. * ::cuGraphUpload,
  20001. * ::cuGraphLaunch,
  20002. * ::cuGraphExecDestroy
  20003. */
  20004. CUresult CUDAAPI cuGraphInstantiate(CUgraphExec *phGraphExec, CUgraph hGraph, unsigned long long flags);
  20005. /**
  20006. * \brief Creates an executable graph from a graph
  20007. *
  20008. * Instantiates \p hGraph as an executable graph according to the \p instantiateParams structure.
  20009. * The graph is validated for any structural constraints or intra-node constraints
  20010. * which were not previously validated. If instantiation is successful, a handle to
  20011. * the instantiated graph is returned in \p phGraphExec.
  20012. *
  20013. * \p instantiateParams controls the behavior of instantiation and subsequent
  20014. * graph launches, as well as returning more detailed information in the event of an error.
  20015. * ::CUDA_GRAPH_INSTANTIATE_PARAMS is defined as:
  20016. *
  20017. * \code
  20018. typedef struct {
  20019. cuuint64_t flags;
  20020. CUstream hUploadStream;
  20021. CUgraphNode hErrNode_out;
  20022. CUgraphInstantiateResult result_out;
  20023. } CUDA_GRAPH_INSTANTIATE_PARAMS;
  20024. * \endcode
  20025. *
  20026. * The \p flags field controls the behavior of instantiation and subsequent
  20027. * graph launches. Valid flags are:
  20028. *
  20029. * - ::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH, which configures a
  20030. * graph containing memory allocation nodes to automatically free any
  20031. * unfreed memory allocations before the graph is relaunched.
  20032. *
  20033. * - ::CUDA_GRAPH_INSTANTIATE_FLAG_UPLOAD, which will perform an upload of the graph
  20034. * into \p hUploadStream once the graph has been instantiated.
  20035. *
  20036. * - ::CUDA_GRAPH_INSTANTIATE_FLAG_DEVICE_LAUNCH, which configures the graph for launch
  20037. * from the device. If this flag is passed, the executable graph handle returned can be
  20038. * used to launch the graph from both the host and device. This flag can only be used
  20039. * on platforms which support unified addressing. This flag cannot be used in
  20040. * conjunction with ::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH.
  20041. *
  20042. * - ::CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY, which causes the graph
  20043. * to use the priorities from the per-node attributes rather than the priority
  20044. * of the launch stream during execution. Note that priorities are only available
  20045. * on kernel nodes, and are copied from stream priority during stream capture.
  20046. *
  20047. * If \p hGraph contains any allocation or free nodes, there can be at most one
  20048. * executable graph in existence for that graph at a time. An attempt to instantiate a
  20049. * second executable graph before destroying the first with ::cuGraphExecDestroy will
  20050. * result in an error.
  20051. * The same also applies if \p hGraph contains any device-updatable kernel nodes.
  20052. *
  20053. * If \p hGraph contains kernels which call device-side cudaGraphLaunch() from multiple
  20054. * contexts, this will result in an error.
  20055. *
  20056. * Graphs instantiated for launch on the device have additional restrictions which do not
  20057. * apply to host graphs:
  20058. *
  20059. * - The graph's nodes must reside on a single context.
  20060. * - The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes.
  20061. * - The graph cannot be empty and must contain at least one kernel, memcpy, or memset node.
  20062. * Operation-specific restrictions are outlined below.
  20063. * - Kernel nodes:
  20064. * - Use of CUDA Dynamic Parallelism is not permitted.
  20065. * - Cooperative launches are permitted as long as MPS is not in use.
  20066. * - Memcpy nodes:
  20067. * - Only copies involving device memory and/or pinned device-mapped host memory are permitted.
  20068. * - Copies involving CUDA arrays are not permitted.
  20069. * - Both operands must be accessible from the current context, and the current context must
  20070. * match the context of other nodes in the graph.
  20071. *
  20072. * In the event of an error, the \p result_out and \p hErrNode_out fields will contain more
  20073. * information about the nature of the error. Possible error reporting includes:
  20074. *
  20075. * - ::CUDA_GRAPH_INSTANTIATE_ERROR, if passed an invalid value or if an unexpected error occurred
  20076. * which is described by the return value of the function. \p hErrNode_out will be set to NULL.
  20077. * - ::CUDA_GRAPH_INSTANTIATE_INVALID_STRUCTURE, if the graph structure is invalid. \p hErrNode_out
  20078. * will be set to one of the offending nodes.
  20079. * - ::CUDA_GRAPH_INSTANTIATE_NODE_OPERATION_NOT_SUPPORTED, if the graph is instantiated for device
  20080. * launch but contains a node of an unsupported node type, or a node which performs unsupported
  20081. * operations, such as use of CUDA dynamic parallelism within a kernel node. \p hErrNode_out will
  20082. * be set to this node.
  20083. * - ::CUDA_GRAPH_INSTANTIATE_MULTIPLE_CTXS_NOT_SUPPORTED, if the graph is instantiated for device
  20084. * launch but a node’s context differs from that of another node. This error can also be returned
  20085. * if a graph is not instantiated for device launch and it contains kernels which call device-side
  20086. * cudaGraphLaunch() from multiple contexts. \p hErrNode_out will be set to this node.
  20087. *
  20088. * If instantiation is successful, \p result_out will be set to ::CUDA_GRAPH_INSTANTIATE_SUCCESS,
  20089. * and \p hErrNode_out will be set to NULL.
  20090. *
  20091. * \param phGraphExec - Returns instantiated graph
  20092. * \param hGraph - Graph to instantiate
  20093. * \param instantiateParams - Instantiation parameters
  20094. *
  20095. * \return
  20096. * ::CUDA_SUCCESS,
  20097. * ::CUDA_ERROR_INVALID_VALUE,
  20098. * \note_graph_thread_safety
  20099. * \notefnerr
  20100. *
  20101. * \sa
  20102. * ::cuGraphCreate,
  20103. * ::cuGraphInstantiate,
  20104. * ::cuGraphExecDestroy
  20105. */
  20106. CUresult CUDAAPI cuGraphInstantiateWithParams(CUgraphExec *phGraphExec, CUgraph hGraph, CUDA_GRAPH_INSTANTIATE_PARAMS *instantiateParams);
  20107. /**
  20108. * \brief Query the instantiation flags of an executable graph
  20109. *
  20110. * Returns the flags that were passed to instantiation for the given executable graph.
  20111. * ::CUDA_GRAPH_INSTANTIATE_FLAG_UPLOAD will not be returned by this API as it does
  20112. * not affect the resulting executable graph.
  20113. *
  20114. * \param hGraphExec - The executable graph to query
  20115. * \param flags - Returns the instantiation flags
  20116. *
  20117. * \return
  20118. * ::CUDA_SUCCESS,
  20119. * ::CUDA_ERROR_INVALID_VALUE,
  20120. * \note_graph_thread_safety
  20121. * \notefnerr
  20122. *
  20123. * \sa
  20124. * ::cuGraphInstantiate,
  20125. * ::cuGraphInstantiateWithParams
  20126. */
  20127. CUresult CUDAAPI cuGraphExecGetFlags(CUgraphExec hGraphExec, cuuint64_t *flags);
  20128. /**
  20129. * \brief Sets the parameters for a kernel node in the given graphExec
  20130. *
  20131. * Sets the parameters of a kernel node in an executable graph \p hGraphExec.
  20132. * The node is identified by the corresponding node \p hNode in the
  20133. * non-executable graph, from which the executable graph was instantiated.
  20134. *
  20135. * \p hNode must not have been removed from the original graph. All \p nodeParams
  20136. * fields may change, but the following restrictions apply to \p func updates:
  20137. *
  20138. * - The owning context of the function cannot change.
  20139. * - A node whose function originally did not use CUDA dynamic parallelism cannot be updated
  20140. * to a function which uses CDP
  20141. * - A node whose function originally did not make device-side update calls cannot be updated
  20142. * to a function which makes device-side update calls.
  20143. * - If \p hGraphExec was not instantiated for device launch, a node whose function originally
  20144. * did not use device-side cudaGraphLaunch() cannot be updated to a function which uses
  20145. * device-side cudaGraphLaunch() unless the node resides on the same context as nodes which
  20146. * contained such calls at instantiate-time. If no such calls were present at instantiation,
  20147. * these updates cannot be performed at all.
  20148. *
  20149. * The modifications only affect future launches of \p hGraphExec. Already
  20150. * enqueued or running launches of \p hGraphExec are not affected by this call.
  20151. * \p hNode is also not modified by this call.
  20152. *
  20153. * If \p hNode is a device-updatable kernel node, the next upload/launch of \p hGraphExec
  20154. * will overwrite any previous device-side updates. Additionally, applying host updates to a
  20155. * device-updatable kernel node while it is being updated from the device will result in
  20156. * undefined behavior.
  20157. *
  20158. * \param hGraphExec - The executable graph in which to set the specified node
  20159. * \param hNode - kernel node from the graph from which graphExec was instantiated
  20160. * \param nodeParams - Updated Parameters to set
  20161. *
  20162. * \return
  20163. * ::CUDA_SUCCESS,
  20164. * ::CUDA_ERROR_INVALID_VALUE,
  20165. * \note_graph_thread_safety
  20166. * \notefnerr
  20167. *
  20168. * \sa
  20169. * ::cuGraphExecNodeSetParams,
  20170. * ::cuGraphAddKernelNode,
  20171. * ::cuGraphKernelNodeSetParams,
  20172. * ::cuGraphExecMemcpyNodeSetParams,
  20173. * ::cuGraphExecMemsetNodeSetParams,
  20174. * ::cuGraphExecHostNodeSetParams,
  20175. * ::cuGraphExecChildGraphNodeSetParams,
  20176. * ::cuGraphExecEventRecordNodeSetEvent,
  20177. * ::cuGraphExecEventWaitNodeSetEvent,
  20178. * ::cuGraphExecExternalSemaphoresSignalNodeSetParams,
  20179. * ::cuGraphExecExternalSemaphoresWaitNodeSetParams,
  20180. * ::cuGraphExecUpdate,
  20181. * ::cuGraphInstantiate
  20182. */
  20183. CUresult CUDAAPI cuGraphExecKernelNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_KERNEL_NODE_PARAMS *nodeParams);
  20184. /**
  20185. * \brief Sets the parameters for a memcpy node in the given graphExec.
  20186. *
  20187. * Updates the work represented by \p hNode in \p hGraphExec as though \p hNode had
  20188. * contained \p copyParams at instantiation. hNode must remain in the graph which was
  20189. * used to instantiate \p hGraphExec. Changed edges to and from hNode are ignored.
  20190. *
  20191. * The source and destination memory in \p copyParams must be allocated from the same
  20192. * contexts as the original source and destination memory. Both the instantiation-time
  20193. * memory operands and the memory operands in \p copyParams must be 1-dimensional.
  20194. * Zero-length operations are not supported.
  20195. *
  20196. * The modifications only affect future launches of \p hGraphExec. Already enqueued
  20197. * or running launches of \p hGraphExec are not affected by this call. hNode is also
  20198. * not modified by this call.
  20199. *
  20200. * Returns CUDA_ERROR_INVALID_VALUE if the memory operands' mappings changed or
  20201. * either the original or new memory operands are multidimensional.
  20202. *
  20203. * \param hGraphExec - The executable graph in which to set the specified node
  20204. * \param hNode - Memcpy node from the graph which was used to instantiate graphExec
  20205. * \param copyParams - The updated parameters to set
  20206. * \param ctx - Context on which to run the node
  20207. *
  20208. * \return
  20209. * ::CUDA_SUCCESS,
  20210. * ::CUDA_ERROR_INVALID_VALUE,
  20211. * \note_graph_thread_safety
  20212. * \notefnerr
  20213. *
  20214. * \sa
  20215. * ::cuGraphExecNodeSetParams,
  20216. * ::cuGraphAddMemcpyNode,
  20217. * ::cuGraphMemcpyNodeSetParams,
  20218. * ::cuGraphExecKernelNodeSetParams,
  20219. * ::cuGraphExecMemsetNodeSetParams,
  20220. * ::cuGraphExecHostNodeSetParams,
  20221. * ::cuGraphExecChildGraphNodeSetParams,
  20222. * ::cuGraphExecEventRecordNodeSetEvent,
  20223. * ::cuGraphExecEventWaitNodeSetEvent,
  20224. * ::cuGraphExecExternalSemaphoresSignalNodeSetParams,
  20225. * ::cuGraphExecExternalSemaphoresWaitNodeSetParams,
  20226. * ::cuGraphExecUpdate,
  20227. * ::cuGraphInstantiate
  20228. */
  20229. CUresult CUDAAPI cuGraphExecMemcpyNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_MEMCPY3D *copyParams, CUcontext ctx);
  20230. /**
  20231. * \brief Sets the parameters for a memset node in the given graphExec.
  20232. *
  20233. * Updates the work represented by \p hNode in \p hGraphExec as though \p hNode had
  20234. * contained \p memsetParams at instantiation. hNode must remain in the graph which was
  20235. * used to instantiate \p hGraphExec. Changed edges to and from hNode are ignored.
  20236. *
  20237. * Zero sized operations are not supported.
  20238. *
  20239. * The new destination pointer in memsetParams must be to the same kind of allocation
  20240. * as the original destination pointer and have the same context association and device mapping
  20241. * as the original destination pointer.
  20242. *
  20243. * Both the value and pointer address may be updated.
  20244. * Changing other aspects of the memset (width, height, element size or pitch) may cause the update to be rejected.
  20245. * Specifically, for 2d memsets, all dimension changes are rejected.
  20246. * For 1d memsets, changes in height are explicitly rejected and other changes are oportunistically allowed
  20247. * if the resulting work maps onto the work resources already allocated for the node.
  20248. *
  20249. * The modifications only affect future launches of \p hGraphExec. Already enqueued
  20250. * or running launches of \p hGraphExec are not affected by this call. hNode is also
  20251. * not modified by this call.
  20252. *
  20253. * \param hGraphExec - The executable graph in which to set the specified node
  20254. * \param hNode - Memset node from the graph which was used to instantiate graphExec
  20255. * \param memsetParams - The updated parameters to set
  20256. * \param ctx - Context on which to run the node
  20257. *
  20258. * \return
  20259. * ::CUDA_SUCCESS,
  20260. * ::CUDA_ERROR_INVALID_VALUE,
  20261. * \note_graph_thread_safety
  20262. * \notefnerr
  20263. *
  20264. * \sa
  20265. * ::cuGraphExecNodeSetParams,
  20266. * ::cuGraphAddMemsetNode,
  20267. * ::cuGraphMemsetNodeSetParams,
  20268. * ::cuGraphExecKernelNodeSetParams,
  20269. * ::cuGraphExecMemcpyNodeSetParams,
  20270. * ::cuGraphExecHostNodeSetParams,
  20271. * ::cuGraphExecChildGraphNodeSetParams,
  20272. * ::cuGraphExecEventRecordNodeSetEvent,
  20273. * ::cuGraphExecEventWaitNodeSetEvent,
  20274. * ::cuGraphExecExternalSemaphoresSignalNodeSetParams,
  20275. * ::cuGraphExecExternalSemaphoresWaitNodeSetParams,
  20276. * ::cuGraphExecUpdate,
  20277. * ::cuGraphInstantiate
  20278. */
  20279. CUresult CUDAAPI cuGraphExecMemsetNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_MEMSET_NODE_PARAMS *memsetParams, CUcontext ctx);
  20280. /**
  20281. * \brief Sets the parameters for a host node in the given graphExec.
  20282. *
  20283. * Updates the work represented by \p hNode in \p hGraphExec as though \p hNode had
  20284. * contained \p nodeParams at instantiation. hNode must remain in the graph which was
  20285. * used to instantiate \p hGraphExec. Changed edges to and from hNode are ignored.
  20286. *
  20287. * The modifications only affect future launches of \p hGraphExec. Already enqueued
  20288. * or running launches of \p hGraphExec are not affected by this call. hNode is also
  20289. * not modified by this call.
  20290. *
  20291. * \param hGraphExec - The executable graph in which to set the specified node
  20292. * \param hNode - Host node from the graph which was used to instantiate graphExec
  20293. * \param nodeParams - The updated parameters to set
  20294. *
  20295. * \return
  20296. * ::CUDA_SUCCESS,
  20297. * ::CUDA_ERROR_INVALID_VALUE,
  20298. * \note_graph_thread_safety
  20299. * \notefnerr
  20300. *
  20301. * \sa
  20302. * ::cuGraphExecNodeSetParams,
  20303. * ::cuGraphAddHostNode,
  20304. * ::cuGraphHostNodeSetParams,
  20305. * ::cuGraphExecKernelNodeSetParams,
  20306. * ::cuGraphExecMemcpyNodeSetParams,
  20307. * ::cuGraphExecMemsetNodeSetParams,
  20308. * ::cuGraphExecChildGraphNodeSetParams,
  20309. * ::cuGraphExecEventRecordNodeSetEvent,
  20310. * ::cuGraphExecEventWaitNodeSetEvent,
  20311. * ::cuGraphExecExternalSemaphoresSignalNodeSetParams,
  20312. * ::cuGraphExecExternalSemaphoresWaitNodeSetParams,
  20313. * ::cuGraphExecUpdate,
  20314. * ::cuGraphInstantiate
  20315. */
  20316. CUresult CUDAAPI cuGraphExecHostNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_HOST_NODE_PARAMS *nodeParams);
  20317. /**
  20318. * \brief Updates node parameters in the child graph node in the given graphExec.
  20319. *
  20320. * Updates the work represented by \p hNode in \p hGraphExec as though the nodes contained
  20321. * in \p hNode's graph had the parameters contained in \p childGraph's nodes at instantiation.
  20322. * \p hNode must remain in the graph which was used to instantiate \p hGraphExec.
  20323. * Changed edges to and from \p hNode are ignored.
  20324. *
  20325. * The modifications only affect future launches of \p hGraphExec. Already enqueued
  20326. * or running launches of \p hGraphExec are not affected by this call. \p hNode is also
  20327. * not modified by this call.
  20328. *
  20329. * The topology of \p childGraph, as well as the node insertion order, must match that
  20330. * of the graph contained in \p hNode. See ::cuGraphExecUpdate() for a list of restrictions
  20331. * on what can be updated in an instantiated graph. The update is recursive, so child graph
  20332. * nodes contained within the top level child graph will also be updated.
  20333. *
  20334. * \param hGraphExec - The executable graph in which to set the specified node
  20335. * \param hNode - Host node from the graph which was used to instantiate graphExec
  20336. * \param childGraph - The graph supplying the updated parameters
  20337. *
  20338. * \return
  20339. * ::CUDA_SUCCESS,
  20340. * ::CUDA_ERROR_INVALID_VALUE,
  20341. * \note_graph_thread_safety
  20342. * \notefnerr
  20343. *
  20344. * \sa
  20345. * ::cuGraphExecNodeSetParams,
  20346. * ::cuGraphAddChildGraphNode,
  20347. * ::cuGraphChildGraphNodeGetGraph,
  20348. * ::cuGraphExecKernelNodeSetParams,
  20349. * ::cuGraphExecMemcpyNodeSetParams,
  20350. * ::cuGraphExecMemsetNodeSetParams,
  20351. * ::cuGraphExecHostNodeSetParams,
  20352. * ::cuGraphExecEventRecordNodeSetEvent,
  20353. * ::cuGraphExecEventWaitNodeSetEvent,
  20354. * ::cuGraphExecExternalSemaphoresSignalNodeSetParams,
  20355. * ::cuGraphExecExternalSemaphoresWaitNodeSetParams,
  20356. * ::cuGraphExecUpdate,
  20357. * ::cuGraphInstantiate
  20358. */
  20359. CUresult CUDAAPI cuGraphExecChildGraphNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, CUgraph childGraph);
  20360. /**
  20361. * \brief Sets the event for an event record node in the given graphExec
  20362. *
  20363. * Sets the event of an event record node in an executable graph \p hGraphExec.
  20364. * The node is identified by the corresponding node \p hNode in the
  20365. * non-executable graph, from which the executable graph was instantiated.
  20366. *
  20367. * The modifications only affect future launches of \p hGraphExec. Already
  20368. * enqueued or running launches of \p hGraphExec are not affected by this call.
  20369. * \p hNode is also not modified by this call.
  20370. *
  20371. * \param hGraphExec - The executable graph in which to set the specified node
  20372. * \param hNode - event record node from the graph from which graphExec was instantiated
  20373. * \param event - Updated event to use
  20374. *
  20375. * \return
  20376. * ::CUDA_SUCCESS,
  20377. * ::CUDA_ERROR_INVALID_VALUE,
  20378. * \note_graph_thread_safety
  20379. * \notefnerr
  20380. *
  20381. * \sa
  20382. * ::cuGraphExecNodeSetParams,
  20383. * ::cuGraphAddEventRecordNode,
  20384. * ::cuGraphEventRecordNodeGetEvent,
  20385. * ::cuGraphEventWaitNodeSetEvent,
  20386. * ::cuEventRecordWithFlags,
  20387. * ::cuStreamWaitEvent,
  20388. * ::cuGraphExecKernelNodeSetParams,
  20389. * ::cuGraphExecMemcpyNodeSetParams,
  20390. * ::cuGraphExecMemsetNodeSetParams,
  20391. * ::cuGraphExecHostNodeSetParams,
  20392. * ::cuGraphExecChildGraphNodeSetParams,
  20393. * ::cuGraphExecEventWaitNodeSetEvent,
  20394. * ::cuGraphExecExternalSemaphoresSignalNodeSetParams,
  20395. * ::cuGraphExecExternalSemaphoresWaitNodeSetParams,
  20396. * ::cuGraphExecUpdate,
  20397. * ::cuGraphInstantiate
  20398. */
  20399. CUresult CUDAAPI cuGraphExecEventRecordNodeSetEvent(CUgraphExec hGraphExec, CUgraphNode hNode, CUevent event);
  20400. /**
  20401. * \brief Sets the event for an event wait node in the given graphExec
  20402. *
  20403. * Sets the event of an event wait node in an executable graph \p hGraphExec.
  20404. * The node is identified by the corresponding node \p hNode in the
  20405. * non-executable graph, from which the executable graph was instantiated.
  20406. *
  20407. * The modifications only affect future launches of \p hGraphExec. Already
  20408. * enqueued or running launches of \p hGraphExec are not affected by this call.
  20409. * \p hNode is also not modified by this call.
  20410. *
  20411. * \param hGraphExec - The executable graph in which to set the specified node
  20412. * \param hNode - event wait node from the graph from which graphExec was instantiated
  20413. * \param event - Updated event to use
  20414. *
  20415. * \return
  20416. * ::CUDA_SUCCESS,
  20417. * ::CUDA_ERROR_INVALID_VALUE,
  20418. * \note_graph_thread_safety
  20419. * \notefnerr
  20420. *
  20421. * \sa
  20422. * ::cuGraphExecNodeSetParams,
  20423. * ::cuGraphAddEventWaitNode,
  20424. * ::cuGraphEventWaitNodeGetEvent,
  20425. * ::cuGraphEventRecordNodeSetEvent,
  20426. * ::cuEventRecordWithFlags,
  20427. * ::cuStreamWaitEvent,
  20428. * ::cuGraphExecKernelNodeSetParams,
  20429. * ::cuGraphExecMemcpyNodeSetParams,
  20430. * ::cuGraphExecMemsetNodeSetParams,
  20431. * ::cuGraphExecHostNodeSetParams,
  20432. * ::cuGraphExecChildGraphNodeSetParams,
  20433. * ::cuGraphExecEventRecordNodeSetEvent,
  20434. * ::cuGraphExecExternalSemaphoresSignalNodeSetParams,
  20435. * ::cuGraphExecExternalSemaphoresWaitNodeSetParams,
  20436. * ::cuGraphExecUpdate,
  20437. * ::cuGraphInstantiate
  20438. */
  20439. CUresult CUDAAPI cuGraphExecEventWaitNodeSetEvent(CUgraphExec hGraphExec, CUgraphNode hNode, CUevent event);
  20440. /**
  20441. * \brief Sets the parameters for an external semaphore signal node in the given graphExec
  20442. *
  20443. * Sets the parameters of an external semaphore signal node in an executable graph \p hGraphExec.
  20444. * The node is identified by the corresponding node \p hNode in the
  20445. * non-executable graph, from which the executable graph was instantiated.
  20446. *
  20447. * \p hNode must not have been removed from the original graph.
  20448. *
  20449. * The modifications only affect future launches of \p hGraphExec. Already
  20450. * enqueued or running launches of \p hGraphExec are not affected by this call.
  20451. * \p hNode is also not modified by this call.
  20452. *
  20453. * Changing \p nodeParams->numExtSems is not supported.
  20454. *
  20455. * \param hGraphExec - The executable graph in which to set the specified node
  20456. * \param hNode - semaphore signal node from the graph from which graphExec was instantiated
  20457. * \param nodeParams - Updated Parameters to set
  20458. *
  20459. * \return
  20460. * ::CUDA_SUCCESS,
  20461. * ::CUDA_ERROR_INVALID_VALUE,
  20462. * \note_graph_thread_safety
  20463. * \notefnerr
  20464. *
  20465. * \sa
  20466. * ::cuGraphExecNodeSetParams,
  20467. * ::cuGraphAddExternalSemaphoresSignalNode,
  20468. * ::cuImportExternalSemaphore,
  20469. * ::cuSignalExternalSemaphoresAsync,
  20470. * ::cuWaitExternalSemaphoresAsync,
  20471. * ::cuGraphExecKernelNodeSetParams,
  20472. * ::cuGraphExecMemcpyNodeSetParams,
  20473. * ::cuGraphExecMemsetNodeSetParams,
  20474. * ::cuGraphExecHostNodeSetParams,
  20475. * ::cuGraphExecChildGraphNodeSetParams,
  20476. * ::cuGraphExecEventRecordNodeSetEvent,
  20477. * ::cuGraphExecEventWaitNodeSetEvent,
  20478. * ::cuGraphExecExternalSemaphoresWaitNodeSetParams,
  20479. * ::cuGraphExecUpdate,
  20480. * ::cuGraphInstantiate
  20481. */
  20482. CUresult CUDAAPI cuGraphExecExternalSemaphoresSignalNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS *nodeParams);
  20483. /**
  20484. * \brief Sets the parameters for an external semaphore wait node in the given graphExec
  20485. *
  20486. * Sets the parameters of an external semaphore wait node in an executable graph \p hGraphExec.
  20487. * The node is identified by the corresponding node \p hNode in the
  20488. * non-executable graph, from which the executable graph was instantiated.
  20489. *
  20490. * \p hNode must not have been removed from the original graph.
  20491. *
  20492. * The modifications only affect future launches of \p hGraphExec. Already
  20493. * enqueued or running launches of \p hGraphExec are not affected by this call.
  20494. * \p hNode is also not modified by this call.
  20495. *
  20496. * Changing \p nodeParams->numExtSems is not supported.
  20497. *
  20498. * \param hGraphExec - The executable graph in which to set the specified node
  20499. * \param hNode - semaphore wait node from the graph from which graphExec was instantiated
  20500. * \param nodeParams - Updated Parameters to set
  20501. *
  20502. * \return
  20503. * ::CUDA_SUCCESS,
  20504. * ::CUDA_ERROR_INVALID_VALUE,
  20505. * \note_graph_thread_safety
  20506. * \notefnerr
  20507. *
  20508. * \sa
  20509. * ::cuGraphExecNodeSetParams,
  20510. * ::cuGraphAddExternalSemaphoresWaitNode,
  20511. * ::cuImportExternalSemaphore,
  20512. * ::cuSignalExternalSemaphoresAsync,
  20513. * ::cuWaitExternalSemaphoresAsync,
  20514. * ::cuGraphExecKernelNodeSetParams,
  20515. * ::cuGraphExecMemcpyNodeSetParams,
  20516. * ::cuGraphExecMemsetNodeSetParams,
  20517. * ::cuGraphExecHostNodeSetParams,
  20518. * ::cuGraphExecChildGraphNodeSetParams,
  20519. * ::cuGraphExecEventRecordNodeSetEvent,
  20520. * ::cuGraphExecEventWaitNodeSetEvent,
  20521. * ::cuGraphExecExternalSemaphoresSignalNodeSetParams,
  20522. * ::cuGraphExecUpdate,
  20523. * ::cuGraphInstantiate
  20524. */
  20525. CUresult CUDAAPI cuGraphExecExternalSemaphoresWaitNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_EXT_SEM_WAIT_NODE_PARAMS *nodeParams);
  20526. /**
  20527. * \brief Enables or disables the specified node in the given graphExec
  20528. *
  20529. * Sets \p hNode to be either enabled or disabled. Disabled nodes are functionally equivalent
  20530. * to empty nodes until they are reenabled. Existing node parameters are not affected by
  20531. * disabling/enabling the node.
  20532. *
  20533. * The node is identified by the corresponding node \p hNode in the non-executable
  20534. * graph, from which the executable graph was instantiated.
  20535. *
  20536. * \p hNode must not have been removed from the original graph.
  20537. *
  20538. * The modifications only affect future launches of \p hGraphExec. Already
  20539. * enqueued or running launches of \p hGraphExec are not affected by this call.
  20540. * \p hNode is also not modified by this call.
  20541. *
  20542. * If \p hNode is a device-updatable kernel node, the next upload/launch of \p hGraphExec
  20543. * will overwrite any previous device-side updates. Additionally, applying host updates to a
  20544. * device-updatable kernel node while it is being updated from the device will result in
  20545. * undefined behavior.
  20546. *
  20547. * \note Currently only kernel, memset and memcpy nodes are supported.
  20548. *
  20549. * \param hGraphExec - The executable graph in which to set the specified node
  20550. * \param hNode - Node from the graph from which graphExec was instantiated
  20551. * \param isEnabled - Node is enabled if != 0, otherwise the node is disabled
  20552. *
  20553. * \return
  20554. * ::CUDA_SUCCESS,
  20555. * ::CUDA_ERROR_INVALID_VALUE,
  20556. * \note_graph_thread_safety
  20557. * \notefnerr
  20558. *
  20559. * \sa
  20560. * ::cuGraphNodeGetEnabled,
  20561. * ::cuGraphExecUpdate,
  20562. * ::cuGraphInstantiate
  20563. * ::cuGraphLaunch
  20564. */
  20565. CUresult CUDAAPI cuGraphNodeSetEnabled(CUgraphExec hGraphExec, CUgraphNode hNode, unsigned int isEnabled);
  20566. /**
  20567. * \brief Query whether a node in the given graphExec is enabled
  20568. *
  20569. * Sets isEnabled to 1 if \p hNode is enabled, or 0 if \p hNode is disabled.
  20570. *
  20571. * The node is identified by the corresponding node \p hNode in the non-executable
  20572. * graph, from which the executable graph was instantiated.
  20573. *
  20574. * \p hNode must not have been removed from the original graph.
  20575. *
  20576. * \note Currently only kernel, memset and memcpy nodes are supported.
  20577. * \note This function will not reflect device-side updates for device-updatable kernel nodes.
  20578. *
  20579. * \param hGraphExec - The executable graph in which to set the specified node
  20580. * \param hNode - Node from the graph from which graphExec was instantiated
  20581. * \param isEnabled - Location to return the enabled status of the node
  20582. *
  20583. * \return
  20584. * ::CUDA_SUCCESS,
  20585. * ::CUDA_ERROR_INVALID_VALUE,
  20586. * \note_graph_thread_safety
  20587. * \notefnerr
  20588. *
  20589. * \sa
  20590. * ::cuGraphNodeSetEnabled,
  20591. * ::cuGraphExecUpdate,
  20592. * ::cuGraphInstantiate
  20593. * ::cuGraphLaunch
  20594. */
  20595. CUresult CUDAAPI cuGraphNodeGetEnabled(CUgraphExec hGraphExec, CUgraphNode hNode, unsigned int *isEnabled);
  20596. /**
  20597. * \brief Uploads an executable graph in a stream
  20598. *
  20599. * Uploads \p hGraphExec to the device in \p hStream without executing it. Uploads of
  20600. * the same \p hGraphExec will be serialized. Each upload is ordered behind both any
  20601. * previous work in \p hStream and any previous launches of \p hGraphExec.
  20602. * Uses memory cached by \p stream to back the allocations owned by \p hGraphExec.
  20603. *
  20604. * \param hGraphExec - Executable graph to upload
  20605. * \param hStream - Stream in which to upload the graph
  20606. *
  20607. * \return
  20608. * ::CUDA_SUCCESS,
  20609. * ::CUDA_ERROR_DEINITIALIZED,
  20610. * ::CUDA_ERROR_NOT_INITIALIZED,
  20611. * ::CUDA_ERROR_INVALID_VALUE
  20612. * \note_graph_thread_safety
  20613. * \notefnerr
  20614. *
  20615. * \sa
  20616. * ::cuGraphInstantiate,
  20617. * ::cuGraphLaunch,
  20618. * ::cuGraphExecDestroy
  20619. */
  20620. CUresult CUDAAPI cuGraphUpload(CUgraphExec hGraphExec, CUstream hStream);
  20621. /**
  20622. * \brief Launches an executable graph in a stream
  20623. *
  20624. * Executes \p hGraphExec in \p hStream. Only one instance of \p hGraphExec may be executing
  20625. * at a time. Each launch is ordered behind both any previous work in \p hStream
  20626. * and any previous launches of \p hGraphExec. To execute a graph concurrently, it must be
  20627. * instantiated multiple times into multiple executable graphs.
  20628. *
  20629. * If any allocations created by \p hGraphExec remain unfreed (from a previous launch) and
  20630. * \p hGraphExec was not instantiated with ::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH,
  20631. * the launch will fail with ::CUDA_ERROR_INVALID_VALUE.
  20632. *
  20633. * \param hGraphExec - Executable graph to launch
  20634. * \param hStream - Stream in which to launch the graph
  20635. *
  20636. * \return
  20637. * ::CUDA_SUCCESS,
  20638. * ::CUDA_ERROR_DEINITIALIZED,
  20639. * ::CUDA_ERROR_NOT_INITIALIZED,
  20640. * ::CUDA_ERROR_INVALID_VALUE
  20641. * \note_graph_thread_safety
  20642. * \notefnerr
  20643. *
  20644. * \sa
  20645. * ::cuGraphInstantiate,
  20646. * ::cuGraphUpload,
  20647. * ::cuGraphExecDestroy
  20648. */
  20649. CUresult CUDAAPI cuGraphLaunch(CUgraphExec hGraphExec, CUstream hStream);
  20650. /**
  20651. * \brief Destroys an executable graph
  20652. *
  20653. * Destroys the executable graph specified by \p hGraphExec, as well
  20654. * as all of its executable nodes. If the executable graph is
  20655. * in-flight, it will not be terminated, but rather freed
  20656. * asynchronously on completion.
  20657. *
  20658. * \param hGraphExec - Executable graph to destroy
  20659. *
  20660. * \return
  20661. * ::CUDA_SUCCESS,
  20662. * ::CUDA_ERROR_DEINITIALIZED,
  20663. * ::CUDA_ERROR_NOT_INITIALIZED,
  20664. * ::CUDA_ERROR_INVALID_VALUE
  20665. * \note_graph_thread_safety
  20666. * \notefnerr
  20667. *
  20668. * \sa
  20669. * ::cuGraphInstantiate,
  20670. * ::cuGraphUpload,
  20671. * ::cuGraphLaunch
  20672. */
  20673. CUresult CUDAAPI cuGraphExecDestroy(CUgraphExec hGraphExec);
  20674. /**
  20675. * \brief Destroys a graph
  20676. *
  20677. * Destroys the graph specified by \p hGraph, as well as all of its nodes.
  20678. *
  20679. * \param hGraph - Graph to destroy
  20680. *
  20681. * \return
  20682. * ::CUDA_SUCCESS,
  20683. * ::CUDA_ERROR_DEINITIALIZED,
  20684. * ::CUDA_ERROR_NOT_INITIALIZED,
  20685. * ::CUDA_ERROR_INVALID_VALUE
  20686. * \note_graph_thread_safety
  20687. * \notefnerr
  20688. *
  20689. * \sa
  20690. * ::cuGraphCreate
  20691. */
  20692. CUresult CUDAAPI cuGraphDestroy(CUgraph hGraph);
  20693. /**
  20694. * \brief Check whether an executable graph can be updated with a graph and perform the update if possible
  20695. *
  20696. * Updates the node parameters in the instantiated graph specified by \p hGraphExec with the
  20697. * node parameters in a topologically identical graph specified by \p hGraph.
  20698. *
  20699. * Limitations:
  20700. *
  20701. * - Kernel nodes:
  20702. * - The owning context of the function cannot change.
  20703. * - A node whose function originally did not use CUDA dynamic parallelism cannot be updated
  20704. * to a function which uses CDP.
  20705. * - A node whose function originally did not make device-side update calls cannot be updated
  20706. * to a function which makes device-side update calls.
  20707. * - A cooperative node cannot be updated to a non-cooperative node, and vice-versa.
  20708. * - If the graph was instantiated with CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY, the
  20709. * priority attribute cannot change. Equality is checked on the originally requested
  20710. * priority values, before they are clamped to the device's supported range.
  20711. * - If \p hGraphExec was not instantiated for device launch, a node whose function originally
  20712. * did not use device-side cudaGraphLaunch() cannot be updated to a function which uses
  20713. * device-side cudaGraphLaunch() unless the node resides on the same context as nodes which
  20714. * contained such calls at instantiate-time. If no such calls were present at instantiation,
  20715. * these updates cannot be performed at all.
  20716. * - Neither \p hGraph nor \p hGraphExec may contain device-updatable kernel nodes.
  20717. * - Memset and memcpy nodes:
  20718. * - The CUDA device(s) to which the operand(s) was allocated/mapped cannot change.
  20719. * - The source/destination memory must be allocated from the same contexts as the original
  20720. * source/destination memory.
  20721. * - For 2d memsets, only address and assinged value may be updated.
  20722. * - For 1d memsets, updating dimensions is also allowed, but may fail if the resulting operation doesn't
  20723. * map onto the work resources already allocated for the node.
  20724. * - Additional memcpy node restrictions:
  20725. * - Changing either the source or destination memory type(i.e. CU_MEMORYTYPE_DEVICE,
  20726. * CU_MEMORYTYPE_ARRAY, etc.) is not supported.
  20727. * - External semaphore wait nodes and record nodes:
  20728. * - Changing the number of semaphores is not supported.
  20729. * - Conditional nodes:
  20730. * - Changing node parameters is not supported.
  20731. * - Changeing parameters of nodes within the conditional body graph is subject to the rules above.
  20732. * - Conditional handle flags and default values are updated as part of the graph update.
  20733. *
  20734. * Note: The API may add further restrictions in future releases. The return code should always be checked.
  20735. *
  20736. * cuGraphExecUpdate sets the result member of \p resultInfo to CU_GRAPH_EXEC_UPDATE_ERROR_TOPOLOGY_CHANGED
  20737. * under the following conditions:
  20738. * - The count of nodes directly in \p hGraphExec and \p hGraph differ, in which case resultInfo->errorNode
  20739. * is set to NULL.
  20740. * - \p hGraph has more exit nodes than \p hGraph, in which case resultInfo->errorNode is set to one of
  20741. * the exit nodes in hGraph.
  20742. * - A node in \p hGraph has a different number of dependencies than the node from \p hGraphExec it is paired with,
  20743. * in which case resultInfo->errorNode is set to the node from \p hGraph.
  20744. * - A node in \p hGraph has a dependency that does not match with the corresponding dependency of the paired node
  20745. * from \p hGraphExec. resultInfo->errorNode will be set to the node from \p hGraph. resultInfo->errorFromNode
  20746. * will be set to the mismatched dependency. The dependencies are paired based on edge order and a dependency
  20747. * does not match when the nodes are already paired based on other edges examined in the graph.
  20748. *
  20749. * cuGraphExecUpdate sets the result member of \p resultInfo to:
  20750. * - CU_GRAPH_EXEC_UPDATE_ERROR if passed an invalid value.
  20751. * - CU_GRAPH_EXEC_UPDATE_ERROR_TOPOLOGY_CHANGED if the graph topology changed
  20752. * - CU_GRAPH_EXEC_UPDATE_ERROR_NODE_TYPE_CHANGED if the type of a node changed, in which case
  20753. * \p hErrorNode_out is set to the node from \p hGraph.
  20754. * - CU_GRAPH_EXEC_UPDATE_ERROR_UNSUPPORTED_FUNCTION_CHANGE if the function changed in an unsupported
  20755. * way(see note above), in which case \p hErrorNode_out is set to the node from \p hGraph
  20756. * - CU_GRAPH_EXEC_UPDATE_ERROR_PARAMETERS_CHANGED if any parameters to a node changed in a way
  20757. * that is not supported, in which case \p hErrorNode_out is set to the node from \p hGraph.
  20758. * - CU_GRAPH_EXEC_UPDATE_ERROR_ATTRIBUTES_CHANGED if any attributes of a node changed in a way
  20759. * that is not supported, in which case \p hErrorNode_out is set to the node from \p hGraph.
  20760. * - CU_GRAPH_EXEC_UPDATE_ERROR_NOT_SUPPORTED if something about a node is unsupported, like
  20761. * the node's type or configuration, in which case \p hErrorNode_out is set to the node from \p hGraph
  20762. *
  20763. * If the update fails for a reason not listed above, the result member of \p resultInfo will be set
  20764. * to CU_GRAPH_EXEC_UPDATE_ERROR. If the update succeeds, the result member will be set to CU_GRAPH_EXEC_UPDATE_SUCCESS.
  20765. *
  20766. * cuGraphExecUpdate returns CUDA_SUCCESS when the updated was performed successfully. It returns
  20767. * CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE if the graph update was not performed because it included
  20768. * changes which violated constraints specific to instantiated graph update.
  20769. *
  20770. * \param hGraphExec The instantiated graph to be updated
  20771. * \param hGraph The graph containing the updated parameters
  20772. * \param resultInfo the error info structure
  20773. *
  20774. * \return
  20775. * ::CUDA_SUCCESS,
  20776. * ::CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE,
  20777. * \note_graph_thread_safety
  20778. * \notefnerr
  20779. *
  20780. * \sa
  20781. * ::cuGraphInstantiate
  20782. */
  20783. CUresult CUDAAPI cuGraphExecUpdate(CUgraphExec hGraphExec, CUgraph hGraph, CUgraphExecUpdateResultInfo *resultInfo);
  20784. /**
  20785. * \brief Copies attributes from source node to destination node.
  20786. *
  20787. * Copies attributes from source node \p src to destination node \p dst.
  20788. * Both node must have the same context.
  20789. *
  20790. * \param[out] dst Destination node
  20791. * \param[in] src Source node
  20792. * For list of attributes see ::CUkernelNodeAttrID
  20793. *
  20794. * \return
  20795. * ::CUDA_SUCCESS,
  20796. * ::CUDA_ERROR_INVALID_VALUE
  20797. * \notefnerr
  20798. *
  20799. * \sa
  20800. * ::CUaccessPolicyWindow
  20801. */
  20802. CUresult CUDAAPI cuGraphKernelNodeCopyAttributes(CUgraphNode dst, CUgraphNode src);
  20803. /**
  20804. * \brief Queries node attribute.
  20805. *
  20806. * Queries attribute \p attr from node \p hNode and stores it in corresponding
  20807. * member of \p value_out.
  20808. *
  20809. * \param[in] hNode
  20810. * \param[in] attr
  20811. * \param[out] value_out
  20812. *
  20813. * \return
  20814. * ::CUDA_SUCCESS,
  20815. * ::CUDA_ERROR_INVALID_VALUE,
  20816. * ::CUDA_ERROR_INVALID_HANDLE
  20817. * \notefnerr
  20818. *
  20819. * \sa
  20820. * ::CUaccessPolicyWindow
  20821. */
  20822. CUresult CUDAAPI cuGraphKernelNodeGetAttribute(CUgraphNode hNode, CUkernelNodeAttrID attr,
  20823. CUkernelNodeAttrValue *value_out);
  20824. /**
  20825. * \brief Sets node attribute.
  20826. *
  20827. * Sets attribute \p attr on node \p hNode from corresponding attribute of
  20828. * \p value.
  20829. *
  20830. * \param[out] hNode
  20831. * \param[in] attr
  20832. * \param[out] value
  20833. *
  20834. * \return
  20835. * ::CUDA_SUCCESS,
  20836. * ::CUDA_ERROR_INVALID_VALUE,
  20837. * ::CUDA_ERROR_INVALID_HANDLE
  20838. * \notefnerr
  20839. *
  20840. * \sa
  20841. * ::CUaccessPolicyWindow
  20842. */
  20843. CUresult CUDAAPI cuGraphKernelNodeSetAttribute(CUgraphNode hNode, CUkernelNodeAttrID attr,
  20844. const CUkernelNodeAttrValue *value);
  20845. /**
  20846. * \brief Write a DOT file describing graph structure
  20847. *
  20848. * Using the provided \p hGraph, write to \p path a DOT formatted description of the graph.
  20849. * By default this includes the graph topology, node types, node id, kernel names and memcpy direction.
  20850. * \p flags can be specified to write more detailed information about each node type such as
  20851. * parameter values, kernel attributes, node and function handles.
  20852. *
  20853. * \param hGraph - The graph to create a DOT file from
  20854. * \param path - The path to write the DOT file to
  20855. * \param flags - Flags from CUgraphDebugDot_flags for specifying which additional node information to write
  20856. *
  20857. * \return
  20858. * ::CUDA_SUCCESS,
  20859. * ::CUDA_ERROR_INVALID_VALUE,
  20860. * ::CUDA_ERROR_OPERATING_SYSTEM
  20861. */
  20862. CUresult CUDAAPI cuGraphDebugDotPrint(CUgraph hGraph, const char *path, unsigned int flags);
  20863. /**
  20864. * \brief Create a user object
  20865. *
  20866. * Create a user object with the specified destructor callback and initial reference count. The
  20867. * initial references are owned by the caller.
  20868. *
  20869. * Destructor callbacks cannot make CUDA API calls and should avoid blocking behavior, as they
  20870. * are executed by a shared internal thread. Another thread may be signaled to perform such
  20871. * actions, if it does not block forward progress of tasks scheduled through CUDA.
  20872. *
  20873. * See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
  20874. *
  20875. * \param object_out - Location to return the user object handle
  20876. * \param ptr - The pointer to pass to the destroy function
  20877. * \param destroy - Callback to free the user object when it is no longer in use
  20878. * \param initialRefcount - The initial refcount to create the object with, typically 1. The
  20879. * initial references are owned by the calling thread.
  20880. * \param flags - Currently it is required to pass ::CU_USER_OBJECT_NO_DESTRUCTOR_SYNC,
  20881. * which is the only defined flag. This indicates that the destroy
  20882. * callback cannot be waited on by any CUDA API. Users requiring
  20883. * synchronization of the callback should signal its completion
  20884. * manually.
  20885. *
  20886. * \return
  20887. * ::CUDA_SUCCESS,
  20888. * ::CUDA_ERROR_INVALID_VALUE
  20889. *
  20890. * \sa
  20891. * ::cuUserObjectRetain,
  20892. * ::cuUserObjectRelease,
  20893. * ::cuGraphRetainUserObject,
  20894. * ::cuGraphReleaseUserObject,
  20895. * ::cuGraphCreate
  20896. */
  20897. CUresult CUDAAPI cuUserObjectCreate(CUuserObject *object_out, void *ptr, CUhostFn destroy,
  20898. unsigned int initialRefcount, unsigned int flags);
  20899. /**
  20900. * \brief Retain a reference to a user object
  20901. *
  20902. * Retains new references to a user object. The new references are owned by the caller.
  20903. *
  20904. * See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
  20905. *
  20906. * \param object - The object to retain
  20907. * \param count - The number of references to retain, typically 1. Must be nonzero
  20908. * and not larger than INT_MAX.
  20909. *
  20910. * \return
  20911. * ::CUDA_SUCCESS,
  20912. * ::CUDA_ERROR_INVALID_VALUE
  20913. *
  20914. * \sa
  20915. * ::cuUserObjectCreate,
  20916. * ::cuUserObjectRelease,
  20917. * ::cuGraphRetainUserObject,
  20918. * ::cuGraphReleaseUserObject,
  20919. * ::cuGraphCreate
  20920. */
  20921. CUresult CUDAAPI cuUserObjectRetain(CUuserObject object, unsigned int count);
  20922. /**
  20923. * \brief Release a reference to a user object
  20924. *
  20925. * Releases user object references owned by the caller. The object's destructor is invoked if
  20926. * the reference count reaches zero.
  20927. *
  20928. * It is undefined behavior to release references not owned by the caller, or to use a user
  20929. * object handle after all references are released.
  20930. *
  20931. * See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
  20932. *
  20933. * \param object - The object to release
  20934. * \param count - The number of references to release, typically 1. Must be nonzero
  20935. * and not larger than INT_MAX.
  20936. *
  20937. * \return
  20938. * ::CUDA_SUCCESS,
  20939. * ::CUDA_ERROR_INVALID_VALUE
  20940. *
  20941. * \sa
  20942. * ::cuUserObjectCreate,
  20943. * ::cuUserObjectRetain,
  20944. * ::cuGraphRetainUserObject,
  20945. * ::cuGraphReleaseUserObject,
  20946. * ::cuGraphCreate
  20947. */
  20948. CUresult CUDAAPI cuUserObjectRelease(CUuserObject object, unsigned int count);
  20949. /**
  20950. * \brief Retain a reference to a user object from a graph
  20951. *
  20952. * Creates or moves user object references that will be owned by a CUDA graph.
  20953. *
  20954. * See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
  20955. *
  20956. * \param graph - The graph to associate the reference with
  20957. * \param object - The user object to retain a reference for
  20958. * \param count - The number of references to add to the graph, typically 1. Must be
  20959. * nonzero and not larger than INT_MAX.
  20960. * \param flags - The optional flag ::CU_GRAPH_USER_OBJECT_MOVE transfers references
  20961. * from the calling thread, rather than create new references. Pass 0
  20962. * to create new references.
  20963. *
  20964. * \return
  20965. * ::CUDA_SUCCESS,
  20966. * ::CUDA_ERROR_INVALID_VALUE
  20967. *
  20968. * \sa
  20969. * ::cuUserObjectCreate,
  20970. * ::cuUserObjectRetain,
  20971. * ::cuUserObjectRelease,
  20972. * ::cuGraphReleaseUserObject,
  20973. * ::cuGraphCreate
  20974. */
  20975. CUresult CUDAAPI cuGraphRetainUserObject(CUgraph graph, CUuserObject object, unsigned int count, unsigned int flags);
  20976. /**
  20977. * \brief Release a user object reference from a graph
  20978. *
  20979. * Releases user object references owned by a graph.
  20980. *
  20981. * See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
  20982. *
  20983. * \param graph - The graph that will release the reference
  20984. * \param object - The user object to release a reference for
  20985. * \param count - The number of references to release, typically 1. Must be nonzero
  20986. * and not larger than INT_MAX.
  20987. *
  20988. * \return
  20989. * ::CUDA_SUCCESS,
  20990. * ::CUDA_ERROR_INVALID_VALUE
  20991. *
  20992. * \sa
  20993. * ::cuUserObjectCreate,
  20994. * ::cuUserObjectRetain,
  20995. * ::cuUserObjectRelease,
  20996. * ::cuGraphRetainUserObject,
  20997. * ::cuGraphCreate
  20998. */
  20999. CUresult CUDAAPI cuGraphReleaseUserObject(CUgraph graph, CUuserObject object, unsigned int count);
  21000. /**
  21001. * \brief Adds a node of arbitrary type to a graph
  21002. *
  21003. * Creates a new node in \p hGraph described by \p nodeParams with \p numDependencies
  21004. * dependencies specified via \p dependencies. \p numDependencies may be 0.
  21005. * \p dependencies may be null if \p numDependencies is 0. \p dependencies may not have
  21006. * any duplicate entries.
  21007. *
  21008. * \p nodeParams is a tagged union. The node type should be specified in the \p type field,
  21009. * and type-specific parameters in the corresponding union member. All unused bytes - that
  21010. * is, \p reserved0 and all bytes past the utilized union member - must be set to zero.
  21011. * It is recommended to use brace initialization or memset to ensure all bytes are
  21012. * initialized.
  21013. *
  21014. * Note that for some node types, \p nodeParams may contain "out parameters" which are
  21015. * modified during the call, such as \p nodeParams->alloc.dptr.
  21016. *
  21017. * A handle to the new node will be returned in \p phGraphNode.
  21018. *
  21019. * \param phGraphNode - Returns newly created node
  21020. * \param hGraph - Graph to which to add the node
  21021. * \param dependencies - Dependencies of the node
  21022. * \param numDependencies - Number of dependencies
  21023. * \param nodeParams - Specification of the node
  21024. *
  21025. * \return
  21026. * ::CUDA_SUCCESS,
  21027. * ::CUDA_ERROR_INVALID_VALUE,
  21028. * ::CUDA_ERROR_INVALID_CONTEXT,
  21029. * ::CUDA_ERROR_NOT_SUPPORTED
  21030. * \note_graph_thread_safety
  21031. * \notefnerr
  21032. *
  21033. * \sa
  21034. * ::cuGraphCreate,
  21035. * ::cuGraphNodeSetParams,
  21036. * ::cuGraphExecNodeSetParams
  21037. */
  21038. CUresult CUDAAPI cuGraphAddNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, CUgraphNodeParams *nodeParams);
  21039. /**
  21040. * \brief Adds a node of arbitrary type to a graph (12.3+)
  21041. *
  21042. * Creates a new node in \p hGraph described by \p nodeParams with \p numDependencies
  21043. * dependencies specified via \p dependencies. \p numDependencies may be 0.
  21044. * \p dependencies may be null if \p numDependencies is 0. \p dependencies may not have
  21045. * any duplicate entries.
  21046. *
  21047. * \p nodeParams is a tagged union. The node type should be specified in the \p type field,
  21048. * and type-specific parameters in the corresponding union member. All unused bytes - that
  21049. * is, \p reserved0 and all bytes past the utilized union member - must be set to zero.
  21050. * It is recommended to use brace initialization or memset to ensure all bytes are
  21051. * initialized.
  21052. *
  21053. * Note that for some node types, \p nodeParams may contain "out parameters" which are
  21054. * modified during the call, such as \p nodeParams->alloc.dptr.
  21055. *
  21056. * A handle to the new node will be returned in \p phGraphNode.
  21057. *
  21058. * \param phGraphNode - Returns newly created node
  21059. * \param hGraph - Graph to which to add the node
  21060. * \param dependencies - Dependencies of the node
  21061. * \param dependencyData - Optional edge data for the dependencies. If NULL, the data is
  21062. * assumed to be default (zeroed) for all dependencies.
  21063. * \param numDependencies - Number of dependencies
  21064. * \param nodeParams - Specification of the node
  21065. *
  21066. * \return
  21067. * ::CUDA_SUCCESS,
  21068. * ::CUDA_ERROR_INVALID_VALUE,
  21069. * ::CUDA_ERROR_INVALID_CONTEXT,
  21070. * ::CUDA_ERROR_NOT_SUPPORTED
  21071. * \note_graph_thread_safety
  21072. * \notefnerr
  21073. *
  21074. * \sa
  21075. * ::cuGraphCreate,
  21076. * ::cuGraphNodeSetParams,
  21077. * ::cuGraphExecNodeSetParams
  21078. */
  21079. CUresult CUDAAPI cuGraphAddNode_v2(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, const CUgraphEdgeData *dependencyData, size_t numDependencies, CUgraphNodeParams *nodeParams);
  21080. /**
  21081. * \brief Update's a graph node's parameters
  21082. *
  21083. * Sets the parameters of graph node \p hNode to \p nodeParams. The node type specified by
  21084. * \p nodeParams->type must match the type of \p hNode. \p nodeParams must be fully
  21085. * initialized and all unused bytes (reserved, padding) zeroed.
  21086. *
  21087. * Modifying parameters is not supported for node types CU_GRAPH_NODE_TYPE_MEM_ALLOC and
  21088. * CU_GRAPH_NODE_TYPE_MEM_FREE.
  21089. *
  21090. * \param hNode - Node to set the parameters for
  21091. * \param nodeParams - Parameters to copy
  21092. *
  21093. * \return
  21094. * ::CUDA_SUCCESS,
  21095. * ::CUDA_ERROR_INVALID_VALUE,
  21096. * ::CUDA_ERROR_NOT_SUPPORTED
  21097. * \note_graph_thread_safety
  21098. * \notefnerr
  21099. *
  21100. * \sa
  21101. * ::cuGraphAddNode,
  21102. * ::cuGraphExecNodeSetParams
  21103. */
  21104. CUresult CUDAAPI cuGraphNodeSetParams(CUgraphNode hNode, CUgraphNodeParams *nodeParams);
  21105. /**
  21106. * \brief Update's a graph node's parameters in an instantiated graph
  21107. *
  21108. * Sets the parameters of a node in an executable graph \p hGraphExec. The node is identified
  21109. * by the corresponding node \p hNode in the non-executable graph from which the executable
  21110. * graph was instantiated. \p hNode must not have been removed from the original graph.
  21111. *
  21112. * The modifications only affect future launches of \p hGraphExec. Already
  21113. * enqueued or running launches of \p hGraphExec are not affected by this call.
  21114. * \p hNode is also not modified by this call.
  21115. *
  21116. * Allowed changes to parameters on executable graphs are as follows:
  21117. * <table>
  21118. * <tr><th>Node type<th>Allowed changes
  21119. * <tr><td>kernel<td>See ::cuGraphExecKernelNodeSetParams
  21120. * <tr><td>memcpy<td>Addresses for 1-dimensional copies if allocated in same context; see ::cuGraphExecMemcpyNodeSetParams
  21121. * <tr><td>memset<td>Addresses for 1-dimensional memsets if allocated in same context; see ::cuGraphExecMemsetNodeSetParams
  21122. * <tr><td>host<td>Unrestricted
  21123. * <tr><td>child graph<td>Topology must match and restrictions apply recursively; see ::cuGraphExecUpdate
  21124. * <tr><td>event wait<td>Unrestricted
  21125. * <tr><td>event record<td>Unrestricted
  21126. * <tr><td>external semaphore signal<td>Number of semaphore operations cannot change
  21127. * <tr><td>external semaphore wait<td>Number of semaphore operations cannot change
  21128. * <tr><td>memory allocation<td>API unsupported
  21129. * <tr><td>memory free<td>API unsupported
  21130. * <tr><td>batch memops<td>Addresses, values, and operation type for wait operations; see ::cuGraphExecBatchMemOpNodeSetParams
  21131. * </table>
  21132. *
  21133. * \param hGraphExec - The executable graph in which to update the specified node
  21134. * \param hNode - Corresponding node from the graph from which graphExec was instantiated
  21135. * \param nodeParams - Updated Parameters to set
  21136. *
  21137. * \return
  21138. * ::CUDA_SUCCESS,
  21139. * ::CUDA_ERROR_INVALID_VALUE,
  21140. * ::CUDA_ERROR_NOT_SUPPORTED
  21141. * \note_graph_thread_safety
  21142. * \notefnerr
  21143. *
  21144. * \sa
  21145. * ::cuGraphAddNode,
  21146. * ::cuGraphNodeSetParams
  21147. * ::cuGraphExecUpdate,
  21148. * ::cuGraphInstantiate
  21149. */
  21150. CUresult CUDAAPI cuGraphExecNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, CUgraphNodeParams *nodeParams);
  21151. /**
  21152. * \brief Create a conditional handle
  21153. *
  21154. * Creates a conditional handle associated with \p hGraph.
  21155. *
  21156. * The conditional handle must be associated with a conditional node in this graph or one of its children.
  21157. *
  21158. * Handles not associated with a conditional node may cause graph instantiation to fail.
  21159. *
  21160. * Handles can only be set from the context with which they are associated.
  21161. *
  21162. * \param pHandle_out - Pointer used to return the handle to the caller.
  21163. * \param hGraph - Graph which will contain the conditional node using this handle.
  21164. * \param ctx - Context for the handle and associated conditional node.
  21165. * \param defaultLaunchValue - Optional initial value for the conditional variable.
  21166. * Applied at the beginning of each graph execution if CU_GRAPH_COND_ASSIGN_DEFAULT is set in \p flags.
  21167. * \param flags - Currently must be CU_GRAPH_COND_ASSIGN_DEFAULT or 0.
  21168. *
  21169. * \return
  21170. * ::CUDA_SUCCESS,
  21171. * ::CUDA_ERROR_INVALID_VALUE,
  21172. * ::CUDA_ERROR_NOT_SUPPORTED
  21173. * \note_graph_thread_safety
  21174. * \notefnerr
  21175. *
  21176. * \sa
  21177. * ::cuGraphAddNode
  21178. */
  21179. CUresult CUDAAPI cuGraphConditionalHandleCreate(CUgraphConditionalHandle *pHandle_out, CUgraph hGraph, CUcontext ctx, unsigned int defaultLaunchValue, unsigned int flags);
  21180. /** @} */ /* END CUDA_GRAPH */
  21181. /**
  21182. * \defgroup CUDA_OCCUPANCY Occupancy
  21183. *
  21184. * ___MANBRIEF___ occupancy calculation functions of the low-level CUDA driver
  21185. * API (___CURRENT_FILE___) ___ENDMANBRIEF___
  21186. *
  21187. * This section describes the occupancy calculation functions of the low-level CUDA
  21188. * driver application programming interface.
  21189. *
  21190. * @{
  21191. */
  21192. /**
  21193. * \brief Returns occupancy of a function
  21194. *
  21195. * Returns in \p *numBlocks the number of the maximum active blocks per
  21196. * streaming multiprocessor.
  21197. *
  21198. * Note that the API can also be used with context-less kernel ::CUkernel
  21199. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  21200. * to the API by casting to ::CUfunction. Here, the context to use for calculations
  21201. * will be the current context.
  21202. *
  21203. * \param numBlocks - Returned occupancy
  21204. * \param func - Kernel for which occupancy is calculated
  21205. * \param blockSize - Block size the kernel is intended to be launched with
  21206. * \param dynamicSMemSize - Per-block dynamic shared memory usage intended, in bytes
  21207. *
  21208. * \return
  21209. * ::CUDA_SUCCESS,
  21210. * ::CUDA_ERROR_DEINITIALIZED,
  21211. * ::CUDA_ERROR_NOT_INITIALIZED,
  21212. * ::CUDA_ERROR_INVALID_CONTEXT,
  21213. * ::CUDA_ERROR_INVALID_VALUE,
  21214. * ::CUDA_ERROR_UNKNOWN
  21215. * \notefnerr
  21216. *
  21217. * \sa
  21218. * ::cudaOccupancyMaxActiveBlocksPerMultiprocessor
  21219. */
  21220. CUresult CUDAAPI cuOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, CUfunction func, int blockSize, size_t dynamicSMemSize);
  21221. /**
  21222. * \brief Returns occupancy of a function
  21223. *
  21224. * Returns in \p *numBlocks the number of the maximum active blocks per
  21225. * streaming multiprocessor.
  21226. *
  21227. * The \p Flags parameter controls how special cases are handled. The
  21228. * valid flags are:
  21229. *
  21230. * - ::CU_OCCUPANCY_DEFAULT, which maintains the default behavior as
  21231. * ::cuOccupancyMaxActiveBlocksPerMultiprocessor;
  21232. *
  21233. * - ::CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE, which suppresses the
  21234. * default behavior on platform where global caching affects
  21235. * occupancy. On such platforms, if caching is enabled, but
  21236. * per-block SM resource usage would result in zero occupancy, the
  21237. * occupancy calculator will calculate the occupancy as if caching
  21238. * is disabled. Setting ::CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE makes
  21239. * the occupancy calculator to return 0 in such cases. More information
  21240. * can be found about this feature in the "Unified L1/Texture Cache"
  21241. * section of the Maxwell tuning guide.
  21242. *
  21243. * Note that the API can also be with launch context-less kernel ::CUkernel
  21244. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  21245. * to the API by casting to ::CUfunction. Here, the context to use for calculations
  21246. * will be the current context.
  21247. *
  21248. * \param numBlocks - Returned occupancy
  21249. * \param func - Kernel for which occupancy is calculated
  21250. * \param blockSize - Block size the kernel is intended to be launched with
  21251. * \param dynamicSMemSize - Per-block dynamic shared memory usage intended, in bytes
  21252. * \param flags - Requested behavior for the occupancy calculator
  21253. *
  21254. * \return
  21255. * ::CUDA_SUCCESS,
  21256. * ::CUDA_ERROR_DEINITIALIZED,
  21257. * ::CUDA_ERROR_NOT_INITIALIZED,
  21258. * ::CUDA_ERROR_INVALID_CONTEXT,
  21259. * ::CUDA_ERROR_INVALID_VALUE,
  21260. * ::CUDA_ERROR_UNKNOWN
  21261. * \notefnerr
  21262. *
  21263. * \sa
  21264. * ::cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
  21265. */
  21266. CUresult CUDAAPI cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, CUfunction func, int blockSize, size_t dynamicSMemSize, unsigned int flags);
  21267. /**
  21268. * \brief Suggest a launch configuration with reasonable occupancy
  21269. *
  21270. * Returns in \p *blockSize a reasonable block size that can achieve
  21271. * the maximum occupancy (or, the maximum number of active warps with
  21272. * the fewest blocks per multiprocessor), and in \p *minGridSize the
  21273. * minimum grid size to achieve the maximum occupancy.
  21274. *
  21275. * If \p blockSizeLimit is 0, the configurator will use the maximum
  21276. * block size permitted by the device / function instead.
  21277. *
  21278. * If per-block dynamic shared memory allocation is not needed, the
  21279. * user should leave both \p blockSizeToDynamicSMemSize and \p
  21280. * dynamicSMemSize as 0.
  21281. *
  21282. * If per-block dynamic shared memory allocation is needed, then if
  21283. * the dynamic shared memory size is constant regardless of block
  21284. * size, the size should be passed through \p dynamicSMemSize, and \p
  21285. * blockSizeToDynamicSMemSize should be NULL.
  21286. *
  21287. * Otherwise, if the per-block dynamic shared memory size varies with
  21288. * different block sizes, the user needs to provide a unary function
  21289. * through \p blockSizeToDynamicSMemSize that computes the dynamic
  21290. * shared memory needed by \p func for any given block size. \p
  21291. * dynamicSMemSize is ignored. An example signature is:
  21292. *
  21293. * \code
  21294. * // Take block size, returns dynamic shared memory needed
  21295. * size_t blockToSmem(int blockSize);
  21296. * \endcode
  21297. *
  21298. * Note that the API can also be used with context-less kernel ::CUkernel
  21299. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  21300. * to the API by casting to ::CUfunction. Here, the context to use for calculations
  21301. * will be the current context.
  21302. *
  21303. * \param minGridSize - Returned minimum grid size needed to achieve the maximum occupancy
  21304. * \param blockSize - Returned maximum block size that can achieve the maximum occupancy
  21305. * \param func - Kernel for which launch configuration is calculated
  21306. * \param blockSizeToDynamicSMemSize - A function that calculates how much per-block dynamic shared memory \p func uses based on the block size
  21307. * \param dynamicSMemSize - Dynamic shared memory usage intended, in bytes
  21308. * \param blockSizeLimit - The maximum block size \p func is designed to handle
  21309. *
  21310. * \return
  21311. * ::CUDA_SUCCESS,
  21312. * ::CUDA_ERROR_DEINITIALIZED,
  21313. * ::CUDA_ERROR_NOT_INITIALIZED,
  21314. * ::CUDA_ERROR_INVALID_CONTEXT,
  21315. * ::CUDA_ERROR_INVALID_VALUE,
  21316. * ::CUDA_ERROR_UNKNOWN
  21317. * \notefnerr
  21318. *
  21319. * \sa
  21320. * ::cudaOccupancyMaxPotentialBlockSize
  21321. */
  21322. CUresult CUDAAPI cuOccupancyMaxPotentialBlockSize(int *minGridSize, int *blockSize, CUfunction func, CUoccupancyB2DSize blockSizeToDynamicSMemSize, size_t dynamicSMemSize, int blockSizeLimit);
  21323. /**
  21324. * \brief Suggest a launch configuration with reasonable occupancy
  21325. *
  21326. * An extended version of ::cuOccupancyMaxPotentialBlockSize. In
  21327. * addition to arguments passed to ::cuOccupancyMaxPotentialBlockSize,
  21328. * ::cuOccupancyMaxPotentialBlockSizeWithFlags also takes a \p Flags
  21329. * parameter.
  21330. *
  21331. * The \p Flags parameter controls how special cases are handled. The
  21332. * valid flags are:
  21333. *
  21334. * - ::CU_OCCUPANCY_DEFAULT, which maintains the default behavior as
  21335. * ::cuOccupancyMaxPotentialBlockSize;
  21336. *
  21337. * - ::CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE, which suppresses the
  21338. * default behavior on platform where global caching affects
  21339. * occupancy. On such platforms, the launch configurations that
  21340. * produces maximal occupancy might not support global
  21341. * caching. Setting ::CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE
  21342. * guarantees that the the produced launch configuration is global
  21343. * caching compatible at a potential cost of occupancy. More information
  21344. * can be found about this feature in the "Unified L1/Texture Cache"
  21345. * section of the Maxwell tuning guide.
  21346. *
  21347. * Note that the API can also be used with context-less kernel ::CUkernel
  21348. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  21349. * to the API by casting to ::CUfunction. Here, the context to use for calculations
  21350. * will be the current context.
  21351. *
  21352. * \param minGridSize - Returned minimum grid size needed to achieve the maximum occupancy
  21353. * \param blockSize - Returned maximum block size that can achieve the maximum occupancy
  21354. * \param func - Kernel for which launch configuration is calculated
  21355. * \param blockSizeToDynamicSMemSize - A function that calculates how much per-block dynamic shared memory \p func uses based on the block size
  21356. * \param dynamicSMemSize - Dynamic shared memory usage intended, in bytes
  21357. * \param blockSizeLimit - The maximum block size \p func is designed to handle
  21358. * \param flags - Options
  21359. *
  21360. * \return
  21361. * ::CUDA_SUCCESS,
  21362. * ::CUDA_ERROR_DEINITIALIZED,
  21363. * ::CUDA_ERROR_NOT_INITIALIZED,
  21364. * ::CUDA_ERROR_INVALID_CONTEXT,
  21365. * ::CUDA_ERROR_INVALID_VALUE,
  21366. * ::CUDA_ERROR_UNKNOWN
  21367. * \notefnerr
  21368. *
  21369. * \sa
  21370. * ::cudaOccupancyMaxPotentialBlockSizeWithFlags
  21371. */
  21372. CUresult CUDAAPI cuOccupancyMaxPotentialBlockSizeWithFlags(int *minGridSize, int *blockSize, CUfunction func, CUoccupancyB2DSize blockSizeToDynamicSMemSize, size_t dynamicSMemSize, int blockSizeLimit, unsigned int flags);
  21373. /**
  21374. * \brief Returns dynamic shared memory available per block when launching \p numBlocks blocks on SM
  21375. *
  21376. * Returns in \p *dynamicSmemSize the maximum size of dynamic shared memory to allow \p numBlocks blocks per SM.
  21377. *
  21378. * Note that the API can also be used with context-less kernel ::CUkernel
  21379. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  21380. * to the API by casting to ::CUfunction. Here, the context to use for calculations
  21381. * will be the current context.
  21382. *
  21383. * \param dynamicSmemSize - Returned maximum dynamic shared memory
  21384. * \param func - Kernel function for which occupancy is calculated
  21385. * \param numBlocks - Number of blocks to fit on SM
  21386. * \param blockSize - Size of the blocks
  21387. *
  21388. * \return
  21389. * ::CUDA_SUCCESS,
  21390. * ::CUDA_ERROR_DEINITIALIZED,
  21391. * ::CUDA_ERROR_NOT_INITIALIZED,
  21392. * ::CUDA_ERROR_INVALID_CONTEXT,
  21393. * ::CUDA_ERROR_INVALID_VALUE,
  21394. * ::CUDA_ERROR_UNKNOWN
  21395. * \notefnerr
  21396. */
  21397. CUresult CUDAAPI cuOccupancyAvailableDynamicSMemPerBlock(size_t *dynamicSmemSize, CUfunction func, int numBlocks, int blockSize);
  21398. /**
  21399. * \brief Given the kernel function (\p func) and launch configuration
  21400. * (\p config), return the maximum cluster size in \p *clusterSize.
  21401. *
  21402. * The cluster dimensions in \p config are ignored. If func has a required
  21403. * cluster size set (see ::cudaFuncGetAttributes / ::cuFuncGetAttribute),\p
  21404. * *clusterSize will reflect the required cluster size.
  21405. *
  21406. * By default this function will always return a value that's portable on
  21407. * future hardware. A higher value may be returned if the kernel function
  21408. * allows non-portable cluster sizes.
  21409. *
  21410. * This function will respect the compile time launch bounds.
  21411. *
  21412. * Note that the API can also be used with context-less kernel ::CUkernel
  21413. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  21414. * to the API by casting to ::CUfunction. Here, the context to use for calculations
  21415. * will either be taken from the specified stream \p config->hStream
  21416. * or the current context in case of NULL stream.
  21417. *
  21418. * \param clusterSize - Returned maximum cluster size that can be launched
  21419. * for the given kernel function and launch configuration
  21420. * \param func - Kernel function for which maximum cluster
  21421. * size is calculated
  21422. * \param config - Launch configuration for the given kernel function
  21423. *
  21424. * \return
  21425. * ::CUDA_SUCCESS,
  21426. * ::CUDA_ERROR_DEINITIALIZED,
  21427. * ::CUDA_ERROR_NOT_INITIALIZED,
  21428. * ::CUDA_ERROR_INVALID_CONTEXT,
  21429. * ::CUDA_ERROR_INVALID_VALUE,
  21430. * ::CUDA_ERROR_UNKNOWN
  21431. * \notefnerr
  21432. *
  21433. * \sa
  21434. * ::cudaFuncGetAttributes,
  21435. * ::cuFuncGetAttribute
  21436. */
  21437. CUresult CUDAAPI cuOccupancyMaxPotentialClusterSize(int *clusterSize, CUfunction func, const CUlaunchConfig *config);
  21438. /**
  21439. * \brief Given the kernel function (\p func) and launch configuration
  21440. * (\p config), return the maximum number of clusters that could co-exist
  21441. * on the target device in \p *numClusters.
  21442. *
  21443. * If the function has required cluster size already set (see
  21444. * ::cudaFuncGetAttributes / ::cuFuncGetAttribute), the cluster size
  21445. * from config must either be unspecified or match the required size.
  21446. * Without required sizes, the cluster size must be specified in config,
  21447. * else the function will return an error.
  21448. *
  21449. * Note that various attributes of the kernel function may affect occupancy
  21450. * calculation. Runtime environment may affect how the hardware schedules
  21451. * the clusters, so the calculated occupancy is not guaranteed to be achievable.
  21452. *
  21453. * Note that the API can also be used with context-less kernel ::CUkernel
  21454. * by querying the handle using ::cuLibraryGetKernel() and then passing it
  21455. * to the API by casting to ::CUfunction. Here, the context to use for calculations
  21456. * will either be taken from the specified stream \p config->hStream
  21457. * or the current context in case of NULL stream.
  21458. *
  21459. * \param numClusters - Returned maximum number of clusters that
  21460. * could co-exist on the target device
  21461. * \param func - Kernel function for which maximum number
  21462. * of clusters are calculated
  21463. * \param config - Launch configuration for the given kernel function
  21464. *
  21465. * \return
  21466. * ::CUDA_SUCCESS,
  21467. * ::CUDA_ERROR_DEINITIALIZED,
  21468. * ::CUDA_ERROR_NOT_INITIALIZED,
  21469. * ::CUDA_ERROR_INVALID_CONTEXT,
  21470. * ::CUDA_ERROR_INVALID_VALUE,
  21471. * ::CUDA_ERROR_INVALID_CLUSTER_SIZE,
  21472. * ::CUDA_ERROR_UNKNOWN
  21473. * \notefnerr
  21474. *
  21475. * \sa
  21476. * ::cudaFuncGetAttributes,
  21477. * ::cuFuncGetAttribute
  21478. */
  21479. CUresult CUDAAPI cuOccupancyMaxActiveClusters(int *numClusters, CUfunction func, const CUlaunchConfig *config);
  21480. /** @} */ /* END CUDA_OCCUPANCY */
  21481. /**
  21482. * \defgroup CUDA_TEXREF_DEPRECATED Texture Reference Management [DEPRECATED]
  21483. *
  21484. * ___MANBRIEF___ deprecated texture reference management functions of the
  21485. * low-level CUDA driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  21486. *
  21487. * This section describes the deprecated texture reference management
  21488. * functions of the low-level CUDA driver application programming interface.
  21489. *
  21490. * @{
  21491. */
  21492. /**
  21493. * \brief Binds an array as a texture reference
  21494. *
  21495. * \deprecated
  21496. *
  21497. * Binds the CUDA array \p hArray to the texture reference \p hTexRef. Any
  21498. * previous address or CUDA array state associated with the texture reference
  21499. * is superseded by this function. \p Flags must be set to
  21500. * ::CU_TRSA_OVERRIDE_FORMAT. Any CUDA array previously bound to \p hTexRef is
  21501. * unbound.
  21502. *
  21503. * \param hTexRef - Texture reference to bind
  21504. * \param hArray - Array to bind
  21505. * \param Flags - Options (must be ::CU_TRSA_OVERRIDE_FORMAT)
  21506. *
  21507. * \return
  21508. * ::CUDA_SUCCESS,
  21509. * ::CUDA_ERROR_DEINITIALIZED,
  21510. * ::CUDA_ERROR_NOT_INITIALIZED,
  21511. * ::CUDA_ERROR_INVALID_CONTEXT,
  21512. * ::CUDA_ERROR_INVALID_VALUE
  21513. *
  21514. * \sa
  21515. * ::cuTexRefSetAddress,
  21516. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode,
  21517. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21518. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21519. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21520. */
  21521. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetArray(CUtexref hTexRef, CUarray hArray, unsigned int Flags);
  21522. /**
  21523. * \brief Binds a mipmapped array to a texture reference
  21524. *
  21525. * \deprecated
  21526. *
  21527. * Binds the CUDA mipmapped array \p hMipmappedArray to the texture reference \p hTexRef.
  21528. * Any previous address or CUDA array state associated with the texture reference
  21529. * is superseded by this function. \p Flags must be set to ::CU_TRSA_OVERRIDE_FORMAT.
  21530. * Any CUDA array previously bound to \p hTexRef is unbound.
  21531. *
  21532. * \param hTexRef - Texture reference to bind
  21533. * \param hMipmappedArray - Mipmapped array to bind
  21534. * \param Flags - Options (must be ::CU_TRSA_OVERRIDE_FORMAT)
  21535. *
  21536. * \return
  21537. * ::CUDA_SUCCESS,
  21538. * ::CUDA_ERROR_DEINITIALIZED,
  21539. * ::CUDA_ERROR_NOT_INITIALIZED,
  21540. * ::CUDA_ERROR_INVALID_CONTEXT,
  21541. * ::CUDA_ERROR_INVALID_VALUE
  21542. *
  21543. * \sa
  21544. * ::cuTexRefSetAddress,
  21545. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode,
  21546. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21547. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21548. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21549. */
  21550. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetMipmappedArray(CUtexref hTexRef, CUmipmappedArray hMipmappedArray, unsigned int Flags);
  21551. /**
  21552. * \brief Binds an address as a texture reference
  21553. *
  21554. * \deprecated
  21555. *
  21556. * Binds a linear address range to the texture reference \p hTexRef. Any
  21557. * previous address or CUDA array state associated with the texture reference
  21558. * is superseded by this function. Any memory previously bound to \p hTexRef
  21559. * is unbound.
  21560. *
  21561. * Since the hardware enforces an alignment requirement on texture base
  21562. * addresses, ::cuTexRefSetAddress() passes back a byte offset in
  21563. * \p *ByteOffset that must be applied to texture fetches in order to read from
  21564. * the desired memory. This offset must be divided by the texel size and
  21565. * passed to kernels that read from the texture so they can be applied to the
  21566. * ::tex1Dfetch() function.
  21567. *
  21568. * If the device memory pointer was returned from ::cuMemAlloc(), the offset
  21569. * is guaranteed to be 0 and NULL may be passed as the \p ByteOffset parameter.
  21570. *
  21571. * The total number of elements (or texels) in the linear address range
  21572. * cannot exceed ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH.
  21573. * The number of elements is computed as (\p bytes / bytesPerElement),
  21574. * where bytesPerElement is determined from the data format and number of
  21575. * components set using ::cuTexRefSetFormat().
  21576. *
  21577. * \param ByteOffset - Returned byte offset
  21578. * \param hTexRef - Texture reference to bind
  21579. * \param dptr - Device pointer to bind
  21580. * \param bytes - Size of memory to bind in bytes
  21581. *
  21582. * \return
  21583. * ::CUDA_SUCCESS,
  21584. * ::CUDA_ERROR_DEINITIALIZED,
  21585. * ::CUDA_ERROR_NOT_INITIALIZED,
  21586. * ::CUDA_ERROR_INVALID_CONTEXT,
  21587. * ::CUDA_ERROR_INVALID_VALUE
  21588. *
  21589. * \sa
  21590. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21591. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21592. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21593. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21594. */
  21595. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetAddress(size_t *ByteOffset, CUtexref hTexRef, CUdeviceptr dptr, size_t bytes);
  21596. /**
  21597. * \brief Binds an address as a 2D texture reference
  21598. *
  21599. * \deprecated
  21600. *
  21601. * Binds a linear address range to the texture reference \p hTexRef. Any
  21602. * previous address or CUDA array state associated with the texture reference
  21603. * is superseded by this function. Any memory previously bound to \p hTexRef
  21604. * is unbound.
  21605. *
  21606. * Using a ::tex2D() function inside a kernel requires a call to either
  21607. * ::cuTexRefSetArray() to bind the corresponding texture reference to an
  21608. * array, or ::cuTexRefSetAddress2D() to bind the texture reference to linear
  21609. * memory.
  21610. *
  21611. * Function calls to ::cuTexRefSetFormat() cannot follow calls to
  21612. * ::cuTexRefSetAddress2D() for the same texture reference.
  21613. *
  21614. * It is required that \p dptr be aligned to the appropriate hardware-specific
  21615. * texture alignment. You can query this value using the device attribute
  21616. * ::CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT. If an unaligned \p dptr is
  21617. * supplied, ::CUDA_ERROR_INVALID_VALUE is returned.
  21618. *
  21619. * \p Pitch has to be aligned to the hardware-specific texture pitch alignment.
  21620. * This value can be queried using the device attribute
  21621. * ::CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT. If an unaligned \p Pitch is
  21622. * supplied, ::CUDA_ERROR_INVALID_VALUE is returned.
  21623. *
  21624. * Width and Height, which are specified in elements (or texels), cannot exceed
  21625. * ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH and
  21626. * ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT respectively.
  21627. * \p Pitch, which is specified in bytes, cannot exceed
  21628. * ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH.
  21629. *
  21630. * \param hTexRef - Texture reference to bind
  21631. * \param desc - Descriptor of CUDA array
  21632. * \param dptr - Device pointer to bind
  21633. * \param Pitch - Line pitch in bytes
  21634. *
  21635. * \return
  21636. * ::CUDA_SUCCESS,
  21637. * ::CUDA_ERROR_DEINITIALIZED,
  21638. * ::CUDA_ERROR_NOT_INITIALIZED,
  21639. * ::CUDA_ERROR_INVALID_CONTEXT,
  21640. * ::CUDA_ERROR_INVALID_VALUE
  21641. *
  21642. * \sa
  21643. * ::cuTexRefSetAddress,
  21644. * ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21645. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21646. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21647. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21648. */
  21649. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetAddress2D(CUtexref hTexRef, const CUDA_ARRAY_DESCRIPTOR *desc, CUdeviceptr dptr, size_t Pitch);
  21650. /**
  21651. * \brief Sets the format for a texture reference
  21652. *
  21653. * \deprecated
  21654. *
  21655. * Specifies the format of the data to be read by the texture reference
  21656. * \p hTexRef. \p fmt and \p NumPackedComponents are exactly analogous to the
  21657. * ::Format and ::NumChannels members of the ::CUDA_ARRAY_DESCRIPTOR structure:
  21658. * They specify the format of each component and the number of components per
  21659. * array element.
  21660. *
  21661. * \param hTexRef - Texture reference
  21662. * \param fmt - Format to set
  21663. * \param NumPackedComponents - Number of components per array element
  21664. *
  21665. * \return
  21666. * ::CUDA_SUCCESS,
  21667. * ::CUDA_ERROR_DEINITIALIZED,
  21668. * ::CUDA_ERROR_NOT_INITIALIZED,
  21669. * ::CUDA_ERROR_INVALID_CONTEXT,
  21670. * ::CUDA_ERROR_INVALID_VALUE
  21671. *
  21672. * \sa
  21673. * ::cuTexRefSetAddress,
  21674. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21675. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags,
  21676. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21677. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat,
  21678. * ::cudaCreateChannelDesc
  21679. */
  21680. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetFormat(CUtexref hTexRef, CUarray_format fmt, int NumPackedComponents);
  21681. /**
  21682. * \brief Sets the addressing mode for a texture reference
  21683. *
  21684. * \deprecated
  21685. *
  21686. * Specifies the addressing mode \p am for the given dimension \p dim of the
  21687. * texture reference \p hTexRef. If \p dim is zero, the addressing mode is
  21688. * applied to the first parameter of the functions used to fetch from the
  21689. * texture; if \p dim is 1, the second, and so on. ::CUaddress_mode is defined
  21690. * as:
  21691. * \code
  21692. typedef enum CUaddress_mode_enum {
  21693. CU_TR_ADDRESS_MODE_WRAP = 0,
  21694. CU_TR_ADDRESS_MODE_CLAMP = 1,
  21695. CU_TR_ADDRESS_MODE_MIRROR = 2,
  21696. CU_TR_ADDRESS_MODE_BORDER = 3
  21697. } CUaddress_mode;
  21698. * \endcode
  21699. *
  21700. * Note that this call has no effect if \p hTexRef is bound to linear memory.
  21701. * Also, if the flag, ::CU_TRSF_NORMALIZED_COORDINATES, is not set, the only
  21702. * supported address mode is ::CU_TR_ADDRESS_MODE_CLAMP.
  21703. *
  21704. * \param hTexRef - Texture reference
  21705. * \param dim - Dimension
  21706. * \param am - Addressing mode to set
  21707. *
  21708. * \return
  21709. * ::CUDA_SUCCESS,
  21710. * ::CUDA_ERROR_DEINITIALIZED,
  21711. * ::CUDA_ERROR_NOT_INITIALIZED,
  21712. * ::CUDA_ERROR_INVALID_CONTEXT,
  21713. * ::CUDA_ERROR_INVALID_VALUE
  21714. *
  21715. * \sa
  21716. * ::cuTexRefSetAddress,
  21717. * ::cuTexRefSetAddress2D, ::cuTexRefSetArray,
  21718. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21719. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21720. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21721. */
  21722. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetAddressMode(CUtexref hTexRef, int dim, CUaddress_mode am);
  21723. /**
  21724. * \brief Sets the filtering mode for a texture reference
  21725. *
  21726. * \deprecated
  21727. *
  21728. * Specifies the filtering mode \p fm to be used when reading memory through
  21729. * the texture reference \p hTexRef. ::CUfilter_mode_enum is defined as:
  21730. *
  21731. * \code
  21732. typedef enum CUfilter_mode_enum {
  21733. CU_TR_FILTER_MODE_POINT = 0,
  21734. CU_TR_FILTER_MODE_LINEAR = 1
  21735. } CUfilter_mode;
  21736. * \endcode
  21737. *
  21738. * Note that this call has no effect if \p hTexRef is bound to linear memory.
  21739. *
  21740. * \param hTexRef - Texture reference
  21741. * \param fm - Filtering mode to set
  21742. *
  21743. * \return
  21744. * ::CUDA_SUCCESS,
  21745. * ::CUDA_ERROR_DEINITIALIZED,
  21746. * ::CUDA_ERROR_NOT_INITIALIZED,
  21747. * ::CUDA_ERROR_INVALID_CONTEXT,
  21748. * ::CUDA_ERROR_INVALID_VALUE
  21749. *
  21750. * \sa
  21751. * ::cuTexRefSetAddress,
  21752. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21753. * ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21754. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21755. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21756. */
  21757. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetFilterMode(CUtexref hTexRef, CUfilter_mode fm);
  21758. /**
  21759. * \brief Sets the mipmap filtering mode for a texture reference
  21760. *
  21761. * \deprecated
  21762. *
  21763. * Specifies the mipmap filtering mode \p fm to be used when reading memory through
  21764. * the texture reference \p hTexRef. ::CUfilter_mode_enum is defined as:
  21765. *
  21766. * \code
  21767. typedef enum CUfilter_mode_enum {
  21768. CU_TR_FILTER_MODE_POINT = 0,
  21769. CU_TR_FILTER_MODE_LINEAR = 1
  21770. } CUfilter_mode;
  21771. * \endcode
  21772. *
  21773. * Note that this call has no effect if \p hTexRef is not bound to a mipmapped array.
  21774. *
  21775. * \param hTexRef - Texture reference
  21776. * \param fm - Filtering mode to set
  21777. *
  21778. * \return
  21779. * ::CUDA_SUCCESS,
  21780. * ::CUDA_ERROR_DEINITIALIZED,
  21781. * ::CUDA_ERROR_NOT_INITIALIZED,
  21782. * ::CUDA_ERROR_INVALID_CONTEXT,
  21783. * ::CUDA_ERROR_INVALID_VALUE
  21784. *
  21785. * \sa
  21786. * ::cuTexRefSetAddress,
  21787. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21788. * ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21789. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21790. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21791. */
  21792. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetMipmapFilterMode(CUtexref hTexRef, CUfilter_mode fm);
  21793. /**
  21794. * \brief Sets the mipmap level bias for a texture reference
  21795. *
  21796. * \deprecated
  21797. *
  21798. * Specifies the mipmap level bias \p bias to be added to the specified mipmap level when
  21799. * reading memory through the texture reference \p hTexRef.
  21800. *
  21801. * Note that this call has no effect if \p hTexRef is not bound to a mipmapped array.
  21802. *
  21803. * \param hTexRef - Texture reference
  21804. * \param bias - Mipmap level bias
  21805. *
  21806. * \return
  21807. * ::CUDA_SUCCESS,
  21808. * ::CUDA_ERROR_DEINITIALIZED,
  21809. * ::CUDA_ERROR_NOT_INITIALIZED,
  21810. * ::CUDA_ERROR_INVALID_CONTEXT,
  21811. * ::CUDA_ERROR_INVALID_VALUE
  21812. *
  21813. * \sa
  21814. * ::cuTexRefSetAddress,
  21815. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21816. * ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21817. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21818. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21819. */
  21820. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetMipmapLevelBias(CUtexref hTexRef, float bias);
  21821. /**
  21822. * \brief Sets the mipmap min/max mipmap level clamps for a texture reference
  21823. *
  21824. * \deprecated
  21825. *
  21826. * Specifies the min/max mipmap level clamps, \p minMipmapLevelClamp and \p maxMipmapLevelClamp
  21827. * respectively, to be used when reading memory through the texture reference
  21828. * \p hTexRef.
  21829. *
  21830. * Note that this call has no effect if \p hTexRef is not bound to a mipmapped array.
  21831. *
  21832. * \param hTexRef - Texture reference
  21833. * \param minMipmapLevelClamp - Mipmap min level clamp
  21834. * \param maxMipmapLevelClamp - Mipmap max level clamp
  21835. *
  21836. * \return
  21837. * ::CUDA_SUCCESS,
  21838. * ::CUDA_ERROR_DEINITIALIZED,
  21839. * ::CUDA_ERROR_NOT_INITIALIZED,
  21840. * ::CUDA_ERROR_INVALID_CONTEXT,
  21841. * ::CUDA_ERROR_INVALID_VALUE
  21842. *
  21843. * \sa
  21844. * ::cuTexRefSetAddress,
  21845. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21846. * ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21847. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21848. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21849. */
  21850. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetMipmapLevelClamp(CUtexref hTexRef, float minMipmapLevelClamp, float maxMipmapLevelClamp);
  21851. /**
  21852. * \brief Sets the maximum anisotropy for a texture reference
  21853. *
  21854. * \deprecated
  21855. *
  21856. * Specifies the maximum anisotropy \p maxAniso to be used when reading memory through
  21857. * the texture reference \p hTexRef.
  21858. *
  21859. * Note that this call has no effect if \p hTexRef is bound to linear memory.
  21860. *
  21861. * \param hTexRef - Texture reference
  21862. * \param maxAniso - Maximum anisotropy
  21863. *
  21864. * \return
  21865. * ::CUDA_SUCCESS,
  21866. * ::CUDA_ERROR_DEINITIALIZED,
  21867. * ::CUDA_ERROR_NOT_INITIALIZED,
  21868. * ::CUDA_ERROR_INVALID_CONTEXT,
  21869. * ::CUDA_ERROR_INVALID_VALUE
  21870. *
  21871. * \sa
  21872. * ::cuTexRefSetAddress,
  21873. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21874. * ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21875. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21876. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21877. */
  21878. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetMaxAnisotropy(CUtexref hTexRef, unsigned int maxAniso);
  21879. /**
  21880. * \brief Sets the border color for a texture reference
  21881. *
  21882. * \deprecated
  21883. *
  21884. * Specifies the value of the RGBA color via the \p pBorderColor to the texture reference
  21885. * \p hTexRef. The color value supports only float type and holds color components in
  21886. * the following sequence:
  21887. * pBorderColor[0] holds 'R' component
  21888. * pBorderColor[1] holds 'G' component
  21889. * pBorderColor[2] holds 'B' component
  21890. * pBorderColor[3] holds 'A' component
  21891. *
  21892. * Note that the color values can be set only when the Address mode is set to
  21893. * CU_TR_ADDRESS_MODE_BORDER using ::cuTexRefSetAddressMode.
  21894. * Applications using integer border color values have to "reinterpret_cast" their values to float.
  21895. *
  21896. * \param hTexRef - Texture reference
  21897. * \param pBorderColor - RGBA color
  21898. *
  21899. * \return
  21900. * ::CUDA_SUCCESS,
  21901. * ::CUDA_ERROR_DEINITIALIZED,
  21902. * ::CUDA_ERROR_NOT_INITIALIZED,
  21903. * ::CUDA_ERROR_INVALID_CONTEXT,
  21904. * ::CUDA_ERROR_INVALID_VALUE
  21905. *
  21906. * \sa
  21907. * ::cuTexRefSetAddressMode,
  21908. * ::cuTexRefGetAddressMode, ::cuTexRefGetBorderColor
  21909. */
  21910. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetBorderColor(CUtexref hTexRef, float *pBorderColor);
  21911. /**
  21912. * \brief Sets the flags for a texture reference
  21913. *
  21914. * \deprecated
  21915. *
  21916. * Specifies optional flags via \p Flags to specify the behavior of data
  21917. * returned through the texture reference \p hTexRef. The valid flags are:
  21918. *
  21919. * - ::CU_TRSF_READ_AS_INTEGER, which suppresses the default behavior of
  21920. * having the texture promote integer data to floating point data in the
  21921. * range [0, 1]. Note that texture with 32-bit integer format
  21922. * would not be promoted, regardless of whether or not this
  21923. * flag is specified;
  21924. * - ::CU_TRSF_NORMALIZED_COORDINATES, which suppresses the
  21925. * default behavior of having the texture coordinates range
  21926. * from [0, Dim) where Dim is the width or height of the CUDA
  21927. * array. Instead, the texture coordinates [0, 1.0) reference
  21928. * the entire breadth of the array dimension;
  21929. * - ::CU_TRSF_DISABLE_TRILINEAR_OPTIMIZATION, which disables any trilinear
  21930. * filtering optimizations. Trilinear optimizations improve texture filtering
  21931. * performance by allowing bilinear filtering on textures in scenarios where
  21932. * it can closely approximate the expected results.
  21933. *
  21934. * \param hTexRef - Texture reference
  21935. * \param Flags - Optional flags to set
  21936. *
  21937. * \return
  21938. * ::CUDA_SUCCESS,
  21939. * ::CUDA_ERROR_DEINITIALIZED,
  21940. * ::CUDA_ERROR_NOT_INITIALIZED,
  21941. * ::CUDA_ERROR_INVALID_CONTEXT,
  21942. * ::CUDA_ERROR_INVALID_VALUE
  21943. *
  21944. * \sa
  21945. * ::cuTexRefSetAddress,
  21946. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21947. * ::cuTexRefSetFilterMode, ::cuTexRefSetFormat,
  21948. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21949. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21950. */
  21951. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefSetFlags(CUtexref hTexRef, unsigned int Flags);
  21952. /**
  21953. * \brief Gets the address associated with a texture reference
  21954. *
  21955. * \deprecated
  21956. *
  21957. * Returns in \p *pdptr the base address bound to the texture reference
  21958. * \p hTexRef, or returns ::CUDA_ERROR_INVALID_VALUE if the texture reference
  21959. * is not bound to any device memory range.
  21960. *
  21961. * \param pdptr - Returned device address
  21962. * \param hTexRef - Texture reference
  21963. *
  21964. * \return
  21965. * ::CUDA_SUCCESS,
  21966. * ::CUDA_ERROR_DEINITIALIZED,
  21967. * ::CUDA_ERROR_NOT_INITIALIZED,
  21968. * ::CUDA_ERROR_INVALID_CONTEXT,
  21969. * ::CUDA_ERROR_INVALID_VALUE
  21970. *
  21971. * \sa ::cuTexRefSetAddress,
  21972. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21973. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  21974. * ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  21975. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  21976. */
  21977. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetAddress(CUdeviceptr *pdptr, CUtexref hTexRef);
  21978. /**
  21979. * \brief Gets the array bound to a texture reference
  21980. *
  21981. * \deprecated
  21982. *
  21983. * Returns in \p *phArray the CUDA array bound to the texture reference
  21984. * \p hTexRef, or returns ::CUDA_ERROR_INVALID_VALUE if the texture reference
  21985. * is not bound to any CUDA array.
  21986. *
  21987. * \param phArray - Returned array
  21988. * \param hTexRef - Texture reference
  21989. *
  21990. * \return
  21991. * ::CUDA_SUCCESS,
  21992. * ::CUDA_ERROR_DEINITIALIZED,
  21993. * ::CUDA_ERROR_NOT_INITIALIZED,
  21994. * ::CUDA_ERROR_INVALID_CONTEXT,
  21995. * ::CUDA_ERROR_INVALID_VALUE
  21996. *
  21997. * \sa ::cuTexRefSetAddress,
  21998. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  21999. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22000. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode,
  22001. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  22002. */
  22003. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetArray(CUarray *phArray, CUtexref hTexRef);
  22004. /**
  22005. * \brief Gets the mipmapped array bound to a texture reference
  22006. *
  22007. * \deprecated
  22008. *
  22009. * Returns in \p *phMipmappedArray the CUDA mipmapped array bound to the texture
  22010. * reference \p hTexRef, or returns ::CUDA_ERROR_INVALID_VALUE if the texture reference
  22011. * is not bound to any CUDA mipmapped array.
  22012. *
  22013. * \param phMipmappedArray - Returned mipmapped array
  22014. * \param hTexRef - Texture reference
  22015. *
  22016. * \return
  22017. * ::CUDA_SUCCESS,
  22018. * ::CUDA_ERROR_DEINITIALIZED,
  22019. * ::CUDA_ERROR_NOT_INITIALIZED,
  22020. * ::CUDA_ERROR_INVALID_CONTEXT,
  22021. * ::CUDA_ERROR_INVALID_VALUE
  22022. *
  22023. * \sa ::cuTexRefSetAddress,
  22024. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  22025. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22026. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode,
  22027. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  22028. */
  22029. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetMipmappedArray(CUmipmappedArray *phMipmappedArray, CUtexref hTexRef);
  22030. /**
  22031. * \brief Gets the addressing mode used by a texture reference
  22032. *
  22033. * \deprecated
  22034. *
  22035. * Returns in \p *pam the addressing mode corresponding to the
  22036. * dimension \p dim of the texture reference \p hTexRef. Currently, the only
  22037. * valid value for \p dim are 0 and 1.
  22038. *
  22039. * \param pam - Returned addressing mode
  22040. * \param hTexRef - Texture reference
  22041. * \param dim - Dimension
  22042. *
  22043. * \return
  22044. * ::CUDA_SUCCESS,
  22045. * ::CUDA_ERROR_DEINITIALIZED,
  22046. * ::CUDA_ERROR_NOT_INITIALIZED,
  22047. * ::CUDA_ERROR_INVALID_CONTEXT,
  22048. * ::CUDA_ERROR_INVALID_VALUE
  22049. *
  22050. * \sa ::cuTexRefSetAddress,
  22051. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  22052. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22053. * ::cuTexRefGetAddress, ::cuTexRefGetArray,
  22054. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  22055. */
  22056. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetAddressMode(CUaddress_mode *pam, CUtexref hTexRef, int dim);
  22057. /**
  22058. * \brief Gets the filter-mode used by a texture reference
  22059. *
  22060. * \deprecated
  22061. *
  22062. * Returns in \p *pfm the filtering mode of the texture reference
  22063. * \p hTexRef.
  22064. *
  22065. * \param pfm - Returned filtering mode
  22066. * \param hTexRef - Texture reference
  22067. *
  22068. * \return
  22069. * ::CUDA_SUCCESS,
  22070. * ::CUDA_ERROR_DEINITIALIZED,
  22071. * ::CUDA_ERROR_NOT_INITIALIZED,
  22072. * ::CUDA_ERROR_INVALID_CONTEXT,
  22073. * ::CUDA_ERROR_INVALID_VALUE
  22074. *
  22075. * \sa ::cuTexRefSetAddress,
  22076. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  22077. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22078. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  22079. * ::cuTexRefGetFlags, ::cuTexRefGetFormat
  22080. */
  22081. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetFilterMode(CUfilter_mode *pfm, CUtexref hTexRef);
  22082. /**
  22083. * \brief Gets the format used by a texture reference
  22084. *
  22085. * \deprecated
  22086. *
  22087. * Returns in \p *pFormat and \p *pNumChannels the format and number
  22088. * of components of the CUDA array bound to the texture reference \p hTexRef.
  22089. * If \p pFormat or \p pNumChannels is NULL, it will be ignored.
  22090. *
  22091. * \param pFormat - Returned format
  22092. * \param pNumChannels - Returned number of components
  22093. * \param hTexRef - Texture reference
  22094. *
  22095. * \return
  22096. * ::CUDA_SUCCESS,
  22097. * ::CUDA_ERROR_DEINITIALIZED,
  22098. * ::CUDA_ERROR_NOT_INITIALIZED,
  22099. * ::CUDA_ERROR_INVALID_CONTEXT,
  22100. * ::CUDA_ERROR_INVALID_VALUE
  22101. *
  22102. * \sa ::cuTexRefSetAddress,
  22103. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  22104. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22105. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  22106. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags
  22107. */
  22108. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetFormat(CUarray_format *pFormat, int *pNumChannels, CUtexref hTexRef);
  22109. /**
  22110. * \brief Gets the mipmap filtering mode for a texture reference
  22111. *
  22112. * \deprecated
  22113. *
  22114. * Returns the mipmap filtering mode in \p pfm that's used when reading memory through
  22115. * the texture reference \p hTexRef.
  22116. *
  22117. * \param pfm - Returned mipmap filtering mode
  22118. * \param hTexRef - Texture reference
  22119. *
  22120. * \return
  22121. * ::CUDA_SUCCESS,
  22122. * ::CUDA_ERROR_DEINITIALIZED,
  22123. * ::CUDA_ERROR_NOT_INITIALIZED,
  22124. * ::CUDA_ERROR_INVALID_CONTEXT,
  22125. * ::CUDA_ERROR_INVALID_VALUE
  22126. *
  22127. * \sa ::cuTexRefSetAddress,
  22128. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  22129. * ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22130. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  22131. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  22132. */
  22133. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetMipmapFilterMode(CUfilter_mode *pfm, CUtexref hTexRef);
  22134. /**
  22135. * \brief Gets the mipmap level bias for a texture reference
  22136. *
  22137. * \deprecated
  22138. *
  22139. * Returns the mipmap level bias in \p pBias that's added to the specified mipmap
  22140. * level when reading memory through the texture reference \p hTexRef.
  22141. *
  22142. * \param pbias - Returned mipmap level bias
  22143. * \param hTexRef - Texture reference
  22144. *
  22145. * \return
  22146. * ::CUDA_SUCCESS,
  22147. * ::CUDA_ERROR_DEINITIALIZED,
  22148. * ::CUDA_ERROR_NOT_INITIALIZED,
  22149. * ::CUDA_ERROR_INVALID_CONTEXT,
  22150. * ::CUDA_ERROR_INVALID_VALUE
  22151. *
  22152. * \sa ::cuTexRefSetAddress,
  22153. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  22154. * ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22155. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  22156. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  22157. */
  22158. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetMipmapLevelBias(float *pbias, CUtexref hTexRef);
  22159. /**
  22160. * \brief Gets the min/max mipmap level clamps for a texture reference
  22161. *
  22162. * \deprecated
  22163. *
  22164. * Returns the min/max mipmap level clamps in \p pminMipmapLevelClamp and \p pmaxMipmapLevelClamp
  22165. * that's used when reading memory through the texture reference \p hTexRef.
  22166. *
  22167. * \param pminMipmapLevelClamp - Returned mipmap min level clamp
  22168. * \param pmaxMipmapLevelClamp - Returned mipmap max level clamp
  22169. * \param hTexRef - Texture reference
  22170. *
  22171. * \return
  22172. * ::CUDA_SUCCESS,
  22173. * ::CUDA_ERROR_DEINITIALIZED,
  22174. * ::CUDA_ERROR_NOT_INITIALIZED,
  22175. * ::CUDA_ERROR_INVALID_CONTEXT,
  22176. * ::CUDA_ERROR_INVALID_VALUE
  22177. *
  22178. * \sa ::cuTexRefSetAddress,
  22179. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  22180. * ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22181. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  22182. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  22183. */
  22184. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetMipmapLevelClamp(float *pminMipmapLevelClamp, float *pmaxMipmapLevelClamp, CUtexref hTexRef);
  22185. /**
  22186. * \brief Gets the maximum anisotropy for a texture reference
  22187. *
  22188. * \deprecated
  22189. *
  22190. * Returns the maximum anisotropy in \p pmaxAniso that's used when reading memory through
  22191. * the texture reference \p hTexRef.
  22192. *
  22193. * \param pmaxAniso - Returned maximum anisotropy
  22194. * \param hTexRef - Texture reference
  22195. *
  22196. * \return
  22197. * ::CUDA_SUCCESS,
  22198. * ::CUDA_ERROR_DEINITIALIZED,
  22199. * ::CUDA_ERROR_NOT_INITIALIZED,
  22200. * ::CUDA_ERROR_INVALID_CONTEXT,
  22201. * ::CUDA_ERROR_INVALID_VALUE
  22202. *
  22203. * \sa ::cuTexRefSetAddress,
  22204. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  22205. * ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22206. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  22207. * ::cuTexRefGetFilterMode, ::cuTexRefGetFlags, ::cuTexRefGetFormat
  22208. */
  22209. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetMaxAnisotropy(int *pmaxAniso, CUtexref hTexRef);
  22210. /**
  22211. * \brief Gets the border color used by a texture reference
  22212. *
  22213. * \deprecated
  22214. *
  22215. * Returns in \p pBorderColor, values of the RGBA color used by
  22216. * the texture reference \p hTexRef.
  22217. * The color value is of type float and holds color components in
  22218. * the following sequence:
  22219. * pBorderColor[0] holds 'R' component
  22220. * pBorderColor[1] holds 'G' component
  22221. * pBorderColor[2] holds 'B' component
  22222. * pBorderColor[3] holds 'A' component
  22223. *
  22224. * \param hTexRef - Texture reference
  22225. * \param pBorderColor - Returned Type and Value of RGBA color
  22226. *
  22227. * \return
  22228. * ::CUDA_SUCCESS,
  22229. * ::CUDA_ERROR_DEINITIALIZED,
  22230. * ::CUDA_ERROR_NOT_INITIALIZED,
  22231. * ::CUDA_ERROR_INVALID_CONTEXT,
  22232. * ::CUDA_ERROR_INVALID_VALUE
  22233. *
  22234. * \sa ::cuTexRefSetAddressMode,
  22235. * ::cuTexRefSetAddressMode, ::cuTexRefSetBorderColor
  22236. */
  22237. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetBorderColor(float *pBorderColor, CUtexref hTexRef);
  22238. /**
  22239. * \brief Gets the flags used by a texture reference
  22240. *
  22241. * \deprecated
  22242. *
  22243. * Returns in \p *pFlags the flags of the texture reference \p hTexRef.
  22244. *
  22245. * \param pFlags - Returned flags
  22246. * \param hTexRef - Texture reference
  22247. *
  22248. * \return
  22249. * ::CUDA_SUCCESS,
  22250. * ::CUDA_ERROR_DEINITIALIZED,
  22251. * ::CUDA_ERROR_NOT_INITIALIZED,
  22252. * ::CUDA_ERROR_INVALID_CONTEXT,
  22253. * ::CUDA_ERROR_INVALID_VALUE
  22254. *
  22255. * \sa ::cuTexRefSetAddress,
  22256. * ::cuTexRefSetAddress2D, ::cuTexRefSetAddressMode, ::cuTexRefSetArray,
  22257. * ::cuTexRefSetFilterMode, ::cuTexRefSetFlags, ::cuTexRefSetFormat,
  22258. * ::cuTexRefGetAddress, ::cuTexRefGetAddressMode, ::cuTexRefGetArray,
  22259. * ::cuTexRefGetFilterMode, ::cuTexRefGetFormat
  22260. */
  22261. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefGetFlags(unsigned int *pFlags, CUtexref hTexRef);
  22262. /**
  22263. * \brief Creates a texture reference
  22264. *
  22265. * \deprecated
  22266. *
  22267. * Creates a texture reference and returns its handle in \p *pTexRef. Once
  22268. * created, the application must call ::cuTexRefSetArray() or
  22269. * ::cuTexRefSetAddress() to associate the reference with allocated memory.
  22270. * Other texture reference functions are used to specify the format and
  22271. * interpretation (addressing, filtering, etc.) to be used when the memory is
  22272. * read through this texture reference.
  22273. *
  22274. * \param pTexRef - Returned texture reference
  22275. *
  22276. * \return
  22277. * ::CUDA_SUCCESS,
  22278. * ::CUDA_ERROR_DEINITIALIZED,
  22279. * ::CUDA_ERROR_NOT_INITIALIZED,
  22280. * ::CUDA_ERROR_INVALID_CONTEXT,
  22281. * ::CUDA_ERROR_INVALID_VALUE
  22282. *
  22283. * \sa ::cuTexRefDestroy
  22284. */
  22285. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefCreate(CUtexref *pTexRef);
  22286. /**
  22287. * \brief Destroys a texture reference
  22288. *
  22289. * \deprecated
  22290. *
  22291. * Destroys the texture reference specified by \p hTexRef.
  22292. *
  22293. * \param hTexRef - Texture reference to destroy
  22294. *
  22295. * \return
  22296. * ::CUDA_SUCCESS,
  22297. * ::CUDA_ERROR_DEINITIALIZED,
  22298. * ::CUDA_ERROR_NOT_INITIALIZED,
  22299. * ::CUDA_ERROR_INVALID_CONTEXT,
  22300. * ::CUDA_ERROR_INVALID_VALUE
  22301. *
  22302. * \sa ::cuTexRefCreate
  22303. */
  22304. __CUDA_DEPRECATED CUresult CUDAAPI cuTexRefDestroy(CUtexref hTexRef);
  22305. /** @} */ /* END CUDA_TEXREF_DEPRECATED */
  22306. /**
  22307. * \defgroup CUDA_SURFREF_DEPRECATED Surface Reference Management [DEPRECATED]
  22308. *
  22309. * ___MANBRIEF___ surface reference management functions of the low-level CUDA
  22310. * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  22311. *
  22312. * This section describes the surface reference management functions of the
  22313. * low-level CUDA driver application programming interface.
  22314. *
  22315. * @{
  22316. */
  22317. /**
  22318. * \brief Sets the CUDA array for a surface reference.
  22319. *
  22320. * \deprecated
  22321. *
  22322. * Sets the CUDA array \p hArray to be read and written by the surface reference
  22323. * \p hSurfRef. Any previous CUDA array state associated with the surface
  22324. * reference is superseded by this function. \p Flags must be set to 0.
  22325. * The ::CUDA_ARRAY3D_SURFACE_LDST flag must have been set for the CUDA array.
  22326. * Any CUDA array previously bound to \p hSurfRef is unbound.
  22327. * \param hSurfRef - Surface reference handle
  22328. * \param hArray - CUDA array handle
  22329. * \param Flags - set to 0
  22330. *
  22331. * \return
  22332. * ::CUDA_SUCCESS,
  22333. * ::CUDA_ERROR_DEINITIALIZED,
  22334. * ::CUDA_ERROR_NOT_INITIALIZED,
  22335. * ::CUDA_ERROR_INVALID_CONTEXT,
  22336. * ::CUDA_ERROR_INVALID_VALUE
  22337. *
  22338. * \sa
  22339. * ::cuModuleGetSurfRef,
  22340. * ::cuSurfRefGetArray
  22341. */
  22342. __CUDA_DEPRECATED CUresult CUDAAPI cuSurfRefSetArray(CUsurfref hSurfRef, CUarray hArray, unsigned int Flags);
  22343. /**
  22344. * \brief Passes back the CUDA array bound to a surface reference.
  22345. *
  22346. * \deprecated
  22347. *
  22348. * Returns in \p *phArray the CUDA array bound to the surface reference
  22349. * \p hSurfRef, or returns ::CUDA_ERROR_INVALID_VALUE if the surface reference
  22350. * is not bound to any CUDA array.
  22351. * \param phArray - Surface reference handle
  22352. * \param hSurfRef - Surface reference handle
  22353. *
  22354. * \return
  22355. * ::CUDA_SUCCESS,
  22356. * ::CUDA_ERROR_DEINITIALIZED,
  22357. * ::CUDA_ERROR_NOT_INITIALIZED,
  22358. * ::CUDA_ERROR_INVALID_CONTEXT,
  22359. * ::CUDA_ERROR_INVALID_VALUE
  22360. *
  22361. * \sa ::cuModuleGetSurfRef, ::cuSurfRefSetArray
  22362. */
  22363. __CUDA_DEPRECATED CUresult CUDAAPI cuSurfRefGetArray(CUarray *phArray, CUsurfref hSurfRef);
  22364. /** @} */ /* END CUDA_SURFREF_DEPRECATED */
  22365. /**
  22366. * \defgroup CUDA_TEXOBJECT Texture Object Management
  22367. *
  22368. * ___MANBRIEF___ texture object management functions of the low-level CUDA
  22369. * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  22370. *
  22371. * This section describes the texture object management functions of the
  22372. * low-level CUDA driver application programming interface. The texture
  22373. * object API is only supported on devices of compute capability 3.0 or higher.
  22374. *
  22375. * @{
  22376. */
  22377. /**
  22378. * \brief Creates a texture object
  22379. *
  22380. * Creates a texture object and returns it in \p pTexObject. \p pResDesc describes
  22381. * the data to texture from. \p pTexDesc describes how the data should be sampled.
  22382. * \p pResViewDesc is an optional argument that specifies an alternate format for
  22383. * the data described by \p pResDesc, and also describes the subresource region
  22384. * to restrict access to when texturing. \p pResViewDesc can only be specified if
  22385. * the type of resource is a CUDA array or a CUDA mipmapped array not in a block
  22386. * compressed format.
  22387. *
  22388. * Texture objects are only supported on devices of compute capability 3.0 or higher.
  22389. * Additionally, a texture object is an opaque value, and, as such, should only be
  22390. * accessed through CUDA API calls.
  22391. *
  22392. * The ::CUDA_RESOURCE_DESC structure is defined as:
  22393. * \code
  22394. typedef struct CUDA_RESOURCE_DESC_st
  22395. {
  22396. CUresourcetype resType;
  22397. union {
  22398. struct {
  22399. CUarray hArray;
  22400. } array;
  22401. struct {
  22402. CUmipmappedArray hMipmappedArray;
  22403. } mipmap;
  22404. struct {
  22405. CUdeviceptr devPtr;
  22406. CUarray_format format;
  22407. unsigned int numChannels;
  22408. size_t sizeInBytes;
  22409. } linear;
  22410. struct {
  22411. CUdeviceptr devPtr;
  22412. CUarray_format format;
  22413. unsigned int numChannels;
  22414. size_t width;
  22415. size_t height;
  22416. size_t pitchInBytes;
  22417. } pitch2D;
  22418. } res;
  22419. unsigned int flags;
  22420. } CUDA_RESOURCE_DESC;
  22421. * \endcode
  22422. * where:
  22423. * - ::CUDA_RESOURCE_DESC::resType specifies the type of resource to texture from.
  22424. * CUresourceType is defined as:
  22425. * \code
  22426. typedef enum CUresourcetype_enum {
  22427. CU_RESOURCE_TYPE_ARRAY = 0x00,
  22428. CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01,
  22429. CU_RESOURCE_TYPE_LINEAR = 0x02,
  22430. CU_RESOURCE_TYPE_PITCH2D = 0x03
  22431. } CUresourcetype;
  22432. * \endcode
  22433. *
  22434. * \par
  22435. * If ::CUDA_RESOURCE_DESC::resType is set to ::CU_RESOURCE_TYPE_ARRAY, ::CUDA_RESOURCE_DESC::res::array::hArray
  22436. * must be set to a valid CUDA array handle.
  22437. *
  22438. * \par
  22439. * If ::CUDA_RESOURCE_DESC::resType is set to ::CU_RESOURCE_TYPE_MIPMAPPED_ARRAY, ::CUDA_RESOURCE_DESC::res::mipmap::hMipmappedArray
  22440. * must be set to a valid CUDA mipmapped array handle.
  22441. *
  22442. * \par
  22443. * If ::CUDA_RESOURCE_DESC::resType is set to ::CU_RESOURCE_TYPE_LINEAR, ::CUDA_RESOURCE_DESC::res::linear::devPtr
  22444. * must be set to a valid device pointer, that is aligned to ::CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT.
  22445. * ::CUDA_RESOURCE_DESC::res::linear::format and ::CUDA_RESOURCE_DESC::res::linear::numChannels
  22446. * describe the format of each component and the number of components per array element. ::CUDA_RESOURCE_DESC::res::linear::sizeInBytes
  22447. * specifies the size of the array in bytes. The total number of elements in the linear address range cannot exceed
  22448. * ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH. The number of elements is computed as (sizeInBytes / (sizeof(format) * numChannels)).
  22449. *
  22450. * \par
  22451. * If ::CUDA_RESOURCE_DESC::resType is set to ::CU_RESOURCE_TYPE_PITCH2D, ::CUDA_RESOURCE_DESC::res::pitch2D::devPtr
  22452. * must be set to a valid device pointer, that is aligned to ::CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT.
  22453. * ::CUDA_RESOURCE_DESC::res::pitch2D::format and ::CUDA_RESOURCE_DESC::res::pitch2D::numChannels
  22454. * describe the format of each component and the number of components per array element. ::CUDA_RESOURCE_DESC::res::pitch2D::width
  22455. * and ::CUDA_RESOURCE_DESC::res::pitch2D::height specify the width and height of the array in elements, and cannot exceed
  22456. * ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH and ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT respectively.
  22457. * ::CUDA_RESOURCE_DESC::res::pitch2D::pitchInBytes specifies the pitch between two rows in bytes and has to be aligned to
  22458. * ::CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT. Pitch cannot exceed ::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH.
  22459. *
  22460. * - ::flags must be set to zero.
  22461. *
  22462. *
  22463. * The ::CUDA_TEXTURE_DESC struct is defined as
  22464. * \code
  22465. typedef struct CUDA_TEXTURE_DESC_st {
  22466. CUaddress_mode addressMode[3];
  22467. CUfilter_mode filterMode;
  22468. unsigned int flags;
  22469. unsigned int maxAnisotropy;
  22470. CUfilter_mode mipmapFilterMode;
  22471. float mipmapLevelBias;
  22472. float minMipmapLevelClamp;
  22473. float maxMipmapLevelClamp;
  22474. } CUDA_TEXTURE_DESC;
  22475. * \endcode
  22476. * where
  22477. * - ::CUDA_TEXTURE_DESC::addressMode specifies the addressing mode for each dimension of the texture data. ::CUaddress_mode is defined as:
  22478. * \code
  22479. typedef enum CUaddress_mode_enum {
  22480. CU_TR_ADDRESS_MODE_WRAP = 0,
  22481. CU_TR_ADDRESS_MODE_CLAMP = 1,
  22482. CU_TR_ADDRESS_MODE_MIRROR = 2,
  22483. CU_TR_ADDRESS_MODE_BORDER = 3
  22484. } CUaddress_mode;
  22485. * \endcode
  22486. * This is ignored if ::CUDA_RESOURCE_DESC::resType is ::CU_RESOURCE_TYPE_LINEAR. Also, if the flag, ::CU_TRSF_NORMALIZED_COORDINATES
  22487. * is not set, the only supported address mode is ::CU_TR_ADDRESS_MODE_CLAMP.
  22488. *
  22489. * - ::CUDA_TEXTURE_DESC::filterMode specifies the filtering mode to be used when fetching from the texture. CUfilter_mode is defined as:
  22490. * \code
  22491. typedef enum CUfilter_mode_enum {
  22492. CU_TR_FILTER_MODE_POINT = 0,
  22493. CU_TR_FILTER_MODE_LINEAR = 1
  22494. } CUfilter_mode;
  22495. * \endcode
  22496. * This is ignored if ::CUDA_RESOURCE_DESC::resType is ::CU_RESOURCE_TYPE_LINEAR.
  22497. *
  22498. * - ::CUDA_TEXTURE_DESC::flags can be any combination of the following:
  22499. * - ::CU_TRSF_READ_AS_INTEGER, which suppresses the default behavior of
  22500. * having the texture promote integer data to floating point data in the
  22501. * range [0, 1]. Note that texture with 32-bit integer format would not be
  22502. * promoted, regardless of whether or not this flag is specified.
  22503. * - ::CU_TRSF_NORMALIZED_COORDINATES, which suppresses the default behavior
  22504. * of having the texture coordinates range from [0, Dim) where Dim is the
  22505. * width or height of the CUDA array. Instead, the texture coordinates
  22506. * [0, 1.0) reference the entire breadth of the array dimension; Note that
  22507. * for CUDA mipmapped arrays, this flag has to be set.
  22508. * - ::CU_TRSF_DISABLE_TRILINEAR_OPTIMIZATION, which disables any trilinear
  22509. * filtering optimizations. Trilinear optimizations improve texture filtering
  22510. * performance by allowing bilinear filtering on textures in scenarios where
  22511. * it can closely approximate the expected results.
  22512. * - ::CU_TRSF_SEAMLESS_CUBEMAP, which enables seamless cube map filtering.
  22513. * This flag can only be specified if the underlying resource is a CUDA array
  22514. * or a CUDA mipmapped array that was created with the flag ::CUDA_ARRAY3D_CUBEMAP.
  22515. * When seamless cube map filtering is enabled, texture address modes specified
  22516. * by ::CUDA_TEXTURE_DESC::addressMode are ignored. Instead, if the ::CUDA_TEXTURE_DESC::filterMode
  22517. * is set to ::CU_TR_FILTER_MODE_POINT the address mode ::CU_TR_ADDRESS_MODE_CLAMP
  22518. * will be applied for all dimensions. If the ::CUDA_TEXTURE_DESC::filterMode is
  22519. * set to ::CU_TR_FILTER_MODE_LINEAR seamless cube map filtering will be performed
  22520. * when sampling along the cube face borders.
  22521. *
  22522. * - ::CUDA_TEXTURE_DESC::maxAnisotropy specifies the maximum anisotropy ratio to be used when doing anisotropic filtering. This value will be
  22523. * clamped to the range [1,16].
  22524. *
  22525. * - ::CUDA_TEXTURE_DESC::mipmapFilterMode specifies the filter mode when the calculated mipmap level lies between two defined mipmap levels.
  22526. *
  22527. * - ::CUDA_TEXTURE_DESC::mipmapLevelBias specifies the offset to be applied to the calculated mipmap level.
  22528. *
  22529. * - ::CUDA_TEXTURE_DESC::minMipmapLevelClamp specifies the lower end of the mipmap level range to clamp access to.
  22530. *
  22531. * - ::CUDA_TEXTURE_DESC::maxMipmapLevelClamp specifies the upper end of the mipmap level range to clamp access to.
  22532. *
  22533. *
  22534. * The ::CUDA_RESOURCE_VIEW_DESC struct is defined as
  22535. * \code
  22536. typedef struct CUDA_RESOURCE_VIEW_DESC_st
  22537. {
  22538. CUresourceViewFormat format;
  22539. size_t width;
  22540. size_t height;
  22541. size_t depth;
  22542. unsigned int firstMipmapLevel;
  22543. unsigned int lastMipmapLevel;
  22544. unsigned int firstLayer;
  22545. unsigned int lastLayer;
  22546. } CUDA_RESOURCE_VIEW_DESC;
  22547. * \endcode
  22548. * where:
  22549. * - ::CUDA_RESOURCE_VIEW_DESC::format specifies how the data contained in the CUDA array or CUDA mipmapped array should
  22550. * be interpreted. Note that this can incur a change in size of the texture data. If the resource view format is a block
  22551. * compressed format, then the underlying CUDA array or CUDA mipmapped array has to have a base of format ::CU_AD_FORMAT_UNSIGNED_INT32.
  22552. * with 2 or 4 channels, depending on the block compressed format. For ex., BC1 and BC4 require the underlying CUDA array to have
  22553. * a format of ::CU_AD_FORMAT_UNSIGNED_INT32 with 2 channels. The other BC formats require the underlying resource to have the same base
  22554. * format but with 4 channels.
  22555. *
  22556. * - ::CUDA_RESOURCE_VIEW_DESC::width specifies the new width of the texture data. If the resource view format is a block
  22557. * compressed format, this value has to be 4 times the original width of the resource. For non block compressed formats,
  22558. * this value has to be equal to that of the original resource.
  22559. *
  22560. * - ::CUDA_RESOURCE_VIEW_DESC::height specifies the new height of the texture data. If the resource view format is a block
  22561. * compressed format, this value has to be 4 times the original height of the resource. For non block compressed formats,
  22562. * this value has to be equal to that of the original resource.
  22563. *
  22564. * - ::CUDA_RESOURCE_VIEW_DESC::depth specifies the new depth of the texture data. This value has to be equal to that of the
  22565. * original resource.
  22566. *
  22567. * - ::CUDA_RESOURCE_VIEW_DESC::firstMipmapLevel specifies the most detailed mipmap level. This will be the new mipmap level zero.
  22568. * For non-mipmapped resources, this value has to be zero.::CUDA_TEXTURE_DESC::minMipmapLevelClamp and ::CUDA_TEXTURE_DESC::maxMipmapLevelClamp
  22569. * will be relative to this value. For ex., if the firstMipmapLevel is set to 2, and a minMipmapLevelClamp of 1.2 is specified,
  22570. * then the actual minimum mipmap level clamp will be 3.2.
  22571. *
  22572. * - ::CUDA_RESOURCE_VIEW_DESC::lastMipmapLevel specifies the least detailed mipmap level. For non-mipmapped resources, this value
  22573. * has to be zero.
  22574. *
  22575. * - ::CUDA_RESOURCE_VIEW_DESC::firstLayer specifies the first layer index for layered textures. This will be the new layer zero.
  22576. * For non-layered resources, this value has to be zero.
  22577. *
  22578. * - ::CUDA_RESOURCE_VIEW_DESC::lastLayer specifies the last layer index for layered textures. For non-layered resources,
  22579. * this value has to be zero.
  22580. *
  22581. *
  22582. * \param pTexObject - Texture object to create
  22583. * \param pResDesc - Resource descriptor
  22584. * \param pTexDesc - Texture descriptor
  22585. * \param pResViewDesc - Resource view descriptor
  22586. *
  22587. * \return
  22588. * ::CUDA_SUCCESS,
  22589. * ::CUDA_ERROR_DEINITIALIZED,
  22590. * ::CUDA_ERROR_NOT_INITIALIZED,
  22591. * ::CUDA_ERROR_INVALID_CONTEXT,
  22592. * ::CUDA_ERROR_INVALID_VALUE
  22593. *
  22594. * \sa
  22595. * ::cuTexObjectDestroy,
  22596. * ::cudaCreateTextureObject
  22597. */
  22598. CUresult CUDAAPI cuTexObjectCreate(CUtexObject *pTexObject, const CUDA_RESOURCE_DESC *pResDesc, const CUDA_TEXTURE_DESC *pTexDesc, const CUDA_RESOURCE_VIEW_DESC *pResViewDesc);
  22599. /**
  22600. * \brief Destroys a texture object
  22601. *
  22602. * Destroys the texture object specified by \p texObject.
  22603. *
  22604. * \param texObject - Texture object to destroy
  22605. *
  22606. * \return
  22607. * ::CUDA_SUCCESS,
  22608. * ::CUDA_ERROR_DEINITIALIZED,
  22609. * ::CUDA_ERROR_NOT_INITIALIZED,
  22610. * ::CUDA_ERROR_INVALID_CONTEXT,
  22611. * ::CUDA_ERROR_INVALID_VALUE
  22612. *
  22613. * \sa
  22614. * ::cuTexObjectCreate,
  22615. * ::cudaDestroyTextureObject
  22616. */
  22617. CUresult CUDAAPI cuTexObjectDestroy(CUtexObject texObject);
  22618. /**
  22619. * \brief Returns a texture object's resource descriptor
  22620. *
  22621. * Returns the resource descriptor for the texture object specified by \p texObject.
  22622. *
  22623. * \param pResDesc - Resource descriptor
  22624. * \param texObject - Texture object
  22625. *
  22626. * \return
  22627. * ::CUDA_SUCCESS,
  22628. * ::CUDA_ERROR_DEINITIALIZED,
  22629. * ::CUDA_ERROR_NOT_INITIALIZED,
  22630. * ::CUDA_ERROR_INVALID_CONTEXT,
  22631. * ::CUDA_ERROR_INVALID_VALUE
  22632. *
  22633. * \sa
  22634. * ::cuTexObjectCreate,
  22635. * ::cudaGetTextureObjectResourceDesc,
  22636. */
  22637. CUresult CUDAAPI cuTexObjectGetResourceDesc(CUDA_RESOURCE_DESC *pResDesc, CUtexObject texObject);
  22638. /**
  22639. * \brief Returns a texture object's texture descriptor
  22640. *
  22641. * Returns the texture descriptor for the texture object specified by \p texObject.
  22642. *
  22643. * \param pTexDesc - Texture descriptor
  22644. * \param texObject - Texture object
  22645. *
  22646. * \return
  22647. * ::CUDA_SUCCESS,
  22648. * ::CUDA_ERROR_DEINITIALIZED,
  22649. * ::CUDA_ERROR_NOT_INITIALIZED,
  22650. * ::CUDA_ERROR_INVALID_CONTEXT,
  22651. * ::CUDA_ERROR_INVALID_VALUE
  22652. *
  22653. * \sa
  22654. * ::cuTexObjectCreate,
  22655. * ::cudaGetTextureObjectTextureDesc
  22656. */
  22657. CUresult CUDAAPI cuTexObjectGetTextureDesc(CUDA_TEXTURE_DESC *pTexDesc, CUtexObject texObject);
  22658. /**
  22659. * \brief Returns a texture object's resource view descriptor
  22660. *
  22661. * Returns the resource view descriptor for the texture object specified by \p texObject.
  22662. * If no resource view was set for \p texObject, the ::CUDA_ERROR_INVALID_VALUE is returned.
  22663. *
  22664. * \param pResViewDesc - Resource view descriptor
  22665. * \param texObject - Texture object
  22666. *
  22667. * \return
  22668. * ::CUDA_SUCCESS,
  22669. * ::CUDA_ERROR_DEINITIALIZED,
  22670. * ::CUDA_ERROR_NOT_INITIALIZED,
  22671. * ::CUDA_ERROR_INVALID_CONTEXT,
  22672. * ::CUDA_ERROR_INVALID_VALUE
  22673. *
  22674. * \sa
  22675. * ::cuTexObjectCreate,
  22676. * ::cudaGetTextureObjectResourceViewDesc
  22677. */
  22678. CUresult CUDAAPI cuTexObjectGetResourceViewDesc(CUDA_RESOURCE_VIEW_DESC *pResViewDesc, CUtexObject texObject);
  22679. /** @} */ /* END CUDA_TEXOBJECT */
  22680. /**
  22681. * \defgroup CUDA_SURFOBJECT Surface Object Management
  22682. *
  22683. * ___MANBRIEF___ surface object management functions of the low-level CUDA
  22684. * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  22685. *
  22686. * This section describes the surface object management functions of the
  22687. * low-level CUDA driver application programming interface. The surface
  22688. * object API is only supported on devices of compute capability 3.0 or higher.
  22689. *
  22690. * @{
  22691. */
  22692. /**
  22693. * \brief Creates a surface object
  22694. *
  22695. * Creates a surface object and returns it in \p pSurfObject. \p pResDesc describes
  22696. * the data to perform surface load/stores on. ::CUDA_RESOURCE_DESC::resType must be
  22697. * ::CU_RESOURCE_TYPE_ARRAY and ::CUDA_RESOURCE_DESC::res::array::hArray
  22698. * must be set to a valid CUDA array handle. ::CUDA_RESOURCE_DESC::flags must be set to zero.
  22699. *
  22700. * Surface objects are only supported on devices of compute capability 3.0 or higher.
  22701. * Additionally, a surface object is an opaque value, and, as such, should only be
  22702. * accessed through CUDA API calls.
  22703. *
  22704. * \param pSurfObject - Surface object to create
  22705. * \param pResDesc - Resource descriptor
  22706. *
  22707. * \return
  22708. * ::CUDA_SUCCESS,
  22709. * ::CUDA_ERROR_DEINITIALIZED,
  22710. * ::CUDA_ERROR_NOT_INITIALIZED,
  22711. * ::CUDA_ERROR_INVALID_CONTEXT,
  22712. * ::CUDA_ERROR_INVALID_VALUE
  22713. *
  22714. * \sa
  22715. * ::cuSurfObjectDestroy,
  22716. * ::cudaCreateSurfaceObject
  22717. */
  22718. CUresult CUDAAPI cuSurfObjectCreate(CUsurfObject *pSurfObject, const CUDA_RESOURCE_DESC *pResDesc);
  22719. /**
  22720. * \brief Destroys a surface object
  22721. *
  22722. * Destroys the surface object specified by \p surfObject.
  22723. *
  22724. * \param surfObject - Surface object to destroy
  22725. *
  22726. * \return
  22727. * ::CUDA_SUCCESS,
  22728. * ::CUDA_ERROR_DEINITIALIZED,
  22729. * ::CUDA_ERROR_NOT_INITIALIZED,
  22730. * ::CUDA_ERROR_INVALID_CONTEXT,
  22731. * ::CUDA_ERROR_INVALID_VALUE
  22732. *
  22733. * \sa
  22734. * ::cuSurfObjectCreate,
  22735. * ::cudaDestroySurfaceObject
  22736. */
  22737. CUresult CUDAAPI cuSurfObjectDestroy(CUsurfObject surfObject);
  22738. /**
  22739. * \brief Returns a surface object's resource descriptor
  22740. *
  22741. * Returns the resource descriptor for the surface object specified by \p surfObject.
  22742. *
  22743. * \param pResDesc - Resource descriptor
  22744. * \param surfObject - Surface object
  22745. *
  22746. * \return
  22747. * ::CUDA_SUCCESS,
  22748. * ::CUDA_ERROR_DEINITIALIZED,
  22749. * ::CUDA_ERROR_NOT_INITIALIZED,
  22750. * ::CUDA_ERROR_INVALID_CONTEXT,
  22751. * ::CUDA_ERROR_INVALID_VALUE
  22752. *
  22753. * \sa
  22754. * ::cuSurfObjectCreate,
  22755. * ::cudaGetSurfaceObjectResourceDesc
  22756. */
  22757. CUresult CUDAAPI cuSurfObjectGetResourceDesc(CUDA_RESOURCE_DESC *pResDesc, CUsurfObject surfObject);
  22758. /** @} */ /* END CUDA_SURFOBJECT */
  22759. /**
  22760. * \defgroup CUDA_TENSOR_MEMORY Tensor Map Object Managment
  22761. *
  22762. * ___MANBRIEF___ tensor map object management functions of the low-level CUDA
  22763. * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  22764. *
  22765. * This section describes the tensor map object management functions of the
  22766. * low-level CUDA driver application programming interface. The tensor
  22767. * core API is only supported on devices of compute capability 9.0 or higher.
  22768. *
  22769. * @{
  22770. */
  22771. /**
  22772. * \brief Create a tensor map descriptor object representing tiled memory region
  22773. *
  22774. * Creates a descriptor for Tensor Memory Access (TMA) object specified
  22775. * by the parameters describing a tiled region and returns it in \p tensorMap.
  22776. *
  22777. * Tensor map objects are only supported on devices of compute capability 9.0 or higher.
  22778. * Additionally, a tensor map object is an opaque value, and, as such, should only be
  22779. * accessed through CUDA APIs and PTX.
  22780. *
  22781. * The parameters passed are bound to the following requirements:
  22782. *
  22783. * - \p tensorMap address must be aligned to 64 bytes.
  22784. *
  22785. * - \p tensorDataType has to be an enum from ::CUtensorMapDataType which is defined as:
  22786. * \code
  22787. typedef enum CUtensorMapDataType_enum {
  22788. CU_TENSOR_MAP_DATA_TYPE_UINT8 = 0, // 1 byte
  22789. CU_TENSOR_MAP_DATA_TYPE_UINT16, // 2 bytes
  22790. CU_TENSOR_MAP_DATA_TYPE_UINT32, // 4 bytes
  22791. CU_TENSOR_MAP_DATA_TYPE_INT32, // 4 bytes
  22792. CU_TENSOR_MAP_DATA_TYPE_UINT64, // 8 bytes
  22793. CU_TENSOR_MAP_DATA_TYPE_INT64, // 8 bytes
  22794. CU_TENSOR_MAP_DATA_TYPE_FLOAT16, // 2 bytes
  22795. CU_TENSOR_MAP_DATA_TYPE_FLOAT32, // 4 bytes
  22796. CU_TENSOR_MAP_DATA_TYPE_FLOAT64, // 8 bytes
  22797. CU_TENSOR_MAP_DATA_TYPE_BFLOAT16, // 2 bytes
  22798. CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ, // 4 bytes
  22799. CU_TENSOR_MAP_DATA_TYPE_TFLOAT32, // 4 bytes
  22800. CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ, // 4 bytes
  22801. CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, // 4 bits
  22802. CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, // 4 bits
  22803. CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B // 6 bits
  22804. } CUtensorMapDataType;
  22805. * \endcode
  22806. * ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B copies '16 x U4' packed values to memory aligned as 8 bytes. There are no gaps between packed values.
  22807. * ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B copies '16 x U4' packed values to memory aligned as 16 bytes. There are 8 byte gaps between every 8 byte chunk of packed values.
  22808. * ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B copies '16 x U6' packed values to memory aligned as 16 bytes. There are 4 byte gaps between every 12 byte chunk of packed values.
  22809. *
  22810. * - \p tensorRank must be non-zero and less than or equal to the maximum supported dimensionality of 5. If \p interleave is not
  22811. * ::CU_TENSOR_MAP_INTERLEAVE_NONE, then \p tensorRank must additionally be greater than or equal to 3.
  22812. *
  22813. * - \p globalAddress, which specifies the starting address of the memory region described, must be 16 byte aligned. The following requirements need to also be met:
  22814. * - When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_32B, \p globalAddress must be 32 byte aligned.
  22815. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, \p globalAddress must be 32 byte aligned.
  22816. *
  22817. * - \p globalDim array, which specifies tensor size of each of the \p tensorRank dimensions, must be non-zero and less than or
  22818. * equal to 2^32. Additionally, the following requirements need to be met for the packed data types:
  22819. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, globalDim[0] must be a multiple of 128.
  22820. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, \p globalDim[0] must be a multiple of 2.
  22821. * - Dimension for the packed data types must reflect the number of individual U# values.
  22822. *
  22823. * - \p globalStrides array, which specifies tensor stride of each of the lower \p tensorRank - 1 dimensions in bytes, must be a
  22824. * multiple of 16 and less than 2^40. Additionally, the following requirements need to be met:
  22825. * - When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_32B, the strides must be a multiple of 32.
  22826. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, the strides must be a multiple of 32.
  22827. * Each following dimension specified includes previous dimension stride:
  22828. * \code
  22829. globalStrides[0] = globalDim[0] * elementSizeInBytes(tensorDataType) + padding[0];
  22830. for (i = 1; i < tensorRank - 1; i++)
  22831. globalStrides[i] = globalStrides[i – 1] * (globalDim[i] + padding[i]);
  22832. assert(globalStrides[i] >= globalDim[i]);
  22833. * \endcode
  22834. *
  22835. * - \p boxDim array, which specifies number of elements to be traversed along each of the \p tensorRank dimensions, must be non-zero
  22836. * and less than or equal to 256. Additionally, the following requirements need to be met:
  22837. * - When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_NONE, { \p boxDim[0] * elementSizeInBytes( \p tensorDataType ) } must be a multiple of 16 bytes.
  22838. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, boxDim[0] must be 128.
  22839. *
  22840. * - \p elementStrides array, which specifies the iteration step along each of the \p tensorRank dimensions, must be non-zero and less
  22841. * than or equal to 8. Note that when \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_NONE, the first element of this array is ignored since
  22842. * TMA doesn’t support the stride for dimension zero.
  22843. * When all elements of \p elementStrides array is one, \p boxDim specifies the number of elements to load. However, if the \p elementStrides[i]
  22844. * is not equal to one, then TMA loads ceil( \p boxDim[i] / \p elementStrides[i]) number of elements along i-th dimension. To load N elements along
  22845. * i-th dimension, \p boxDim[i] must be set to N * \p elementStrides[i].
  22846. *
  22847. * - \p interleave specifies the interleaved layout of type ::CUtensorMapInterleave, which is defined as:
  22848. * \code
  22849. typedef enum CUtensorMapInterleave_enum {
  22850. CU_TENSOR_MAP_INTERLEAVE_NONE = 0,
  22851. CU_TENSOR_MAP_INTERLEAVE_16B,
  22852. CU_TENSOR_MAP_INTERLEAVE_32B
  22853. } CUtensorMapInterleave;
  22854. * \endcode
  22855. * TMA supports interleaved layouts like NC/8HWC8 where C8 utilizes 16 bytes in memory assuming 2 byte per channel or NC/16HWC16 where C16
  22856. * uses 32 bytes.
  22857. * When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_NONE and \p swizzle is not ::CU_TENSOR_MAP_SWIZZLE_NONE, the bounding box inner dimension
  22858. * (computed as \p boxDim[0] multiplied by element size derived from \p tensorDataType) must be less than or equal to the swizzle size.
  22859. * - CU_TENSOR_MAP_SWIZZLE_32B requires the bounding box inner dimension to be <= 32.
  22860. * - CU_TENSOR_MAP_SWIZZLE_64B requires the bounding box inner dimension to be <= 64.
  22861. * - CU_TENSOR_MAP_SWIZZLE_128B* require the bounding box inner dimension to be <= 128.
  22862. * Additionally, \p tensorDataType of ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B requires \p interleave to be ::CU_TENSOR_MAP_INTERLEAVE_NONE.
  22863. *
  22864. * - \p swizzle, which specifies the shared memory bank swizzling pattern, has to be of type ::CUtensorMapSwizzle which is defined as:
  22865. * \code
  22866. typedef enum CUtensorMapSwizzle_enum {
  22867. CU_TENSOR_MAP_SWIZZLE_NONE = 0,
  22868. CU_TENSOR_MAP_SWIZZLE_32B, // Swizzle 16B chunks within 32B span
  22869. CU_TENSOR_MAP_SWIZZLE_64B, // Swizzle 16B chunks within 64B span
  22870. CU_TENSOR_MAP_SWIZZLE_128B, // Swizzle 16B chunks within 128B span
  22871. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B, // Swizzle 32B chunks within 128B span
  22872. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B_FLIP_8B, // Swizzle 32B chunks within 128B span, additionally swap lower 8B with upper 8B within each 16B for every alternate row
  22873. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B // Swizzle 64B chunks within 128B span
  22874. } CUtensorMapSwizzle;
  22875. * \endcode
  22876. * Data are organized in a specific order in global memory; however, this may not match the order in which the application accesses data
  22877. * in shared memory. This difference in data organization may cause bank conflicts when shared memory is accessed. In order to avoid this
  22878. * problem, data can be loaded to shared memory with shuffling across shared memory banks.
  22879. * When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_32B, \p swizzle must be ::CU_TENSOR_MAP_SWIZZLE_32B.
  22880. * Other interleave modes can have any swizzling pattern.
  22881. * When the \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B, only the following swizzle modes are supported:
  22882. * - CU_TENSOR_MAP_SWIZZLE_NONE (Load & Store)
  22883. * - CU_TENSOR_MAP_SWIZZLE_128B (Load & Store)
  22884. * - CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B (Load & Store)
  22885. * - CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B (Store only)
  22886. * When the \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, only the following swizzle modes are supported:
  22887. * - CU_TENSOR_MAP_SWIZZLE_NONE (Load only)
  22888. * - CU_TENSOR_MAP_SWIZZLE_128B (Load only)
  22889. * - CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B (Load only)
  22890. *
  22891. * - \p l2Promotion specifies L2 fetch size which indicates the byte granurality at which L2 requests is filled from DRAM. It must be of
  22892. * type ::CUtensorMapL2promotion, which is defined as:
  22893. * \code
  22894. typedef enum CUtensorMapL2promotion_enum {
  22895. CU_TENSOR_MAP_L2_PROMOTION_NONE = 0,
  22896. CU_TENSOR_MAP_L2_PROMOTION_L2_64B,
  22897. CU_TENSOR_MAP_L2_PROMOTION_L2_128B,
  22898. CU_TENSOR_MAP_L2_PROMOTION_L2_256B
  22899. } CUtensorMapL2promotion;
  22900. * \endcode
  22901. *
  22902. * - \p oobFill, which indicates whether zero or a special NaN constant should be used to fill out-of-bound elements, must be of type
  22903. * ::CUtensorMapFloatOOBfill which is defined as:
  22904. * \code
  22905. typedef enum CUtensorMapFloatOOBfill_enum {
  22906. CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE = 0,
  22907. CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA
  22908. } CUtensorMapFloatOOBfill;
  22909. * \endcode
  22910. * Note that ::CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA can only be used when \p tensorDataType represents a floating-point data type,
  22911. * and when \p tensorDataType is not ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, and ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B.
  22912. *
  22913. * \param tensorMap - Tensor map object to create
  22914. * \param tensorDataType - Tensor data type
  22915. * \param tensorRank - Dimensionality of tensor
  22916. * \param globalAddress - Starting address of memory region described by tensor
  22917. * \param globalDim - Array containing tensor size (number of elements) along each of the \p tensorRank dimensions
  22918. * \param globalStrides - Array containing stride size (in bytes) along each of the \p tensorRank - 1 dimensions
  22919. * \param boxDim - Array containing traversal box size (number of elments) along each of the \p tensorRank dimensions. Specifies how many elements to be traversed along each tensor dimension.
  22920. * \param elementStrides - Array containing traversal stride in each of the \p tensorRank dimensions
  22921. * \param interleave - Type of interleaved layout the tensor addresses
  22922. * \param swizzle - Bank swizzling pattern inside shared memory
  22923. * \param l2Promotion - L2 promotion size
  22924. * \param oobFill - Indicate whether zero or special NaN constant must be used to fill out-of-bound elements
  22925. *
  22926. * \return
  22927. * ::CUDA_SUCCESS,
  22928. * ::CUDA_ERROR_DEINITIALIZED,
  22929. * ::CUDA_ERROR_NOT_INITIALIZED,
  22930. * ::CUDA_ERROR_INVALID_CONTEXT,
  22931. * ::CUDA_ERROR_INVALID_VALUE
  22932. *
  22933. * \sa
  22934. * ::cuTensorMapEncodeIm2col,
  22935. * ::cuTensorMapEncodeIm2colWide,
  22936. * ::cuTensorMapReplaceAddress
  22937. */
  22938. CUresult CUDAAPI cuTensorMapEncodeTiled(CUtensorMap *tensorMap, CUtensorMapDataType tensorDataType, cuuint32_t tensorRank, void *globalAddress, const cuuint64_t *globalDim, const cuuint64_t *globalStrides, const cuuint32_t *boxDim, const cuuint32_t *elementStrides, CUtensorMapInterleave interleave, CUtensorMapSwizzle swizzle, CUtensorMapL2promotion l2Promotion, CUtensorMapFloatOOBfill oobFill);
  22939. /**
  22940. * \brief Create a tensor map descriptor object representing im2col memory region
  22941. *
  22942. * Creates a descriptor for Tensor Memory Access (TMA) object specified
  22943. * by the parameters describing a im2col memory layout and returns it in \p tensorMap.
  22944. *
  22945. * Tensor map objects are only supported on devices of compute capability 9.0 or higher.
  22946. * Additionally, a tensor map object is an opaque value, and, as such, should only be
  22947. * accessed through CUDA APIs and PTX.
  22948. *
  22949. * The parameters passed are bound to the following requirements:
  22950. *
  22951. * - \p tensorMap address must be aligned to 64 bytes.
  22952. *
  22953. * - \p tensorDataType has to be an enum from ::CUtensorMapDataType which is defined as:
  22954. * \code
  22955. typedef enum CUtensorMapDataType_enum {
  22956. CU_TENSOR_MAP_DATA_TYPE_UINT8 = 0, // 1 byte
  22957. CU_TENSOR_MAP_DATA_TYPE_UINT16, // 2 bytes
  22958. CU_TENSOR_MAP_DATA_TYPE_UINT32, // 4 bytes
  22959. CU_TENSOR_MAP_DATA_TYPE_INT32, // 4 bytes
  22960. CU_TENSOR_MAP_DATA_TYPE_UINT64, // 8 bytes
  22961. CU_TENSOR_MAP_DATA_TYPE_INT64, // 8 bytes
  22962. CU_TENSOR_MAP_DATA_TYPE_FLOAT16, // 2 bytes
  22963. CU_TENSOR_MAP_DATA_TYPE_FLOAT32, // 4 bytes
  22964. CU_TENSOR_MAP_DATA_TYPE_FLOAT64, // 8 bytes
  22965. CU_TENSOR_MAP_DATA_TYPE_BFLOAT16, // 2 bytes
  22966. CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ, // 4 bytes
  22967. CU_TENSOR_MAP_DATA_TYPE_TFLOAT32, // 4 bytes
  22968. CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ // 4 bytes
  22969. CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, // 4 bits
  22970. CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, // 4 bits
  22971. CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B // 6 bits
  22972. } CUtensorMapDataType;
  22973. * \endcode
  22974. * ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B copies '16 x U4' packed values to memory aligned as 8 bytes. There are no gaps between packed values.
  22975. * ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B copies '16 x U4' packed values to memory aligned as 16 bytes. There are 8 byte gaps between every 8 byte chunk of packed values.
  22976. * ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B copies '16 x U6' packed values to memory aligned as 16 bytes. There are 4 byte gaps between every 12 byte chunk of packed values.
  22977. *
  22978. * - \p tensorRank, which specifies the number of tensor dimensions, must be 3, 4, or 5.
  22979. *
  22980. * - \p globalAddress, which specifies the starting address of the memory region described, must be 16 byte aligned. The following requirements need to also be met:
  22981. * - When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_32B, \p globalAddress must be 32 byte aligned.
  22982. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, \p globalAddress must be 32 byte aligned.
  22983. *
  22984. * - \p globalDim array, which specifies tensor size of each of the \p tensorRank dimensions, must be non-zero and less than or
  22985. * equal to 2^32. Additionally, the following requirements need to be met for the packed data types:
  22986. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, globalDim[0] must be a multiple of 128.
  22987. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, \p globalDim[0] must be a multiple of 2.
  22988. * - Dimension for the packed data types must reflect the number of individual U# values.
  22989. *
  22990. * - \p globalStrides array, which specifies tensor stride of each of the lower \p tensorRank - 1 dimensions in bytes, must be a
  22991. * multiple of 16 and less than 2^40. Additionally, the following requirements need to be met:
  22992. * - When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_32B, the strides must be a multiple of 32.
  22993. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, the strides must be a multiple of 32.
  22994. * Each following dimension specified includes previous dimension stride:
  22995. * \code
  22996. globalStrides[0] = globalDim[0] * elementSizeInBytes(tensorDataType) + padding[0];
  22997. for (i = 1; i < tensorRank - 1; i++)
  22998. globalStrides[i] = globalStrides[i – 1] * (globalDim[i] + padding[i]);
  22999. assert(globalStrides[i] >= globalDim[i]);
  23000. * \endcode
  23001. *
  23002. * - \p pixelBoxLowerCorner array specifies the coordinate offsets {D, H, W} of the bounding box from top/left/front corner. The number of
  23003. * offsets and their precision depend on the tensor dimensionality:
  23004. * - When \p tensorRank is 3, one signed offset within range [-32768, 32767] is supported.
  23005. * - When \p tensorRank is 4, two signed offsets each within range [-128, 127] are supported.
  23006. * - When \p tensorRank is 5, three offsets each within range [-16, 15] are supported.
  23007. *
  23008. * - \p pixelBoxUpperCorner array specifies the coordinate offsets {D, H, W} of the bounding box from bottom/right/back corner. The number of
  23009. * offsets and their precision depend on the tensor dimensionality:
  23010. * - When \p tensorRank is 3, one signed offset within range [-32768, 32767] is supported.
  23011. * - When \p tensorRank is 4, two signed offsets each within range [-128, 127] are supported.
  23012. * - When \p tensorRank is 5, three offsets each within range [-16, 15] are supported.
  23013. * The bounding box specified by \p pixelBoxLowerCorner and \p pixelBoxUpperCorner must have non-zero area.
  23014. *
  23015. * - \p channelsPerPixel, which specifies the number of elements which must be accessed along C dimension, must be less than or equal to 256.
  23016. * Additionally, when \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, \p channelsPerPixel must be 128.
  23017. *
  23018. * - \p pixelsPerColumn, which specifies the number of elements that must be accessed along the {N, D, H, W} dimensions, must be less than or
  23019. * equal to 1024.
  23020. *
  23021. * - \p elementStrides array, which specifies the iteration step along each of the \p tensorRank dimensions, must be non-zero and less
  23022. * than or equal to 8. Note that when \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_NONE, the first element of this array is ignored since
  23023. * TMA doesn’t support the stride for dimension zero.
  23024. * When all elements of the \p elementStrides array are one, \p boxDim specifies the number of elements to load. However, if \p elementStrides[i]
  23025. * is not equal to one for some \p i, then TMA loads ceil( \p boxDim[i] / \p elementStrides[i]) number of elements along i-th dimension.
  23026. * To load N elements along i-th dimension, \p boxDim[i] must be set to N * \p elementStrides[i].
  23027. *
  23028. * - \p interleave specifies the interleaved layout of type ::CUtensorMapInterleave, which is defined as:
  23029. * \code
  23030. typedef enum CUtensorMapInterleave_enum {
  23031. CU_TENSOR_MAP_INTERLEAVE_NONE = 0,
  23032. CU_TENSOR_MAP_INTERLEAVE_16B,
  23033. CU_TENSOR_MAP_INTERLEAVE_32B
  23034. } CUtensorMapInterleave;
  23035. * \endcode
  23036. * TMA supports interleaved layouts like NC/8HWC8 where C8 utilizes 16 bytes in memory assuming 2 byte per channel or NC/16HWC16 where C16
  23037. * uses 32 bytes.
  23038. * When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_NONE and \p swizzle is not ::CU_TENSOR_MAP_SWIZZLE_NONE, the bounding box inner dimension
  23039. * (computed as \p channelsPerPixel multiplied by element size in bytes derived from \p tensorDataType) must be less than or equal to the swizzle size.
  23040. * - CU_TENSOR_MAP_SWIZZLE_32B requires the bounding box inner dimension to be <= 32.
  23041. * - CU_TENSOR_MAP_SWIZZLE_64B requires the bounding box inner dimension to be <= 64.
  23042. * - CU_TENSOR_MAP_SWIZZLE_128B* require the bounding box inner dimension to be <= 128.
  23043. * Additionally, \p tensorDataType of ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B requires \p interleave to be ::CU_TENSOR_MAP_INTERLEAVE_NONE.
  23044. *
  23045. * - \p swizzle, which specifies the shared memory bank swizzling pattern, has to be of type ::CUtensorMapSwizzle which is defined as:
  23046. * \code
  23047. typedef enum CUtensorMapSwizzle_enum {
  23048. CU_TENSOR_MAP_SWIZZLE_NONE = 0,
  23049. CU_TENSOR_MAP_SWIZZLE_32B, // Swizzle 16B chunks within 32B span
  23050. CU_TENSOR_MAP_SWIZZLE_64B, // Swizzle 16B chunks within 64B span
  23051. CU_TENSOR_MAP_SWIZZLE_128B, // Swizzle 16B chunks within 128B span
  23052. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B, // Swizzle 32B chunks within 128B span
  23053. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B_FLIP_8B, // Swizzle 32B chunks within 128B span, additionally swap lower 8B with upper 8B within each 16B for every alternate row
  23054. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B // Swizzle 64B chunks within 128B span
  23055. } CUtensorMapSwizzle;
  23056. * \endcode
  23057. * Data are organized in a specific order in global memory; however, this may not match the order in which the application accesses data
  23058. * in shared memory. This difference in data organization may cause bank conflicts when shared memory is accessed. In order to avoid this
  23059. * problem, data can be loaded to shared memory with shuffling across shared memory banks.
  23060. * When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_32B, \p swizzle must be ::CU_TENSOR_MAP_SWIZZLE_32B.
  23061. * Other interleave modes can have any swizzling pattern.
  23062. * When the \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B, only the following swizzle modes are supported:
  23063. * - CU_TENSOR_MAP_SWIZZLE_NONE (Load & Store)
  23064. * - CU_TENSOR_MAP_SWIZZLE_128B (Load & Store)
  23065. * - CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B (Load & Store)
  23066. * - CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B (Store only)
  23067. * When the \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, only the following swizzle modes are supported:
  23068. * - CU_TENSOR_MAP_SWIZZLE_NONE (Load only)
  23069. * - CU_TENSOR_MAP_SWIZZLE_128B (Load only)
  23070. * - CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B (Load only)
  23071. *
  23072. * - \p l2Promotion specifies L2 fetch size which indicates the byte granularity at which L2 requests are filled from DRAM. It must be of
  23073. * type ::CUtensorMapL2promotion, which is defined as:
  23074. * \code
  23075. typedef enum CUtensorMapL2promotion_enum {
  23076. CU_TENSOR_MAP_L2_PROMOTION_NONE = 0,
  23077. CU_TENSOR_MAP_L2_PROMOTION_L2_64B,
  23078. CU_TENSOR_MAP_L2_PROMOTION_L2_128B,
  23079. CU_TENSOR_MAP_L2_PROMOTION_L2_256B
  23080. } CUtensorMapL2promotion;
  23081. * \endcode
  23082. *
  23083. * - \p oobFill, which indicates whether zero or a special NaN constant should be used to fill out-of-bound elements, must be of type
  23084. * ::CUtensorMapFloatOOBfill which is defined as:
  23085. * \code
  23086. typedef enum CUtensorMapFloatOOBfill_enum {
  23087. CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE = 0,
  23088. CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA
  23089. } CUtensorMapFloatOOBfill;
  23090. * \endcode
  23091. * Note that ::CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA can only be used when \p tensorDataType represents a floating-point data type,
  23092. * and when \p tensorDataType is not ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, and ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B.
  23093. *
  23094. * \param tensorMap - Tensor map object to create
  23095. * \param tensorDataType - Tensor data type
  23096. * \param tensorRank - Dimensionality of tensor; must be at least 3
  23097. * \param globalAddress - Starting address of memory region described by tensor
  23098. * \param globalDim - Array containing tensor size (number of elements) along each of the \p tensorRank dimensions
  23099. * \param globalStrides - Array containing stride size (in bytes) along each of the \p tensorRank - 1 dimensions
  23100. * \param pixelBoxLowerCorner - Array containing DHW dimensions of lower box corner
  23101. * \param pixelBoxUpperCorner - Array containing DHW dimensions of upper box corner
  23102. * \param channelsPerPixel - Number of channels per pixel
  23103. * \param pixelsPerColumn - Number of pixels per column
  23104. * \param elementStrides - Array containing traversal stride in each of the \p tensorRank dimensions
  23105. * \param interleave - Type of interleaved layout the tensor addresses
  23106. * \param swizzle - Bank swizzling pattern inside shared memory
  23107. * \param l2Promotion - L2 promotion size
  23108. * \param oobFill - Indicate whether zero or special NaN constant will be used to fill out-of-bound elements
  23109. *
  23110. * \return
  23111. * ::CUDA_SUCCESS,
  23112. * ::CUDA_ERROR_DEINITIALIZED,
  23113. * ::CUDA_ERROR_NOT_INITIALIZED,
  23114. * ::CUDA_ERROR_INVALID_CONTEXT,
  23115. * ::CUDA_ERROR_INVALID_VALUE
  23116. *
  23117. * \sa
  23118. * ::cuTensorMapEncodeTiled,
  23119. * ::cuTensorMapEncodeIm2colWide,
  23120. * ::cuTensorMapReplaceAddress
  23121. */
  23122. CUresult CUDAAPI cuTensorMapEncodeIm2col(CUtensorMap *tensorMap, CUtensorMapDataType tensorDataType, cuuint32_t tensorRank, void *globalAddress, const cuuint64_t *globalDim, const cuuint64_t *globalStrides, const int *pixelBoxLowerCorner, const int *pixelBoxUpperCorner, cuuint32_t channelsPerPixel, cuuint32_t pixelsPerColumn, const cuuint32_t *elementStrides, CUtensorMapInterleave interleave, CUtensorMapSwizzle swizzle, CUtensorMapL2promotion l2Promotion, CUtensorMapFloatOOBfill oobFill);
  23123. /**
  23124. * \brief Create a tensor map descriptor object representing im2col memory region, but where
  23125. * the elements are exclusively loaded along the W dimension.
  23126. *
  23127. * Creates a descriptor for Tensor Memory Access (TMA) object specified by the parameters
  23128. * describing a im2col memory layout and where the row is always loaded along the W dimensuin
  23129. * and returns it in \p tensorMap. This assumes the tensor layout in memory is either NDHWC,
  23130. * NHWC, or NWC.
  23131. *
  23132. * This API is only supported on devices of compute capability 10.0 or higher.
  23133. * Additionally, a tensor map object is an opaque value, and, as such, should only be
  23134. * accessed through CUDA APIs and PTX.
  23135. *
  23136. * The parameters passed are bound to the following requirements:
  23137. *
  23138. * - \p tensorMap address must be aligned to 64 bytes.
  23139. *
  23140. * - \p tensorDataType has to be an enum from ::CUtensorMapDataType which is defined as:
  23141. * \code
  23142. typedef enum CUtensorMapDataType_enum {
  23143. CU_TENSOR_MAP_DATA_TYPE_UINT8 = 0, // 1 byte
  23144. CU_TENSOR_MAP_DATA_TYPE_UINT16, // 2 bytes
  23145. CU_TENSOR_MAP_DATA_TYPE_UINT32, // 4 bytes
  23146. CU_TENSOR_MAP_DATA_TYPE_INT32, // 4 bytes
  23147. CU_TENSOR_MAP_DATA_TYPE_UINT64, // 8 bytes
  23148. CU_TENSOR_MAP_DATA_TYPE_INT64, // 8 bytes
  23149. CU_TENSOR_MAP_DATA_TYPE_FLOAT16, // 2 bytes
  23150. CU_TENSOR_MAP_DATA_TYPE_FLOAT32, // 4 bytes
  23151. CU_TENSOR_MAP_DATA_TYPE_FLOAT64, // 8 bytes
  23152. CU_TENSOR_MAP_DATA_TYPE_BFLOAT16, // 2 bytes
  23153. CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ, // 4 bytes
  23154. CU_TENSOR_MAP_DATA_TYPE_TFLOAT32, // 4 bytes
  23155. CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ // 4 bytes
  23156. CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, // 4 bits
  23157. CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, // 4 bits
  23158. CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B // 6 bits
  23159. } CUtensorMapDataType;
  23160. * \endcode
  23161. * ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B copies '16 x U4' packed values to memory aligned as 8 bytes. There are no gaps between packed values.
  23162. * ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B copies '16 x U4' packed values to memory aligned as 16 bytes. There are 8 byte gaps between every 8 byte chunk of packed values.
  23163. * ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B copies '16 x U6' packed values to memory aligned as 16 bytes. There are 4 byte gaps between every 12 byte chunk of packed values.
  23164. *
  23165. * - \p tensorRank, which specifies the number of tensor dimensions, must be 3, 4, or 5.
  23166. *
  23167. * - \p globalAddress, which specifies the starting address of the memory region described, must be 16 byte aligned. The following requirements need to also be met:
  23168. * - When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_32B, \p globalAddress must be 32 byte aligned.
  23169. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, \p globalAddress must be 32 byte aligned.
  23170. *
  23171. * - \p globalDim array, which specifies tensor size of each of the \p tensorRank dimensions, must be non-zero and less than or
  23172. * equal to 2^32. Additionally, the following requirements need to be met for the packed data types:
  23173. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, globalDim[0] must be a multiple of 128.
  23174. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, \p globalDim[0] must be a multiple of 2.
  23175. * - Dimension for the packed data types must reflect the number of individual U# values.
  23176. *
  23177. * - \p globalStrides array, which specifies tensor stride of each of the lower \p tensorRank - 1 dimensions in bytes, must be a
  23178. * multiple of 16 and less than 2^40. Additionally, the following requirements need to be met:
  23179. * - When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_32B, the strides must be a multiple of 32.
  23180. * - When \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, the strides must be a multiple of 32.
  23181. * Each following dimension specified includes previous dimension stride:
  23182. * \code
  23183. globalStrides[0] = globalDim[0] * elementSizeInBytes(tensorDataType) + padding[0];
  23184. for (i = 1; i < tensorRank - 1; i++)
  23185. globalStrides[i] = globalStrides[i – 1] * (globalDim[i] + padding[i]);
  23186. assert(globalStrides[i] >= globalDim[i]);
  23187. * \endcode
  23188. *
  23189. * - \p pixelBoxLowerCornerWidth specifies the coordinate offset W of the bounding box from left corner. The offset must be
  23190. * within range [-32768, 32767].
  23191. *
  23192. * - \p pixelBoxUpperCornerWidth specifies the coordinate offset W of the bounding box from right corner. The offset must be
  23193. * within range [-32768, 32767].
  23194. *
  23195. * The bounding box specified by \p pixelBoxLowerCornerWidth and \p pixelBoxUpperCornerWidth must have non-zero area. Note
  23196. * that the size of the box along D and H dimensions is always equal to one.
  23197. *
  23198. * - \p channelsPerPixel, which specifies the number of elements which must be accessed along C dimension, must be less than or equal to 256.
  23199. * Additionally, when \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B or ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, \p channelsPerPixel must be 128.
  23200. *
  23201. * - \p pixelsPerColumn, which specifies the number of elements that must be accessed along the W dimension, must be less than or
  23202. * equal to 1024. This field is ignored when \p mode is ::CU_TENSOR_MAP_IM2COL_WIDE_MODE_W128.
  23203. *
  23204. * - \p elementStrides array, which specifies the iteration step along each of the \p tensorRank dimensions, must be non-zero and less
  23205. * than or equal to 8. Note that when \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_NONE, the first element of this array is ignored since
  23206. * TMA doesn’t support the stride for dimension zero.
  23207. * When all elements of the \p elementStrides array are one, \p boxDim specifies the number of elements to load. However, if \p elementStrides[i]
  23208. * is not equal to one for some \p i, then TMA loads ceil( \p boxDim[i] / \p elementStrides[i]) number of elements along i-th dimension.
  23209. * To load N elements along i-th dimension, \p boxDim[i] must be set to N * \p elementStrides[i].
  23210. *
  23211. * - \p interleave specifies the interleaved layout of type ::CUtensorMapInterleave, which is defined as:
  23212. * \code
  23213. typedef enum CUtensorMapInterleave_enum {
  23214. CU_TENSOR_MAP_INTERLEAVE_NONE = 0,
  23215. CU_TENSOR_MAP_INTERLEAVE_16B,
  23216. CU_TENSOR_MAP_INTERLEAVE_32B
  23217. } CUtensorMapInterleave;
  23218. * \endcode
  23219. * TMA supports interleaved layouts like NC/8HWC8 where C8 utilizes 16 bytes in memory assuming 2 byte per channel or NC/16HWC16 where C16
  23220. * uses 32 bytes.
  23221. * When \p interleave is ::CU_TENSOR_MAP_INTERLEAVE_NONE, the bounding box inner dimension (computed as \p channelsPerPixel multiplied by
  23222. * element size in bytes derived from \p tensorDataType) must be less than or equal to the swizzle size.
  23223. * - CU_TENSOR_MAP_SWIZZLE_64B requires the bounding box inner dimension to be <= 64.
  23224. * - CU_TENSOR_MAP_SWIZZLE_128B* require the bounding box inner dimension to be <= 128.
  23225. * Additionally, \p tensorDataType of ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B requires \p interleave to be ::CU_TENSOR_MAP_INTERLEAVE_NONE.
  23226. *
  23227. * - \p mode, which describes loading of elements loaded along the W dimension, has to be one of the following ::CUtensorMapIm2ColWideMode types:
  23228. * \code
  23229. * CU_TENSOR_MAP_IM2COL_WIDE_MODE_W,
  23230. * CU_TENSOR_MAP_IM2COL_WIDE_MODE_W128
  23231. * \endcode
  23232. * ::CU_TENSOR_MAP_IM2COL_WIDE_MODE_W allows the number of elements loaded along the W dimension to be specified
  23233. * via the \p pixelsPerColumn field.
  23234. *
  23235. * - \p swizzle, which specifies the shared memory bank swizzling pattern, must be one of the following
  23236. * ::CUtensorMapSwizzle modes (other swizzle modes are not supported):
  23237. * \code
  23238. typedef enum CUtensorMapSwizzle_enum {
  23239. CU_TENSOR_MAP_SWIZZLE_64B, // Swizzle 16B chunks within 64B span
  23240. CU_TENSOR_MAP_SWIZZLE_128B, // Swizzle 16B chunks within 128B span
  23241. CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B, // Swizzle 32B chunks within 128B span
  23242. } CUtensorMapSwizzle;
  23243. * \endcode
  23244. * Data are organized in a specific order in global memory; however, this may not match the order in which the application accesses data
  23245. * in shared memory. This difference in data organization may cause bank conflicts when shared memory is accessed. In order to avoid this
  23246. * problem, data can be loaded to shared memory with shuffling across shared memory banks.
  23247. * When the \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B, only the following swizzle modes are supported:
  23248. * - CU_TENSOR_MAP_SWIZZLE_128B (Load & Store)
  23249. * - CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B (Load & Store)
  23250. * When the \p tensorDataType is ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, only the following swizzle modes are supported:
  23251. * - CU_TENSOR_MAP_SWIZZLE_128B (Load only)
  23252. * - CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B (Load only)
  23253. *
  23254. * - \p l2Promotion specifies L2 fetch size which indicates the byte granularity at which L2 requests are filled from DRAM. It must be of
  23255. * type ::CUtensorMapL2promotion, which is defined as:
  23256. * \code
  23257. typedef enum CUtensorMapL2promotion_enum {
  23258. CU_TENSOR_MAP_L2_PROMOTION_NONE = 0,
  23259. CU_TENSOR_MAP_L2_PROMOTION_L2_64B,
  23260. CU_TENSOR_MAP_L2_PROMOTION_L2_128B,
  23261. CU_TENSOR_MAP_L2_PROMOTION_L2_256B
  23262. } CUtensorMapL2promotion;
  23263. * \endcode
  23264. *
  23265. * - \p oobFill, which indicates whether zero or a special NaN constant should be used to fill out-of-bound elements, must be of type
  23266. * ::CUtensorMapFloatOOBfill which is defined as:
  23267. * \code
  23268. typedef enum CUtensorMapFloatOOBfill_enum {
  23269. CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE = 0,
  23270. CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA
  23271. } CUtensorMapFloatOOBfill;
  23272. * \endcode
  23273. * Note that ::CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA can only be used when \p tensorDataType represents a floating-point data type,
  23274. * and when \p tensorDataType is not ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, ::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, and ::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B.
  23275. *
  23276. * \param tensorMap - Tensor map object to create
  23277. * \param tensorDataType - Tensor data type
  23278. * \param tensorRank - Dimensionality of tensor; must be at least 3
  23279. * \param globalAddress - Starting address of memory region described by tensor
  23280. * \param globalDim - Array containing tensor size (number of elements) along each of the \p tensorRank dimensions
  23281. * \param globalStrides - Array containing stride size (in bytes) along each of the \p tensorRank - 1 dimensions
  23282. * \param pixelBoxLowerCornerWidth - Width offset of left box corner
  23283. * \param pixelBoxUpperCornerWidth - Width offset of right box corner
  23284. * \param channelsPerPixel - Number of channels per pixel
  23285. * \param pixelsPerColumn - Number of pixels per column
  23286. * \param elementStrides - Array containing traversal stride in each of the \p tensorRank dimensions
  23287. * \param interleave - Type of interleaved layout the tensor addresses
  23288. * \param mode - W or W128 mode
  23289. * \param swizzle - Bank swizzling pattern inside shared memory
  23290. * \param l2Promotion - L2 promotion size
  23291. * \param oobFill - Indicate whether zero or special NaN constant will be used to fill out-of-bound elements
  23292. *
  23293. * \return
  23294. * ::CUDA_SUCCESS,
  23295. * ::CUDA_ERROR_DEINITIALIZED,
  23296. * ::CUDA_ERROR_NOT_INITIALIZED,
  23297. * ::CUDA_ERROR_INVALID_CONTEXT,
  23298. * ::CUDA_ERROR_INVALID_VALUE
  23299. *
  23300. * \sa
  23301. * ::cuTensorMapEncodeTiled,
  23302. * ::cuTensorMapEncodeIm2col,
  23303. * ::cuTensorMapReplaceAddress
  23304. */
  23305. CUresult CUDAAPI cuTensorMapEncodeIm2colWide(CUtensorMap *tensorMap, CUtensorMapDataType tensorDataType, cuuint32_t tensorRank, void *globalAddress, const cuuint64_t *globalDim, const cuuint64_t *globalStrides, int pixelBoxLowerCornerWidth, int pixelBoxUpperCornerWidth, cuuint32_t channelsPerPixel, cuuint32_t pixelsPerColumn, const cuuint32_t *elementStrides, CUtensorMapInterleave interleave, CUtensorMapIm2ColWideMode mode, CUtensorMapSwizzle swizzle, CUtensorMapL2promotion l2Promotion, CUtensorMapFloatOOBfill oobFill);
  23306. /**
  23307. * \brief Modify an existing tensor map descriptor with an updated global address
  23308. *
  23309. * Modifies the descriptor for Tensor Memory Access (TMA) object passed in \p tensorMap with
  23310. * an updated \p globalAddress.
  23311. *
  23312. * Tensor map objects are only supported on devices of compute capability 9.0 or higher.
  23313. * Additionally, a tensor map object is an opaque value, and, as such, should only be
  23314. * accessed through CUDA API calls.
  23315. *
  23316. * \param tensorMap - Tensor map object to modify
  23317. * \param globalAddress - Starting address of memory region described by tensor, must follow previous alignment requirements
  23318. *
  23319. * \return
  23320. * ::CUDA_SUCCESS,
  23321. * ::CUDA_ERROR_DEINITIALIZED,
  23322. * ::CUDA_ERROR_NOT_INITIALIZED,
  23323. * ::CUDA_ERROR_INVALID_CONTEXT,
  23324. * ::CUDA_ERROR_INVALID_VALUE
  23325. *
  23326. * \sa
  23327. * ::cuTensorMapEncodeTiled,
  23328. * ::cuTensorMapEncodeIm2col
  23329. * ::cuTensorMapEncodeIm2colWide
  23330. */
  23331. CUresult CUDAAPI cuTensorMapReplaceAddress(CUtensorMap *tensorMap, void *globalAddress);
  23332. /** @} */
  23333. /* END CUDA_TENSOR_MEMORY */
  23334. /**
  23335. * \defgroup CUDA_PEER_ACCESS Peer Context Memory Access
  23336. *
  23337. * ___MANBRIEF___ direct peer context memory access functions of the low-level
  23338. * CUDA driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  23339. *
  23340. * This section describes the direct peer context memory access functions
  23341. * of the low-level CUDA driver application programming interface.
  23342. *
  23343. * @{
  23344. */
  23345. /**
  23346. * \brief Queries if a device may directly access a peer device's memory.
  23347. *
  23348. * Returns in \p *canAccessPeer a value of 1 if contexts on \p dev are capable of
  23349. * directly accessing memory from contexts on \p peerDev and 0 otherwise.
  23350. * If direct access of \p peerDev from \p dev is possible, then access may be
  23351. * enabled on two specific contexts by calling ::cuCtxEnablePeerAccess().
  23352. *
  23353. * \param canAccessPeer - Returned access capability
  23354. * \param dev - Device from which allocations on \p peerDev are to
  23355. * be directly accessed.
  23356. * \param peerDev - Device on which the allocations to be directly accessed
  23357. * by \p dev reside.
  23358. *
  23359. * \return
  23360. * ::CUDA_SUCCESS,
  23361. * ::CUDA_ERROR_DEINITIALIZED,
  23362. * ::CUDA_ERROR_NOT_INITIALIZED,
  23363. * ::CUDA_ERROR_INVALID_DEVICE
  23364. * \notefnerr
  23365. *
  23366. * \sa
  23367. * ::cuCtxEnablePeerAccess,
  23368. * ::cuCtxDisablePeerAccess,
  23369. * ::cudaDeviceCanAccessPeer
  23370. */
  23371. CUresult CUDAAPI cuDeviceCanAccessPeer(int *canAccessPeer, CUdevice dev, CUdevice peerDev);
  23372. /**
  23373. * \brief Enables direct access to memory allocations in a peer context.
  23374. *
  23375. * If both the current context and \p peerContext are on devices which support unified
  23376. * addressing (as may be queried using ::CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING) and same
  23377. * major compute capability, then on success all allocations from \p peerContext will
  23378. * immediately be accessible by the current context. See \ref CUDA_UNIFIED for additional
  23379. * details.
  23380. *
  23381. * Note that access granted by this call is unidirectional and that in order to access
  23382. * memory from the current context in \p peerContext, a separate symmetric call
  23383. * to ::cuCtxEnablePeerAccess() is required.
  23384. *
  23385. * Note that there are both device-wide and system-wide limitations per system
  23386. * configuration, as noted in the CUDA Programming Guide under the section
  23387. * "Peer-to-Peer Memory Access".
  23388. *
  23389. * Returns ::CUDA_ERROR_PEER_ACCESS_UNSUPPORTED if ::cuDeviceCanAccessPeer() indicates
  23390. * that the ::CUdevice of the current context cannot directly access memory
  23391. * from the ::CUdevice of \p peerContext.
  23392. *
  23393. * Returns ::CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED if direct access of
  23394. * \p peerContext from the current context has already been enabled.
  23395. *
  23396. * Returns ::CUDA_ERROR_TOO_MANY_PEERS if direct peer access is not possible
  23397. * because hardware resources required for peer access have been exhausted.
  23398. *
  23399. * Returns ::CUDA_ERROR_INVALID_CONTEXT if there is no current context, \p peerContext
  23400. * is not a valid context, or if the current context is \p peerContext.
  23401. *
  23402. * Returns ::CUDA_ERROR_INVALID_VALUE if \p Flags is not 0.
  23403. *
  23404. * \param peerContext - Peer context to enable direct access to from the current context
  23405. * \param Flags - Reserved for future use and must be set to 0
  23406. *
  23407. * \return
  23408. * ::CUDA_SUCCESS,
  23409. * ::CUDA_ERROR_DEINITIALIZED,
  23410. * ::CUDA_ERROR_NOT_INITIALIZED,
  23411. * ::CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED,
  23412. * ::CUDA_ERROR_TOO_MANY_PEERS,
  23413. * ::CUDA_ERROR_INVALID_CONTEXT,
  23414. * ::CUDA_ERROR_PEER_ACCESS_UNSUPPORTED,
  23415. * ::CUDA_ERROR_INVALID_VALUE
  23416. * \notefnerr
  23417. *
  23418. * \sa
  23419. * ::cuDeviceCanAccessPeer,
  23420. * ::cuCtxDisablePeerAccess,
  23421. * ::cudaDeviceEnablePeerAccess
  23422. */
  23423. CUresult CUDAAPI cuCtxEnablePeerAccess(CUcontext peerContext, unsigned int Flags);
  23424. /**
  23425. * \brief Disables direct access to memory allocations in a peer context and
  23426. * unregisters any registered allocations.
  23427. *
  23428. Returns ::CUDA_ERROR_PEER_ACCESS_NOT_ENABLED if direct peer access has
  23429. * not yet been enabled from \p peerContext to the current context.
  23430. *
  23431. * Returns ::CUDA_ERROR_INVALID_CONTEXT if there is no current context, or if
  23432. * \p peerContext is not a valid context.
  23433. *
  23434. * \param peerContext - Peer context to disable direct access to
  23435. *
  23436. * \return
  23437. * ::CUDA_SUCCESS,
  23438. * ::CUDA_ERROR_DEINITIALIZED,
  23439. * ::CUDA_ERROR_NOT_INITIALIZED,
  23440. * ::CUDA_ERROR_PEER_ACCESS_NOT_ENABLED,
  23441. * ::CUDA_ERROR_INVALID_CONTEXT,
  23442. * \notefnerr
  23443. *
  23444. * \sa
  23445. * ::cuDeviceCanAccessPeer,
  23446. * ::cuCtxEnablePeerAccess,
  23447. * ::cudaDeviceDisablePeerAccess
  23448. */
  23449. CUresult CUDAAPI cuCtxDisablePeerAccess(CUcontext peerContext);
  23450. /**
  23451. * \brief Queries attributes of the link between two devices.
  23452. *
  23453. * Returns in \p *value the value of the requested attribute \p attrib of the
  23454. * link between \p srcDevice and \p dstDevice. The supported attributes are:
  23455. * - ::CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK: A relative value indicating the
  23456. * performance of the link between two devices.
  23457. * - ::CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED P2P: 1 if P2P Access is enable.
  23458. * - ::CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED: 1 if Atomic operations over
  23459. * the link are supported.
  23460. * - ::CU_DEVICE_P2P_ATTRIBUTE_CUDA_ARRAY_ACCESS_SUPPORTED: 1 if cudaArray can
  23461. * be accessed over the link.
  23462. *
  23463. * Returns ::CUDA_ERROR_INVALID_DEVICE if \p srcDevice or \p dstDevice are not valid
  23464. * or if they represent the same device.
  23465. *
  23466. * Returns ::CUDA_ERROR_INVALID_VALUE if \p attrib is not valid or if \p value is
  23467. * a null pointer.
  23468. *
  23469. * \param value - Returned value of the requested attribute
  23470. * \param attrib - The requested attribute of the link between \p srcDevice and \p dstDevice.
  23471. * \param srcDevice - The source device of the target link.
  23472. * \param dstDevice - The destination device of the target link.
  23473. *
  23474. * \return
  23475. * ::CUDA_SUCCESS,
  23476. * ::CUDA_ERROR_DEINITIALIZED,
  23477. * ::CUDA_ERROR_NOT_INITIALIZED,
  23478. * ::CUDA_ERROR_INVALID_DEVICE,
  23479. * ::CUDA_ERROR_INVALID_VALUE
  23480. * \notefnerr
  23481. *
  23482. * \sa
  23483. * ::cuCtxEnablePeerAccess,
  23484. * ::cuCtxDisablePeerAccess,
  23485. * ::cuDeviceCanAccessPeer,
  23486. * ::cudaDeviceGetP2PAttribute
  23487. */
  23488. CUresult CUDAAPI cuDeviceGetP2PAttribute(int* value, CUdevice_P2PAttribute attrib, CUdevice srcDevice, CUdevice dstDevice);
  23489. /** @} */ /* END CUDA_PEER_ACCESS */
  23490. /**
  23491. * \defgroup CUDA_GRAPHICS Graphics Interoperability
  23492. *
  23493. * ___MANBRIEF___ graphics interoperability functions of the low-level CUDA
  23494. * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  23495. *
  23496. * This section describes the graphics interoperability functions of the
  23497. * low-level CUDA driver application programming interface.
  23498. *
  23499. * @{
  23500. */
  23501. /**
  23502. * \brief Unregisters a graphics resource for access by CUDA
  23503. *
  23504. * Unregisters the graphics resource \p resource so it is not accessible by
  23505. * CUDA unless registered again.
  23506. *
  23507. * If \p resource is invalid then ::CUDA_ERROR_INVALID_HANDLE is
  23508. * returned.
  23509. *
  23510. * \param resource - Resource to unregister
  23511. *
  23512. * \return
  23513. * ::CUDA_SUCCESS,
  23514. * ::CUDA_ERROR_DEINITIALIZED,
  23515. * ::CUDA_ERROR_NOT_INITIALIZED,
  23516. * ::CUDA_ERROR_INVALID_CONTEXT,
  23517. * ::CUDA_ERROR_INVALID_HANDLE,
  23518. * ::CUDA_ERROR_UNKNOWN
  23519. * \notefnerr
  23520. *
  23521. * \sa
  23522. * ::cuGraphicsD3D9RegisterResource,
  23523. * ::cuGraphicsD3D10RegisterResource,
  23524. * ::cuGraphicsD3D11RegisterResource,
  23525. * ::cuGraphicsGLRegisterBuffer,
  23526. * ::cuGraphicsGLRegisterImage,
  23527. * ::cudaGraphicsUnregisterResource
  23528. */
  23529. CUresult CUDAAPI cuGraphicsUnregisterResource(CUgraphicsResource resource);
  23530. /**
  23531. * \brief Get an array through which to access a subresource of a mapped graphics resource.
  23532. *
  23533. * Returns in \p *pArray an array through which the subresource of the mapped
  23534. * graphics resource \p resource which corresponds to array index \p arrayIndex
  23535. * and mipmap level \p mipLevel may be accessed. The value set in \p *pArray may
  23536. * change every time that \p resource is mapped.
  23537. *
  23538. * If \p resource is not a texture then it cannot be accessed via an array and
  23539. * ::CUDA_ERROR_NOT_MAPPED_AS_ARRAY is returned.
  23540. * If \p arrayIndex is not a valid array index for \p resource then
  23541. * ::CUDA_ERROR_INVALID_VALUE is returned.
  23542. * If \p mipLevel is not a valid mipmap level for \p resource then
  23543. * ::CUDA_ERROR_INVALID_VALUE is returned.
  23544. * If \p resource is not mapped then ::CUDA_ERROR_NOT_MAPPED is returned.
  23545. *
  23546. * \param pArray - Returned array through which a subresource of \p resource may be accessed
  23547. * \param resource - Mapped resource to access
  23548. * \param arrayIndex - Array index for array textures or cubemap face
  23549. * index as defined by ::CUarray_cubemap_face for
  23550. * cubemap textures for the subresource to access
  23551. * \param mipLevel - Mipmap level for the subresource to access
  23552. *
  23553. * \return
  23554. * ::CUDA_SUCCESS,
  23555. * ::CUDA_ERROR_DEINITIALIZED,
  23556. * ::CUDA_ERROR_NOT_INITIALIZED,
  23557. * ::CUDA_ERROR_INVALID_CONTEXT,
  23558. * ::CUDA_ERROR_INVALID_VALUE,
  23559. * ::CUDA_ERROR_INVALID_HANDLE,
  23560. * ::CUDA_ERROR_NOT_MAPPED,
  23561. * ::CUDA_ERROR_NOT_MAPPED_AS_ARRAY
  23562. * \notefnerr
  23563. *
  23564. * \sa
  23565. * ::cuGraphicsResourceGetMappedPointer,
  23566. * ::cudaGraphicsSubResourceGetMappedArray
  23567. */
  23568. CUresult CUDAAPI cuGraphicsSubResourceGetMappedArray(CUarray *pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel);
  23569. /**
  23570. * \brief Get a mipmapped array through which to access a mapped graphics resource.
  23571. *
  23572. * Returns in \p *pMipmappedArray a mipmapped array through which the mapped graphics
  23573. * resource \p resource. The value set in \p *pMipmappedArray may change every time
  23574. * that \p resource is mapped.
  23575. *
  23576. * If \p resource is not a texture then it cannot be accessed via a mipmapped array and
  23577. * ::CUDA_ERROR_NOT_MAPPED_AS_ARRAY is returned.
  23578. * If \p resource is not mapped then ::CUDA_ERROR_NOT_MAPPED is returned.
  23579. *
  23580. * \param pMipmappedArray - Returned mipmapped array through which \p resource may be accessed
  23581. * \param resource - Mapped resource to access
  23582. *
  23583. * \return
  23584. * ::CUDA_SUCCESS,
  23585. * ::CUDA_ERROR_DEINITIALIZED,
  23586. * ::CUDA_ERROR_NOT_INITIALIZED,
  23587. * ::CUDA_ERROR_INVALID_CONTEXT,
  23588. * ::CUDA_ERROR_INVALID_VALUE,
  23589. * ::CUDA_ERROR_INVALID_HANDLE,
  23590. * ::CUDA_ERROR_NOT_MAPPED,
  23591. * ::CUDA_ERROR_NOT_MAPPED_AS_ARRAY
  23592. * \notefnerr
  23593. *
  23594. * \sa
  23595. * ::cuGraphicsResourceGetMappedPointer,
  23596. * ::cudaGraphicsResourceGetMappedMipmappedArray
  23597. */
  23598. CUresult CUDAAPI cuGraphicsResourceGetMappedMipmappedArray(CUmipmappedArray *pMipmappedArray, CUgraphicsResource resource);
  23599. /**
  23600. * \brief Get a device pointer through which to access a mapped graphics resource.
  23601. *
  23602. * Returns in \p *pDevPtr a pointer through which the mapped graphics resource
  23603. * \p resource may be accessed.
  23604. * Returns in \p pSize the size of the memory in bytes which may be accessed from that pointer.
  23605. * The value set in \p pPointer may change every time that \p resource is mapped.
  23606. *
  23607. * If \p resource is not a buffer then it cannot be accessed via a pointer and
  23608. * ::CUDA_ERROR_NOT_MAPPED_AS_POINTER is returned.
  23609. * If \p resource is not mapped then ::CUDA_ERROR_NOT_MAPPED is returned.
  23610. * *
  23611. * \param pDevPtr - Returned pointer through which \p resource may be accessed
  23612. * \param pSize - Returned size of the buffer accessible starting at \p *pPointer
  23613. * \param resource - Mapped resource to access
  23614. *
  23615. * \return
  23616. * ::CUDA_SUCCESS,
  23617. * ::CUDA_ERROR_DEINITIALIZED,
  23618. * ::CUDA_ERROR_NOT_INITIALIZED,
  23619. * ::CUDA_ERROR_INVALID_CONTEXT,
  23620. * ::CUDA_ERROR_INVALID_VALUE,
  23621. * ::CUDA_ERROR_INVALID_HANDLE,
  23622. * ::CUDA_ERROR_NOT_MAPPED,
  23623. * ::CUDA_ERROR_NOT_MAPPED_AS_POINTER
  23624. * \notefnerr
  23625. *
  23626. * \sa
  23627. * ::cuGraphicsMapResources,
  23628. * ::cuGraphicsSubResourceGetMappedArray,
  23629. * ::cudaGraphicsResourceGetMappedPointer
  23630. */
  23631. CUresult CUDAAPI cuGraphicsResourceGetMappedPointer(CUdeviceptr *pDevPtr, size_t *pSize, CUgraphicsResource resource);
  23632. /**
  23633. * \brief Set usage flags for mapping a graphics resource
  23634. *
  23635. * Set \p flags for mapping the graphics resource \p resource.
  23636. *
  23637. * Changes to \p flags will take effect the next time \p resource is mapped.
  23638. * The \p flags argument may be any of the following:
  23639. * - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE: Specifies no hints about how this
  23640. * resource will be used. It is therefore assumed that this resource will be
  23641. * read from and written to by CUDA kernels. This is the default value.
  23642. * - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_READONLY: Specifies that CUDA kernels which
  23643. * access this resource will not write to this resource.
  23644. * - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITEDISCARD: Specifies that CUDA kernels
  23645. * which access this resource will not read from this resource and will
  23646. * write over the entire contents of the resource, so none of the data
  23647. * previously stored in the resource will be preserved.
  23648. *
  23649. * If \p resource is presently mapped for access by CUDA then
  23650. * ::CUDA_ERROR_ALREADY_MAPPED is returned.
  23651. * If \p flags is not one of the above values then ::CUDA_ERROR_INVALID_VALUE is returned.
  23652. *
  23653. * \param resource - Registered resource to set flags for
  23654. * \param flags - Parameters for resource mapping
  23655. *
  23656. * \return
  23657. * ::CUDA_SUCCESS,
  23658. * ::CUDA_ERROR_DEINITIALIZED,
  23659. * ::CUDA_ERROR_NOT_INITIALIZED,
  23660. * ::CUDA_ERROR_INVALID_CONTEXT,
  23661. * ::CUDA_ERROR_INVALID_VALUE,
  23662. * ::CUDA_ERROR_INVALID_HANDLE,
  23663. * ::CUDA_ERROR_ALREADY_MAPPED
  23664. * \notefnerr
  23665. *
  23666. * \sa
  23667. * ::cuGraphicsMapResources,
  23668. * ::cudaGraphicsResourceSetMapFlags
  23669. */
  23670. CUresult CUDAAPI cuGraphicsResourceSetMapFlags(CUgraphicsResource resource, unsigned int flags);
  23671. /**
  23672. * \brief Map graphics resources for access by CUDA
  23673. *
  23674. * Maps the \p count graphics resources in \p resources for access by CUDA.
  23675. *
  23676. * The resources in \p resources may be accessed by CUDA until they
  23677. * are unmapped. The graphics API from which \p resources were registered
  23678. * should not access any resources while they are mapped by CUDA. If an
  23679. * application does so, the results are undefined.
  23680. *
  23681. * This function provides the synchronization guarantee that any graphics calls
  23682. * issued before ::cuGraphicsMapResources() will complete before any subsequent CUDA
  23683. * work issued in \p stream begins.
  23684. *
  23685. * If \p resources includes any duplicate entries then ::CUDA_ERROR_INVALID_HANDLE is returned.
  23686. * If any of \p resources are presently mapped for access by CUDA then ::CUDA_ERROR_ALREADY_MAPPED is returned.
  23687. *
  23688. * \param count - Number of resources to map
  23689. * \param resources - Resources to map for CUDA usage
  23690. * \param hStream - Stream with which to synchronize
  23691. *
  23692. * \return
  23693. * ::CUDA_SUCCESS,
  23694. * ::CUDA_ERROR_DEINITIALIZED,
  23695. * ::CUDA_ERROR_NOT_INITIALIZED,
  23696. * ::CUDA_ERROR_INVALID_CONTEXT,
  23697. * ::CUDA_ERROR_INVALID_HANDLE,
  23698. * ::CUDA_ERROR_ALREADY_MAPPED,
  23699. * ::CUDA_ERROR_UNKNOWN
  23700. * \note_null_stream
  23701. * \notefnerr
  23702. *
  23703. * \sa
  23704. * ::cuGraphicsResourceGetMappedPointer,
  23705. * ::cuGraphicsSubResourceGetMappedArray,
  23706. * ::cuGraphicsUnmapResources,
  23707. * ::cudaGraphicsMapResources
  23708. */
  23709. CUresult CUDAAPI cuGraphicsMapResources(unsigned int count, CUgraphicsResource *resources, CUstream hStream);
  23710. /**
  23711. * \brief Unmap graphics resources.
  23712. *
  23713. * Unmaps the \p count graphics resources in \p resources.
  23714. *
  23715. * Once unmapped, the resources in \p resources may not be accessed by CUDA
  23716. * until they are mapped again.
  23717. *
  23718. * This function provides the synchronization guarantee that any CUDA work issued
  23719. * in \p stream before ::cuGraphicsUnmapResources() will complete before any
  23720. * subsequently issued graphics work begins.
  23721. *
  23722. *
  23723. * If \p resources includes any duplicate entries then ::CUDA_ERROR_INVALID_HANDLE is returned.
  23724. * If any of \p resources are not presently mapped for access by CUDA then ::CUDA_ERROR_NOT_MAPPED is returned.
  23725. *
  23726. * \param count - Number of resources to unmap
  23727. * \param resources - Resources to unmap
  23728. * \param hStream - Stream with which to synchronize
  23729. *
  23730. * \return
  23731. * ::CUDA_SUCCESS,
  23732. * ::CUDA_ERROR_DEINITIALIZED,
  23733. * ::CUDA_ERROR_NOT_INITIALIZED,
  23734. * ::CUDA_ERROR_INVALID_CONTEXT,
  23735. * ::CUDA_ERROR_INVALID_HANDLE,
  23736. * ::CUDA_ERROR_NOT_MAPPED,
  23737. * ::CUDA_ERROR_UNKNOWN
  23738. * \note_null_stream
  23739. * \notefnerr
  23740. *
  23741. * \sa
  23742. * ::cuGraphicsMapResources,
  23743. * ::cudaGraphicsUnmapResources
  23744. */
  23745. CUresult CUDAAPI cuGraphicsUnmapResources(unsigned int count, CUgraphicsResource *resources, CUstream hStream);
  23746. /** @} */ /* END CUDA_GRAPHICS */
  23747. /**
  23748. * \defgroup CUDA_DRIVER_ENTRY_POINT Driver Entry Point Access
  23749. *
  23750. * ___MANBRIEF___ driver entry point access functions of the low-level CUDA driver API
  23751. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  23752. *
  23753. * This section describes the driver entry point access functions of the low-level CUDA
  23754. * driver application programming interface.
  23755. *
  23756. * @{
  23757. */
  23758. /**
  23759. * \brief Returns the requested driver API function pointer
  23760. *
  23761. * Returns in \p **pfn the address of the CUDA driver function for the requested
  23762. * CUDA version and flags.
  23763. *
  23764. * The CUDA version is specified as (1000 * major + 10 * minor), so CUDA 11.2
  23765. * should be specified as 11020. For a requested driver symbol, if the specified
  23766. * CUDA version is greater than or equal to the CUDA version in which the driver symbol
  23767. * was introduced, this API will return the function pointer to the corresponding
  23768. * versioned function.
  23769. *
  23770. * The pointer returned by the API should be cast to a function pointer matching the
  23771. * requested driver function's definition in the API header file. The function pointer
  23772. * typedef can be picked up from the corresponding typedefs header file. For example,
  23773. * cudaTypedefs.h consists of function pointer typedefs for driver APIs defined in cuda.h.
  23774. *
  23775. * The API will return ::CUDA_SUCCESS and set the returned \p pfn to NULL if the
  23776. * requested driver function is not supported on the platform, no ABI
  23777. * compatible driver function exists for the specified \p cudaVersion or if the
  23778. * driver symbol is invalid.
  23779. *
  23780. * It will also set the optional \p symbolStatus to one of the values in
  23781. * ::CUdriverProcAddressQueryResult with the following meanings:
  23782. * - ::CU_GET_PROC_ADDRESS_SUCCESS - The requested symbol was succesfully found based
  23783. * on input arguments and \p pfn is valid
  23784. * - ::CU_GET_PROC_ADDRESS_SYMBOL_NOT_FOUND - The requested symbol was not found
  23785. * - ::CU_GET_PROC_ADDRESS_VERSION_NOT_SUFFICIENT - The requested symbol was found but is
  23786. * not supported by cudaVersion specified
  23787. *
  23788. * The requested flags can be:
  23789. * - ::CU_GET_PROC_ADDRESS_DEFAULT: This is the default mode. This is equivalent to
  23790. * ::CU_GET_PROC_ADDRESS_PER_THREAD_DEFAULT_STREAM if the code is compiled with
  23791. * --default-stream per-thread compilation flag or the macro CUDA_API_PER_THREAD_DEFAULT_STREAM
  23792. * is defined; ::CU_GET_PROC_ADDRESS_LEGACY_STREAM otherwise.
  23793. * - ::CU_GET_PROC_ADDRESS_LEGACY_STREAM: This will enable the search for all driver symbols
  23794. * that match the requested driver symbol name except the corresponding per-thread versions.
  23795. * - ::CU_GET_PROC_ADDRESS_PER_THREAD_DEFAULT_STREAM: This will enable the search for all
  23796. * driver symbols that match the requested driver symbol name including the per-thread
  23797. * versions. If a per-thread version is not found, the API will return the legacy version
  23798. * of the driver function.
  23799. *
  23800. * \param symbol - The base name of the driver API function to look for. As an example,
  23801. * for the driver API ::cuMemAlloc_v2, \p symbol would be cuMemAlloc and
  23802. * \p cudaVersion would be the ABI compatible CUDA version for the _v2 variant.
  23803. * \param pfn - Location to return the function pointer to the requested driver function
  23804. * \param cudaVersion - The CUDA version to look for the requested driver symbol
  23805. * \param flags - Flags to specify search options.
  23806. * \param symbolStatus - Optional location to store the status of the search for
  23807. * \p symbol based on \p cudaVersion. See ::CUdriverProcAddressQueryResult
  23808. * for possible values.
  23809. *
  23810. * \return
  23811. * ::CUDA_SUCCESS,
  23812. * ::CUDA_ERROR_INVALID_VALUE,
  23813. * ::CUDA_ERROR_NOT_SUPPORTED
  23814. * \note_version_mixing
  23815. *
  23816. * \sa
  23817. * ::cudaGetDriverEntryPoint
  23818. */
  23819. CUresult CUDAAPI cuGetProcAddress(const char *symbol, void **pfn, int cudaVersion, cuuint64_t flags, CUdriverProcAddressQueryResult *symbolStatus);
  23820. /** @} */ /* END CUDA_DRIVER_ENTRY_POINT */
  23821. /**
  23822. * \defgroup CUDA_COREDUMP Coredump Attributes Control API
  23823. *
  23824. * ___MANBRIEF___ coredump attribute control functions for the low-level CUDA API
  23825. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  23826. *
  23827. * This section describes the coredump attribute control functions of the low-level CUDA
  23828. * driver application programming interface.
  23829. *
  23830. * @{
  23831. */
  23832. /**
  23833. * Flags for choosing a coredump attribute to get/set
  23834. */
  23835. typedef enum CUcoredumpSettings_enum {
  23836. CU_COREDUMP_ENABLE_ON_EXCEPTION = 1,
  23837. CU_COREDUMP_TRIGGER_HOST,
  23838. CU_COREDUMP_LIGHTWEIGHT,
  23839. CU_COREDUMP_ENABLE_USER_TRIGGER,
  23840. CU_COREDUMP_FILE,
  23841. CU_COREDUMP_PIPE,
  23842. CU_COREDUMP_GENERATION_FLAGS,
  23843. CU_COREDUMP_MAX
  23844. } CUcoredumpSettings;
  23845. /**
  23846. * Flags for controlling coredump contents
  23847. */
  23848. typedef enum CUCoredumpGenerationFlags {
  23849. CU_COREDUMP_DEFAULT_FLAGS = 0,
  23850. CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES = (1 << 0),
  23851. CU_COREDUMP_SKIP_GLOBAL_MEMORY = (1 << 1),
  23852. CU_COREDUMP_SKIP_SHARED_MEMORY = (1 << 2),
  23853. CU_COREDUMP_SKIP_LOCAL_MEMORY = (1 << 3),
  23854. CU_COREDUMP_SKIP_ABORT = (1 << 4),
  23855. CU_COREDUMP_SKIP_CONSTBANK_MEMORY = (1 << 5),
  23856. CU_COREDUMP_LIGHTWEIGHT_FLAGS = CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES
  23857. | CU_COREDUMP_SKIP_GLOBAL_MEMORY
  23858. | CU_COREDUMP_SKIP_SHARED_MEMORY
  23859. | CU_COREDUMP_SKIP_LOCAL_MEMORY
  23860. | CU_COREDUMP_SKIP_CONSTBANK_MEMORY
  23861. } CUCoredumpGenerationFlags;
  23862. /**
  23863. * \brief Allows caller to fetch a coredump attribute value for the current context
  23864. *
  23865. * Returns in \p *value the requested value specified by \p attrib. It is up to the caller
  23866. * to ensure that the data type and size of \p *value matches the request.
  23867. *
  23868. * If the caller calls this function with \p *value equal to NULL, the size of the memory
  23869. * region (in bytes) expected for \p attrib will be placed in \p size.
  23870. *
  23871. * The supported attributes are:
  23872. * - ::CU_COREDUMP_ENABLE_ON_EXCEPTION: Bool where ::true means that GPU exceptions from
  23873. * this context will create a coredump at the location specified by ::CU_COREDUMP_FILE.
  23874. * The default value is ::false unless set to ::true globally or locally, or the
  23875. * CU_CTX_USER_COREDUMP_ENABLE flag was set during context creation.
  23876. * - ::CU_COREDUMP_TRIGGER_HOST: Bool where ::true means that the host CPU will
  23877. * also create a coredump. The default value is ::true unless set to ::false globally or
  23878. * or locally. This value is deprecated as of CUDA 12.5 - raise the ::CU_COREDUMP_SKIP_ABORT
  23879. * flag to disable host device abort() if needed.
  23880. * - ::CU_COREDUMP_LIGHTWEIGHT: Bool where ::true means that any resulting coredumps
  23881. * will not have a dump of GPU memory or non-reloc ELF images. The default value is
  23882. * ::false unless set to ::true globally or locally. This attribute is deprecated as
  23883. * of CUDA 12.5, please use ::CU_COREDUMP_GENERATION_FLAGS instead.
  23884. * - ::CU_COREDUMP_ENABLE_USER_TRIGGER: Bool where ::true means that a coredump can be
  23885. * created by writing to the system pipe specified by ::CU_COREDUMP_PIPE. The default
  23886. * value is ::false unless set to ::true globally or locally.
  23887. * - ::CU_COREDUMP_FILE: String of up to 1023 characters that defines the location where
  23888. * any coredumps generated by this context will be written. The default value is
  23889. * ::core.cuda.HOSTNAME.PID where ::HOSTNAME is the host name of the machine running
  23890. * the CUDA applications and ::PID is the process ID of the CUDA application.
  23891. * - ::CU_COREDUMP_PIPE: String of up to 1023 characters that defines the name of the pipe
  23892. * that will be monitored if user-triggered coredumps are enabled. The default value is
  23893. * ::corepipe.cuda.HOSTNAME.PID where ::HOSTNAME is the host name of the machine running
  23894. * the CUDA application and ::PID is the process ID of the CUDA application.
  23895. * - ::CU_COREDUMP_GENERATION_FLAGS: An integer with values to allow granular control the data
  23896. * contained in a coredump specified as a bitwise OR combination of the following values:
  23897. * + ::CU_COREDUMP_DEFAULT_FLAGS - if set by itself, coredump generation returns to its
  23898. * default settings of including all memory regions that it is able to access
  23899. * + ::CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES - Coredump will not include the data from
  23900. * CUDA source modules that are not relocated at runtime.
  23901. * + ::CU_COREDUMP_SKIP_GLOBAL_MEMORY - Coredump will not include device-side global data
  23902. * that does not belong to any context.
  23903. * + ::CU_COREDUMP_SKIP_SHARED_MEMORY - Coredump will not include grid-scale shared memory
  23904. * for the warp that the dumped kernel belonged to.
  23905. * + ::CU_COREDUMP_SKIP_LOCAL_MEMORY - Coredump will not include local memory from the kernel.
  23906. * + ::CU_COREDUMP_LIGHTWEIGHT_FLAGS - Enables all of the above options. Equiavlent to setting
  23907. * the ::CU_COREDUMP_LIGHTWEIGHT attribute to ::true.
  23908. * + ::CU_COREDUMP_SKIP_ABORT - If set, GPU exceptions will not raise an abort() in the host CPU
  23909. * process. Same functional goal as ::CU_COREDUMP_TRIGGER_HOST but better reflects the default
  23910. * behavior.
  23911. *
  23912. * \param attrib - The enum defining which value to fetch.
  23913. * \param value - void* containing the requested data.
  23914. * \param size - The size of the memory region \p value points to.
  23915. *
  23916. * \return
  23917. * ::CUDA_SUCCESS,
  23918. * ::CUDA_ERROR_INVALID_VALUE,
  23919. * ::CUDA_ERROR_NOT_PERMITTED,
  23920. * ::CUDA_ERROR_DEINITIALIZED,
  23921. * ::CUDA_ERROR_NOT_INITIALIZED,
  23922. * ::CUDA_ERROR_INVALID_CONTEXT,
  23923. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED
  23924. *
  23925. * \sa
  23926. * ::cuCoredumpGetAttributeGlobal,
  23927. * ::cuCoredumpSetAttribute,
  23928. * ::cuCoredumpSetAttributeGlobal
  23929. */
  23930. CUresult CUDAAPI cuCoredumpGetAttribute(CUcoredumpSettings attrib, void* value, size_t *size);
  23931. /**
  23932. * \brief Allows caller to fetch a coredump attribute value for the entire application
  23933. *
  23934. * Returns in \p *value the requested value specified by \p attrib. It is up to the caller
  23935. * to ensure that the data type and size of \p *value matches the request.
  23936. *
  23937. * If the caller calls this function with \p *value equal to NULL, the size of the memory
  23938. * region (in bytes) expected for \p attrib will be placed in \p size.
  23939. *
  23940. * The supported attributes are:
  23941. * - ::CU_COREDUMP_ENABLE_ON_EXCEPTION: Bool where ::true means that GPU exceptions from
  23942. * this context will create a coredump at the location specified by ::CU_COREDUMP_FILE.
  23943. * The default value is ::false.
  23944. * - ::CU_COREDUMP_TRIGGER_HOST: Bool where ::true means that the host CPU will
  23945. * also create a coredump. The default value is ::true unless set to ::false globally or
  23946. * or locally. This value is deprecated as of CUDA 12.5 - raise the ::CU_COREDUMP_SKIP_ABORT
  23947. * flag to disable host device abort() if needed.
  23948. * - ::CU_COREDUMP_LIGHTWEIGHT: Bool where ::true means that any resulting coredumps
  23949. * will not have a dump of GPU memory or non-reloc ELF images. The default value is
  23950. * ::false. This attribute is deprecated as of CUDA 12.5, please use ::CU_COREDUMP_GENERATION_FLAGS
  23951. * instead.
  23952. * - ::CU_COREDUMP_ENABLE_USER_TRIGGER: Bool where ::true means that a coredump can be
  23953. * created by writing to the system pipe specified by ::CU_COREDUMP_PIPE. The default
  23954. * value is ::false.
  23955. * - ::CU_COREDUMP_FILE: String of up to 1023 characters that defines the location where
  23956. * any coredumps generated by this context will be written. The default value is
  23957. * ::core.cuda.HOSTNAME.PID where ::HOSTNAME is the host name of the machine running
  23958. * the CUDA applications and ::PID is the process ID of the CUDA application.
  23959. * - ::CU_COREDUMP_PIPE: String of up to 1023 characters that defines the name of the pipe
  23960. * that will be monitored if user-triggered coredumps are enabled. The default value is
  23961. * ::corepipe.cuda.HOSTNAME.PID where ::HOSTNAME is the host name of the machine running
  23962. * the CUDA application and ::PID is the process ID of the CUDA application.
  23963. * - ::CU_COREDUMP_GENERATION_FLAGS: An integer with values to allow granular control the data
  23964. * contained in a coredump specified as a bitwise OR combination of the following values:
  23965. * + ::CU_COREDUMP_DEFAULT_FLAGS - if set by itself, coredump generation returns to its
  23966. * default settings of including all memory regions that it is able to access
  23967. * + ::CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES - Coredump will not include the data from
  23968. * CUDA source modules that are not relocated at runtime.
  23969. * + ::CU_COREDUMP_SKIP_GLOBAL_MEMORY - Coredump will not include device-side global data
  23970. * that does not belong to any context.
  23971. * + ::CU_COREDUMP_SKIP_SHARED_MEMORY - Coredump will not include grid-scale shared memory
  23972. * for the warp that the dumped kernel belonged to.
  23973. * + ::CU_COREDUMP_SKIP_LOCAL_MEMORY - Coredump will not include local memory from the kernel.
  23974. * + ::CU_COREDUMP_LIGHTWEIGHT_FLAGS - Enables all of the above options. Equiavlent to setting
  23975. * the ::CU_COREDUMP_LIGHTWEIGHT attribute to ::true.
  23976. * + ::CU_COREDUMP_SKIP_ABORT - If set, GPU exceptions will not raise an abort() in the host CPU
  23977. * process. Same functional goal as ::CU_COREDUMP_TRIGGER_HOST but better reflects the default
  23978. * behavior.
  23979. *
  23980. * \param attrib - The enum defining which value to fetch.
  23981. * \param value - void* containing the requested data.
  23982. * \param size - The size of the memory region \p value points to.
  23983. *
  23984. * \return
  23985. * ::CUDA_SUCCESS,
  23986. * ::CUDA_ERROR_INVALID_VALUE
  23987. *
  23988. * \sa
  23989. * ::cuCoredumpGetAttribute,
  23990. * ::cuCoredumpSetAttribute,
  23991. * ::cuCoredumpSetAttributeGlobal
  23992. */
  23993. CUresult CUDAAPI cuCoredumpGetAttributeGlobal(CUcoredumpSettings attrib, void *value, size_t *size);
  23994. /**
  23995. * \brief Allows caller to set a coredump attribute value for the current context
  23996. *
  23997. * This function should be considered an alternate interface to the CUDA-GDB environment
  23998. * variables defined in this document: https://docs.nvidia.com/cuda/cuda-gdb/index.html#gpu-coredump
  23999. *
  24000. * An important design decision to note is that any coredump environment variable values
  24001. * set before CUDA initializes will take permanent precedence over any values set with this
  24002. * function. This decision was made to ensure no change in behavior for any users that
  24003. * may be currently using these variables to get coredumps.
  24004. *
  24005. * \p *value shall contain the requested value specified by \p set. It is up to the caller
  24006. * to ensure that the data type and size of \p *value matches the request.
  24007. *
  24008. * If the caller calls this function with \p *value equal to NULL, the size of the memory
  24009. * region (in bytes) expected for \p set will be placed in \p size.
  24010. *
  24011. * /note This function will return ::CUDA_ERROR_NOT_SUPPORTED if the caller attempts to set
  24012. * ::CU_COREDUMP_ENABLE_ON_EXCEPTION on a GPU of with Compute Capability < 6.0. ::cuCoredumpSetAttributeGlobal
  24013. * works on those platforms as an alternative.
  24014. *
  24015. * /note ::CU_COREDUMP_ENABLE_USER_TRIGGER and ::CU_COREDUMP_PIPE cannot be set on a per-context basis.
  24016. *
  24017. * The supported attributes are:
  24018. * - ::CU_COREDUMP_ENABLE_ON_EXCEPTION: Bool where ::true means that GPU exceptions from
  24019. * this context will create a coredump at the location specified by ::CU_COREDUMP_FILE.
  24020. * The default value is ::false.
  24021. * - ::CU_COREDUMP_TRIGGER_HOST: Bool where ::true means that the host CPU will
  24022. * also create a coredump. The default value is ::true unless set to ::false globally or
  24023. * or locally. This value is deprecated as of CUDA 12.5 - raise the ::CU_COREDUMP_SKIP_ABORT
  24024. * flag to disable host device abort() if needed.
  24025. * - ::CU_COREDUMP_LIGHTWEIGHT: Bool where ::true means that any resulting coredumps
  24026. * will not have a dump of GPU memory or non-reloc ELF images. The default value is
  24027. * ::false. This attribute is deprecated as of CUDA 12.5, please use ::CU_COREDUMP_GENERATION_FLAGS
  24028. * instead.
  24029. * - ::CU_COREDUMP_FILE: String of up to 1023 characters that defines the location where
  24030. * any coredumps generated by this context will be written. The default value is
  24031. * ::core.cuda.HOSTNAME.PID where ::HOSTNAME is the host name of the machine running
  24032. * the CUDA applications and ::PID is the process ID of the CUDA application.
  24033. * - ::CU_COREDUMP_GENERATION_FLAGS: An integer with values to allow granular control the data
  24034. * contained in a coredump specified as a bitwise OR combination of the following values:
  24035. * + ::CU_COREDUMP_DEFAULT_FLAGS - if set by itself, coredump generation returns to its
  24036. * default settings of including all memory regions that it is able to access
  24037. * + ::CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES - Coredump will not include the data from
  24038. * CUDA source modules that are not relocated at runtime.
  24039. * + ::CU_COREDUMP_SKIP_GLOBAL_MEMORY - Coredump will not include device-side global data
  24040. * that does not belong to any context.
  24041. * + ::CU_COREDUMP_SKIP_SHARED_MEMORY - Coredump will not include grid-scale shared memory
  24042. * for the warp that the dumped kernel belonged to.
  24043. * + ::CU_COREDUMP_SKIP_LOCAL_MEMORY - Coredump will not include local memory from the kernel.
  24044. * + ::CU_COREDUMP_LIGHTWEIGHT_FLAGS - Enables all of the above options. Equiavlent to setting
  24045. * the ::CU_COREDUMP_LIGHTWEIGHT attribute to ::true.
  24046. * + ::CU_COREDUMP_SKIP_ABORT - If set, GPU exceptions will not raise an abort() in the host CPU
  24047. * process. Same functional goal as ::CU_COREDUMP_TRIGGER_HOST but better reflects the default
  24048. * behavior.
  24049. *
  24050. * \param attrib - The enum defining which value to set.
  24051. * \param value - void* containing the requested data.
  24052. * \param size - The size of the memory region \p value points to.
  24053. *
  24054. * \return
  24055. * ::CUDA_SUCCESS,
  24056. * ::CUDA_ERROR_INVALID_VALUE,
  24057. * ::CUDA_ERROR_NOT_PERMITTED,
  24058. * ::CUDA_ERROR_DEINITIALIZED,
  24059. * ::CUDA_ERROR_NOT_INITIALIZED,
  24060. * ::CUDA_ERROR_INVALID_CONTEXT,
  24061. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED,
  24062. * ::CUDA_ERROR_NOT_SUPPORTED
  24063. *
  24064. * \sa
  24065. * ::cuCoredumpGetAttributeGlobal,
  24066. * ::cuCoredumpGetAttribute,
  24067. * ::cuCoredumpSetAttributeGlobal
  24068. */
  24069. CUresult CUDAAPI cuCoredumpSetAttribute(CUcoredumpSettings attrib, void* value, size_t *size);
  24070. /**
  24071. * \brief Allows caller to set a coredump attribute value globally
  24072. *
  24073. * This function should be considered an alternate interface to the CUDA-GDB environment
  24074. * variables defined in this document: https://docs.nvidia.com/cuda/cuda-gdb/index.html#gpu-coredump
  24075. *
  24076. * An important design decision to note is that any coredump environment variable values
  24077. * set before CUDA initializes will take permanent precedence over any values set with this
  24078. * function. This decision was made to ensure no change in behavior for any users that
  24079. * may be currently using these variables to get coredumps.
  24080. *
  24081. * \p *value shall contain the requested value specified by \p set. It is up to the caller
  24082. * to ensure that the data type and size of \p *value matches the request.
  24083. *
  24084. * If the caller calls this function with \p *value equal to NULL, the size of the memory
  24085. * region (in bytes) expected for \p set will be placed in \p size.
  24086. *
  24087. * The supported attributes are:
  24088. * - ::CU_COREDUMP_ENABLE_ON_EXCEPTION: Bool where ::true means that GPU exceptions from
  24089. * this context will create a coredump at the location specified by ::CU_COREDUMP_FILE.
  24090. * The default value is ::false.
  24091. * - ::CU_COREDUMP_TRIGGER_HOST: Bool where ::true means that the host CPU will
  24092. * also create a coredump. The default value is ::true unless set to ::false globally or
  24093. * or locally. This value is deprecated as of CUDA 12.5 - raise the ::CU_COREDUMP_SKIP_ABORT
  24094. * flag to disable host device abort() if needed.
  24095. * - ::CU_COREDUMP_LIGHTWEIGHT: Bool where ::true means that any resulting coredumps
  24096. * will not have a dump of GPU memory or non-reloc ELF images. The default value is
  24097. * ::false. This attribute is deprecated as of CUDA 12.5, please use ::CU_COREDUMP_GENERATION_FLAGS
  24098. * instead.
  24099. * - ::CU_COREDUMP_ENABLE_USER_TRIGGER: Bool where ::true means that a coredump can be
  24100. * created by writing to the system pipe specified by ::CU_COREDUMP_PIPE. The default
  24101. * value is ::false.
  24102. * - ::CU_COREDUMP_FILE: String of up to 1023 characters that defines the location where
  24103. * any coredumps generated by this context will be written. The default value is
  24104. * ::core.cuda.HOSTNAME.PID where ::HOSTNAME is the host name of the machine running
  24105. * the CUDA applications and ::PID is the process ID of the CUDA application.
  24106. * - ::CU_COREDUMP_PIPE: String of up to 1023 characters that defines the name of the pipe
  24107. * that will be monitored if user-triggered coredumps are enabled. This value may not be
  24108. * changed after ::CU_COREDUMP_ENABLE_USER_TRIGGER is set to ::true. The default
  24109. * value is ::corepipe.cuda.HOSTNAME.PID where ::HOSTNAME is the host name of the machine
  24110. * running the CUDA application and ::PID is the process ID of the CUDA application.
  24111. * - ::CU_COREDUMP_GENERATION_FLAGS: An integer with values to allow granular control the data
  24112. * contained in a coredump specified as a bitwise OR combination of the following values:
  24113. * + ::CU_COREDUMP_DEFAULT_FLAGS - if set by itself, coredump generation returns to its
  24114. * default settings of including all memory regions that it is able to access
  24115. * + ::CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES - Coredump will not include the data from
  24116. * CUDA source modules that are not relocated at runtime.
  24117. * + ::CU_COREDUMP_SKIP_GLOBAL_MEMORY - Coredump will not include device-side global data
  24118. * that does not belong to any context.
  24119. * + ::CU_COREDUMP_SKIP_SHARED_MEMORY - Coredump will not include grid-scale shared memory
  24120. * for the warp that the dumped kernel belonged to.
  24121. * + ::CU_COREDUMP_SKIP_LOCAL_MEMORY - Coredump will not include local memory from the kernel.
  24122. * + ::CU_COREDUMP_LIGHTWEIGHT_FLAGS - Enables all of the above options. Equiavlent to setting
  24123. * the ::CU_COREDUMP_LIGHTWEIGHT attribute to ::true.
  24124. * + ::CU_COREDUMP_SKIP_ABORT - If set, GPU exceptions will not raise an abort() in the host CPU
  24125. * process. Same functional goal as ::CU_COREDUMP_TRIGGER_HOST but better reflects the default
  24126. * behavior.
  24127. *
  24128. * \param attrib - The enum defining which value to set.
  24129. * \param value - void* containing the requested data.
  24130. * \param size - The size of the memory region \p value points to.
  24131. *
  24132. * \return
  24133. * ::CUDA_SUCCESS,
  24134. * ::CUDA_ERROR_INVALID_VALUE,
  24135. * ::CUDA_ERROR_NOT_PERMITTED
  24136. *
  24137. * \sa
  24138. * ::cuCoredumpGetAttribute,
  24139. * ::cuCoredumpGetAttributeGlobal,
  24140. * ::cuCoredumpSetAttribute
  24141. */
  24142. CUresult CUDAAPI cuCoredumpSetAttributeGlobal(CUcoredumpSettings attrib, void *value, size_t *size);
  24143. /** @} */ /* END CUDA_COREDUMP */
  24144. CUresult CUDAAPI cuGetExportTable(const void **ppExportTable, const CUuuid *pExportTableId);
  24145. /*
  24146. ** ******************* GREEN CONTEXTS **********************
  24147. */
  24148. /**
  24149. * \defgroup CUDA_GREEN_CONTEXTS Green Contexts
  24150. *
  24151. * ___MANBRIEF___ Driver level API for creation and manipulation of green contexts
  24152. * (___CURRENT_FILE___) ___ENDMANBRIEF___
  24153. *
  24154. * This section describes the APIs for creation and manipulation of green contexts in the CUDA
  24155. * driver. Green contexts are a lightweight alternative to traditional contexts, with the ability
  24156. * to pass in a set of resources that they should be initialized with. This allows the developer to
  24157. * represent distinct spatial partitions of the GPU, provision resources for them, and target them
  24158. * via the same programming model that CUDA exposes (streams, kernel launches, etc.).
  24159. *
  24160. * There are 4 main steps to using these new set of APIs.
  24161. * - (1) Start with an initial set of resources, for example via ::cuDeviceGetDevResource. Only SM type is supported today.
  24162. * - (2) Partition this set of resources by providing them as input to a partition API, for example: ::cuDevSmResourceSplitByCount.
  24163. * - (3) Finalize the specification of resources by creating a descriptor via ::cuDevResourceGenerateDesc.
  24164. * - (4) Provision the resources and create a green context via ::cuGreenCtxCreate.
  24165. *
  24166. * For \p CU_DEV_RESOURCE_TYPE_SM, the partitions created have minimum SM count requirements, often rounding up and aligning the
  24167. * minCount provided to ::cuDevSmResourceSplitByCount. The following is a guideline for each architecture
  24168. * and may be subject to change:
  24169. * - On Compute Architecture 6.X: The minimum count is 1 SM.
  24170. * - On Compute Architecture 7.X: The minimum count is 2 SMs and must be a multiple of 2.
  24171. * - On Compute Architecture 8.X: The minimum count is 4 SMs and must be a multiple of 2.
  24172. * - On Compute Architecture 9.0+: The minimum count is 8 SMs and must be a multiple of 8.
  24173. *
  24174. * In the future, flags can be provided to tradeoff functional and performance characteristics versus finer grained SM partitions.
  24175. *
  24176. * Even if the green contexts have disjoint SM partitions, it is not guaranteed that the kernels launched
  24177. * in them will run concurrently or have forward progress guarantees. This is due to other resources (like HW connections,
  24178. * see ::CUDA_DEVICE_MAX_CONNECTIONS) that could cause a dependency. Additionally, in certain scenarios,
  24179. * it is possible for the workload to run on more SMs than was provisioned (but never less).
  24180. * The following are two scenarios which can exhibit this behavior:
  24181. * - On Volta+ MPS: When \p CUDA_MPS_ACTIVE_THREAD_PERCENTAGE is used,
  24182. * the set of SMs that are used for running kernels can be scaled up to the value of SMs used for the MPS client.
  24183. * - On Compute Architecture 9.x: When a module with dynamic parallelism (CDP) is loaded, all future
  24184. * kernels running under green contexts may use and share an additional set of 2 SMs.
  24185. *
  24186. * @{
  24187. */
  24188. /*!
  24189. * \typedef struct CUdevResourceDesc_st* CUdevResourceDesc;
  24190. * An opaque descriptor handle. The descriptor encapsulates multiple created and configured resources.
  24191. * Created via ::cuDevResourceGenerateDesc
  24192. */
  24193. typedef struct CUdevResourceDesc_st *CUdevResourceDesc;
  24194. typedef enum {
  24195. CU_GREEN_CTX_DEFAULT_STREAM = 0x1, /**< Required. Creates a default stream to use inside the green context */
  24196. } CUgreenCtxCreate_flags;
  24197. typedef enum {
  24198. CU_DEV_SM_RESOURCE_SPLIT_IGNORE_SM_COSCHEDULING = 0x1,
  24199. CU_DEV_SM_RESOURCE_SPLIT_MAX_POTENTIAL_CLUSTER_SIZE = 0x2,
  24200. } CUdevSmResourceSplit_flags;
  24201. #define RESOURCE_ABI_VERSION 1
  24202. #define RESOURCE_ABI_EXTERNAL_BYTES 48
  24203. #define _CONCAT_INNER(x, y) x ## y
  24204. #define _CONCAT_OUTER(x, y) _CONCAT_INNER(x, y)
  24205. /*!
  24206. * \typedef enum CUdevResourceType
  24207. * Type of resource
  24208. */
  24209. typedef enum {
  24210. CU_DEV_RESOURCE_TYPE_INVALID = 0,
  24211. CU_DEV_RESOURCE_TYPE_SM = 1, /**< Streaming multiprocessors related information */
  24212. #if defined(__CUDA_API_VERSION_INTERNAL) && !defined(__CUDA_API_VERSION_INTERNAL_ODR)
  24213. CU_DEV_RESOURCE_TYPE_MAX,
  24214. #endif
  24215. } CUdevResourceType;
  24216. /*!
  24217. * \struct CUdevSmResource
  24218. * Data for SM-related resources
  24219. */
  24220. typedef struct CUdevSmResource_st {
  24221. unsigned int smCount; /**< The amount of streaming multiprocessors available in this resource. This is an output parameter only, do not write to this field. */
  24222. } CUdevSmResource;
  24223. /*!
  24224. * \struct CUdevResource
  24225. * A tagged union describing different resources identified by the type field. This structure should not be directly modified outside of the API that created it.
  24226. * \code
  24227. * struct {
  24228. * CUdevResourceType type;
  24229. * union {
  24230. * CUdevSmResource sm;
  24231. * };
  24232. * };
  24233. * \endcode
  24234. * - If \p type is \p CU_DEV_RESOURCE_TYPE_INVALID, this resoure is not valid and cannot be further accessed.
  24235. * - If \p type is \p CU_DEV_RESOURCE_TYPE_SM, the ::CUdevSmResource structure \p sm is filled in. For example,
  24236. * \p sm.smCount will reflect the amount of streaming multiprocessors available in this resource.
  24237. */
  24238. typedef struct CUdevResource_st {
  24239. CUdevResourceType type; /**< Type of resource, dictates which union field was last set */
  24240. unsigned char _internal_padding[92];
  24241. union {
  24242. CUdevSmResource sm; /**< Resource corresponding to CU_DEV_RESOURCE_TYPE_SM \p. type. */
  24243. unsigned char _oversize[RESOURCE_ABI_EXTERNAL_BYTES];
  24244. };
  24245. } _CONCAT_OUTER(CUdevResource_v, RESOURCE_ABI_VERSION);
  24246. typedef _CONCAT_OUTER(CUdevResource_v, RESOURCE_ABI_VERSION) CUdevResource;
  24247. #undef _CONCAT_INNER
  24248. #undef _CONCAT_OUTER
  24249. #undef ABI_PER_RESOURCE_EXTERNAL_BYTES
  24250. #undef ABI_RESOURCE_VERSION
  24251. /**
  24252. * \brief Creates a green context with a specified set of resources.
  24253. *
  24254. * This API creates a green context with the resources specified in the descriptor \p desc and
  24255. * returns it in the handle represented by \p phCtx. This API will retain the primary context on device \p dev,
  24256. * which will is released when the green context is destroyed. It is advised to have the primary context active
  24257. * before calling this API to avoid the heavy cost of triggering primary context initialization and
  24258. * deinitialization multiple times.
  24259. *
  24260. * The API does not set the green context current. In order to set it current, you need to explicitly set it current
  24261. * by first converting the green context to a CUcontext using ::cuCtxFromGreenCtx and subsequently calling
  24262. * ::cuCtxSetCurrent / ::cuCtxPushCurrent. It should be noted that a green context can be current to only one
  24263. * thread at a time. There is no internal synchronization to make API calls accessing the same green context
  24264. * from multiple threads work.
  24265. *
  24266. * Note: The API is not supported on 32-bit platforms.
  24267. *
  24268. * \param phCtx - Pointer for the output handle to the green context
  24269. * \param desc - Descriptor generated via ::cuDevResourceGenerateDesc which contains the set of resources to be used
  24270. * \param dev - Device on which to create the green context.
  24271. * \param flags - One of the supported green context creation flags. \p CU_GREEN_CTX_DEFAULT_STREAM is required.
  24272. *
  24273. * The supported flags are:
  24274. * - \p CU_GREEN_CTX_DEFAULT_STREAM : Creates a default stream to use inside the green context. Required.
  24275. *
  24276. * \return
  24277. * ::CUDA_SUCCESS,
  24278. * ::CUDA_ERROR_DEINITIALIZED,
  24279. * ::CUDA_ERROR_NOT_INITIALIZED,
  24280. * ::CUDA_ERROR_INVALID_DEVICE,
  24281. * ::CUDA_ERROR_INVALID_VALUE,
  24282. * ::CUDA_ERROR_NOT_SUPPORTED,
  24283. * ::CUDA_ERROR_OUT_OF_MEMORY
  24284. *
  24285. * \sa
  24286. * ::cuGreenCtxDestroy,
  24287. * ::cuCtxFromGreenCtx,
  24288. * ::cuCtxSetCurrent,
  24289. * ::cuCtxPushCurrent,
  24290. * ::cuDevResourceGenerateDesc,
  24291. * ::cuDevicePrimaryCtxRetain,
  24292. * ::cuCtxCreate,
  24293. * ::cuCtxCreate_v3
  24294. */
  24295. CUresult CUDAAPI cuGreenCtxCreate(CUgreenCtx* phCtx, CUdevResourceDesc desc, CUdevice dev, unsigned int flags);
  24296. /**
  24297. * \brief Destroys a green context
  24298. *
  24299. * Destroys the green context, releasing the primary context of the device that this green context was created for.
  24300. * Any resources provisioned for this green context (that were initially available via the resource descriptor)
  24301. * are released as well.
  24302. * \param hCtx - Green context to be destroyed
  24303. *
  24304. * \return
  24305. * ::CUDA_SUCCESS,
  24306. * ::CUDA_ERROR_DEINITIALIZED,
  24307. * ::CUDA_ERROR_NOT_INITIALIZED,
  24308. * ::CUDA_ERROR_INVALID_CONTEXT,
  24309. * ::CUDA_ERROR_CONTEXT_IS_DESTROYED
  24310. *
  24311. * \sa
  24312. * ::cuGreenCtxCreate,
  24313. * ::cuCtxDestroy
  24314. */
  24315. CUresult CUDAAPI cuGreenCtxDestroy(CUgreenCtx hCtx);
  24316. /**
  24317. * \brief Converts a green context into the primary context
  24318. *
  24319. * The API converts a green context into the primary context returned in \p pContext. It is important
  24320. * to note that the converted context \p pContext is a normal primary context but with
  24321. * the resources of the specified green context \p hCtx. Once converted, it can then
  24322. * be used to set the context current with ::cuCtxSetCurrent or with any of the CUDA APIs
  24323. * that accept a CUcontext parameter.
  24324. *
  24325. * Users are expected to call this API before calling any CUDA APIs that accept a
  24326. * CUcontext. Failing to do so will result in the APIs returning ::CUDA_ERROR_INVALID_CONTEXT.
  24327. *
  24328. * \param pContext Returned primary context with green context resources
  24329. * \param hCtx Green context to convert
  24330. *
  24331. * \return
  24332. * ::CUDA_SUCCESS,
  24333. * ::CUDA_ERROR_DEINITIALIZED,
  24334. * ::CUDA_ERROR_NOT_INITIALIZED,
  24335. * ::CUDA_ERROR_INVALID_CONTEXT,
  24336. * ::CUDA_ERROR_INVALID_VALUE
  24337. *
  24338. * \sa
  24339. * ::cuGreenCtxCreate
  24340. */
  24341. CUresult CUDAAPI cuCtxFromGreenCtx(CUcontext *pContext, CUgreenCtx hCtx);
  24342. /**
  24343. * \brief Get device resources
  24344. *
  24345. * Get the \p type resources available to the \p device.
  24346. * This may often be the starting point for further partitioning or configuring of resources.
  24347. *
  24348. * Note: The API is not supported on 32-bit platforms.
  24349. *
  24350. * \param device - Device to get resource for
  24351. * \param resource - Output pointer to a CUdevResource structure
  24352. * \param type - Type of resource to retrieve
  24353. *
  24354. * \return
  24355. * ::CUDA_SUCCESS,
  24356. * ::CUDA_ERROR_DEINITIALIZED,
  24357. * ::CUDA_ERROR_NOT_INITIALIZED,
  24358. * ::CUDA_ERROR_INVALID_RESOURCE_TYPE,
  24359. * ::CUDA_ERROR_INVALID_VALUE,
  24360. * ::CUDA_ERROR_INVALID_DEVICE
  24361. *
  24362. * \sa
  24363. * ::cuDevResourceGenerateDesc
  24364. */
  24365. CUresult CUDAAPI cuDeviceGetDevResource(CUdevice device, CUdevResource* resource, CUdevResourceType type);
  24366. /**
  24367. * \brief Get context resources
  24368. *
  24369. * Get the \p type resources available to the context represented by \p hCtx
  24370. * \param hCtx - Context to get resource for
  24371. *
  24372. * Note: The API is not supported on 32-bit platforms.
  24373. *
  24374. * \param resource - Output pointer to a CUdevResource structure
  24375. * \param type - Type of resource to retrieve
  24376. *
  24377. * \return
  24378. * ::CUDA_SUCCESS,
  24379. * ::CUDA_ERROR_DEINITIALIZED,
  24380. * ::CUDA_ERROR_NOT_INITIALIZED,
  24381. * ::CUDA_ERROR_INVALID_RESOURCE_TYPE,
  24382. * ::CUDA_ERROR_INVALID_VALUE,
  24383. * ::CUDA_ERROR_INVALID_CONTEXT
  24384. *
  24385. * \sa
  24386. * ::cuDevResourceGenerateDesc
  24387. */
  24388. CUresult CUDAAPI cuCtxGetDevResource(CUcontext hCtx, CUdevResource* resource, CUdevResourceType type);
  24389. /**
  24390. * \brief Get green context resources
  24391. *
  24392. * Get the \p type resources available to the green context represented by \p hCtx
  24393. * \param hCtx - Green context to get resource for
  24394. * \param resource - Output pointer to a CUdevResource structure
  24395. * \param type - Type of resource to retrieve
  24396. *
  24397. * \return
  24398. * ::CUDA_SUCCESS
  24399. * ::CUDA_ERROR_DEINITIALIZED,
  24400. * ::CUDA_ERROR_NOT_INITIALIZED,
  24401. * ::CUDA_ERROR_INVALID_CONTEXT,
  24402. * ::CUDA_ERROR_INVALID_RESOURCE_TYPE,
  24403. * ::CUDA_ERROR_INVALID_VALUE
  24404. *
  24405. * \sa
  24406. * ::cuDevResourceGenerateDesc
  24407. */
  24408. CUresult CUDAAPI cuGreenCtxGetDevResource(CUgreenCtx hCtx, CUdevResource* resource, CUdevResourceType type);
  24409. /**
  24410. * \brief Splits \p CU_DEV_RESOURCE_TYPE_SM resources.
  24411. *
  24412. * Splits \p CU_DEV_RESOURCE_TYPE_SM resources into \p nbGroups, adhering to the minimum SM count specified in \p minCount
  24413. * and the usage flags in \p useFlags. If \p result is NULL, the API simulates a split and provides the amount of groups that
  24414. * would be created in \p nbGroups. Otherwise, \p nbGroups must point to the amount of elements in \p result and on return,
  24415. * the API will overwrite \p nbGroups with the amount actually created. The groups are written to the array in \p result.
  24416. * \p nbGroups can be less than the total amount if a smaller number of groups is needed.
  24417. *
  24418. * This API is used to spatially partition the input resource. The input resource needs to come from one of
  24419. * ::cuDeviceGetDevResource, ::cuCtxGetDevResource, or ::cuGreenCtxGetDevResource.
  24420. * A limitation of the API is that the output results cannot be split again without
  24421. * first creating a descriptor and a green context with that descriptor.
  24422. *
  24423. * When creating the groups, the API will take into account the performance and functional characteristics of the
  24424. * input resource, and guarantee a split that will create a disjoint set of symmetrical partitions. This may lead to fewer groups created
  24425. * than purely dividing the total SM count by the \p minCount due to cluster requirements or
  24426. * alignment and granularity requirements for the minCount.
  24427. *
  24428. * The \p remainder set does not have the same functional or performance guarantees as the groups in \p result.
  24429. * Its use should be carefully planned and future partitions of the \p remainder set are discouraged.
  24430. *
  24431. * The following flags are supported:
  24432. * - \p CU_DEV_SM_RESOURCE_SPLIT_IGNORE_SM_COSCHEDULING : Lower the minimum SM count and alignment, and treat each SM independent of its hierarchy.
  24433. * This allows more fine grained partitions but at the cost of advanced features (such as large clusters on compute capability 9.0+).
  24434. * - \p CU_DEV_SM_RESOURCE_SPLIT_MAX_POTENTIAL_CLUSTER_SIZE : Compute Capability 9.0+ only. Attempt to create groups that may allow
  24435. * for maximally sized thread clusters. This can be queried post green context creation using ::cuOccupancyMaxPotentialClusterSize.
  24436. *
  24437. * A successful API call must either have:
  24438. * - A valid array of \p result pointers of size passed in \p nbGroups, with \p input of type \p CU_DEV_RESOURCE_TYPE_SM.
  24439. * Value of \p minCount must be between 0 and the SM count specified in \p input. \p remaining may be NULL.
  24440. * - NULL passed in for \p result, with a valid integer pointer in \p nbGroups and \p input of type \p CU_DEV_RESOURCE_TYPE_SM.
  24441. * Value of \p minCount must be between 0 and the SM count specified in \p input. \p remaining may be NULL.
  24442. * This queries the number of groups that would be created by the API.
  24443. *
  24444. * Note: The API is not supported on 32-bit platforms.
  24445. *
  24446. * \param result - Output array of \p CUdevResource resources. Can be NULL to query the number of groups.
  24447. * \param nbGroups - This is a pointer, specifying the number of groups that would be or should be created as described below.
  24448. * \param input - Input SM resource to be split. Must be a valid \p CU_DEV_RESOURCE_TYPE_SM resource.
  24449. * \param remaining - If the input resource cannot be cleanly split among \p nbGroups, the remaining is placed in here.
  24450. * Can be ommitted (NULL) if the user does not need the remaining set.
  24451. * \param useFlags - Flags specifying how these partitions are used or which constraints to abide by when splitting the input. Zero is valid for default behavior.
  24452. * \param minCount - Minimum number of SMs required
  24453. *
  24454. * \return
  24455. * ::CUDA_SUCCESS,
  24456. * ::CUDA_ERROR_DEINITIALIZED,
  24457. * ::CUDA_ERROR_NOT_INITIALIZED,
  24458. * ::CUDA_ERROR_INVALID_DEVICE,
  24459. * ::CUDA_ERROR_INVALID_VALUE,
  24460. * ::CUDA_ERROR_INVALID_RESOURCE_TYPE,
  24461. * ::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION
  24462. *
  24463. * \sa
  24464. * ::cuGreenCtxGetDevResource,
  24465. * ::cuCtxGetDevResource,
  24466. * ::cuDeviceGetDevResource
  24467. */
  24468. CUresult CUDAAPI cuDevSmResourceSplitByCount(
  24469. CUdevResource* result, unsigned int* nbGroups, const CUdevResource* input, CUdevResource* remaining, unsigned int useFlags, unsigned int minCount);
  24470. /**
  24471. * \brief Generate a resource descriptor
  24472. *
  24473. * Generates a single resource descriptor with the set of resources specified in \p resources.
  24474. * The generated resource descriptor is necessary for the creation of green contexts via the ::cuGreenCtxCreate API.
  24475. * Resources of the same type can be passed in, provided they meet the requirements as noted below.
  24476. *
  24477. * A successful API call must have:
  24478. * - A valid output pointer for the \p phDesc descriptor as well as a valid array of \p resources pointers,
  24479. * with the array size passed in \p nbResources.
  24480. * If multiple resources are provided in \p resources, the device they came from must be the same,
  24481. * otherwise CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION is returned.
  24482. * If multiple resources are provided in \p resources and they are of type ::CU_DEV_RESOURCE_TYPE_SM,
  24483. * they must be outputs (whether \p result or \p remaining) from the same split API instance,
  24484. * otherwise CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION is returned.
  24485. *
  24486. * Note: The API is not supported on 32-bit platforms.
  24487. *
  24488. * \param phDesc - Output descriptor
  24489. * \param resources - Array of resources to be included in the descriptor
  24490. * \param nbResources - Number of resources passed in \p resources
  24491. *
  24492. * \return
  24493. * ::CUDA_SUCCESS,
  24494. * ::CUDA_ERROR_DEINITIALIZED,
  24495. * ::CUDA_ERROR_NOT_INITIALIZED,
  24496. * ::CUDA_ERROR_INVALID_VALUE,
  24497. * ::CUDA_ERROR_INVALID_RESOURCE_TYPE,
  24498. * ::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION
  24499. *
  24500. * \sa
  24501. * ::cuDevSmResourceSplitByCount
  24502. */
  24503. CUresult CUDAAPI cuDevResourceGenerateDesc(CUdevResourceDesc *phDesc, CUdevResource *resources, unsigned int nbResources);
  24504. /**
  24505. * \brief Records an event.
  24506. *
  24507. * Captures in \p hEvent all the activities of the green context of \p hCtx
  24508. * at the time of this call. \p hEvent and \p hCtx must be from the same
  24509. * primary context otherwise ::CUDA_ERROR_INVALID_HANDLE is returned.
  24510. * Calls such as ::cuEventQuery() or ::cuGreenCtxWaitEvent() will
  24511. * then examine or wait for completion of the work that was captured. Uses of
  24512. * \p hCtx after this call do not modify \p hEvent.
  24513. *
  24514. * \note The API will return ::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED if the
  24515. * specified green context \p hCtx has a stream in the capture mode. In such
  24516. * a case, the call will invalidate all the conflicting captures.
  24517. *
  24518. * \param hCtx - Green context to record event for
  24519. * \param hEvent - Event to record
  24520. *
  24521. * \return
  24522. * ::CUDA_SUCCESS
  24523. * ::CUDA_ERROR_DEINITIALIZED,
  24524. * ::CUDA_ERROR_NOT_INITIALIZED,
  24525. * ::CUDA_ERROR_INVALID_CONTEXT,
  24526. * ::CUDA_ERROR_INVALID_HANDLE,
  24527. * ::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED
  24528. *
  24529. * \sa
  24530. * ::cuGreenCtxWaitEvent,
  24531. * ::cuEventRecord,
  24532. * ::cuCtxRecordEvent,
  24533. * ::cuCtxWaitEvent
  24534. */
  24535. CUresult CUDAAPI cuGreenCtxRecordEvent(CUgreenCtx hCtx, CUevent hEvent);
  24536. /**
  24537. * \brief Make a green context wait on an event
  24538. *
  24539. * Makes all future work submitted to green context \p hCtx wait for all work
  24540. * captured in \p hEvent. The synchronization will be performed on the device
  24541. * and will not block the calling CPU thread. See ::cuGreenCtxRecordEvent()
  24542. * or ::cuEventRecord(), for details on what is captured by an event.
  24543. *
  24544. * \note \p hEvent may be from a different context or device than \p hCtx.
  24545. *
  24546. * \note The API will return ::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED and
  24547. * invalidate the capture if the specified event \p hEvent is part of an
  24548. * ongoing capture sequence or if the specified green context \p hCtx has
  24549. * a stream in the capture mode.
  24550. *
  24551. * \param hCtx - Green context to wait
  24552. * \param hEvent - Event to wait on
  24553. *
  24554. * \return
  24555. * ::CUDA_SUCCESS,
  24556. * ::CUDA_ERROR_DEINITIALIZED,
  24557. * ::CUDA_ERROR_NOT_INITIALIZED,
  24558. * ::CUDA_ERROR_INVALID_CONTEXT,
  24559. * ::CUDA_ERROR_INVALID_HANDLE,
  24560. * ::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED
  24561. *
  24562. * \sa
  24563. * ::cuGreenCtxRecordEvent,
  24564. * ::cuStreamWaitEvent
  24565. * ::cuCtxRecordEvent,
  24566. * ::cuCtxWaitEvent
  24567. */
  24568. CUresult CUDAAPI cuGreenCtxWaitEvent(CUgreenCtx hCtx, CUevent hEvent);
  24569. /**
  24570. * \brief Query the green context associated with a stream
  24571. *
  24572. * Returns the CUDA green context that the stream is associated with, or NULL if the stream
  24573. * is not associated with any green context.
  24574. *
  24575. * The stream handle \p hStream can refer to any of the following:
  24576. * <ul>
  24577. * <li>
  24578. * a stream created via any of the CUDA driver APIs such as ::cuStreamCreate, ::cuStreamCreateWithPriority
  24579. * and ::cuGreenCtxStreamCreate, or their runtime API equivalents such as
  24580. * ::cudaStreamCreate, ::cudaStreamCreateWithFlags and ::cudaStreamCreateWithPriority.
  24581. * If during stream creation the context that was active in the calling thread was obtained
  24582. * with cuCtxFromGreenCtx, that green context is returned in \p phCtx.
  24583. * Otherwise, \p *phCtx is set to NULL instead.
  24584. * </li>
  24585. * <li>
  24586. * special stream such as the NULL stream or ::CU_STREAM_LEGACY.
  24587. * In that case if context that is active in the calling thread was obtained
  24588. * with cuCtxFromGreenCtx, that green context is returned.
  24589. * Otherwise, \p *phCtx is set to NULL instead.
  24590. * </li>
  24591. * </ul>
  24592. * Passing an invalid handle will result in undefined behavior.
  24593. *
  24594. * \param hStream - Handle to the stream to be queried
  24595. * \param phCtx - Returned green context associated with the stream
  24596. *
  24597. * \return
  24598. * ::CUDA_SUCCESS,
  24599. * ::CUDA_ERROR_DEINITIALIZED,
  24600. * ::CUDA_ERROR_NOT_INITIALIZED,
  24601. * ::CUDA_ERROR_INVALID_CONTEXT,
  24602. * ::CUDA_ERROR_INVALID_HANDLE,
  24603. * \notefnerr
  24604. *
  24605. * \sa ::cuStreamDestroy,
  24606. * ::cuStreamCreate,
  24607. * ::cuStreamCreateWithPriority,
  24608. * ::cuStreamGetCtx_v2,
  24609. * ::cuGreenCtxStreamCreate,
  24610. * ::cuStreamGetPriority,
  24611. * ::cuStreamGetFlags,
  24612. * ::cuStreamGetDevice
  24613. * ::cuStreamWaitEvent,
  24614. * ::cuStreamQuery,
  24615. * ::cuStreamSynchronize,
  24616. * ::cuStreamAddCallback,
  24617. * ::cudaStreamCreate,
  24618. * ::cudaStreamCreateWithFlags
  24619. */
  24620. CUresult CUDAAPI cuStreamGetGreenCtx(CUstream hStream, CUgreenCtx *phCtx);
  24621. /**
  24622. * \brief Create a stream for use in the green context
  24623. *
  24624. * Creates a stream for use in the specified green context \p greenCtx and returns a handle in \p phStream.
  24625. * The stream can be destroyed by calling ::cuStreamDestroy(). Note that the API ignores the context that
  24626. * is current to the calling thread and creates a stream in the specified green context \p greenCtx.
  24627. *
  24628. * The supported values for \p flags are:
  24629. * - ::CU_STREAM_NON_BLOCKING: This must be specified. It indicates that work running in the created
  24630. * stream may run concurrently with work in the default stream, and that
  24631. * the created stream should perform no implicit synchronization with the default stream.
  24632. *
  24633. * Specifying \p priority affects the scheduling priority of work in the stream. Priorities provide a
  24634. * hint to preferentially run work with higher priority when possible, but do not preempt
  24635. * already-running work or provide any other functional guarantee on execution order.
  24636. * \p priority follows a convention where lower numbers represent higher priorities.
  24637. * '0' represents default priority. The range of meaningful numerical priorities can
  24638. * be queried using ::cuCtxGetStreamPriorityRange. If the specified priority is
  24639. * outside the numerical range returned by ::cuCtxGetStreamPriorityRange,
  24640. * it will automatically be clamped to the lowest or the highest number in the range.
  24641. *
  24642. * \param phStream - Returned newly created stream
  24643. * \param greenCtx - Green context for which to create the stream for
  24644. * \param flags - Flags for stream creation. \p CU_STREAM_NON_BLOCKING must be specified.
  24645. * \param priority - Stream priority. Lower numbers represent higher priorities.
  24646. * See ::cuCtxGetStreamPriorityRange for more information about
  24647. * meaningful stream priorities that can be passed.
  24648. *
  24649. * \return
  24650. * ::CUDA_SUCCESS,
  24651. * ::CUDA_ERROR_DEINITIALIZED,
  24652. * ::CUDA_ERROR_NOT_INITIALIZED,
  24653. * ::CUDA_ERROR_INVALID_CONTEXT,
  24654. * ::CUDA_ERROR_INVALID_VALUE,
  24655. * ::CUDA_ERROR_OUT_OF_MEMORY
  24656. * \notefnerr
  24657. *
  24658. * \note In the current implementation, only compute kernels launched in
  24659. * priority streams are affected by the stream's priority. Stream priorities have
  24660. * no effect on host-to-device and device-to-host memory operations.
  24661. *
  24662. * \sa ::cuStreamDestroy,
  24663. * ::cuGreenCtxCreate
  24664. * ::cuStreamCreate,
  24665. * ::cuStreamGetPriority,
  24666. * ::cuCtxGetStreamPriorityRange,
  24667. * ::cuStreamGetFlags,
  24668. * ::cuStreamGetDevice
  24669. * ::cuStreamWaitEvent,
  24670. * ::cuStreamQuery,
  24671. * ::cuStreamSynchronize,
  24672. * ::cuStreamAddCallback,
  24673. * ::cudaStreamCreateWithPriority
  24674. */
  24675. CUresult CUDAAPI cuGreenCtxStreamCreate(CUstream* phStream, CUgreenCtx greenCtx, unsigned int flags, int priority);
  24676. /** @} */
  24677. /*
  24678. ** *************** END CUDA_GREEN_CONTEXTS *****************
  24679. */
  24680. /**
  24681. * CUDA API versioning support
  24682. */
  24683. #if defined(__CUDA_API_VERSION_INTERNAL)
  24684. #undef cuMemHostRegister
  24685. #undef cuGraphicsResourceSetMapFlags
  24686. #undef cuLinkCreate
  24687. #undef cuLinkAddData
  24688. #undef cuLinkAddFile
  24689. #undef cuDeviceTotalMem
  24690. #undef cuCtxCreate
  24691. #undef cuModuleGetGlobal
  24692. #undef cuMemGetInfo
  24693. #undef cuMemAlloc
  24694. #undef cuMemAllocPitch
  24695. #undef cuMemFree
  24696. #undef cuMemGetAddressRange
  24697. #undef cuMemAllocHost
  24698. #undef cuMemHostGetDevicePointer
  24699. #undef cuMemcpyHtoD
  24700. #undef cuMemcpyDtoH
  24701. #undef cuMemcpyDtoD
  24702. #undef cuMemcpyDtoA
  24703. #undef cuMemcpyAtoD
  24704. #undef cuMemcpyHtoA
  24705. #undef cuMemcpyAtoH
  24706. #undef cuMemcpyAtoA
  24707. #undef cuMemcpyHtoAAsync
  24708. #undef cuMemcpyAtoHAsync
  24709. #undef cuMemcpy2D
  24710. #undef cuMemcpy2DUnaligned
  24711. #undef cuMemcpy3D
  24712. #undef cuMemcpyHtoDAsync
  24713. #undef cuMemcpyDtoHAsync
  24714. #undef cuMemcpyDtoDAsync
  24715. #undef cuMemcpy2DAsync
  24716. #undef cuMemcpy3DAsync
  24717. #undef cuMemcpyBatchAsync
  24718. #undef cuMemcpy3DBatchAsync
  24719. #undef cuMemsetD8
  24720. #undef cuMemsetD16
  24721. #undef cuMemsetD32
  24722. #undef cuMemsetD2D8
  24723. #undef cuMemsetD2D16
  24724. #undef cuMemsetD2D32
  24725. #undef cuArrayCreate
  24726. #undef cuArrayGetDescriptor
  24727. #undef cuArray3DCreate
  24728. #undef cuArray3DGetDescriptor
  24729. #undef cuTexRefSetAddress
  24730. #undef cuTexRefSetAddress2D
  24731. #undef cuTexRefGetAddress
  24732. #undef cuGraphicsResourceGetMappedPointer
  24733. #undef cuCtxDestroy
  24734. #undef cuCtxPopCurrent
  24735. #undef cuCtxPushCurrent
  24736. #undef cuStreamDestroy
  24737. #undef cuEventDestroy
  24738. #undef cuMemcpy
  24739. #undef cuMemcpyAsync
  24740. #undef cuMemcpyPeer
  24741. #undef cuMemcpyPeerAsync
  24742. #undef cuMemcpy3DPeer
  24743. #undef cuMemcpy3DPeerAsync
  24744. #undef cuMemsetD8Async
  24745. #undef cuMemsetD16Async
  24746. #undef cuMemsetD32Async
  24747. #undef cuMemsetD2D8Async
  24748. #undef cuMemsetD2D16Async
  24749. #undef cuMemsetD2D32Async
  24750. #undef cuStreamGetPriority
  24751. #undef cuStreamGetId
  24752. #undef cuStreamGetFlags
  24753. #undef cuStreamGetDevice
  24754. #undef cuStreamGetCtx
  24755. #undef cuStreamWaitEvent
  24756. #undef cuStreamAddCallback
  24757. #undef cuStreamAttachMemAsync
  24758. #undef cuStreamQuery
  24759. #undef cuStreamSynchronize
  24760. #undef cuEventRecord
  24761. #undef cuEventRecordWithFlags
  24762. #undef cuLaunchKernel
  24763. #undef cuLaunchKernelEx
  24764. #undef cuLaunchHostFunc
  24765. #undef cuGraphicsMapResources
  24766. #undef cuGraphicsUnmapResources
  24767. #undef cuStreamWriteValue32
  24768. #undef cuStreamWaitValue32
  24769. #undef cuStreamWriteValue64
  24770. #undef cuStreamWaitValue64
  24771. #undef cuStreamBatchMemOp
  24772. #undef cuStreamWriteValue32_v2
  24773. #undef cuStreamWaitValue32_v2
  24774. #undef cuStreamWriteValue64_v2
  24775. #undef cuStreamWaitValue64_v2
  24776. #undef cuStreamBatchMemOp_v2
  24777. #undef cuMemPrefetchAsync
  24778. #undef cuMemPrefetchAsync_v2
  24779. #undef cuLaunchCooperativeKernel
  24780. #undef cuSignalExternalSemaphoresAsync
  24781. #undef cuWaitExternalSemaphoresAsync
  24782. #undef cuStreamBeginCapture
  24783. #undef cuStreamBeginCaptureToGraph
  24784. #undef cuStreamEndCapture
  24785. #undef cuStreamIsCapturing
  24786. #undef cuStreamGetCaptureInfo
  24787. #undef cuStreamGetCaptureInfo_v2
  24788. #undef cuStreamGetCaptureInfo_v3
  24789. #undef cuGraphInstantiateWithParams
  24790. #undef cuGraphExecUpdate
  24791. #undef cuGraphUpload
  24792. #undef cuGraphLaunch
  24793. #undef cuDevicePrimaryCtxRelease
  24794. #undef cuDevicePrimaryCtxReset
  24795. #undef cuDevicePrimaryCtxSetFlags
  24796. #undef cuIpcOpenMemHandle
  24797. #undef cuStreamCopyAttributes
  24798. #undef cuStreamSetAttribute
  24799. #undef cuStreamGetAttribute
  24800. #undef cuGraphInstantiate
  24801. #undef cuGraphAddKernelNode
  24802. #undef cuGraphKernelNodeGetParams
  24803. #undef cuGraphKernelNodeSetParams
  24804. #undef cuGraphExecKernelNodeSetParams
  24805. #undef cuMemMapArrayAsync
  24806. #undef cuMemFreeAsync
  24807. #undef cuMemAllocAsync
  24808. #undef cuMemAllocFromPoolAsync
  24809. #undef cuStreamUpdateCaptureDependencies
  24810. #undef cuStreamUpdateCaptureDependencies_v2
  24811. #undef cuGetProcAddress
  24812. #undef cuStreamGetCtx_v2
  24813. #undef cuMemBatchDecompressAsync
  24814. CUresult CUDAAPI cuMemHostRegister(void *p, size_t bytesize, unsigned int Flags);
  24815. CUresult CUDAAPI cuGraphicsResourceSetMapFlags(CUgraphicsResource resource, unsigned int flags);
  24816. CUresult CUDAAPI cuLinkCreate(unsigned int numOptions, CUjit_option *options, void **optionValues, CUlinkState *stateOut);
  24817. CUresult CUDAAPI cuLinkAddData(CUlinkState state, CUjitInputType type, void *data, size_t size, const char *name,
  24818. unsigned int numOptions, CUjit_option *options, void **optionValues);
  24819. CUresult CUDAAPI cuLinkAddFile(CUlinkState state, CUjitInputType type, const char *path,
  24820. unsigned int numOptions, CUjit_option *options, void **optionValues);
  24821. CUresult CUDAAPI cuTexRefSetAddress2D_v2(CUtexref hTexRef, const CUDA_ARRAY_DESCRIPTOR *desc, CUdeviceptr dptr, size_t Pitch);
  24822. typedef unsigned int CUdeviceptr_v1;
  24823. typedef struct CUDA_MEMCPY2D_v1_st
  24824. {
  24825. unsigned int srcXInBytes; /**< Source X in bytes */
  24826. unsigned int srcY; /**< Source Y */
  24827. CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */
  24828. const void *srcHost; /**< Source host pointer */
  24829. CUdeviceptr_v1 srcDevice; /**< Source device pointer */
  24830. CUarray srcArray; /**< Source array reference */
  24831. unsigned int srcPitch; /**< Source pitch (ignored when src is array) */
  24832. unsigned int dstXInBytes; /**< Destination X in bytes */
  24833. unsigned int dstY; /**< Destination Y */
  24834. CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */
  24835. void *dstHost; /**< Destination host pointer */
  24836. CUdeviceptr_v1 dstDevice; /**< Destination device pointer */
  24837. CUarray dstArray; /**< Destination array reference */
  24838. unsigned int dstPitch; /**< Destination pitch (ignored when dst is array) */
  24839. unsigned int WidthInBytes; /**< Width of 2D memory copy in bytes */
  24840. unsigned int Height; /**< Height of 2D memory copy */
  24841. } CUDA_MEMCPY2D_v1;
  24842. typedef struct CUDA_MEMCPY3D_v1_st
  24843. {
  24844. unsigned int srcXInBytes; /**< Source X in bytes */
  24845. unsigned int srcY; /**< Source Y */
  24846. unsigned int srcZ; /**< Source Z */
  24847. unsigned int srcLOD; /**< Source LOD */
  24848. CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */
  24849. const void *srcHost; /**< Source host pointer */
  24850. CUdeviceptr_v1 srcDevice; /**< Source device pointer */
  24851. CUarray srcArray; /**< Source array reference */
  24852. void *reserved0; /**< Must be NULL */
  24853. unsigned int srcPitch; /**< Source pitch (ignored when src is array) */
  24854. unsigned int srcHeight; /**< Source height (ignored when src is array; may be 0 if Depth==1) */
  24855. unsigned int dstXInBytes; /**< Destination X in bytes */
  24856. unsigned int dstY; /**< Destination Y */
  24857. unsigned int dstZ; /**< Destination Z */
  24858. unsigned int dstLOD; /**< Destination LOD */
  24859. CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */
  24860. void *dstHost; /**< Destination host pointer */
  24861. CUdeviceptr_v1 dstDevice; /**< Destination device pointer */
  24862. CUarray dstArray; /**< Destination array reference */
  24863. void *reserved1; /**< Must be NULL */
  24864. unsigned int dstPitch; /**< Destination pitch (ignored when dst is array) */
  24865. unsigned int dstHeight; /**< Destination height (ignored when dst is array; may be 0 if Depth==1) */
  24866. unsigned int WidthInBytes; /**< Width of 3D memory copy in bytes */
  24867. unsigned int Height; /**< Height of 3D memory copy */
  24868. unsigned int Depth; /**< Depth of 3D memory copy */
  24869. } CUDA_MEMCPY3D_v1;
  24870. typedef struct CUDA_ARRAY_DESCRIPTOR_v1_st
  24871. {
  24872. unsigned int Width; /**< Width of array */
  24873. unsigned int Height; /**< Height of array */
  24874. CUarray_format Format; /**< Array format */
  24875. unsigned int NumChannels; /**< Channels per array element */
  24876. } CUDA_ARRAY_DESCRIPTOR_v1;
  24877. typedef struct CUDA_ARRAY3D_DESCRIPTOR_v1_st
  24878. {
  24879. unsigned int Width; /**< Width of 3D array */
  24880. unsigned int Height; /**< Height of 3D array */
  24881. unsigned int Depth; /**< Depth of 3D array */
  24882. CUarray_format Format; /**< Array format */
  24883. unsigned int NumChannels; /**< Channels per array element */
  24884. unsigned int Flags; /**< Flags */
  24885. } CUDA_ARRAY3D_DESCRIPTOR_v1;
  24886. CUresult CUDAAPI cuDeviceTotalMem(unsigned int *bytes, CUdevice dev);
  24887. CUresult CUDAAPI cuCtxCreate(CUcontext *pctx, unsigned int flags, CUdevice dev);
  24888. CUresult CUDAAPI cuModuleGetGlobal(CUdeviceptr_v1 *dptr, unsigned int *bytes, CUmodule hmod, const char *name);
  24889. CUresult CUDAAPI cuMemGetInfo(unsigned int *free, unsigned int *total);
  24890. CUresult CUDAAPI cuMemAlloc(CUdeviceptr_v1 *dptr, unsigned int bytesize);
  24891. CUresult CUDAAPI cuMemAllocPitch(CUdeviceptr_v1 *dptr, unsigned int *pPitch, unsigned int WidthInBytes, unsigned int Height, unsigned int ElementSizeBytes);
  24892. CUresult CUDAAPI cuMemFree(CUdeviceptr_v1 dptr);
  24893. CUresult CUDAAPI cuMemGetAddressRange(CUdeviceptr_v1 *pbase, unsigned int *psize, CUdeviceptr_v1 dptr);
  24894. CUresult CUDAAPI cuMemAllocHost(void **pp, unsigned int bytesize);
  24895. CUresult CUDAAPI cuMemHostGetDevicePointer(CUdeviceptr_v1 *pdptr, void *p, unsigned int Flags);
  24896. CUresult CUDAAPI cuMemcpyHtoD(CUdeviceptr_v1 dstDevice, const void *srcHost, unsigned int ByteCount);
  24897. CUresult CUDAAPI cuMemcpyDtoH(void *dstHost, CUdeviceptr_v1 srcDevice, unsigned int ByteCount);
  24898. CUresult CUDAAPI cuMemcpyDtoD(CUdeviceptr_v1 dstDevice, CUdeviceptr_v1 srcDevice, unsigned int ByteCount);
  24899. CUresult CUDAAPI cuMemcpyDtoA(CUarray dstArray, unsigned int dstOffset, CUdeviceptr_v1 srcDevice, unsigned int ByteCount);
  24900. CUresult CUDAAPI cuMemcpyAtoD(CUdeviceptr_v1 dstDevice, CUarray srcArray, unsigned int srcOffset, unsigned int ByteCount);
  24901. CUresult CUDAAPI cuMemcpyHtoA(CUarray dstArray, unsigned int dstOffset, const void *srcHost, unsigned int ByteCount);
  24902. CUresult CUDAAPI cuMemcpyAtoH(void *dstHost, CUarray srcArray, unsigned int srcOffset, unsigned int ByteCount);
  24903. CUresult CUDAAPI cuMemcpyAtoA(CUarray dstArray, unsigned int dstOffset, CUarray srcArray, unsigned int srcOffset, unsigned int ByteCount);
  24904. CUresult CUDAAPI cuMemcpyHtoAAsync(CUarray dstArray, unsigned int dstOffset, const void *srcHost, unsigned int ByteCount, CUstream hStream);
  24905. CUresult CUDAAPI cuMemcpyAtoHAsync(void *dstHost, CUarray srcArray, unsigned int srcOffset, unsigned int ByteCount, CUstream hStream);
  24906. CUresult CUDAAPI cuMemcpy2D(const CUDA_MEMCPY2D_v1 *pCopy);
  24907. CUresult CUDAAPI cuMemcpy2DUnaligned(const CUDA_MEMCPY2D_v1 *pCopy);
  24908. CUresult CUDAAPI cuMemcpy3D(const CUDA_MEMCPY3D_v1 *pCopy);
  24909. CUresult CUDAAPI cuMemcpyHtoDAsync(CUdeviceptr_v1 dstDevice, const void *srcHost, unsigned int ByteCount, CUstream hStream);
  24910. CUresult CUDAAPI cuMemcpyDtoHAsync(void *dstHost, CUdeviceptr_v1 srcDevice, unsigned int ByteCount, CUstream hStream);
  24911. CUresult CUDAAPI cuMemcpyDtoDAsync(CUdeviceptr_v1 dstDevice, CUdeviceptr_v1 srcDevice, unsigned int ByteCount, CUstream hStream);
  24912. CUresult CUDAAPI cuMemcpy2DAsync(const CUDA_MEMCPY2D_v1 *pCopy, CUstream hStream);
  24913. CUresult CUDAAPI cuMemcpy3DAsync(const CUDA_MEMCPY3D_v1 *pCopy, CUstream hStream);
  24914. CUresult CUDAAPI cuMemsetD8(CUdeviceptr_v1 dstDevice, unsigned char uc, unsigned int N);
  24915. CUresult CUDAAPI cuMemsetD16(CUdeviceptr_v1 dstDevice, unsigned short us, unsigned int N);
  24916. CUresult CUDAAPI cuMemsetD32(CUdeviceptr_v1 dstDevice, unsigned int ui, unsigned int N);
  24917. CUresult CUDAAPI cuMemsetD2D8(CUdeviceptr_v1 dstDevice, unsigned int dstPitch, unsigned char uc, unsigned int Width, unsigned int Height);
  24918. CUresult CUDAAPI cuMemsetD2D16(CUdeviceptr_v1 dstDevice, unsigned int dstPitch, unsigned short us, unsigned int Width, unsigned int Height);
  24919. CUresult CUDAAPI cuMemsetD2D32(CUdeviceptr_v1 dstDevice, unsigned int dstPitch, unsigned int ui, unsigned int Width, unsigned int Height);
  24920. CUresult CUDAAPI cuArrayCreate(CUarray *pHandle, const CUDA_ARRAY_DESCRIPTOR_v1 *pAllocateArray);
  24921. CUresult CUDAAPI cuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR_v1 *pArrayDescriptor, CUarray hArray);
  24922. CUresult CUDAAPI cuArray3DCreate(CUarray *pHandle, const CUDA_ARRAY3D_DESCRIPTOR_v1 *pAllocateArray);
  24923. CUresult CUDAAPI cuArray3DGetDescriptor(CUDA_ARRAY3D_DESCRIPTOR_v1 *pArrayDescriptor, CUarray hArray);
  24924. CUresult CUDAAPI cuTexRefSetAddress(unsigned int *ByteOffset, CUtexref hTexRef, CUdeviceptr_v1 dptr, unsigned int bytes);
  24925. CUresult CUDAAPI cuTexRefSetAddress2D(CUtexref hTexRef, const CUDA_ARRAY_DESCRIPTOR_v1 *desc, CUdeviceptr_v1 dptr, unsigned int Pitch);
  24926. CUresult CUDAAPI cuTexRefGetAddress(CUdeviceptr_v1 *pdptr, CUtexref hTexRef);
  24927. CUresult CUDAAPI cuGraphicsResourceGetMappedPointer(CUdeviceptr_v1 *pDevPtr, unsigned int *pSize, CUgraphicsResource resource);
  24928. CUresult CUDAAPI cuCtxDestroy(CUcontext ctx);
  24929. CUresult CUDAAPI cuCtxPopCurrent(CUcontext *pctx);
  24930. CUresult CUDAAPI cuCtxPushCurrent(CUcontext ctx);
  24931. CUresult CUDAAPI cuStreamDestroy(CUstream hStream);
  24932. CUresult CUDAAPI cuEventDestroy(CUevent hEvent);
  24933. CUresult CUDAAPI cuDevicePrimaryCtxRelease(CUdevice dev);
  24934. CUresult CUDAAPI cuDevicePrimaryCtxReset(CUdevice dev);
  24935. CUresult CUDAAPI cuDevicePrimaryCtxSetFlags(CUdevice dev, unsigned int flags);
  24936. CUresult CUDAAPI cuMemcpyHtoD_v2(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount);
  24937. CUresult CUDAAPI cuMemcpyDtoH_v2(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount);
  24938. CUresult CUDAAPI cuMemcpyDtoD_v2(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount);
  24939. CUresult CUDAAPI cuMemcpyDtoA_v2(CUarray dstArray, size_t dstOffset, CUdeviceptr srcDevice, size_t ByteCount);
  24940. CUresult CUDAAPI cuMemcpyAtoD_v2(CUdeviceptr dstDevice, CUarray srcArray, size_t srcOffset, size_t ByteCount);
  24941. CUresult CUDAAPI cuMemcpyHtoA_v2(CUarray dstArray, size_t dstOffset, const void *srcHost, size_t ByteCount);
  24942. CUresult CUDAAPI cuMemcpyAtoH_v2(void *dstHost, CUarray srcArray, size_t srcOffset, size_t ByteCount);
  24943. CUresult CUDAAPI cuMemcpyAtoA_v2(CUarray dstArray, size_t dstOffset, CUarray srcArray, size_t srcOffset, size_t ByteCount);
  24944. CUresult CUDAAPI cuMemcpyHtoAAsync_v2(CUarray dstArray, size_t dstOffset, const void *srcHost, size_t ByteCount, CUstream hStream);
  24945. CUresult CUDAAPI cuMemcpyAtoHAsync_v2(void *dstHost, CUarray srcArray, size_t srcOffset, size_t ByteCount, CUstream hStream);
  24946. CUresult CUDAAPI cuMemcpy2D_v2(const CUDA_MEMCPY2D *pCopy);
  24947. CUresult CUDAAPI cuMemcpy2DUnaligned_v2(const CUDA_MEMCPY2D *pCopy);
  24948. CUresult CUDAAPI cuMemcpy3D_v2(const CUDA_MEMCPY3D *pCopy);
  24949. CUresult CUDAAPI cuMemcpyHtoDAsync_v2(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount, CUstream hStream);
  24950. CUresult CUDAAPI cuMemcpyDtoHAsync_v2(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream);
  24951. CUresult CUDAAPI cuMemcpyDtoDAsync_v2(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream);
  24952. CUresult CUDAAPI cuMemcpy2DAsync_v2(const CUDA_MEMCPY2D *pCopy, CUstream hStream);
  24953. CUresult CUDAAPI cuMemcpy3DAsync_v2(const CUDA_MEMCPY3D *pCopy, CUstream hStream);
  24954. CUresult CUDAAPI cuMemsetD8_v2(CUdeviceptr dstDevice, unsigned char uc, size_t N);
  24955. CUresult CUDAAPI cuMemsetD16_v2(CUdeviceptr dstDevice, unsigned short us, size_t N);
  24956. CUresult CUDAAPI cuMemsetD32_v2(CUdeviceptr dstDevice, unsigned int ui, size_t N);
  24957. CUresult CUDAAPI cuMemsetD2D8_v2(CUdeviceptr dstDevice, size_t dstPitch, unsigned char uc, size_t Width, size_t Height);
  24958. CUresult CUDAAPI cuMemsetD2D16_v2(CUdeviceptr dstDevice, size_t dstPitch, unsigned short us, size_t Width, size_t Height);
  24959. CUresult CUDAAPI cuMemsetD2D32_v2(CUdeviceptr dstDevice, size_t dstPitch, unsigned int ui, size_t Width, size_t Height);
  24960. CUresult CUDAAPI cuMemcpy(CUdeviceptr dst, CUdeviceptr src, size_t ByteCount);
  24961. CUresult CUDAAPI cuMemcpyAsync(CUdeviceptr dst, CUdeviceptr src, size_t ByteCount, CUstream hStream);
  24962. CUresult CUDAAPI cuMemcpyPeer(CUdeviceptr dstDevice, CUcontext dstContext, CUdeviceptr srcDevice, CUcontext srcContext, size_t ByteCount);
  24963. CUresult CUDAAPI cuMemcpyPeerAsync(CUdeviceptr dstDevice, CUcontext dstContext, CUdeviceptr srcDevice, CUcontext srcContext, size_t ByteCount, CUstream hStream);
  24964. CUresult CUDAAPI cuMemcpy3DPeer(const CUDA_MEMCPY3D_PEER *pCopy);
  24965. CUresult CUDAAPI cuMemcpy3DPeerAsync(const CUDA_MEMCPY3D_PEER *pCopy, CUstream hStream);
  24966. CUresult CUDAAPI cuMemcpyBatchAsync(CUdeviceptr *dsts, CUdeviceptr *srcs, size_t *sizes, size_t count,
  24967. CUmemcpyAttributes *attrs, size_t *attrsIdxs, size_t numAttrs,
  24968. size_t *failIdx, CUstream hStream);
  24969. CUresult CUDAAPI cuMemcpy3DBatchAsync(size_t numOps, CUDA_MEMCPY3D_BATCH_OP *opList,
  24970. size_t *failIdx, unsigned long long flags, CUstream hStream);
  24971. CUresult CUDAAPI cuMemsetD8Async(CUdeviceptr dstDevice, unsigned char uc, size_t N, CUstream hStream);
  24972. CUresult CUDAAPI cuMemsetD16Async(CUdeviceptr dstDevice, unsigned short us, size_t N, CUstream hStream);
  24973. CUresult CUDAAPI cuMemsetD32Async(CUdeviceptr dstDevice, unsigned int ui, size_t N, CUstream hStream);
  24974. CUresult CUDAAPI cuMemsetD2D8Async(CUdeviceptr dstDevice, size_t dstPitch, unsigned char uc, size_t Width, size_t Height, CUstream hStream);
  24975. CUresult CUDAAPI cuMemsetD2D16Async(CUdeviceptr dstDevice, size_t dstPitch, unsigned short us, size_t Width, size_t Height, CUstream hStream);
  24976. CUresult CUDAAPI cuMemsetD2D32Async(CUdeviceptr dstDevice, size_t dstPitch, unsigned int ui, size_t Width, size_t Height, CUstream hStream);
  24977. CUresult CUDAAPI cuStreamGetPriority(CUstream hStream, int *priority);
  24978. CUresult CUDAAPI cuStreamGetId(CUstream hStream, unsigned long long *streamId);
  24979. CUresult CUDAAPI cuStreamGetFlags(CUstream hStream, unsigned int *flags);
  24980. CUresult CUDAAPI cuStreamGetDevice(CUstream hStream, CUdevice *device);
  24981. CUresult CUDAAPI cuStreamGetCtx(CUstream hStream, CUcontext *pctx);
  24982. CUresult CUDAAPI cuStreamGetCtx_v2(CUstream hStream, CUcontext *pCtx, CUgreenCtx *pGreenCtx);
  24983. CUresult CUDAAPI cuStreamWaitEvent(CUstream hStream, CUevent hEvent, unsigned int Flags);
  24984. CUresult CUDAAPI cuStreamAddCallback(CUstream hStream, CUstreamCallback callback, void *userData, unsigned int flags);
  24985. CUresult CUDAAPI cuStreamAttachMemAsync(CUstream hStream, CUdeviceptr dptr, size_t length, unsigned int flags);
  24986. CUresult CUDAAPI cuStreamQuery(CUstream hStream);
  24987. CUresult CUDAAPI cuStreamSynchronize(CUstream hStream);
  24988. CUresult CUDAAPI cuEventRecord(CUevent hEvent, CUstream hStream);
  24989. CUresult CUDAAPI cuEventRecordWithFlags(CUevent hEvent, CUstream hStream, unsigned int flags);
  24990. CUresult CUDAAPI cuLaunchKernel(CUfunction f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, CUstream hStream, void **kernelParams, void **extra);
  24991. CUresult CUDAAPI cuLaunchKernelEx(const CUlaunchConfig *config, CUfunction f, void **kernelParams, void **extra);
  24992. CUresult CUDAAPI cuLaunchHostFunc(CUstream hStream, CUhostFn fn, void *userData);
  24993. CUresult CUDAAPI cuGraphicsMapResources(unsigned int count, CUgraphicsResource *resources, CUstream hStream);
  24994. CUresult CUDAAPI cuGraphicsUnmapResources(unsigned int count, CUgraphicsResource *resources, CUstream hStream);
  24995. CUresult CUDAAPI cuStreamWriteValue32(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
  24996. CUresult CUDAAPI cuStreamWaitValue32(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
  24997. CUresult CUDAAPI cuStreamWriteValue64(CUstream stream, CUdeviceptr addr, cuuint64_t value, unsigned int flags);
  24998. CUresult CUDAAPI cuStreamWaitValue64(CUstream stream, CUdeviceptr addr, cuuint64_t value, unsigned int flags);
  24999. CUresult CUDAAPI cuStreamBatchMemOp(CUstream stream, unsigned int count, CUstreamBatchMemOpParams *paramArray, unsigned int flags);
  25000. CUresult CUDAAPI cuStreamWriteValue32_ptsz(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
  25001. CUresult CUDAAPI cuStreamWaitValue32_ptsz(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
  25002. CUresult CUDAAPI cuStreamWriteValue64_ptsz(CUstream stream, CUdeviceptr addr, cuuint64_t value, unsigned int flags);
  25003. CUresult CUDAAPI cuStreamWaitValue64_ptsz(CUstream stream, CUdeviceptr addr, cuuint64_t value, unsigned int flags);
  25004. CUresult CUDAAPI cuStreamBatchMemOp_ptsz(CUstream stream, unsigned int count, CUstreamBatchMemOpParams *paramArray, unsigned int flags);
  25005. CUresult CUDAAPI cuStreamWriteValue32_v2(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
  25006. CUresult CUDAAPI cuStreamWaitValue32_v2(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags);
  25007. CUresult CUDAAPI cuStreamWriteValue64_v2(CUstream stream, CUdeviceptr addr, cuuint64_t value, unsigned int flags);
  25008. CUresult CUDAAPI cuStreamWaitValue64_v2(CUstream stream, CUdeviceptr addr, cuuint64_t value, unsigned int flags);
  25009. CUresult CUDAAPI cuStreamBatchMemOp_v2(CUstream stream, unsigned int count, CUstreamBatchMemOpParams *paramArray, unsigned int flags);
  25010. CUresult CUDAAPI cuMemPrefetchAsync(CUdeviceptr devPtr, size_t count, CUdevice dstDevice, CUstream hStream);
  25011. CUresult CUDAAPI cuMemPrefetchAsync_v2(CUdeviceptr devPtr, size_t count, CUmemLocation location, unsigned int flags, CUstream hStream);
  25012. CUresult CUDAAPI cuLaunchCooperativeKernel(CUfunction f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, CUstream hStream, void **kernelParams);
  25013. CUresult CUDAAPI cuSignalExternalSemaphoresAsync(const CUexternalSemaphore *extSemArray, const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS *paramsArray, unsigned int numExtSems, CUstream stream);
  25014. CUresult CUDAAPI cuWaitExternalSemaphoresAsync(const CUexternalSemaphore *extSemArray, const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS *paramsArray, unsigned int numExtSems, CUstream stream);
  25015. CUresult CUDAAPI cuStreamBeginCapture(CUstream hStream);
  25016. CUresult CUDAAPI cuStreamBeginCapture_ptsz(CUstream hStream);
  25017. CUresult CUDAAPI cuStreamBeginCapture_v2(CUstream hStream, CUstreamCaptureMode mode);
  25018. CUresult CUDAAPI cuStreamBeginCaptureToGraph(CUstream hStream, CUgraph hGraph, const CUgraphNode *dependencies, const CUgraphEdgeData *dependencyData, size_t numDependencies, CUstreamCaptureMode mode);
  25019. CUresult CUDAAPI cuStreamEndCapture(CUstream hStream, CUgraph *phGraph);
  25020. CUresult CUDAAPI cuStreamIsCapturing(CUstream hStream, CUstreamCaptureStatus *captureStatus);
  25021. CUresult CUDAAPI cuStreamGetCaptureInfo(CUstream hStream, CUstreamCaptureStatus *captureStatus_out, cuuint64_t *id_out);
  25022. CUresult CUDAAPI cuStreamGetCaptureInfo_ptsz(CUstream hStream, CUstreamCaptureStatus *captureStatus_out, cuuint64_t *id_out);
  25023. CUresult CUDAAPI cuStreamGetCaptureInfo_v2(CUstream hStream, CUstreamCaptureStatus *captureStatus_out, cuuint64_t *id_out, CUgraph *graph_out, const CUgraphNode **dependencies_out, size_t *numDependencies_out);
  25024. CUresult CUDAAPI cuStreamGetCaptureInfo_v3(CUstream hStream, CUstreamCaptureStatus *captureStatus_out, cuuint64_t *id_out, CUgraph *graph_out, const CUgraphNode **dependencies_out, const CUgraphEdgeData **edgeData_out, size_t *numDependencies_out);
  25025. CUresult CUDAAPI cuGraphAddKernelNode(CUgraphNode *phGraphNode, CUgraph hGraph, const CUgraphNode *dependencies, size_t numDependencies, const CUDA_KERNEL_NODE_PARAMS_v1 *nodeParams);
  25026. CUresult CUDAAPI cuGraphKernelNodeGetParams(CUgraphNode hNode, CUDA_KERNEL_NODE_PARAMS_v1 *nodeParams);
  25027. CUresult CUDAAPI cuGraphKernelNodeSetParams(CUgraphNode hNode, const CUDA_KERNEL_NODE_PARAMS_v1 *nodeParams);
  25028. CUresult CUDAAPI cuGraphExecKernelNodeSetParams(CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_KERNEL_NODE_PARAMS_v1 *nodeParams);
  25029. CUresult CUDAAPI cuGraphInstantiateWithParams(CUgraphExec *phGraphExec, CUgraph hGraph, CUDA_GRAPH_INSTANTIATE_PARAMS *instantiateParams);
  25030. CUresult CUDAAPI cuGraphExecUpdate(CUgraphExec hGraphExec, CUgraph hGraph, CUgraphNode *hErrorNode_out, CUgraphExecUpdateResult *updateResult_out);
  25031. CUresult CUDAAPI cuGraphUpload(CUgraphExec hGraph, CUstream hStream);
  25032. CUresult CUDAAPI cuGraphLaunch(CUgraphExec hGraph, CUstream hStream);
  25033. CUresult CUDAAPI cuStreamCopyAttributes(CUstream dstStream, CUstream srcStream);
  25034. CUresult CUDAAPI cuStreamGetAttribute(CUstream hStream, CUstreamAttrID attr, CUstreamAttrValue *value);
  25035. CUresult CUDAAPI cuStreamSetAttribute(CUstream hStream, CUstreamAttrID attr, const CUstreamAttrValue *param);
  25036. CUresult CUDAAPI cuIpcOpenMemHandle(CUdeviceptr *pdptr, CUipcMemHandle handle, unsigned int Flags);
  25037. CUresult CUDAAPI cuGraphInstantiate(CUgraphExec *phGraphExec, CUgraph hGraph, CUgraphNode *phErrorNode, char *logBuffer, size_t bufferSize);
  25038. CUresult CUDAAPI cuGraphInstantiate_v2(CUgraphExec *phGraphExec, CUgraph hGraph, CUgraphNode *phErrorNode, char *logBuffer, size_t bufferSize);
  25039. CUresult CUDAAPI cuMemMapArrayAsync(CUarrayMapInfo *mapInfoList, unsigned int count, CUstream hStream);
  25040. CUresult CUDAAPI cuMemFreeAsync(CUdeviceptr dptr, CUstream hStream);
  25041. CUresult CUDAAPI cuMemAllocAsync(CUdeviceptr *dptr, size_t bytesize, CUstream hStream);
  25042. CUresult CUDAAPI cuMemAllocFromPoolAsync(CUdeviceptr *dptr, size_t bytesize, CUmemoryPool pool, CUstream hStream);
  25043. CUresult CUDAAPI cuStreamUpdateCaptureDependencies(CUstream hStream, CUgraphNode *dependencies, size_t numDependencies, unsigned int flags);
  25044. CUresult CUDAAPI cuStreamUpdateCaptureDependencies_v2(CUstream hStream, CUgraphNode *dependencies, const CUgraphEdgeData *dependencyData, size_t numDependencies, unsigned int flags);
  25045. CUresult CUDAAPI cuMemBatchDecompressAsync(
  25046. CUmemDecompressParams *paramsArray,
  25047. size_t count,
  25048. unsigned int flags,
  25049. size_t *errorIndex,
  25050. CUstream stream
  25051. );
  25052. CUresult CUDAAPI cuGetProcAddress(const char *symbol, void **pfn, int cudaVersion, cuuint64_t flags);
  25053. #elif defined(__CUDA_API_PER_THREAD_DEFAULT_STREAM)
  25054. static inline CUresult cuGetProcAddress_v2_ptsz(const char *symbol, void **funcPtr, int driverVersion, cuuint64_t flags, CUdriverProcAddressQueryResult *symbolStatus) {
  25055. const int procAddressMask = (CU_GET_PROC_ADDRESS_LEGACY_STREAM|
  25056. CU_GET_PROC_ADDRESS_PER_THREAD_DEFAULT_STREAM);
  25057. if ((flags & procAddressMask) == 0) {
  25058. flags |= CU_GET_PROC_ADDRESS_PER_THREAD_DEFAULT_STREAM;
  25059. }
  25060. return cuGetProcAddress_v2(symbol, funcPtr, driverVersion, flags, symbolStatus);
  25061. }
  25062. #define cuGetProcAddress_v2 cuGetProcAddress_v2_ptsz
  25063. #endif
  25064. /**
  25065. * \defgroup CUDA_CHECKPOINT CUDA Checkpointing
  25066. *
  25067. * ___MANBRIEF___ CUDA checkpoint and restore functionality of the low-level
  25068. * CUDA driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
  25069. *
  25070. * This sections describes the checkpoint and restore functions of the low-level
  25071. * CUDA driver application programming interface.
  25072. *
  25073. * The CUDA checkpoint and restore API's provide a way to save and restore GPU
  25074. * state for full process checkpoints when used with CPU side process
  25075. * checkpointing solutions. They can also be used to pause GPU work and suspend
  25076. * a CUDA process to allow other applications to make use of GPU resources.
  25077. *
  25078. * Checkpoint and restore capabilities are currently restricted to Linux.
  25079. *
  25080. * @{
  25081. */
  25082. /**
  25083. * \brief Returns the restore thread ID for a CUDA process
  25084. *
  25085. * Returns in \p *tid the thread ID of the CUDA restore thread for the process
  25086. * specified by \p pid.
  25087. *
  25088. * \param pid - The process ID of the CUDA process
  25089. * \param tid - Returned restore thread ID
  25090. *
  25091. * \return
  25092. * ::CUDA_SUCCESS
  25093. * ::CUDA_ERROR_INVALID_VALUE
  25094. * ::CUDA_ERROR_NOT_INITIALIZED
  25095. * ::CUDA_ERROR_NOT_SUPPORTED
  25096. */
  25097. CUresult CUDAAPI cuCheckpointProcessGetRestoreThreadId(int pid, int *tid);
  25098. /**
  25099. * \brief Returns the process state of a CUDA process
  25100. *
  25101. * Returns in \p *state the current state of the CUDA process specified by \p pid.
  25102. *
  25103. * \param pid - The process ID of the CUDA process
  25104. * \param state - Returned CUDA process state
  25105. *
  25106. * \return
  25107. * ::CUDA_SUCCESS
  25108. * ::CUDA_ERROR_INVALID_VALUE
  25109. * ::CUDA_ERROR_NOT_INITIALIZED
  25110. * ::CUDA_ERROR_NOT_SUPPORTED
  25111. */
  25112. CUresult CUDAAPI cuCheckpointProcessGetState(int pid, CUprocessState *state);
  25113. /**
  25114. * \brief Lock a running CUDA process
  25115. *
  25116. * Lock the CUDA process specified by \p pid which will block further CUDA API
  25117. * calls. Process must be in the RUNNING state in order to lock.
  25118. *
  25119. * Upon successful return the process will be in the LOCKED state.
  25120. *
  25121. * If timeoutMs is specified and the timeout is reached the process will be left
  25122. * in the RUNNING state upon return.
  25123. *
  25124. * \param pid - The process ID of the CUDA process
  25125. * \param args - Optional lock operation arguments
  25126. *
  25127. * \return
  25128. * ::CUDA_SUCCESS
  25129. * ::CUDA_ERROR_INVALID_VALUE
  25130. * ::CUDA_ERROR_NOT_INITIALIZED
  25131. * ::CUDA_ERROR_ILLEGAL_STATE
  25132. * ::CUDA_ERROR_NOT_SUPPORTED
  25133. * ::CUDA_ERROR_NOT_READY
  25134. */
  25135. CUresult CUDAAPI cuCheckpointProcessLock(int pid, CUcheckpointLockArgs *args);
  25136. /**
  25137. * \brief Checkpoint a CUDA process's GPU memory contents
  25138. *
  25139. * Checkpoints a CUDA process specified by \p pid that is in the LOCKED
  25140. * state. The GPU memory contents will be brought into host memory and all
  25141. * underlying references will be released. Process must be in the LOCKED state
  25142. * to checkpoint.
  25143. *
  25144. * Upon successful return the process will be in the CHECKPOINTED state.
  25145. *
  25146. * \param pid - The process ID of the CUDA process
  25147. * \param args - Optional checkpoint operation arguments
  25148. *
  25149. * \return
  25150. * ::CUDA_SUCCESS
  25151. * ::CUDA_ERROR_INVALID_VALUE
  25152. * ::CUDA_ERROR_NOT_INITIALIZED
  25153. * ::CUDA_ERROR_ILLEGAL_STATE
  25154. * ::CUDA_ERROR_NOT_SUPPORTED
  25155. */
  25156. CUresult CUDAAPI cuCheckpointProcessCheckpoint(int pid, CUcheckpointCheckpointArgs *args);
  25157. /**
  25158. * \brief Restore a CUDA process's GPU memory contents from its last checkpoint
  25159. *
  25160. * Restores a CUDA process specified by \p pid from its last checkpoint. Process
  25161. * must be in the CHECKPOINTED state to restore.
  25162. *
  25163. * Upon successful return the process will be in the LOCKED state.
  25164. *
  25165. * CUDA process restore requires persistence mode to be enabled or ::cuInit to
  25166. * have been called before execution.
  25167. *
  25168. * \param pid - The process ID of the CUDA process
  25169. * \param args - Optional restore operation arguments
  25170. *
  25171. * \return
  25172. * ::CUDA_SUCCESS
  25173. * ::CUDA_ERROR_INVALID_VALUE
  25174. * ::CUDA_ERROR_NOT_INITIALIZED
  25175. * ::CUDA_ERROR_ILLEGAL_STATE
  25176. * ::CUDA_ERROR_NOT_SUPPORTED
  25177. *
  25178. * \sa
  25179. * ::cuInit
  25180. */
  25181. CUresult CUDAAPI cuCheckpointProcessRestore(int pid, CUcheckpointRestoreArgs *args);
  25182. /**
  25183. * \brief Unlock a CUDA process to allow CUDA API calls
  25184. *
  25185. * Unlocks a process specified by \p pid allowing it to resume making CUDA API
  25186. * calls. Process must be in the LOCKED state.
  25187. *
  25188. * Upon successful return the process will be in the RUNNING state.
  25189. *
  25190. * \param pid - The process ID of the CUDA process
  25191. * \param args - Optional unlock operation arguments
  25192. *
  25193. * \return
  25194. * ::CUDA_SUCCESS
  25195. * ::CUDA_ERROR_INVALID_VALUE
  25196. * ::CUDA_ERROR_NOT_INITIALIZED
  25197. * ::CUDA_ERROR_ILLEGAL_STATE
  25198. * ::CUDA_ERROR_NOT_SUPPORTED
  25199. */
  25200. CUresult CUDAAPI cuCheckpointProcessUnlock(int pid, CUcheckpointUnlockArgs *args);
  25201. /** @} */ /* End CUDA_CHECKPOINT */
  25202. #ifdef __cplusplus
  25203. }
  25204. #endif
  25205. #if defined(__GNUC__)
  25206. #if defined(__CUDA_API_PUSH_VISIBILITY_DEFAULT)
  25207. #pragma GCC visibility pop
  25208. #endif
  25209. #endif
  25210. #undef __CUDA_DEPRECATED
  25211. #endif /* __cuda_cuda_h__ */