1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004
|
/*
* Copyright 2018-2023 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO LICENSEE:
*
* This source code and/or documentation ("Licensed Deliverables") are
* subject to NVIDIA intellectual property rights under U.S. and
* international Copyright laws.
*
* These Licensed Deliverables contained herein is PROPRIETARY and
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
* conditions of a form of NVIDIA software license agreement by and
* between NVIDIA and Licensee ("License Agreement") or electronically
* accepted by Licensee. Notwithstanding any terms or conditions to
* the contrary in the License Agreement, reproduction or disclosure
* of the Licensed Deliverables to any third party without the express
* written consent of NVIDIA is prohibited.
*
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THESE LICENSED DELIVERABLES.
*
* U.S. Government End Users. These Licensed Deliverables are a
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
* 1995), consisting of "commercial computer software" and "commercial
* computer software documentation" as such terms are used in 48
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
* U.S. Government End Users acquire the Licensed Deliverables with
* only those rights set forth herein.
*
* Any use of the Licensed Deliverables in individual and commercial
* software must include, in the user documentation and internal
* comments to the code, the above Disclaimer and U.S. Government End
* Users Notice.
*/
#if !defined(__SANITIZER_CALLBACKS_H__)
#define __SANITIZER_CALLBACKS_H__
#include <sanitizer_patching.h>
#include <sanitizer_result.h>
#include <sanitizer_stream.h>
#include <cuda.h>
#include <stdint.h>
#ifndef SANITIZERAPI
#ifdef _WIN32
#define SANITIZERAPI __stdcall
#else
#define SANITIZERAPI
#endif
#endif
#if defined(__cplusplus)
extern "C" {
#endif
/**
* \defgroup SANITIZER_CALLBACK_API Sanitizer Callback API
* Functions, types, and enums that implement the Sanitizer Callback API.
* @{
*/
/**
* \addtogroup SANITIZER_CALLBACK_API
* @{
*/
/**
* \brief Callback domains.
*
* Callback domain. Each domain represents callback points for a group of
* related API functions or CUDA driver activity.
*/
typedef enum {
/**
* Invalid domain.
*/
SANITIZER_CB_DOMAIN_INVALID = 0,
/**
* Domain containing callback points for all driver API functions.
*/
SANITIZER_CB_DOMAIN_DRIVER_API = 1,
/**
* Domain containing callback points for all runtime API functions.
*/
SANITIZER_CB_DOMAIN_RUNTIME_API = 2,
/**
* Domain containing callback points for CUDA resource tracking.
*/
SANITIZER_CB_DOMAIN_RESOURCE = 3,
/**
* Domain containing callback points for CUDA synchronization.
*/
SANITIZER_CB_DOMAIN_SYNCHRONIZE = 4,
/**
* Domain containing callback points for CUDA grid launches.
*/
SANITIZER_CB_DOMAIN_LAUNCH = 5,
/**
* Domain containing callback points for CUDA memcpy operations.
*/
SANITIZER_CB_DOMAIN_MEMCPY = 6,
/**
* Domain containing callback points for CUDA memset operations.
*/
SANITIZER_CB_DOMAIN_MEMSET = 7,
/**
* Domain containing callback points for CUDA batch memop operations.
*/
SANITIZER_CB_DOMAIN_BATCH_MEMOP = 8,
/**
* Domain containing callback points for CUDA managed memory operations.
*/
SANITIZER_CB_DOMAIN_UVM = 9,
/**
* Domain containing callback points for CUDA graphs operations.
*/
SANITIZER_CB_DOMAIN_GRAPHS = 10,
/**
* Domain containing callback points for CUDA events.
*/
SANITIZER_CB_DOMAIN_EVENTS = 11,
/**
* Domain containing callback points for CUDA external memory.
*/
SANITIZER_CB_DOMAIN_EXTERNAL_MEMORY = 12,
SANITIZER_CB_DOMAIN_SIZE,
SANITIZER_CB_DOMAIN_FORCE_INT = 0x7fffffff
} Sanitizer_CallbackDomain;
/**
* \brief Specifies the point in an API call that a callback is issued.
*
* Specifies the point in an API that a callback is issued. This value is
* communicated to the callback function via \ref
* Sanitizer_CallbackData::CallbackSize.
*/
typedef enum {
/**
* This callback is at API entry.
*/
SANITIZER_API_ENTER = 0,
/**
* This callback is at API exit.
*/
SANITIZER_API_EXIT = 1,
SANITIZER_API_CBSITE_FORCE_INT = 0x7fffffff
} Sanitizer_ApiCallbackSite;
/**
* \brief Data passed into a runtime or driver API callback function.
*
* Data passed into a runtime or driver API callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The \p cbdata will
* be this type for \p domain equal to SANITIZER_CB_DOMAIN_DRIVER_API or
* SANITIZER_CB_DOMAIN_RUNTIME_API. The callback data is valid only within
* the invocation of the callback function that is passed the data. If
* you need to retain some data for use outside of the callback, you
* must make of a copy of that data. For example, if you make a shallow
* copy of Sanitizer_CallbackData within a callback, you cannot
* dereference \p functionParams outside of that callback to access
* the function parameters. \p functionName is an exception: the
* string pointed to by \p functionName is a global constant and so
* may be accessed outside of the callback.
*/
typedef struct {
/**
* Point in the runtime or driver function from where the callback
* was issued.
*/
Sanitizer_ApiCallbackSite callbackSite;
/**
* Name of the runtime or driver API function which issued the
* callback. This string is a global constant and so may be
* accessed outside of the callback.
*/
const char* functionName;
/**
* Pointer to the arguments passed to the runtime or driver API
* call. See generated_cuda_runtime_api_meta.h and
* generated_cuda_meta.h for structure definitions for the
* parameters for each runtime and driver API function.
*/
const void* functionParams;
/**
* Pointer to the return value of the runtime or driver API
* call. This field is only valid within the SANITIZER_API_EXIT
* callback. For a runtime API \p functionReturnValue points to a
* \p cudaError_t. For a driver API \p functionReturnValue points
* to a \p CUresult.
*/
const void* functionReturnValue;
/**
* Name of the symbol operated on by the runtime or driver API
* function which issued the callback. This entry is valid only for
* driver and runtime launch callbacks, where it returns the name of
* the kernel.
*/
const char* symbolName;
/**
* Driver context current to the thread, or null if no context is
* current. This value can change from the entry to exit callback
* of a runtime API function if the runtime initialized a context.
*/
CUcontext context;
} Sanitizer_CallbackData;
/**
* \brief Callback IDs for resource domain.
*
* Callback IDs for resource domain SANITIZER_CB_DOMAIN_RESOURCE. This
* value is communicated to the callback function via the \p cbid
* parameter.
*/
typedef enum {
/**
* Invalid resource callback ID.
*/
SANITIZER_CBID_RESOURCE_INVALID = 0,
/**
* Driver initialization is finished.
*/
SANITIZER_CBID_RESOURCE_INIT_FINISHED = 1,
/**
* A new context is about to be created.
*/
SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_STARTING = 2,
/**
* A new context was created.
*/
SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_FINISHED = 3,
/**
* A context is about to be destroyed.
*/
SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_STARTING = 4,
/**
* A context was destroyed.
*/
SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_FINISHED = 5,
/**
* A new stream was created.
*/
SANITIZER_CBID_RESOURCE_STREAM_CREATED = 6,
/**
* A stream is about to be destroyed.
*/
SANITIZER_CBID_RESOURCE_STREAM_DESTROY_STARTING = 7,
/**
* A stream was destroyed.
*/
SANITIZER_CBID_RESOURCE_STREAM_DESTROY_FINISHED = 8,
/**
* A module was loaded.
*/
SANITIZER_CBID_RESOURCE_MODULE_LOADED = 9,
/**
* A module is about to be unloaded.
*/
SANITIZER_CBID_RESOURCE_MODULE_UNLOAD_STARTING = 10,
/**
* Device memory was allocated.
*/
SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_ALLOC = 11,
/**
* Device memory was freed.
*/
SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_FREE = 12,
/**
* Pinned host memory was allocated.
*/
SANITIZER_CBID_RESOURCE_HOST_MEMORY_ALLOC = 13,
/**
* Pinned host memory was freed.
*/
SANITIZER_CBID_RESOURCE_HOST_MEMORY_FREE = 14,
/**
* Memory was allocated asynchronously.
*/
SANITIZER_CBID_RESOURCE_MEMORY_ALLOC_ASYNC = 15,
/**
* Memory was freed asynchronously.
*/
SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC = 16,
/**
* Memory freed asynchronously was released, only happens if a regular
* allocation (cudaMalloc) is free'd asynchronously (cudaFreeAsync).
*
* See CUDA runtime documentation for cudaFreeAsync
*/
SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC_DONE = 17,
/**
* A new mempool was created.
*/
SANITIZER_CBID_RESOURCE_MEMPOOL_CREATED = 18,
/**
* A mempool is about to be destroyed.
*/
SANITIZER_CBID_RESOURCE_MEMPOOL_DESTROYING = 19,
/**
* A mempool is now accessible from a peer device.
*/
SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_ENABLED = 20,
/**
* A mempool is no longer accessible from a peer device.
*/
SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_DISABLING = 21,
/**
* A CUDA array was created.
*/
SANITIZER_CBID_RESOURCE_ARRAY_CREATED = 22,
/**
* A CUDA array was destroyed.
*/
SANITIZER_CBID_RESOURCE_ARRAY_DESTROYED = 23,
/**
* CUDA functions were loaded lazily and are fully loaded.
*/
SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_LOADED = 24,
/**
* CUDA lazily loaded functions were patched.
*/
SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_PATCHED = 25,
/**
* The CUDA driver reserved a virtual address range.
*/
SANITIZER_CBID_RESOURCE_VIRTUAL_RESERVE = 26,
/**
* The CUDA driver released a virtual address range.
*/
SANITIZER_CBID_RESOURCE_VIRTUAL_RELEASE = 27,
/**
* A memory pool allocation was imported.
*/
SANITIZER_CBID_RESOURCE_MEMPOOL_IMPORT_POINTER = 28,
SANITIZER_CBID_RESOURCE_SIZE,
SANITIZER_CBID_RESOURCE_FORCE_INT = 0x7fffffff
} Sanitizer_CallbackIdResource;
/**
* \brief Data passed into a context resource callback function.
*
* Data passed into a context resource callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
* SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_STARTING,
* SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_FINISHED,
* SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_STARTING or
* SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_FINISHED.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
*/
typedef struct {
/**
* The context being created or destroyed.
*/
CUcontext context;
/**
* The device on which the context is being created or destroyed.
* This field is only valid for SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_*
* callbacks
*/
CUdevice device;
} Sanitizer_ResourceContextData;
/**
* \brief Data passed into a stream resource callback function.
*
* Data passed into a stream resource callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
* SANITIZER_CBID_RESOURCE_STREAM_CREATED,
* SANITIZER_CBID_RESOURCE_STREAM_DESTROY_STARTING or
* SANITIZER_CBID_RESOURCE_STREAM_DESTROY_FINISHED.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
*/
typedef struct {
/**
* The context containing the stream being created or
* destroyed.
*/
CUcontext context;
/**
* The stream being created or destroyed. This handle
* will be NULL for the STREAM_DESTROY_FINISHED cbid.
*/
CUstream stream;
/**
* Unique handle for the stream.
*/
Sanitizer_StreamHandle hStream;
} Sanitizer_ResourceStreamData;
/**
* \brief Data passed into a module resource callback function.
*
* Data passed into a module resource callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
* SANITIZER_CBID_RESOURCE_MODULE_LOADED or
* SANITIZER_CBID_RESOURCE_MODULE_UNLOAD_STARTING.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
*/
typedef struct {
/**
* The context containing the module being loaded or
* unloaded.
*/
CUcontext context;
/**
* The module being loaded or unloaded.
*/
CUmodule module;
/**
* The size of the cubin.
*/
size_t cubinSize;
/**
* Pointer to the associated cubin.
*/
const char* pCubin;
/**
* Library associated with the module.
*/
CUlibrary library;
} Sanitizer_ResourceModuleData;
/**
* \brief Flags describing a memory allocation.
*
* Flags describing a memory allocation. These values are to
* be used in order to interpret the value of
* \ref Sanitizer_ResourceMemoryData::flags
*/
typedef enum {
/**
* Empty flag.
*/
SANITIZER_MEMORY_FLAG_NONE = 0,
/**
* Specifies that the allocation is static scoped to a
* module.
*/
SANITIZER_MEMORY_FLAG_MODULE = 0x1,
/**
* Specifies that the allocation is managed memory.
*/
SANITIZER_MEMORY_FLAG_MANAGED = 0x2,
/**
* Species that the allocation accessible from the
* host.
*/
SANITIZER_MEMORY_FLAG_HOST_MAPPED = 0x4,
/**
* Specifies that the allocation is pinned on the host.
*/
SANITIZER_MEMORY_FLAG_HOST_PINNED = 0x8,
/**
* Specifies that the allocation is located on a peer GPU.
*/
SANITIZER_MEMORY_FLAG_PEER = 0x10,
/**
* Specifies that the allocation is located on a peer GPU
* supporting native atomics. This implies that
* SANITIZER_MEMORY_FLAG_PEER is set as well.
*/
SANITIZER_MEMORY_FLAG_PEER_ATOMIC = 0x20,
/**
* Specifies that the allocation is used by the
* Cooperative Groups runtime functions.
*/
SANITIZER_MEMORY_FLAG_CG_RUNTIME = 0x40,
/**
* Specifies that this is an allocation used for
* CUDA Dynamic Parallelism purposes.
*/
SANITIZER_MEMORY_FLAG_CNP = 0x80,
SANITIZER_MEMORY_FLAG_FORCE_INT = 0x7fffffff
} Sanitizer_ResourceMemoryFlags;
/**
* \brief Permissions for a memory allocation.
*
* Permissions for a memory allocation. These values
* are to be used in order to interpret the value of
* \ref Sanitizer_ResourceMemoryData::permissions
*/
typedef enum {
/**
* No permissions.
*/
SANITIZER_MEMORY_PERMISSION_NONE = 0,
/**
* Specifies that the allocation is readable.
*/
SANITIZER_MEMORY_PERMISSION_READ = 0x1,
/**
* Specifies that the allocation is writable.
*/
SANITIZER_MEMORY_PERMISSION_WRITE = 0x2,
/**
* Specifies that the allocation is readable/writable with atomic
* operations.
*/
SANITIZER_MEMORY_PERMISSION_ATOMIC = 0x4,
/**
* Specifies that the allocation has all permissions.
*/
SANITIZER_MEMORY_PERMISSION_ALL = 0x7,
SANITIZER_MEMORY_PERMISSION_FORCE_INT = 0x7fffffff
} Sanitizer_ResourceMemoryPermissions;
/**
* \brief Specifies the visibility of an allocation
*
* Specifies the visibility of an allocation. This is typically GLOBAL on
* allocations made via cudaMalloc, cudaHostAlloc and similar APIs. This can
* be GLOBAL or HOST for cudaMallocManaged allocations depending on the flags
* parameter. This can be changed after allocation time using cudaMemAttachSingle
* API (see SANITIZER_CBID_UVM_ATTACH_MEM for the corresponding callback).
*/
typedef enum {
/**
* Invalid memory visibility
*/
SANITIZER_MEMORY_VISIBILITY_INVALID = 0,
/**
* Memory can be accessed by any stream on any device
* (see cudaMemAttachGlobal)
*/
SANITIZER_MEMORY_VISIBILITY_GLOBAL = 1,
/**
* Memory cannot be accessed by any stream on any device
* (see cudaMemAttachHost)
*/
SANITIZER_MEMORY_VISIBILITY_HOST = 2,
/**
* Memory can only be accessed by a single stream on the associated device
* (see cudaMemAttachSingle)
*/
SANITIZER_MEMORY_VISIBILITY_STREAM = 3,
SANITIZER_MEMORY_VISIBILITY_FORCE_INT = 0x7fffffff
} Sanitizer_MemoryVisibility;
/**
* \brief Data passed into a memory resource callback function.
*
* Data passed into a memory resource callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
* SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_ALLOC,
* SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_FREE,
* SANITIZER_CBID_RESOURCE_HOST_MEMORY_ALLOC,
* SANITIZER_CBID_RESOURCE_HOST_MEMORY_FREE,
* SANITIZER_CBID_RESOURCE_MEMORY_ALLOC_ASYNC,
* SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC or
* SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC_DONE or
* SANITIZER_CBID_RESOURCE_MEMPOOL_IMPORT_POINTER.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
*/
typedef struct {
/**
* Address of the allocation being created or destroyed.
*/
uint64_t address;
/**
* Size of the allocation being created or destroyed.
*/
uint64_t size;
/**
* Context containing the allocation being created or
* destroyed. Can be NULL if the allocation is not attached to a
* context.
*/
CUcontext context;
/**
* Device where the allocation is being created.
* Available for all cbid with a driver version of 455 or newer.
*/
CUdevice device;
/**
* Public handle for the stream.
*/
CUstream stream;
/**
* Stream containing the allocation being created or
* destroyed. Can be NULL if the allocation is not attached to a
* stream.
*/
Sanitizer_StreamHandle hStream;
/**
* Memory pool containing the allocation being created or
* destroyed. Can be NULL if the allocation is not attached to a
* memory pool.
*/
CUmemoryPool memoryPool;
/**
* Allocation details: use Sanitizer_ResourceMemoryFlags
* to interpret this field.
*/
uint32_t flags;
/**
* Allocation permissions: use Sanitizer_ResourceMemoryPermissions
* to interpret this field.
*/
uint32_t permissions;
/**
* Visibility of the allocation.
*/
Sanitizer_MemoryVisibility visibility;
/**
* Source device of this allocation (different from device if
* SANITIZER_MEMORY_FLAG_PEER is set).
*/
CUdevice sourceDevice;
} Sanitizer_ResourceMemoryData;
/**
* \brief Data passed into a mempool resource callback function.
*
* Data passed into a mempool resource callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
* SANITIZER_CBID_RESOURCE_MEMPOOL_CREATED,
* SANITIZER_CBID_RESOURCE_MEMPOOL_DESTROYING,
* SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_ENABLED or
* SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_DISABLING.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
*/
typedef struct {
/**
* Memory pool being created or destroyed.
*/
CUmemoryPool memoryPool;
/**
* Device that owns the memory pool.
*/
CUdevice device;
/**
* Device that access type changed. Available if cbid is
* SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_ENABLED or
* SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_DISABLING.
*/
CUdevice peerDevice;
} Sanitizer_ResourceMempoolData;
/**
*
* \brief Data passed into a CUDA array callback function.
*
* Data passed into a CUDA array callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal tp
* SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
* SANITIZER_CBID_RESOURCE_ARRAY_CREATED or
* SANITIZER_CBID_RESOURCE_ARRAY_DESTROYED.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
*/
typedef struct {
/**
* The context containing the array being created or
* destroyed.
*/
CUcontext context;
/**
* The CUDA array being created or destroyed.
*/
CUarray hArray;
/**
* The CUDA array size.
*/
uint64_t width;
uint64_t height;
uint64_t depth;
} Sanitizer_ResourceArrayData;
/**
*
* \brief Data passed into a CUDA function callback function.
*
* Data passed into a CUDA function callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal tp
* SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
* SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_LOADED or
* SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_PATCHED.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
*/
typedef struct {
/**
* The context containing the functions.
*/
CUcontext context;
/**
* The module containing the functions.
*/
CUmodule module;
/**
* An array containing the functions.
*/
const CUfunction* functions;
/**
* The size of the function array.
*/
uint32_t numFunctions;
} Sanitizer_ResourceFunctionsLazyLoadedData;
/**
*
* \brief Data passed into a VA reservation callback function.
*
* Data passed into a VA reservation callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal tp
* SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
* SANITIZER_CBID_RESOURCE_VIRTUAL_RESERVE.
* or SANITIZER_CBID_RESOURCE_VIRTUAL_RELEASE.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
* Available with a driver version of 535 or newer.
*/
typedef struct {
/**
* Address of the VA range being reserved or released.
*/
uint64_t address;
/**
* Size of the VA range being reserved or released.
*/
uint64_t size;
} Sanitizer_ResourceVirtualRange;
/**
* \brief Callback IDs for synchronization domain.
*
* Callback IDs for resource domain
* SANITIZER_CB_DOMAIN_SYNCHRONIZE. This value is
* communicated to the callback function via the \p cbid
* parameter.
*/
typedef enum {
/**
* Invalid synchronize callback ID.
*/
SANITIZER_CBID_SYNCHRONIZE_INVALID = 0,
/**
* Stream synchronization has completed for a given stream.
*/
SANITIZER_CBID_SYNCHRONIZE_STREAM_SYNCHRONIZED = 1,
/**
* Context synchronization has completed for a given context.
*/
SANITIZER_CBID_SYNCHRONIZE_CONTEXT_SYNCHRONIZED = 2,
SANITIZER_CBID_SYNCHRONIZE_SIZE,
SANITIZER_CBID_SYNCHRONIZE_FORCE_INT = 0x7fffffff
} Sanitizer_CallackIdSync;
/**
* \brief Data passed into a synchronization callback function.
*
* Data passed into a synchronization callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_SYNCHRONIZE. The callback data is
* only valid within the invocation of the callback function
* that is passed the data. If you need to retain some data
* for use outside of the callback, you must make a copy of it.
*/
typedef struct {
/**
* For SANITIZER_CBID_SYNCHRONIZE_CONTEXT_SYNCHRONIZED, this
* is the context being synchronized. For
* SANITIZER_CBID_SYNCHRONIZE_STREAM_SYNCHRONIZED, this is
* the context of the stream being synchronized.
*/
CUcontext context;
/**
* This field is only valid for
* SANITIZER_CBID_SYNCHRONIZE_STREAM_SYNCHRONIZED. This is
* the stream being synchronized.
*/
CUstream stream;
/**
* Unique handle for the stream.
*/
Sanitizer_StreamHandle hStream;
} Sanitizer_SynchronizeData;
/**
* \brief Callback IDs for launch domain.
*
* Callback IDs for resource domain SANITIZER_CB_DOMAIN_LAUNCH.
* This value is communicated to the callback function via
* the \p cbid parameter.
*/
typedef enum {
/**
* Invalid launch callback ID.
*/
SANITIZER_CBID_LAUNCH_INVALID = 0,
/**
* A grid launch was initiated.
*/
SANITIZER_CBID_LAUNCH_BEGIN = 1,
/**
* A grid launch has completed syscalls setup.
*/
SANITIZER_CBID_LAUNCH_AFTER_SYSCALL_SETUP = 2,
/**
* The grid launch is complete.
*/
SANITIZER_CBID_LAUNCH_END = 3,
SANITIZER_CBID_LAUNCH_SIZE,
SANITIZER_CBID_LAUNCH_FORCE_INT = 0x7fffffff
} Sanitizer_CallbackIdLaunch;
/**
* \brief Data passed into a launch callback function.
*
* Data passed into a launch callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_LAUNCH. The callback data is
* only valid within the invocation of the callback function
* that is passed the data. If you need to retain some data
* for use outside of the callback, you must make a copy of it.
*/
typedef struct {
/**
* The context where the grid is launched. For graph node launches,
* this is the context in which the kernel will run.
*/
CUcontext context;
/**
* The stream where the grid is launched.
*/
CUstream stream;
/**
* Unique handle for the stream.
*/
Sanitizer_StreamHandle hStream;
/**
* The module containing the grid code.
*/
CUmodule module;
/**
* The function of the grid launch.
*/
CUfunction function;
/**
* The name of the launched function.
*/
const char *functionName;
/** @{
* Launch properties of the grid.
* These values are only valid for SANITIZER_CBID_LAUNCH_BEGIN and graph
* node launch callbacks
*/
uint32_t gridDim_x;
uint32_t gridDim_y;
uint32_t gridDim_z;
uint32_t blockDim_x;
uint32_t blockDim_y;
uint32_t blockDim_z;
uint32_t clusterDim_x;
uint32_t clusterDim_y;
uint32_t clusterDim_z;
/** @} */
/**
* Unique identifier of the grid launch.
* For graph node launches, this is only unique within the graphexec launch.
*/
uint64_t gridId;
/**
* Handle of the grid launch. This is only valid between the launch begin
* and end callbacks.
*/
Sanitizer_LaunchHandle hLaunch;
/**
* The device where the grid is launched
*/
CUdevice device;
/**
* Only valid for graph node launches. This is the context of the stream used
* in the graph launch API call.
*/
CUcontext apiContext;
/**
* Only valid for graph node launches. This is the stream used in the graph
* launch API call.
*/
CUstream apiStream;
/**
* Unique handle for the API stream.
*/
Sanitizer_StreamHandle hApiStream;
} Sanitizer_LaunchData;
/**
* \brief Callback IDs for memcpy domain.
*
* Callback IDs for resource domain SANITIZER_CB_DOMAIN_MEMCPY.
* This value is communicated to the callback function via
* the \p cbid parameter.
*/
typedef enum {
/**
* Invalid memcpy callback ID.
*/
SANITIZER_CBID_MEMCPY_INVALID = 0,
/**
* A memcpy operation was initiated.
*/
SANITIZER_CBID_MEMCPY_STARTING = 1,
SANITIZER_CBID_MEMCPY_SIZE,
SANITIZER_CBID_MEMCPY_FORCE_INT = 0x7fffffff
} Sanitizer_CallbackIdMemcpy;
/**
* \brief Memcpy direction.
*
* Indicates the direction of a memcpy, passed inside \p Sanitizer_Memcpydata.
*/
typedef enum {
/**
* Unknown memcpy direction
*/
SANITIZER_MEMCPY_DIRECTION_UNKNOWN = 0,
/**
* Memcpy from host to host.
*/
SANITIZER_MEMCPY_DIRECTION_HOST_TO_HOST = 1,
/**
* Memcpy from host to device.
*/
SANITIZER_MEMCPY_DIRECTION_HOST_TO_DEVICE = 2,
/**
* Memcpy from device to host.
*/
SANITIZER_MEMCPY_DIRECTION_DEVICE_TO_HOST = 3,
/**
* Memcpy from device to device.
*/
SANITIZER_MEMCPY_DIRECTION_DEVICE_TO_DEVICE = 4,
SANITIZER_MEMCPY_DIRECTION_SIZE,
SANITIZER_MEMCPY_DIRECTION_FORCE_INT = 0x7fffffff
} Sanitizer_MemcpyDirection;
/**
* \brief Data passed into a memcpy callback function.
*
* Data passed into a launch callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_MEMCPY. The callback data is
* only valid within the invocation of the callback function
* that is passed the data. If you need to retain some data
* for use outside of the callback, you must make a copy of it.
*/
typedef struct {
/**
* The context where the source allocation is located
*/
CUcontext srcContext;
/**
* The context where the destination allocation is located
*/
CUcontext dstContext;
/**
* The stream where the memcpy is executed on the source context
*/
CUstream srcStream;
/**
* Unique handle for the source context stream.
*/
Sanitizer_StreamHandle hSrcStream;
/**
* The stream where the memcpy is executed on the destination context
*/
CUstream dstStream;
/**
* Unique handle for the destination context stream.
*/
Sanitizer_StreamHandle hDstStream;
/**
* The source allocation address.
*/
uint64_t srcAddress;
/**
* The destination allocation address.
*/
uint64_t dstAddress;
/**
* Size of the transfer in bytes.
*/
uint64_t size;
/**
* Memcpy size configuration.
*/
uint64_t width;
uint64_t height;
uint64_t depth;
/**
* The source allocation pitch.
*/
uint64_t srcPitch;
/**
* The destination allocation pitch.
*/
uint64_t dstPitch;
/**
* Boolean value indicating if the transfer is
* asynchronous.
*/
uint32_t isAsync;
/**
* The direction of the transfer
*/
Sanitizer_MemcpyDirection direction;
/**
* The context on which the operation was requested
*/
CUcontext apiContext;
/**
* The stream on which the operation was requested
*/
CUstream apiStream;
/**
* Unique handle for the API stream.
*/
Sanitizer_StreamHandle hApiStream;
} Sanitizer_MemcpyData;
/**
* \brief Callback IDs for memset domain.
*
* Callback IDs for resource domain SANITIZER_CB_DOMAIN_MEMSET.
* This value is communicated to the callback function via
* the \p cbid parameter.
*/
typedef enum {
/**
* Invalid memset callback ID.
*/
SANITIZER_CBID_MEMSET_INVALID = 0,
/**
* A memset operation was initiated.
*/
SANITIZER_CBID_MEMSET_STARTING = 1,
SANITIZER_CBID_MEMSET_SIZE,
SANITIZER_CBID_MEMSET_FORCE_INT = 0x7fffffff
} Sanitizer_CallbackIdMemset;
/**
* \brief Data passed into a memset callback function.
*
* Data passed into a launch callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_MEMSET. The callback data is
* only valid within the invocation of the callback function
* that is passed the data. If you need to retain some data
* for use outside of the callback, you must make a copy of it.
*/
typedef struct {
/**
* The context where the allocation is located.
*/
CUcontext context;
/**
* The stream where the memset is executed.
*/
CUstream stream;
/**
* Unique handle for the stream.
*/
Sanitizer_StreamHandle hStream;
/**
* The address of the memset start.
*/
uint64_t address;
/**
* Memset size configuration.
*/
uint64_t width;
uint64_t height;
uint64_t pitch;
uint32_t elementSize;
/**
* Value to be written.
*/
uint32_t value;
/**
* Boolean value indicating if the transfer is
* asynchronous.
*/
uint32_t isAsync;
} Sanitizer_MemsetData;
/**
* \brief Callback IDs for batch memop domain.
*
* Callback IDs for resource domain
* SANITIZER_CB_DOMAIN_BATCH_MEMOP. This value is communicated
* to the callback function via the \p cbid parameter.
*/
typedef enum {
/**
* Invalid batch memop callback ID.
*/
SANITIZER_CBID_BATCH_MEMOP_INVALID = 0,
/**
* A batch memory operation was initiated.
*/
SANITIZER_CBID_BATCH_MEMOP_WRITE = 1,
SANITIZER_CBID_BATCH_MEMOP_SIZE,
SANITIZER_CBID_BATCH_MEMOP_FORCE_INT = 0x7fffffff
} Sanitizer_CallbackIdBatchMemop;
/**
* \brief Specifies the type of batch memory operation.
*
* Specifies the type of batch memory operation reported by a
* callback in domain SANITIZER_CB_DOMAIN_BATCH_MEMOP. This
* value is communicated to the callback function via \ref
* Sanitizer_BatchMemopData::type.
*/
typedef enum {
/**
* Batch memory operation size is 32 bits.
*/
SANITIZER_BATCH_MEMOP_TYPE_32B = 0,
/**
* Batch memory operation size is 64 bits.
*/
SANITIZER_BATCH_MEMOP_TYPE_64B = 1,
SANITIZER_BATCH_MEMOP_TYPE_FORCE_INT = 0x7fffffff
} Sanitizer_BatchMemopType;
/**
* \brief Data passed into a batch memop callback function.
*
* Data passed into a batch memop callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_BATCH_MEMOP. The callback data is
* only valid within the invocation of the callback function
* that is passed the data. If you need to retain some data
* for use outside of the callback, you must make a copy of it.
*/
typedef struct {
/**
* The context where the allocation is located
*/
CUcontext context;
/**
* The stream where the batch memop is executed.
*/
CUstream stream;
/**
* Unique handle for the stream.
*/
Sanitizer_StreamHandle hStream;
/**
* The address to be written.
*/
uint64_t address;
/**
* The value to be written.
*/
uint64_t value;
/**
* Type of batch memory operation.
*/
Sanitizer_BatchMemopType type;
} Sanitizer_BatchMemopData;
/**
* \brief Callback IDs for managed memory domain.
*
* Callback IDs for resource domain SANITIZER_CB_DOMAIN_UVM.
* This value is communicated to the callback function via the \p cbid parameter.
*/
typedef enum {
/**
* Invalid managed memory callback ID.
*/
SANITIZER_CBID_UVM_INVALID = 0,
/**
* Modify the stream association of an allocation
* (see cudaStreamAttachMemAsync)
*/
SANITIZER_CBID_UVM_ATTACH_MEM = 1,
SANITIZER_CBID_UVM_SIZE,
SANITIZER_CBID_UVM_FORCE_ITN = 0x7fffffff
} Sanitizer_CallbackIdUvm;
/**
* \brief Data passed into a managed memory callback function
*
* Data passed into a managed memory callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_UVM. The callback data
* is only valid within the invocation of the callback function
* that is passed the data. If you need to retain some data
* for use outside of the callback, you must make a copy of it.
*/
typedef struct {
/**
* The context where the allocation is located.
*/
CUcontext context;
/**
* New visibility for the allocation.
*/
Sanitizer_MemoryVisibility visibility;
/**
* The stream on which the memory is attached.
* This is only valid if visibility is SANITIZER_MEMORY_VISIBILITY_STREAM
*/
CUstream stream;
/**
* Unique handle for the stream.
*/
Sanitizer_StreamHandle hStream;
/**
* The address of the allocation.
*/
uint64_t address;
} Sanitizer_UvmData;
/**
* \brief Callback IDs for graphs domain.
*
* Callback IDs for resource domain SANITIZER_CB_DOMAIN_GRAPHS.
* This value is communicated to the callback function via the \p cbid parameter.
*/
typedef enum {
/**
* Invalid graphs callback ID.
*/
SANITIZER_CBID_GRAPHS_INVALID = 0,
/**
* A new graphexec is being created.
*/
SANITIZER_CBID_GRAPHS_GRAPHEXEC_CREATING = 1,
/**
* A new graphexec is created.
*/
SANITIZER_CBID_GRAPHS_GRAPHEXEC_CREATED = 2,
/**
* A graphexec is being destroyed
*/
SANITIZER_CBID_GRAPHS_GRAPHEXEC_DESTROYING = 3,
/**
* A node launch was initiated.
*/
SANITIZER_CBID_GRAPHS_NODE_LAUNCH_BEGIN = 4,
/**
* A node launch is complete.
*/
SANITIZER_CBID_GRAPHS_NODE_LAUNCH_END = 5,
/**
* A graph launch was initiated.
*/
SANITIZER_CBID_GRAPHS_LAUNCH_BEGIN = 6,
/**
* A graph launch is complete.
*/
SANITIZER_CBID_GRAPHS_LAUNCH_END = 7,
SANITIZER_CBID_GRAPHS_SIZE,
SANITIZER_CBID_GRAPHS_FORCE_INT = 0x7fffffff
} Sanitizer_CallbackIdGraphs;
/**
* \brief Data passed into a graphexec creation callback function
*
* Data passed into a graphs callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_GRAPHS and \p cbid equal to
* SANITIZER_CBID_GRAPHS_GRAPHEXEC_CREATING. The callback data
* is only valid within the invocation of the callback function
* that is passed the data. If you need to retain some data
* for use outside of the callback, you must make a copy of it.
*/
typedef struct {
/**
* CUDA graph being instantiated.
*/
CUgraph graph;
/**
* Instance of the CUDA graph.
* Can be NULL for device graph launches in the
* SANITIZER_CBID_GRAPHS_GRAPHEXEC_CREATING callback.
*/
CUgraphExec graphExec;
/**
* Boolean value indicating if the graphexec is for
* a device graph launch
*/
uint32_t isDeviceLaunch;
/**
* Boolean value indicating if the graphexec may launch device
* graphs. Only valid in the SANITIZER_CBID_GRAPHS_GRAPHEXEC_CREATED
* callback with driver version of 535 or newer.
*/
uint32_t containsDeviceGraphLaunches;
/**
* Context where the graphexec can launch device graphs.
* NULL if the graphExec doesn't launch device graphs.
* Only valid in the SANITIZER_CBID_GRAPHS_GRAPHEXEC_CREATED
* callback with driver version of 535 or newer.
*/
CUcontext deviceGraphLaunchesContext;
} Sanitizer_GraphExecData;
/**
* \brief Data passed into a graph node launch callback function
*
* Data passed into a graphs callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_GRAPHS and \p cbid equal to
* SANITIZER_CBID_GRAPHS_LAUNCH_NODE_BEGIN or
* SANITIZER_CBID_GRAPHS_LAUNCH_NODE_END. The callback data
* is only valid within the invocation of the callback function
* that is passed the data. If you need to retain some data
* for use outside of the callback, you must make a copy of it.
*/
typedef struct {
/**
* Instance of the CUDA graph being launched.
*/
CUgraphExec graphExec;
/**
* Launch ID for this CUDA graph instance
*/
uint32_t launchId;
/**
* CUDA graphs node being launched.
*/
CUgraphNode node;
/**
* CUDA graphs node type.
*/
CUgraphNodeType nodeType;
/**
* Data for this node launch.
*
*/
union {
/**
* This is only valid if nodeType is CU_GRAPH_NODE_TYPE_KERNEL.
*/
Sanitizer_LaunchData launchData;
/**
* This is only valid if nodeType is CU_GRAPH_NODE_TYPE_MEM_ALLOC.
*/
Sanitizer_ResourceMemoryData memAllocData;
/**
* The freed device pointer
* This is only valid if nodeType is CU_GRAPH_NODE_TYPE_MEM_FREE.
*/
uint64_t memFreeAddress;
/**
* This is only valid if nodeType is CU_GRAPH_NODE_TYPE_MEMCPY.
*/
Sanitizer_MemcpyData memcpyData;
/**
* This is only valid if nodeType is CU_GRAPH_NODE_TYPE_MEMSET.
*/
Sanitizer_MemsetData memsetData;
};
/**
* Boolean value indicating if the node launch callback is part
* of a graph upload.
*/
uint32_t isGraphUpload;
} Sanitizer_GraphNodeLaunchData;
/**
* \brief Data passed into a graph launch callback function
*
* Data passed into a graphs callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal to
* SANITIZER_CB_DOMAIN_GRAPHS and \p cbid equal to
* SANITIZER_CBID_GRAPHS_LAUNCH_BEGIN or
* SANITIZER_CBID_GRAPHS_LAUNCH_END. The callback data
* is only valid within the invocation of the callback function
* that is passed the data. If you need to retain some data
* for use outside of the callback, you must make a copy of it.
*/
typedef struct {
/**
* The context where the graph is launched.
*/
CUcontext context;
/**
* The stream where the graph is launched.
*/
CUstream stream;
/**
* Unique handle for the stream.
*/
Sanitizer_StreamHandle hStream;
/**
* Instance of the CUDA graph being launched.
*/
CUgraphExec graphExec;
/**
* Boolean value indicating if the launch callback is part
* of a graph upload. This field is only valid if the driver
* version is 510 or newer.
*/
uint32_t isGraphUpload;
} Sanitizer_GraphLaunchData;
/**
* \brief Callback IDs for events domain.
*
* Callback IDs for resource domain
* SANITIZER_CB_DOMAIN_EVENTS. This value is communicated
* to the callback function via the \p cbid parameter.
* Available with a driver version of 515 or newer.
*/
typedef enum {
/**
* Invalid event callback ID.
*/
SANITIZER_CBID_EVENTS_INVALID = 0,
/**
* An event was created.
*/
SANITIZER_CBID_EVENTS_CREATED = 1,
/**
* An event was destroyed.
*/
SANITIZER_CBID_EVENTS_DESTROYED = 2,
/**
* An event was recorded.
*/
SANITIZER_CBID_EVENTS_RECORD = 3,
/**
* A stream was synchronized to an event.
*/
SANITIZER_CBID_EVENTS_STREAM_WAIT = 4,
/**
* An event was synchronized.
*/
SANITIZER_CBID_EVENTS_SYNCHRONIZE = 5,
SANITIZER_CBID_EVENTS_SIZE,
SANITIZER_CBID_EVENTS_FORCE_INT = 0x7fffffff
} Sanitizer_CallbackIdEvents;
/**
*
* \brief Data passed into an event callback function.
*
* Data passed into an event callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal tp
* SANITIZER_CB_DOMAIN_EVENTS.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
*/
typedef struct {
/**
* The event recording or being waited.
*/
CUevent event;
/**
* For SANITIZER_CBID_EVENTS_CREATED,
* SANITIZER_CBID_EVENTS_DESTROYED, and
* SANITIZER_CBID_EVENTS_SYNCHNONIZED, this is
* the context containing the event.
* For SANITIZER_CBID_EVENTS_RECORD and
* SANITIZER_CBID_EVENTS_STREAM_WAIT, this is
* the context containing the stream being recorded or
* waiting.
*/
CUcontext context;
/**
* The stream being recorded or waiting. Available if
* cbid is SANITIZER_CBID_EVENTS_RECORD or
* SANITIZER_CBID_EVENTS_STREAM_WAIT.
*/
CUstream stream;
/**
* Unique handle for the stream.
*/
Sanitizer_StreamHandle hStream;
} Sanitizer_EventData;
/**
* \brief Callback IDs for external memory domain.
*
* Callback IDs for resource domain
* SANITIZER_CB_DOMAIN_EXTERNA_MEMORY. This value is communicated
* to the callback function via the \p cbid parameter.
* Available with a driver version of 535 or newer.
*/
typedef enum {
/**
* Invalid external memory callback ID.
*/
SANITIZER_CBID_EXTERNAL_MEMORY_INVALID = 0,
/**
* External memory was imported.
*/
SANITIZER_CBID_EXTERNAL_MEMORY_IMPORT = 1,
/**
* External memory was mapped.
*/
SANITIZER_CBID_EXTERNAL_MEMORY_MAPPED = 2,
/**
* External memory was destroyed.
*/
SANITIZER_CBID_EXTERNAL_MEMORY_DESTROYED = 3,
SANITIZER_CBID_EXTERNAL_MEMORY_SIZE,
SANITIZER_CBID_EXTERNAL_MEMORY_FORCE_INT = 0x7fffffff
} Sanitizer_CallbackIdExternalMemory;
/**
*
* \brief Data passed into an external memory callback function.
*
* Data passed into an event callback function as the
* \p cbdata argument to \ref Sanitizer_CallbackFunc. The
* \p cbdata will be this type for \p domain equal tp
* SANITIZER_CB_DOMAIN_EXTERNAL_MEMORY.
* The callback data is only valid within the invocation of the
* callback function that is passed the data. If you need to
* retain some data for use outside of the callback, you must
* make a copy of it.
*/
typedef struct {
/**
* Context containing the external memory.
*/
CUcontext context;
/**
* Device containing the external memory.
*/
CUdevice device;
/**
* External memory object.
*/
CUexternalMemory extMemory;
/**
* Address of the mapped memory. This field is only valid for
* SANITIZER_CBID_EXTERNAL_MEMORY_MAPPED
*/
uint64_t address;
/**
* Size of the memory imported or mapped. This field is only valid
* for SANITIZER_CBID_EXTERNAL_MEMORY_IMPORT and
* SANITIZER_CBID_EXTERNAL_MEMORY_MAPPED.
*/
uint64_t size;
} Sanitizer_ExternalMemoryData;
/**
* \brief Callback ID
*/
typedef uint32_t Sanitizer_CallbackId;
/**
* \brief Function type for a callback.
*
* Function type for a callback. The type of the data passed to the callback
* in \p cbdata depends on the domain.
* If \p domain is SANITIZER_CB_DOMAIN_DRIVER_API or SANITIZER_CB_DOMAIN_RUNTIME_API
* the type of \p cbdata will be Sanitizer_CallbackData.
* If \p domain is SANITIZER_CB_DOMAIN_RESOURCE
* the type of \p cbdata will be dependent on cbid.
* Refer to \ref Sanitizer_ResourceContextData,
* \ref Sanitizer_ResourceStreamData,
* \ref Sanitizer_ResourceModuleData and
* \ref Sanitizer_ResourceMemoryFlags documentations.
* If \p domain is SANITIZER_CB_DOMAIN_SYNCHRONIZE
* the type of \p cbdata will be Sanitizer_SynchronizeData.
* If \p domain is SANITIZER_CB_DOMAIN_LAUNCH
* the type of \p cbdata will be Sanitizer_LaunchData.
* If \p domain is SANITIZER_CB_DOMAIN_MEMCPY
* the type of \p cbdata will be Sanitizer_MemcpyData.
* If \p domain is SANITIZER_CB_DOMAIN_MEMSET
* the type of \p cbdata will be Sanitizer_MemsetData.
* If \p domain is SANITIZER_CB_DOMAIN_BATCH_MEMOP
* the type of \p cbdata will be Sanitizer_BatchMemopData.
*/
typedef void (SANITIZERAPI *Sanitizer_CallbackFunc)(
void *userdata,
Sanitizer_CallbackDomain domain,
Sanitizer_CallbackId cbid,
const void *cbdata);
/**
* \brief A callback subscriber.
*/
typedef struct Sanitizer_Subscriber_st *Sanitizer_SubscriberHandle;
/**
* \brief Initialize a callback subscriber with a callback function and
* user data.
*
* Initialize a callback subscriber with a callback function and (optionally)
* a pointer to user data. The returned subscriber handle can be used to enable
* and disable the callback for specific domains and callback IDs.
* \note Only one subscriber can be registered at a time.
* \note This function does not enable any callbacks.
* \note \b Thread-safety: this function is thread safe.
*
* \param subscriber Returns handle to initialize subscriber
* \param callback The callback function
* \param userdata A pointer to user data. This data will be passed to the
* callback function via the \p userdata parameter
*
* \retval SANITIZER_SUCCESS on success
* \retval SANITIZER_ERROR_NOT_INITIALIZED if unable to initialize the sanitizer
* \retval SANITIZER_ERROR_MAX_LIMIT_RACHED if there is already a sanitizer
* subscriber
* \retval SANITIZER_ERROR_INVALID_PARAMETER if \p subscriber is NULL
*/
SanitizerResult SANITIZERAPI sanitizerSubscribe(Sanitizer_SubscriberHandle* subscriber,
Sanitizer_CallbackFunc callback,
void* userdata);
/**
* \brief Unregister a callback subscriber.
*
* Removes a callback subscriber so that no future callback will be issued to
* that subscriber.
* \note \b Thread-safety: this function is thread safe.
*
* \param subscriber Handle to the initialized subscriber
*
* \retval SANITIZER_SUCCESS on success
* \retval SANITIZER_ERROR_NOT_INITIALIZED if unable to initialize the sanitizer
* \retval SANITIZER_ERROR_INVALID_PARAMETER if \p subscriber is NULL or
* not initialized
*/
SanitizerResult SANITIZERAPI sanitizerUnsubscribe(Sanitizer_SubscriberHandle subscriber);
/**
* \brief Get the current enabled/disabled state of a callback for a specific
* domain and function ID.
*
* Returns non-zero in \p *enable if the callback for a domain and callback
* ID is enabled, and zero if not enabled.
*
* \note \b Thread-safety: a subscriber must serialize access to
* sanitizerGetCallbackState, sanitizerEnableCallback, sanitizerEnableDomain, and
* sanitizerEnableAllDomains. For example, if sanitizerGetCallbackState(sub, d,
* c) and sanitizerEnableCallback(sub, d, c) are called concurrently, the
* results are undefined.
*
* \param enable Returns non-zero if callback enabled, zero if not enabled
* \param subscriber Handle to the initialized subscriber
* \param domain The domain of the callback
* \param cbid The ID of the callback
*
* \retval SANITIZER_SUCCESS on success
* \retval SANITIZER_ERROR_NOT_INITIALIZED if unable to initialize the sanitizer
* \retval SANITIZER_ERROR_INVALID_PARAMETER if \p enabled is NULL, or if
* \p subscriber, \p domain or \p cbid is invalid.
*/
SanitizerResult SANITIZERAPI sanitizerGetCallbackState(uint32_t* enable,
Sanitizer_SubscriberHandle subscriber,
Sanitizer_CallbackDomain domain,
Sanitizer_CallbackId cbid);
/**
* \brief Enable or disable callbacks for a specific domain and callback ID
*
* Enable or disable callbacks for a subscriber for a specific domain and
* callback ID.
*
* \note \b Thread-safety: a subscriber must serialize access to
* sanitizerGetCallbackState, sanitizerEnableCallback, sanitizerEnableDomain, and
* sanitizerEnableAllDomains. For example, if sanitizerGetCallbackState(sub, d,
* c) and sanitizerEnableCallback(sub, d, c) are called concurrently, the
* results are undefined.
*
* \param enable New enable state for the callback. Zero disables the callback,
* non-zero enables the callback
* \param subscriber - Handle of the initialized subscriber
* \param domain The domain of the callback
* \param cbid The ID of the callback
*
* \retval SANITIZER_SUCCESS on success
* \retval SANITIZER_ERROR_NOT_INITIALIZED if unable to initialize the sanitizer
* \retval SANITIZER_ERROR_INVALID_PARAMETER if \p subscriber, \p domain or
* \p cbid is invalid
*/
SanitizerResult SANITIZERAPI sanitizerEnableCallback(uint32_t enable,
Sanitizer_SubscriberHandle subscriber,
Sanitizer_CallbackDomain domain,
Sanitizer_CallbackId cbid);
/**
* \brief Enable or disable all callbacks for a specific domain.
*
* Enable or disable all callbacks for a specific domain.
*
* \note \b Thread-safety: a subscriber must serialize access to
* sanitizerGetCallbackState, sanitizerEnableCallback, sanitizerEnableDomain, and
* sanitizerEnableAllDomains. For example, if sanitizerGetCallbackEnabled(sub,
* d, *) and sanitizerEnableDomain(sub, d) are called concurrently, the
* results are undefined.
*
* \param enable New enable state for all callbacks in the domain. Zero
* disables all callbacks, non-zero enables all callbacks
* \param subscriber - Handle of the initialized subscriber
* \param domain The domain of the callback
*
* \retval SANITIZER_SUCCESS on success
* \retval SANITIZER_ERROR_NOT_INITIALIZED if unable to initialize the sanitizer
* \retval SANITIZER_ERROR_INVALID_PARAMETER if \p subscriber or \p domain is
* invalid
*/
SanitizerResult SANITIZERAPI sanitizerEnableDomain(uint32_t enable,
Sanitizer_SubscriberHandle subscriber,
Sanitizer_CallbackDomain domain);
/**
* \brief Enable or disable all callbacks in all domains.
*
* Enable or disable all callbacks in all domains.
*
* \note \b Thread-safety: a subscriber must serialize access to
* sanitizerGetCallbackState, sanitizerEnableCallback, sanitizerEnableDomain, and
* sanitizerEnableAllDomains. For example, if sanitizerGetCallbackState(sub,
* d, *) and sanitizerEnableAllDomains(sub) are called concurrently, the
* results are undefined.
*
* \param enable New enable state for all callbacks in all domains. Zero
* disables all callbacks, non-zero enables all callbacks.
* \param subscriber - Handle of the initialized subscriber
*
* \retval SANITIZER_SUCCESS on success
* \retval SANITIZER_ERROR_NOT_INITIALIZED if unable to initialize the sanitizer
* \retval SANITIZER_ERROR_INVALID_PARAMETER if \p subscriber is invalid
*/
SanitizerResult SANITIZERAPI sanitizerEnableAllDomains(uint32_t enable,
Sanitizer_SubscriberHandle subscriber);
/** @} */ /* END SANITIZER_CALLBACK_API */
#if defined(__cplusplus)
}
#endif
#endif /* __SANITIZER_CALLBACKS_H__ */
|