Merge remote-tracking branch 'upstream' into new_protocol Conflicts: cgminer.c configure.ac miner.h
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 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907
diff --git a/ADL_SDK/.gitignore b/ADL_SDK/.gitignore
deleted file mode 100644
index 05c579e..0000000
--- a/ADL_SDK/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-adl_defines.h
-adl_sdk.h
-adl_structures.h
diff --git a/ADL_SDK/readme.txt b/ADL_SDK/readme.txt
deleted file mode 100644
index afc3708..0000000
--- a/ADL_SDK/readme.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Please insert AMD ADL files adl_defines.h adl_sdk.h adl_structures.h here.
-They can be found here:
-http://developer.amd.com/tools/graphics-development/display-library-adl-sdk/
diff --git a/API-README b/API-README
index e4f9b30..b5497d3 100644
--- a/API-README
+++ b/API-README
@@ -65,11 +65,11 @@ response, otherwise it replies with text formatted as described further below.
The JSON request format required is '{"command":"CMD","parameter":"PARAM"}'
(though of course parameter is not required for all requests)
where "CMD" is from the "Request" column below and "PARAM" would be e.g.
-the ASC/GPU number if required.
+the ASC/PGA number if required.
-An example request in both formats to set GPU 0 fan to 80%:
- gpufan|0,80
- {"command":"gpufan","parameter":"0,80"}
+An example request in both formats to disable Hotplug:
+ hotplug|0
+ {"command":"hotplug","parameter":"0"}
The format of each reply (unless stated otherwise) is a STATUS section
followed by an optional detail section
@@ -119,15 +119,12 @@ The list of requests - a (*) means it requires privileged access - and replies:
API=API| version
config CONFIG Some miner configuration information:
- GPU Count=N, <- the number of GPUs
ASC Count=N, <- the number of ASCs
PGA Count=N, <- the number of PGAs
Pool Count=N, <- the number of Pools
- ADL=X, <- Y or N if ADL is compiled in the code
- ADL in use=X, <- Y or N if any GPU has ADL
Strategy=Name, <- the current pool strategy
Log Interval=N, <- log interval (--log N)
- Device Code=GPU ICA , <- spaced list of compiled
+ Device Code=ICA , <- spaced list of compiled
device drivers
OS=Linux/Apple/..., <- operating System
Failover-Only=true/false, <- failover-only setting
@@ -141,8 +138,8 @@ The list of requests - a (*) means it requires privileged access - and replies:
pools POOLS The status of each pool e.g.
Pool=0,URL=http://pool.com:6311,Status=Alive,...|
- devs DEVS Each available GPU, PGA and ASC with their details
- e.g. GPU=0,Accepted=NN,MHS av=NNN,...,Intensity=D|
+ devs DEVS Each available PGA and ASC with their details
+ e.g. ASC=0,Accepted=NN,MHS av=NNN,...,Intensity=D|
Last Share Time=NNN, <- standand long time in sec
(or 0 if none) of last accepted share
Last Share Pool=N, <- pool number (or -1 if none)
@@ -151,17 +148,12 @@ The list of requests - a (*) means it requires privileged access - and replies:
Will not report PGAs if PGA mining is disabled
Will not report ASCs if ASC mining is disabled
- gpu|N GPU The details of a single GPU number N in the same
- format and details as for DEVS
-
pga|N PGA The details of a single PGA number N in the same
format and details as for DEVS
This is only available if PGA mining is enabled
Use 'pgacount' or 'config' first to see if there
are any
- gpucount GPUS Count=N| <- the number of GPUs
-
pgacount PGAS Count=N| <- the number of PGAs
Always returns 0 if PGA mining is disabled
@@ -203,42 +195,6 @@ The list of requests - a (*) means it requires privileged access - and replies:
The Msg includes the pool URL
N.B. all details for the pool will be lost
- gpuenable|N (*)
- none There is no reply section just the STATUS section
- stating the results of the enable request
-
- gpudisable|N (*)
- none There is no reply section just the STATUS section
- stating the results of the disable request
-
- gpurestart|N (*)
- none There is no reply section just the STATUS section
- stating the results of the restart request
-
- gpuintensity|N,I (*)
- none There is no reply section just the STATUS section
- stating the results of setting GPU N intensity
- to I
-
- gpumem|N,V (*)
- none There is no reply section just the STATUS section
- stating the results of setting GPU N memoryclock
- to V MHz
-
- gpuengine|N,V (*)
- none There is no reply section just the STATUS section
- stating the results of setting GPU N clock
- to V MHz
-
- gpufan|N,V (*)
- none There is no reply section just the STATUS section
- stating the results of setting GPU N fan speed
- to V%
-
- gpuvddc|N,V (*)
- none There is no reply section just the STATUS section
- stating the results of setting GPU N vddc to V
-
save|filename (*)
none There is no reply section just the STATUS section
stating success or failure saving the cgminer
@@ -253,7 +209,7 @@ The list of requests - a (*) means it requires privileged access - and replies:
problem
This lists all devices including those not
supported by the 'devs' command e.g.
- NOTIFY=0,Name=GPU,ID=0,Last Well=1332432290,...|
+ NOTIFY=0,Name=ASC,ID=0,Last Well=1332432290,...|
privileged (*)
none There is no reply section just the STATUS section
@@ -295,7 +251,7 @@ The list of requests - a (*) means it requires privileged access - and replies:
devdetails DEVDETAILS Each device with a list of their static details
This lists all devices including those not
supported by the 'devs' command
- e.g. DEVDETAILS=0,Name=GPU,ID=0,Driver=opencl,...|
+ e.g. DEVDETAILS=0,Name=ASC,ID=0,Driver=yuu,...|
restart (*) none There is no status section but just a single
"RESTART" reply before cgminer restarts
@@ -443,7 +399,7 @@ The list of requests - a (*) means it requires privileged access - and replies:
into cgminer
The API writes all the lock stats to stderr
-When you enable, disable or restart a GPU, PGA or ASC, you will also get
+When you enable, disable or restart a PGA or ASC, you will also get
Thread messages in the cgminer status window
The 'poolpriority' command can be used to reset the priority order of multiple
@@ -497,6 +453,12 @@ miner.php - an example web page to access the API
Feature Changelog for external applications using the API:
+API V2.0 (cgminer v3.8.0)
+
+Removed all GPU related commands and information from the replies
+
+---------
+
API V1.32 (cgminer v3.6.5)
Modified API commands:
diff --git a/ASIC-README b/ASIC-README
index 5d71f05..bf83045 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -3,7 +3,8 @@ SUPPORTED DEVICES
Currently supported devices include the Avalon (including BitBurner and
Klondike), the Butterfly Labs SC range of devices, the ASICMINER block
erupters, the BF1 (bitfury) USB (red and blue) devices, KnCminer Mercury,
-Saturn and Jupiter devices, and upcoming Hashfast devices.
+Saturn and Jupiter devices, BlackArrow Bitfury devices and upcoming
+Hashfast devices.
No COM ports on windows or TTY devices will be used by cgminer as it
communicates directly with them via USB so it is normal for them to not exist or
@@ -34,6 +35,14 @@ in the FPGA-README. Configuring them uses the same mechanism as outlined
below for getting started with butterfly labs ASICs.
+BlackArrow Bitfury devices
+
+BlackArrow Bitfury devices need the --enable-bab option when compiling cgminer.
+
+The current BlackArrow Bitfury devices are similar to the Bitfury GPIO mining
+boards and come up as BaB. There are no options available for them.
+
+
BITFURY devices
Bitfury devices need the --enable-bitfury option when compiling cgminer.
diff --git a/GPU-README b/GPU-README
deleted file mode 100644
index 1541b88..0000000
--- a/GPU-README
+++ /dev/null
@@ -1,514 +0,0 @@
-EXECUTIVE SUMMARY ON GPU USAGE (SEE ALSO SCRYPT-README FOR SCRYPT MINING):
-
-Single pool, regular desktop:
-
-cgminer -o http://pool:port -u username -p password
-
-By default if you have configured your system properly, cgminer will mine on
-ALL GPUs, but in "dynamic" mode which is designed to keep your system usable
-and sacrifice some mining performance.
-
-Single pool, dedicated miner:
-
-cgminer -o http://pool:port -u username -p password -I 9
-
-Single pool, first card regular desktop, 3 other dedicated cards:
-
-cgminer -o http://pool:port -u username -p password -I d,9,9,9
-
-Multiple pool, dedicated miner:
-
-cgminer -o http://pool1:port -u pool1username -p pool1password -o http://pool2:port -u pool2usernmae -p pool2password -I 9
-
-Add overclocking settings, GPU and fan control for all cards:
-
-cgminer -o http://pool:port -u username -p password -I 9 --auto-fan --auto-gpu --gpu-engine 750-950 --gpu-memclock 300
-
-Add overclocking settings, GPU and fan control with different engine settings for 4 cards:
-
-cgminer -o http://pool:port -u username -p password -I 9 --auto-fan --auto-gpu --gpu-engine 750-950,945,700-930,960 --gpu-memclock 300
-
-READ WARNINGS AND DOCUMENTATION BELOW ABOUT OVERCLOCKING
-
-To configure multiple displays on linux you need to configure your Xorg cleanly
-to use them all:
-
-sudo aticonfig --adapter=all -f --initial
-
-On Linux you virtually always need to export your display settings before
-starting to get all the cards recognised and/or temperature+clocking working:
-
-export DISPLAY=:0
-
----
-BUILDING FOR GPU SUPPORT:
-
- To build with GPU mining support:
- Install AMD APP sdk, ideal version (see FAQ!) - no official place to
- install it so just keep track of where it is if you're not installing
- the include files and library files into the system directory.
- (Do NOT install the ati amd sdk if you are on nvidia.)
- To build with GPU monitoring & clocking support:
- Extract the AMD ADL SDK, latest version - there is also no official
- place for these files. Copy all the *.h files in the "include"
- directory into cgminer's ADL_SDK directory.
-
-The easiest way to install the ATI AMD SPP sdk on linux is to actually put it
-into a system location. Then building will be simpler. Download the correct
-version for either 32 bit or 64 bit from here:
- http://developer.amd.com/tools/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/downloads/
-
-The best version for Radeon 5xxx and 6xxx is v2.5, while 7xxx cards need
-v2.6 or later, 2.7 seems the best.
-
-For versions 2.4 or earlier you will need to manually install them:
-This will give you a file with a name like:
- AMD-APP-SDK-v2.4-lnx64.tgz (64-bit)
-or
- AMD-APP-SDK-v2.4-lnx32.tgz (32-bit)
-
-Then:
-
-sudo su
-cd /opt
-tar xf /path/to/AMD-APP-SDK-v2.4-lnx##.tgz
-cd /
-tar xf /opt/AMD-APP-SDK-v2.4-lnx##/icd-registration.tgz
-ln -s /opt/AMD-APP-SDK-v2.4-lnx##/include/CL /usr/include
-ln -s /opt/AMD-APP-SDK-v2.4-lnx##/lib/x86_64/* /usr/lib/
-ldconfig
-
-Where ## is 32 or 64, depending on the bitness of the SDK you downloaded.
-If you are on 32 bit, x86_64 in the 2nd last line should be x86
-
-Basic *nix build instructions:
- CFLAGS="-O2 -Wall -march=native" ./configure <options>
- or if you haven't installed the AMD files in system locations:
- CFLAGS="-O2 -Wall -march=native -I<path to AMD APP include>" LDFLAGS="-L<path to AMD APP lib/x86_64> ./configure <options>
- make
-
- If it finds the opencl files it will inform you with
- "OpenCL: FOUND. GPU mining support enabled."
-
-
----
-INTENSITY INFORMATION:
-
-Intensity correlates with the size of work being submitted at any one time to
-a GPU. The higher the number the larger the size of work. Generally speaking
-finding an optimal value rather than the highest value is the correct approach
-as hash rate rises up to a point with higher intensities but above that, the
-device may be very slow to return responses, or produce errors.
-
-NOTE: Running BTC intensities above 9 with current hardware is likely to only
-diminish return performance even if the hash rate might appear better. A good
-starting baseline intensity to try on dedicated miners is 9. 11 is the upper
-limit for intensity while BTC mining, if the GPU_USE_SYNC_OBJECTS variable
-is set (see FAQ). The upper limit for sha256 mining is 14 and 20 for scrypt.
-
-
----
-OVERCLOCKING WARNING AND INFORMATION
-
-AS WITH ALL OVERCLOCKING TOOLS YOU ARE ENTIRELY RESPONSIBLE FOR ANY HARM YOU
-MAY CAUSE TO YOUR HARDWARE. OVERCLOCKING CAN INVALIDATE WARRANTIES, DAMAGE
-HARDWARE AND EVEN CAUSE FIRES. THE AUTHOR ASSUMES NO RESPONSIBILITY FOR ANY
-DAMAGE YOU MAY CAUSE OR UNPLANNED CHILDREN THAT MAY OCCUR AS A RESULT.
-
-The GPU monitoring, clocking and fanspeed control incorporated into cgminer
-comes through use of the ATI Display Library. As such, it only supports ATI
-GPUs. Even if ADL support is successfully built into cgminer, unless the card
-and driver supports it, no GPU monitoring/settings will be available.
-
-Cgminer supports initial setting of GPU engine clock speed, memory clock
-speed, voltage, fanspeed, and the undocumented powertune feature of 69x0+ GPUs.
-The setting passed to cgminer is used by all GPUs unless separate values are
-specified. All settings can all be changed within the menu on the fly on a
-per-GPU basis.
-
-For example:
---gpu-engine 950 --gpu-memclock 825
-
-will try to set all GPU engine clocks to 950 and all memory clocks to 825,
-while:
---gpu-engine 950,945,930,960 --gpu-memclock 300
-
-will try to set the engine clock of card 0 to 950, 1 to 945, 2 to 930, 3 to
-960 and all memory clocks to 300.
-
-AUTO MODES:
-There are two "auto" modes in cgminer, --auto-fan and --auto-gpu. These can
-be used independently of each other and are complementary. Both auto modes
-are designed to safely change settings while trying to maintain a target
-temperature. By default this is set to 75 degrees C but can be changed with:
-
---temp-target
-e.g.
---temp-target 80
-Sets all cards' target temperature to 80 degrees.
-
---temp-target 75,85
-Sets card 0 target temperature to 75, and card 1 to 85 degrees.
-
-AUTO FAN:
-e.g.
---auto-fan (implies 85% upper limit)
---gpu-fan 25-85,65 --auto-fan
-
-Fan control in auto fan works off the theory that the minimum possible fan
-required to maintain an optimal temperature will use less power, make less
-noise, and prolong the life of the fan. In auto-fan mode, the fan speed is
-limited to 85% if the temperature is below "overheat" intentionally, as
-higher fanspeeds on GPUs do not produce signficantly more cooling, yet
-significanly shorten the lifespan of the fans. If temperature reaches the
-overheat value, fanspeed will still be increased to 100%. The overheat value
-is set to 85 degrees by default and can be changed with:
-
---temp-overheat
-e.g.
---temp-overheat 75,85
-Sets card 0 overheat threshold to 75 degrees and card 1 to 85.
-
-AUTO GPU:
-e.g.
---auto-gpu --gpu-engine 750-950
---auto-gpu --gpu-engine 750-950,945,700-930,960
-
-GPU control in auto gpu tries to maintain as high a clock speed as possible
-while not reaching overheat temperatures. As a lower clock speed limit,
-the auto-gpu mode checks the GPU card's "normal" clock speed and will not go
-below this unless you have manually set a lower speed in the range. Also,
-unless a higher clock speed was specified at startup, it will not raise the
-clockspeed. If the temperature climbs, fanspeed is adjusted and optimised
-before GPU engine clockspeed is adjusted. If fan speed control is not available
-or already optimal, then GPU clock speed is only decreased if it goes over
-the target temperature by the hysteresis amount, which is set to 3 by default
-and can be changed with:
---temp-hysteresis
-If the temperature drops below the target temperature, and engine clock speed
-is not at the highest level set at startup, cgminer will raise the clock speed.
-If at any time you manually set an even higher clock speed successfully in
-cgminer, it will record this value and use it as its new upper limit (and the
-same for low clock speeds and lower limits). If the temperature goes over the
-cutoff limit (95 degrees by default), cgminer will completely disable the GPU
-from mining and it will not be re-enabled unless manually done so. The cutoff
-temperature can be changed with:
-
---temp-cutoff
-e.g.
---temp-cutoff 95,105
-Sets card 0 cutoff temperature to 95 and card 1 to 105.
-
---gpu-memdiff -125
-This setting will modify the memory speed whenever the GPU clock speed is
-modified by --auto-gpu. In this example, it will set the memory speed to
-be 125 Mhz lower than the GPU speed. This is useful for some cards like the
-6970 which normally don't allow a bigger clock speed difference. The 6970 is
-known to only allow -125, while the 7970 only allows -150.
-
-
-CHANGING SETTINGS:
-When setting values, it is important to realise that even though the driver
-may report the value was changed successfully, and the new card power profile
-information contains the values you set it to, that the card itself may
-refuse to use those settings. As the performance profile changes dynamically,
-querying the "current" value on the card can be wrong as well. So when changing
-values in cgminer, after a pause of 1 second, it will report to you the current
-values where you should check that your change has taken. An example is that
-6970 reference cards will accept low memory values but refuse to actually run
-those lower memory values unless they're within 125 of the engine clock speed.
-In that scenario, they usually set their real speed back to their default.
-
-Cgminer reports the so-called "safe" range of whatever it is you are modifying
-when you ask to modify it on the fly. However, you can change settings to values
-outside this range. Despite this, the card can easily refuse to accept your
-changes, or worse, to accept your changes and then silently ignore them. So
-there is absolutely to know how far to/from where/to it can set things safely or
-otherwise, and there is nothing stopping you from at least trying to set them
-outside this range. Being very conscious of these possible failures is why
-cgminer will report back the current values for you to examine how exactly the
-card has responded. Even within the reported range of accepted values by the
-card, it is very easy to crash just about any card, so it cannot use those
-values to determine what range to set. You have to provide something meaningful
-manually for cgminer to work with through experimentation.
-
-STARTUP / SHUTDOWN:
-When cgminer starts up, it tries to read off the current profile information
-for clock and fan speeds and stores these values. When quitting cgminer, it
-will then try to restore the original values. Changing settings outside of
-cgminer while it's running may be reset to the startup cgminer values when
-cgminer shuts down because of this.
-
----
-
-GPU DEVICE ISSUES and use of --gpu-map
-
-GPUs mine with OpenCL software via the GPU device driver. This means you need
-to have both an OpenCL SDK installed, and the GPU device driver RUNNING (i.e.
-Xorg up and running configured for all devices that will mine on linux etc.)
-Meanwhile, the hardware monitoring that cgminer offers for AMD devices relies
-on the ATI Display Library (ADL) software to work. OpenCL DOES NOT TALK TO THE
-ADL. There is no 100% reliable way to know that OpenCL devices are identical
-to the ADL devices, as neither give off the same information. cgminer does its
-best to correlate these devices based on the order that OpenCL and ADL numbers
-them. It is possible that this will fail for the following reasons:
-
-1. The device order is listed differently by OpenCL and ADL (rare), even if the
-number of devices is the same.
-2. There are more OpenCL devices than ADL. OpenCL stupidly sees one GPU as two
-devices if you have two monitors connected to the one GPU.
-3. There are more ADL devices than OpenCL. ADL devices include any ATI GPUs,
-including ones that can't mine, like some older R4xxx cards.
-
-To cope with this, the ADVANCED option for --gpu-map is provided with cgminer.
-DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING. The default will work the
-vast majority of the time unless you know you have a problem already.
-
-To get useful information, start cgminer with just the -n option. You will get
-output that looks like this:
-
-[2012-04-25 13:17:34] CL Platform 0 vendor: Advanced Micro Devices, Inc.
-[2012-04-25 13:17:34] CL Platform 0 name: AMD Accelerated Parallel Processing
-[2012-04-25 13:17:34] CL Platform 0 version: OpenCL 1.1 AMD-APP (844.4)
-[2012-04-25 13:17:34] Platform 0 devices: 3
-[2012-04-25 13:17:34] 0 Tahiti
-[2012-04-25 13:17:34] 1 Tahiti
-[2012-04-25 13:17:34] 2 Cayman
-[2012-04-25 13:17:34] GPU 0 AMD Radeon HD 7900 Series hardware monitoring enabled
-[2012-04-25 13:17:34] GPU 1 AMD Radeon HD 7900 Series hardware monitoring enabled
-[2012-04-25 13:17:34] GPU 2 AMD Radeon HD 6900 Series hardware monitoring enabled
-[2012-04-25 13:17:34] 3 GPU devices max detected
-
-Note the number of devices here match, and the order is the same. If devices 1
-and 2 were different between Tahiti and Cayman, you could run cgminer with:
---gpu-map 2:1,1:2
-And it would swap the monitoring it received from ADL device 1 and put it to
-opencl device 2 and vice versa.
-
-If you have 2 monitors connected to the first device it would look like this:
-
-[2012-04-25 13:17:34] Platform 0 devices: 4
-[2012-04-25 13:17:34] 0 Tahiti
-[2012-04-25 13:17:34] 1 Tahiti
-[2012-04-25 13:17:34] 2 Tahiti
-[2012-04-25 13:17:34] 3 Cayman
-[2012-04-25 13:17:34] GPU 0 AMD Radeon HD 7900 Series hardware monitoring enabled
-[2012-04-25 13:17:34] GPU 1 AMD Radeon HD 7900 Series hardware monitoring enabled
-[2012-04-25 13:17:34] GPU 2 AMD Radeon HD 6900 Series hardware monitoring enabled
-
-To work around this, you would use:
--d 0 -d 2 -d 3 --gpu-map 2:1,3:2
-
-If you have an older card as well as the rest it would look like this:
-
-[2012-04-25 13:17:34] Platform 0 devices: 3
-[2012-04-25 13:17:34] 0 Tahiti
-[2012-04-25 13:17:34] 1 Tahiti
-[2012-04-25 13:17:34] 2 Cayman
-[2012-04-25 13:17:34] GPU 0 AMD Radeon HD 4500 Series hardware monitoring enabled
-[2012-04-25 13:17:34] GPU 1 AMD Radeon HD 7900 Series hardware monitoring enabled
-[2012-04-25 13:17:34] GPU 2 AMD Radeon HD 7900 Series hardware monitoring enabled
-[2012-04-25 13:17:34] GPU 3 AMD Radeon HD 6900 Series hardware monitoring enabled
-
-To work around this you would use:
---gpu-map 0:1,1:2,2:3
-
-
----
-GPU FAQ:
-
-Q: Can I change the intensity settings individually for each GPU?
-A: Yes, pass a list separated by commas such as -I d,4,9,9
-
-Q: The CPU usage is high.
-A: The ATI drivers after 11.6 have a bug that makes them consume 100% of one
-CPU core unnecessarily so downgrade to 11.6. Binding cgminer to one CPU core on
-windows can minimise it to 100% (instead of more than one core). Driver version
-11.11 on linux and 11.12 on windows appear to have fixed this issue. Note that
-later drivers may have an apparent return of high CPU usage. Try
-'export GPU_USE_SYNC_OBJECTS=1' on Linux before starting cgminer. You can also
-set this variable in windows via a batch file or on the command line before
-starting cgminer with 'setx GPU_USE_SYNC_OBJECTS 1'
-
-Q: My GPU hangs and I have to reboot it to get it going again?
-A: The more aggressively the mining software uses your GPU, the less overclock
-you will be able to run. You are more likely to hit your limits with cgminer
-and you will find you may need to overclock your GPU less aggressively. The
-software cannot be responsible and make your GPU hang directly. If you simply
-cannot get it to ever stop hanging, try decreasing the intensity, and if even
-that fails, try changing to the poclbm kernel with -k poclbm, though you will
-sacrifice performance. cgminer is designed to try and safely restart GPUs as
-much as possible, but NOT if that restart might actually crash the rest of the
-GPUs mining, or even the machine. It tries to restart them with a separate
-thread and if that separate thread dies, it gives up trying to restart any more
-GPUs.
-
-Q: Can you change the autofan/autogpu to change speeds in a different manner?
-A: The defaults are sane and safe. I'm not interested in changing them
-further. The starting fan speed is set to 50% in auto-fan mode as a safety
-precaution.
-
-Q: I upgraded cgminer version and my hashrate suddenly dropped!
-A: No, you upgraded your SDK version unwittingly between upgrades of cgminer
-and that caused your hashrate to drop. See the next question.
-
-Q: I upgraded my ATI driver/SDK/cgminer and my hashrate suddenly dropped!
-A: The hashrate performance in cgminer is tied to the version of the ATI SDK
-that is installed only for the very first time cgminer is run. This generates
-binaries that are used by the GPU every time after that. Any upgrades to the
-SDK after that time will have no effect on the binaries. However, if you
-install a fresh version of cgminer, and have since upgraded your SDK, new
-binaries will be built. It is known that the 2.6 ATI SDK has a huge hashrate
-penalty on generating new binaries. It is recommended to not use this SDK at
-this time unless you are using an ATI 7xxx card that needs it.
-
-Q: Which AMD SDK is the best for cgminer?
-A: At the moment, versions 2.4 and 2.5 work the best for R5xxx and R6xxx GPUS.
-SDK 2.6 or 2.7 works best for R7xxx. SDK 2.8 is known to have many problems.
-If you are need to use the 2.6+ SDK or R7xxx or later, the phatk kernel will
-perform poorly, while the diablo or my custom modified poclbm kernel are
-optimised for it.
-
-Q: Which AMD driver is the best?
-A: Unfortunately AMD has a history of having quite a few releases with issues
-when it comes to mining, either in terms of breaking mining, increasing CPU
-usage or very low hashrates. Only experimentation can tell you for sure, but
-some good releases were 11.6, 11.12, 12.4 and 12.8. Note that older cards may
-not work with the newer drivers.
-
-Q: I have multiple SDKs installed, can I choose which one it uses?
-A: Run cgminer with the -n option and it will list all the platforms currently
-installed. Then you can tell cgminer which platform to use with --gpu-platform.
-
-Q: cgminer reports no devices or only one device on startup on Linux although
-I have multiple devices and drivers+SDK installed properly?
-A: Try "export DISPLAY=:0" before running cgminer.
-
-Q: cgminer crashes immediately on startup.
-A: One of the common reasons for this is that you have mixed files on your
-machine for the driver or SDK. Windows has a nasty history of not cleanly
-uninstalling files so you may have to use third party tools like driversweeper
-to remove old versions. The other common reason for this is windows
-antivirus software is disabling one of the DLLs from working. If cgminer
-starts with the -T option but never starts without it, this is a sure fire
-sign you have this problem and will have to disable your antivirus or make
-exceptions.
-
-Q: Cgminer cannot see any of my GPUs even though I have configured them all
-to be enabled and installed OpenCL (+/- Xorg is running and the DISPLAY
-variable is exported on linux)?
-A: Check the output of 'cgminer -n', it will list what OpenCL devices your
-installed SDK recognises. If it lists none, you have a problem with your
-version or installation of the SDK.
-
-Q: Cgminer is mining on the wrong GPU, I want it on the AMD but it's mining
-on my on board GPU?
-A: Make sure the AMD OpenCL SDK is installed, check the output of 'cgminer -n'
-and use the appropriate parameter with --gpu-platform.
-
-Q: I'm getting much lower hashrates than I should be for my GPU?
-A: Look at your driver/SDK combination and disable power saving options for
-your GPU. Specifically look to disable ULPS. Make sure not to set intensity
-above 11 for BTC mining.
-
-Q: Can I mine with AMD while running Nvidia or Intel GPUs at the same time?
-A: If you can install both drivers successfully (easier on windows) then
-yes, using the --gpu-platform option.
-
-Q: Can I mine with Nvidia or Intel GPUs?
-A: Yes but their hashrate is very poor and likely you'll be using much more
-energy than you'll be earning in coins.
-
-Q: Can I mine on both Nvidia and AMD GPUs at the same time?
-A: No, you must run one instance of cgminer with the --gpu-platform option for
-each.
-
-Q: Can I mine on Linux without running Xorg?
-A: With Nvidia you can, but with AMD you cannot.
-
-Q: I can't get anywhere near enough hashrate for scrypt compared to other
-people?
-A: You may not have enough system RAM as this is also required.
-
-Q: My scrypt hashrate is high but the pool reports only a tiny proportion of
-my hashrate?
-A: You are generating garbage hashes due to your choice of settings. Your
-Work Utility (WU) value will confirm you are not generating garbage. You
-should be getting about .9WU per kHash. If not, then try decreasing your
-intensity, do not increase the number of gpu-threads, and consider adding
-system RAM to match your GPU ram. You may also be using a bad combination
-of driver and/or SDK. If you are getting a lot more HW errors with the
-current version of cgminer but were not on an older version, chances are that
-the older version simply wasn't reporting them so going back to and older
-version is not a real solution.
-
-Q: Scrypt fails to initialise the kernel every time?
-A: Your parameters are too high. Don't add GPU threads, don't set intensity
-too high, decrease thread concurrency. See the SCRYPT-README for a lot more
-help.
-
-Q: Cgminer stops mining (or my GPUs go DEAD) and I can't close it?
-A: Once the driver has crashed, there is no way for cgminer to close cleanly.
-You will have to kill it, and depending on how corrupted your driver state
-has gotten, you may even need to reboot. Windows is known to reset drivers
-when they fail and cgminer will be stuck trying to use the old driver instance.
-GPUs going SICK or DEAD is a sign of overclocking too much, overheating,
-driver or hardware instability.
-
-Q: I can't get any monitoring of temperatures or fanspeed with cgminer when
-I start it remotely?
-A: With linux, make sure to export the DISPLAY variable. On windows, you
-cannot access these monitoring values via RDP. This should work with tightVNC
-or teamviewer though.
-
-Q: I change my GPU engine/memory/voltage and cgminer reports back no change?
-A: Cgminer asks the GPU using the ATI Display Library to change settings, but
-the driver and hardware are free to do what it wants with that query, including
-ignoring it. Some GPUs are locked with one or more of those properties as well.
-The most common of these is that many GPUs only allow a fixed difference
-between the engine clock speed and the memory clock speed (such as the memory
-being no lower than the engine - 150). Other 3rd party tools have unofficial
-data on these devices on windows and can get the memory clock speed down
-further but cgminer does not have access to these means.
-
-Q: I have multiple GPUs and although many devices show up, it appears to be
-working only on one GPU splitting it up.
-A: Your driver setup is failing to properly use the accessory GPUs. Your
-driver may be configured wrong or you have a driver version that needs a dummy
-plug on all the GPUs that aren't connected to a monitor.
-
-Q: Should I use crossfire/SLI?
-A: It does not benefit mining at all and depending on the GPU may actually
-worsen performance.
-
-Q: I have some random GPU performance related problem not addressed above.
-A: Seriously, it's the driver and/or SDK. Uninstall them and start again,
-noting there is no clean way to uninstall them so you have to use extra tools
-or do it manually.
-
-Q: Do I need to recompile after updating my driver/SDK?
-A: No. The software is unchanged regardless of which driver/SDK/ADL_SDK version
-you are running. However if you change SDKs you should delete any generated
-.bin files for them to be recreated with the new SDK.
-
-Q: I do not want cgminer to modify my engine/clock/fanspeed?
-A: Cgminer only modifies values if you tell it to via some parameters.
-Otherwise it will just monitor the values.
-
-Q: Cgminer does not disable my GPU even though it hit the overheat temperature?
-A: It only disables GPUs if you enable the --auto-gpu option. If you don't give
-it parameters for engine clock it will not adjust engine clocks with this
-option.
-
-Q: Can I use the open source radeon driver for AMD GPUs or the nouveau driver
-for NVIDIA GPUs?
-A: None of them currently support OpenCL, so no you cannot.
-
----
-
-This code is provided entirely free of charge by the programmer in his spare
-time so donations would be greatly appreciated. Please consider donating to the
-address below.
-
-Con Kolivas <kernel@kolivas.org>
-15qSxP1SQcUX3o4nhkfdbgyoWEFMomJ4rZ
diff --git a/Makefile.am b/Makefile.am
index 895b60f..91530c5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,12 +9,12 @@ else
USBUTILS_INCLUDES =
endif
-EXTRA_DIST = example.conf m4/gnulib-cache.m4 linux-usb-cgminer \
- ADL_SDK/readme.txt api-example.php miner.php \
+EXTRA_DIST = example.conf linux-usb-cgminer \
+ api-example.php miner.php \
API.class API.java api-example.c windows-build.txt \
- bitstreams/* API-README FPGA-README SCRYPT-README \
+ bitstreams/* API-README FPGA-README \
bitforce-firmware-flash.c hexdump.c ASIC-README \
- 01-cgminer.rules GPU-README
+ 01-cgminer.rules
SUBDIRS = lib compat ccan
@@ -24,18 +24,16 @@ bin_PROGRAMS = cgminer
cgminer_LDFLAGS = $(PTHREAD_FLAGS)
cgminer_LDADD = $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ \
- @OPENCL_LIBS@ @NCURSES_LIBS@ @PDCURSES_LIBS@ @WS2_LIBS@ \
+ @NCURSES_LIBS@ @PDCURSES_LIBS@ @WS2_LIBS@ \
@LIBUSB_LIBS@ @MM_LIBS@ @RT_LIBS@ \
@MATH_LIBS@ lib/libgnu.a ccan/libccan.a
if HAVE_WINDOWS
-cgminer_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib @OPENCL_FLAGS@
+cgminer_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib
else
-cgminer_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib @OPENCL_FLAGS@ @LIBCURL_CFLAGS@
+cgminer_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib @LIBCURL_CFLAGS@
endif
-cgminer_CPPFLAGS += $(ADL_CPPFLAGS)
-
# common sources
cgminer_SOURCES := cgminer.c
@@ -45,20 +43,6 @@ cgminer_SOURCES += elist.h miner.h compat.h bench_block.h \
cgminer_SOURCES += logging.c
-if HAS_OPENCL
-bin_SCRIPTS = $(top_srcdir)/*.cl
-
-cgminer_SOURCES += driver-opencl.h driver-opencl.c
-cgminer_SOURCES += ocl.c ocl.h findnonce.c findnonce.h
-cgminer_SOURCES += adl.c adl.h adl_functions.h
-cgminer_SOURCES += *.cl
-
-if HAS_SCRYPT
-cgminer_SOURCES += scrypt.c scrypt.h
-endif
-
-endif
-
if NEED_FPGAUTILS
cgminer_SOURCES += fpgautils.c fpgautils.h
endif
@@ -104,6 +88,10 @@ if HAS_KLONDIKE
cgminer_SOURCES += driver-klondike.c
endif
+if HAS_BAB
+cgminer_SOURCES += driver-bab.c
+endif
+
if HAS_MODMINER
cgminer_SOURCES += driver-modminer.c
bitstreamsdir = $(bindir)/bitstreams
diff --git a/NEWS b/NEWS
index 48f7f7f..a1209b7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,63 @@
+Version 3.8.1 - 11th November 2013
+
+- Revert "Send a zero length packet at the end of every usb transfer on windows
+in case libusb internally has batched them into one maxpacket sized."
+
+
+Version 3.8.0 - 10th November 2013
+
+- api update version to 2.0 and remove GPU form API-README
+-Remove now unused scrypt files.
+- api.c remove all GPU/gpu references and correct code as required
+- Rudimentary removal of GPU OpenCL and Scrypt features from api.c
+- Reorder configure alphabetically for devices to compile and fail if no support
+is selected to be compiled in.
+- BaB update/format some comments
+- BlackArrowBitfury early GPIO V1 driver
+- Fine tune the reading of results in bitfury driver to not lose any across work
+restarts or corrupt due to store results not parsed during restart.
+- Send a zero length packet at the end of every usb transfer on windows in case
+libusb internally has batched them into one maxpacket sized.
+- Framework for ntime rolling, keep looking for OP_USB_INIT replies when other
+packets received
+- Configure source for a new BaB driver
+- sha2 allow external access to some macros and the K array
+- Fixed a math issue when reporting fan speed on the status line.
+- Use the main hashlist to store work done in the bitfury driver and remove work
+from the list by time, thereby fixing the duplicates at startup. Count hardware
+errors for when no match occurs.
+- Add a get and queue helper work function.
+- Remove GPU mining code.
+- Use libusb's own zero length packet support unless we have to emulate it on
+windows since only libusb knows for sure if it's needed.
+- Unlock the avalon qlock while sending tasks to not hold the lock for an
+extended period.
+- Sleep in avalon send task on return to the function to allow other code to
+work during the sleep period.
+- Send zero length packets when terminating a usb write aligned to
+maxpacketsize.
+- Do the driver flush in avalon code lockless since it can lead to deadlocks.
+- Reset the work_restart bool after the scanwork loop in case the driver flushes
+work synchronously.
+- Only check for the stratum clean message if we have had a valid message.
+- Get rid of the stage thread since all work can be asynchronously added now via
+hash_push anyway.
+- Remove the now incorrect faq entry regarding scrypt difficulty.
+- Check for fatal read errors and break out of the read loop in avalon.
+- Send errors are basically fatal in avalon driver so break out of the send
+tasks loop.
+- Make the avalon driver return -1 for hash count when usb fails, allowing the
+main loop code to send it the shutdown flag.
+- Break out of the hash work loops when a failure is detected instead of
+dropping into mt disable.
+- Use usbutils' own ftdi parser for avalon and the ftdir's own latency for
+managing timeouts since we can wait on reads with completely asynchronous
+reads+writes.
+- Use usbutils' own cps function for slowing rate of usb writes on avalon.
+- Fix build for no libcurl
+- Check length before submitting sync transfers
+
+
Version 3.7.2 - 5th November 2013
- Clean up completely on avalon shutdown.
diff --git a/README b/README
index b8da21f..3e19f78 100644
--- a/README
+++ b/README
@@ -1,6 +1,4 @@
-This is a multi-threaded multi-pool GPU, FPGA and ASIC miner with ATI GPU
-monitoring, (over)clocking and fanspeed support for bitcoin and derivative
-coins. Do not use on multiple block chains at the same time!
+This is a multi-threaded multi-pool FPGA and ASIC miner for bitcoin.
This code is provided entirely free of charge by the programmer in his spare
time so donations would be greatly appreciated. Please consider donating to the
@@ -27,22 +25,12 @@ irc://irc.freenode.net/cgminer
License: GPLv3. See COPYING for details.
-SEE ALSO API-README, ASIC-README, FGPA-README, GPU-README AND SCRYPT-README FOR
-MORE INFORMATION ON EACH.
+SEE ALSO API-README, ASIC-README and FGPA-README FOR MORE INFORMATION ON EACH.
---
EXECUTIVE SUMMARY ON USAGE:
-After saving configuration from the menu, you do not need to give cgminer any
-arguments and it will load your configuration.
-
-Any configuration file may also contain a single
- "include" : "filename"
-to recursively include another configuration file.
-Writing the configuration will save all settings from all files in the output.
-
-
Single pool:
cgminer -o http://pool:port -u username -p password
@@ -51,11 +39,11 @@ Multiple pools:
cgminer -o http://pool1:port -u pool1username -p pool1password -o http://pool2:port -u pool2usernmae -p pool2password
-Single pool with a standard http proxy, regular desktop:
+Single pool with a standard http proxy:
cgminer -o "http:proxy:port|http://pool:port" -u username -p password
-Single pool with a socks5 proxy, regular desktop:
+Single pool with a socks5 proxy:
cgminer -o "socks5:proxy:port|http://pool:port" -u username -p password
@@ -77,28 +65,33 @@ not be available. All are available since CURL version 7.19.4
If you specify the --socks-proxy option to cgminer, it will only be applied to all pools
that don't specify their own proxy setting like above
+
+After saving configuration from the menu, you do not need to give cgminer any
+arguments and it will load your configuration.
+
+Any configuration file may also contain a single
+ "include" : "filename"
+to recursively include another configuration file.
+Writing the configuration will save all settings from all files in the output.
+
+
---
BUILDING CGMINER FOR YOURSELF
DEPENDENCIES:
Mandatory:
- curl dev library http://curl.haxx.se/libcurl/
- (libcurl4-openssl-dev)
-
pkg-config http://www.freedesktop.org/wiki/Software/pkg-config
libtool http://www.gnu.org/software/libtool/
Optional:
+ curl dev library http://curl.haxx.se/libcurl/
+ (libcurl4-openssl-dev - Must tell configure --disable-libcurl otherwise
+ it will attempt to compile it in)
+
curses dev library
(libncurses5-dev or libpdcurses on WIN32 for text user interface)
- AMD APP SDK http://developer.amd.com/sdks/AMDAPPSDK
- (This sdk is mandatory for GPU mining)
-
- AMD ADL SDK http://developer.amd.com/sdks/ADLSDK
- (This sdk is mandatory for ATI GPU monitoring & clocking)
-
libudev dev library (libudev-dev)
- (This is only required for ASIC+FPGA support and is linux only)
+ (This is only required for USB device support and is linux only)
If building from git:
autoconf
@@ -109,10 +102,6 @@ If building on Red Hat:
curl libcurl libcurl-devel openssh
CGMiner specific configuration options:
- --enable-opencl Enable support for GPU mining with opencl
- --disable-adl Override detection and disable building with adl
- --enable-scrypt Compile support for scrypt litecoin mining (default
- disabled)
--enable-avalon Compile support for Avalon (default disabled)
--enable-bflsc Compile support for BFL ASICs (default disabled)
--enable-bitforce Compile support for BitForce FPGAs (default
@@ -121,6 +110,7 @@ CGMiner specific configuration options:
--enable-hashfast Compile support for Hashfast (default disabled)
--enable-icarus Compile support for Icarus (default disabled)
--enable-knc Compile support for KnC miners (default disabled)
+ --enable-bab Compile support for BlackArrow Bitfury (default disabled)
--enable-klondike Compile support for Klondike (default disabled)
--enable-modminer Compile support for ModMiner FPGAs(default disabled)
--without-curses Compile support for curses TUI (default enabled)
@@ -132,6 +122,7 @@ Basic *nix build instructions:
./autogen.sh # only needed if building from git repo
CFLAGS="-O2 -Wall -march=native" ./configure <options>
+ make
No installation is necessary. You may run cgminer from the build
directory directly, but you may do make install if you wish to install
@@ -143,7 +134,8 @@ Native WIN32 build instructions: see windows-build.txt
Usage instructions: Run "cgminer --help" to see options:
-Usage: . [-atDdGCgIKklmpPQqrRsTouvwOchnV]
+Usage: cgminer [-DdElmpPQqUsTouOchnV]
+
Options for both config file and command line:
--api-allow Allow API access (if enabled) only to the given list of [W:]IP[/Prefix] address[/subnets]
This overrides --api-network and you must specify 127.0.0.1 if it is required
@@ -161,8 +153,6 @@ Options for both config file and command line:
--api-mcast-code <arg> Code expected in the API Multicast message, don't use '-' (default: "FTW")
--api-mcast-port <arg> API Multicast listen port, (default: 4028)
--api-port Port number of miner API (default: 4028)
---auto-fan Automatically adjust all GPU fan speeds to maintain a target temperature
---auto-gpu Automatically adjust all GPU engine clock speeds to maintain a target temperature
--balance Change multipool strategy from failover to even share balance
--benchmark Run cgminer in benchmark mode - produces no shares
--compact Use compact display without per device statistics
@@ -173,7 +163,7 @@ Options for both config file and command line:
--failover-only Don't leak work to backup pools when primary pool is lagging
--fix-protocol Do not redirect to a different getwork protocol (eg. stratum)
--hotplug <arg> Set hotplug check time to <arg> seconds (0=never default: 5) - only with libusb
---kernel-path|-K <arg> Specify a path to where bitstream and kernel files are (default: "/usr/local/bin")
+--kernel-path|-K <arg> Specify a path to where bitstream files are (default: "/usr/local/bin")
--load-balance Change multipool strategy from failover to quota based balance
--log|-l <arg> Interval in seconds between log output (default: 5)
--lowmem Minimise caching of shares for low memory applications
@@ -192,7 +182,6 @@ Options for both config file and command line:
--scan-time|-s <arg> Upper bound on time spent scanning current work, in seconds (default: 60)
--sched-start <arg> Set a time of day in HH:MM to start mining (a once off without a stop time)
--sched-stop <arg> Set a time of day in HH:MM to stop mining (will quit without a start time)
---scrypt Use the scrypt algorithm for mining (litecoin only)
--sharelog <arg> Append share log to file
--shares <arg> Quit after mining N shares (default: unlimited)
--socks-proxy <arg> Set socks4 proxy (host:port) for all pools without a proxy specified
@@ -244,46 +233,9 @@ FPGA only options:
See FGPA-README for more information regarding this.
-GPU only options:
-
---auto-fan Automatically adjust all GPU fan speeds to maintain a target temperature
---auto-gpu Automatically adjust all GPU engine clock speeds to maintain a target temperature
---disable-gpu|-G Disable GPU mining even if suitable devices exist
---gpu-threads|-g <arg> Number of threads per GPU (1 - 10) (default: 2)
---gpu-dyninterval <arg> Set the refresh interval in ms for GPUs using dynamic intensity (default: 7)
---gpu-engine <arg> GPU engine (over)clock range in Mhz - one value, range and/or comma separated list (e.g. 850-900,900,750-850)
---gpu-fan <arg> GPU fan percentage range - one value, range and/or comma separated list (e.g. 25-85,85,65)
---gpu-map <arg> Map OpenCL to ADL device order manually, paired CSV (e.g. 1:0,2:1 maps OpenCL 1 to ADL 0, 2 to 1)
---gpu-memclock <arg> Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card.
---gpu-memdiff <arg> Set a fixed difference in clock speed between the GPU and memory in auto-gpu mode
---gpu-powertune <arg> Set the GPU powertune percentage - one value for all or separate by commas for per card.
---gpu-reorder Attempt to reorder GPU devices according to PCI Bus ID
---gpu-vddc <arg> Set the GPU voltage in Volts - one value for all or separate by commas for per card.
---intensity|-I <arg> Intensity of GPU scanning (d or -10 -> 10, default: d to maintain desktop interactivity)
---kernel|-k <arg> Override kernel to use (diablo, poclbm, phatk or diakgcn) - one value or comma separated
---ndevs|-n Enumerate number of detected GPUs and exit
---no-restart Do not attempt to restart GPUs that hang
---temp-hysteresis <arg> Set how much the temperature can fluctuate outside limits when automanaging speeds (default: 3)
---temp-overheat <arg> Overheat temperature when automatically managing fan and GPU speeds (default: 85)
---temp-target <arg> Target temperature when automatically managing fan and GPU speeds (default: 75)
---vectors|-v <arg> Override detected optimal vector (1, 2 or 4) - one value or comma separated list
---worksize|-w <arg> Override detected optimal worksize - one value or comma separated list
-
-See GPU-README for more information regarding GPU mining.
-
-
-SCRYPT only options:
-
---lookup-gap <arg> Set GPU lookup gap for scrypt mining, comma separated
---shaders <arg> GPU shaders per card for tuning scrypt, comma separated
---thread-concurrency <arg> Set GPU thread concurrency for scrypt mining, comma separated
-
-See SCRYPT-README for more information regarding litecoin mining.
-
-
Cgminer should automatically find all of your Avalon ASIC, BFL ASIC, BitForce
FPGAs, Icarus bitstream FPGAs, Klondike ASIC, ASICMINER usb block erupters,
-KnC ASICs, Hashfast ASICs and ModMiner FPGAs.
+KnC ASICs, BaB ASICs, Hashfast ASICs and ModMiner FPGAs.
---
@@ -298,7 +250,7 @@ drivers for you and then once you plug in your device you can choose the
"list all devices" from the "option" menu and you should be able to see the
device as something like: "BitFORCE SHA256 SC". Choose the install or replace
driver option and select WinUSB. You can either google for zadig or download
-it from the cgminer directoy in the DOWNLOADS link above.
+it from the cgminer directory in the DOWNLOADS link above.
LINUX:
@@ -387,7 +339,7 @@ WHILE RUNNING:
The following options are available while running with a single keypress:
-[P]ool management [G]PU management [S]ettings [D]isplay options [Q]uit
+[P]ool management [S]ettings [D]isplay options [Q]uit
P gives you:
@@ -422,33 +374,15 @@ co[M]pact: off
Q quits the application.
-G gives you something like:
-
-GPU 0: [124.2 / 191.3 Mh/s] [A:77 R:33 HW:0 U:1.73/m WU 1.73/m]
-Temp: 67.0 C
-Fan Speed: 35% (2500 RPM)
-Engine Clock: 960 MHz
-Memory Clock: 480 Mhz
-Vddc: 1.200 V
-Activity: 93%
-Powertune: 0%
-Last initialised: [2011-09-06 12:03:56]
-Thread 0: 62.4 Mh/s Enabled ALIVE
-Thread 1: 60.2 Mh/s Enabled ALIVE
-
-[E]nable [D]isable [R]estart GPU [C]hange settings
-Or press any other key to continue
-
-
The running log shows output like this:
- [2012-10-12 18:02:20] Accepted f0c05469 Diff 1/1 GPU 0 pool 1
- [2012-10-12 18:02:22] Accepted 218ac982 Diff 7/1 GPU 1 pool 1
- [2012-10-12 18:02:23] Accepted d8300795 Diff 1/1 GPU 3 pool 1
- [2012-10-12 18:02:24] Accepted 122c1ff1 Diff 14/1 GPU 1 pool 1
+ [2013-11-09 11:04:41] Accepted 01b3bde7 Diff 150/128 AVA 1 pool 0
+ [2013-11-09 11:04:49] Accepted 015df995 Diff 187/128 AVA 1 pool 0
+ [2013-11-09 11:04:50] Accepted 01163b68 Diff 236/128 AVA 1 pool 0
+ [2013-11-09 11:04:53] Accepted 9f745840 Diff 411/128 BAS 1 pool 0
-The 8 byte hex value are the 2nd 8 bytes of the share being submitted to the
-pool. The 2 diff values are the actual difficulty target that share reached
+The 8 byte hex value are the 1st nonzero bytes of the share being submitted to
+the pool. The 2 diff values are the actual difficulty target that share reached
followed by the difficulty target the pool is currently asking for.
---
@@ -468,7 +402,7 @@ HW: The number of HardWare errors
WU: The Work Utility defined as the number of diff1 shares work / minute
(accepted or rejected).
- GPU 1: 73.5C 2551RPM | 427.3/443.0Mh/s | A:8 R:0 HW:0 WU:4.39/m
+ BAS 1: max 67C 3.27V | 62.29G/62.19Gh/s | A:140813 R:256 HW:2860 WU: 852.0/m
Each column is as follows:
Temperature (if supported)
@@ -650,7 +584,7 @@ For RPC API details see the API-README file
FAQ
-Q: Can I mine on servers from different networks (eg smartcoin and bitcoin) at
+Q: Can I mine on servers from different networks (eg xxxcoin and bitcoin) at
the same time?
A: No, cgminer keeps a database of the block it's working on to ensure it does
not work on stale blocks, and having different blocks from two networks would
@@ -677,7 +611,7 @@ Q: Work keeps going to my backup pool even though my primary pool hasn't
failed?
A: Cgminer checks for conditions where the primary pool is lagging and will
pass some work to the backup servers under those conditions. The reason for
-doing this is to try its absolute best to keep the GPUs working on something
+doing this is to try its absolute best to keep the devices working on something
useful and not risk idle periods. You can disable this behaviour with the
option --failover-only.
@@ -698,18 +632,12 @@ any further.
Q: What are the best parameters to pass for X pool/hardware/device.
A: Virtually always, the DEFAULT parameters give the best results. Most user
-defined settings lead to worse performance. The ONLY thing most users should
-need to set is the Intensity for GPUs.
-
-Q: What happened to CPU mining?
-A: Being increasingly irrelevant for most users, and a maintenance issue, it is
-no longer under active development and will not be supported. No binary builds
-supporting CPU mining will be released. Virtually all remaining users of CPU
-mining are as back ends for illegal botnets. The main reason cgminer is being
-inappopriately tagged as a virus by antivirus software is due to the trojans
-packaging a CPU mining capable version of it. There is no longer ANY CPU mining
-code in cgminer. If you are mining bitcoin with CPU today, you are spending
-1000x more in electricity costs than you are earning in bitcoin.
+defined settings lead to worse performance.
+
+Q: What happened to CPU and GPU mining?
+A: Their efficiency makes them irrelevant in the bitcoin mining world today
+and the author has no interest in supporting alternative coins that are better
+mined by these devices.
Q: GUI version?
A: No. The RPC interface makes it possible for someone else to write one
@@ -717,49 +645,25 @@ though.
Q: I'm having an issue. What debugging information should I provide?
A: Start cgminer with your regular commands and add -D -T --verbose and provide
-the full startup output and a summary of your hardware, operating system, ATI
-driver version and ATI stream version.
+the full startup output and a summary of your hardware and operating system.
Q: Why don't you provide win64 builds?
A: Win32 builds work everywhere and there is precisely zero advantage to a
64 bit build on windows.
Q: Is it faster to mine on windows or linux?
-A: It makes no difference. It comes down to choice of operating system for
-their various features. Linux offers much better long term stability and
-remote monitoring and security, while windows offers you overclocking tools
-that can achieve much more than cgminer can do on linux.
-
-Q: Can I mine with cgminer on a MAC?
-A: cgminer will compile on OSX, but the performance of GPU mining is
-compromised due to the opencl implementation on OSX, there is no temperature
-or fanspeed monitoring, and the cooling design of most MACs, despite having
-powerful GPUs, will usually not cope with constant usage leading to a high
-risk of thermal damage. It is highly recommended not to mine on a MAC unless
-it is to a USB device.
-
-Q: I'm trying to mine litecoin but cgminer shows MH values instead of kH and
-submits no shares?
-A: Add the --scrypt parameter.
-
-Q: I switch users on windows and my mining stops working?
-A: That's correct, it does. It's a permissions issue that there is no known
-fix for due to monitoring of GPU fanspeeds and temperatures. If you disable
-the monitoring with --no-adl it should switch okay.
+A: It makes no difference in terms of performance. It comes down to choice of
+operating system for their various features and your comfort level. However
+linux is the primary development platform and is virtually guaranteed to be
+more stable.
Q: My network gets slower and slower and then dies for a minute?
-A; Try the --net-delay option.
+A; Try the --net-delay option if you are on a getwork or GBT server.
Q: How do I tune for p2pool?
-A: p2pool has very rapid expiration of work and new blocks, it is suggested you
-decrease intensity by 1 from your optimal value, and decrease GPU threads to 1
-with -g 1. It is also recommended to use --failover-only since the work is
-effectively like a different block chain. If mining with a minirig, it is worth
-adding the --bfl-range option.
-
-Q: Are OpenCL kernels from other mining software useable in cgminer?
-A: No, the APIs are slightly different between the different software and they
-will not work.
+A: It is also recommended to use --failover-only since the work is effectively
+like a different block chain, and not enabling --no-submit-stale. If mining with
+a BFL (fpga) minirig, it is worth adding the --bfl-range option.
Q: I run PHP on windows to access the API with the example miner.php. Why does
it fail when php is installed properly but I only get errors about Sockets not
@@ -773,9 +677,8 @@ mining. Since the acronym needs to be only 3 characters, the "Field-" part has
been skipped.
Q: What is an ASIC?
-A: Cgminer currently supports 2 ASICs: Avalon and BitForce SC devices. They
-are Application Specify Integrated Circuit devices and provide the highest
-performance per unit power due to being dedicated to only one purpose.
+A: They are Application Specify Integrated Circuit devices and provide the
+highest performance per unit power due to being dedicated to only one purpose.
Q: Can I mine scrypt with FPGAs or ASICs?
A: No.
@@ -802,10 +705,6 @@ average to find one 8 difficulty share, per 8 single difficulty shares found.
However, the number is actually random and converges over time, it is an average,
not an exact value, thus you may find more or less than the expected average.
-Q: Can I make a donation in litecoin?
-A: Yes, see SCRYPT-README for the address, but the author prefers bitcoin if
-possible.
-
Q: My keyboard input momentarily pauses or repeats keys every so often on
windows while mining?
A: The USB implementation on windows can be very flaky on some hardware and
diff --git a/SCRYPT-README b/SCRYPT-README
deleted file mode 100644
index 7addc05..0000000
--- a/SCRYPT-README
+++ /dev/null
@@ -1,242 +0,0 @@
-While BTC donations are preferred, if you wish to donate to the author, Con
-Kolivas, in LTC, please submit your donations to:
-
-Lc8TWMiKM7gRUrG8VB8pPNP1Yvt1SGZnoH
-
-Otherwise, please donate in BTC as per the main README.
-
----
-
-Scrypt mining, AKA litecoin mining, for GPU is completely different to sha256
-used for bitcoin mining. The algorithm was originally developed in a manner
-that it was anticipated would make it suitable for mining on CPU but NOT GPU.
-Thanks to some innovative work by Artforz and mtrlt, this was proven to be
-wrong. However, it has very different requirements to bitcoin mining and is a
-lot more complicated to get working well. Note that it is a ram dependent
-workload, and requires you to have enough system ram as well as fast enough
-GPU ram. If you have less system ram than your GPU has, it may not be possible
-to mine at any reasonable rate.
-
-There are 5 main parameters to tuning scrypt, all of which are optional for
-further fine tuning. When you start scrypt mining with the --scrypt option,
-cgminer will fail IN RANDOM WAYS. They are all due to parameters being outside
-what the GPU can cope with.
-
-NOTE that if it does not fail at startup, the presence of hardware errors (HW)
-are a sure sign that you have set the parameters too high.
-
-
-DRIVERS AND OPENCL SDK
-
-The choice of driver version for your GPU is critical, as some are known to
-break scrypt mining entirely while others give poor hashrates. As for the
-OpenCL SDK installed, for AMD it must be version 2.6 or later.
-
-
-Step 1 on linux:
-export GPU_MAX_ALLOC_PERCENT=100
-If you do not do this, you may find it impossible to scrypt mine. You may find
-a value of 40 is enough and increasing this further has little effect.
-
-export GPU_USE_SYNC_OBJECTS=1
-may help CPU usage a little as well.
-
-On windows the same commands can be passed via a batch file if the following
-lines are in the .bat before starting cgminer:
-setx GPU_MAX_ALLOC_PERCENT 100
-setx GPU_USE_SYNC_OBJECTS 1
-
---intensity XX (-I XX)
-
-Just like in bitcoin mining, scrypt mining takes an intensity, however the
-scale goes from 0 to 20 to mimic the "Aggression" used in mtrlt's reaper. The
-reason this is crucial is that too high an intensity can actually be
-disastrous with scrypt because it CAN run out of ram. High intensities
-start writing over the same ram and it is highly dependent on the GPU, but they
-can start actually DECREASING your hashrate, or even worse, start producing
-garbage with HW errors skyrocketing. Note that if you do NOT specify an
-intensity, cgminer uses dynamic mode which is designed to minimise the harm
-to a running desktop and performance WILL be poor. The lower limit to intensity
-with scrypt is usually 8 and cgminer will prevent it going too low.
-SUMMARY: Setting this for reasonable hashrates is mandatory.
-
---shaders XXX
-
-is a new option where you tell cgminer how many shaders your GPU has. This
-helps cgminer try to choose some meaningful baseline parameters. Use this table
-below to determine how many shaders your GPU has, and note that there are some
-variants of these cards, and nvidia shaders are much much lower and virtually
-pointless trying to mine on. If this is not set, cgminer will query the
-device for how much memory it supports and will try to set a value based on
-that.
-SUMMARY: This will get you started but fine tuning for optimal performance is
-required.
-
-GPU Shaders
-7750 512
-7770 640
-7850 1024
-7870 1280
-7950 1792
-7970 2048
-
-6850 960
-6870 1120
-6950 1408
-6970 1536
-6990 (6970x2)
-
-6570 480
-6670 480
-6790 800
-
-6450 160
-
-5670 400
-5750 720
-5770 800
-5830 1120
-5850 1440
-5870 1600
-5970 (5870x2)
-
-These are only used as a rough guide for cgminer, and it is rare that this is
-all you will need to set.
-
-
-Optional parameters to tune:
--g, --thread-concurrency, --lookup-gap
-
---thread-concurrency:
-This tunes the optimal size of work that scrypt can do. It is internally tuned
-by cgminer to be the highest reasonable multiple of shaders that it can
-allocate on your GPU. Ideally it should be a multiple of your shader count.
-vliw5 architecture (R5XXX) would be best at 5x shaders, while VLIW4 (R6xxx and
-R7xxx) are best at 4x. Setting thread concurrency overrides anything you put
-into --shaders and is ultimately a BETTER way to tune performance.
-SUMMARY: Spend lots of time finding the highest value that your device likes
-and increases hashrate.
-
--g:
-Once you have found the optimal shaders and intensity, you can start increasing
-the -g value till cgminer fails to start. This is really only of value if you
-want to run low intensities as you will be unable to run more than 1.
-SUMMARY: Don't touch this.
-
---lookup-gap
-This tunes a compromise between ram usage and performance. Performance peaks
-at a gap of 2, but increasing the gap can save you some GPU ram, but almost
-always at the cost of significant loss of hashrate. Setting lookup gap
-overrides the default of 2, but cgminer will use the --shaders value to choose
-a thread-concurrency if you haven't chosen one.
-SUMMARY: Don't touch this.
-
-
-Related parameters:
---worksize XX (-w XX)
-Has a minor effect, should be a multiple of 64 up to 256 maximum.
-SUMMARY: Worth playing with once everything else has been tried but will
-probably do nothing.
-
---vectors XX (-v XX)
-Vectors are NOT used by the scrypt mining kernel.
-SUMMARY: Does nothing.
-
-
-Overclocking for scrypt mining:
-First of all, do not underclock your memory initially. Scrypt mining requires
-memory speed and on most, but not all, GPUs, lowering memory speed lowers
-mining performance.
-
-Second, absolute engine clock speeds do NOT correlate with hashrate. The ratio
-of engine clock speed to memory matters, so if you set your memory to the
-default value, and then start overclocking as you are running it, you should
-find a sweet spot where the hashrate peaks and then it might actually drop if
-you increase the engine clock speed further.
-
-Third, the combination of motherboard, CPU and system ram ALSO makes a
-difference, so values that work for a GPU on one system may not work for the
-same GPU on a different system. A decent amount of system ram is actually
-required for scrypt mining, and 4GB is suggested.
-
-Finally, the power consumption while mining at high engine clocks, very high
-memory clocks can be far in excess of what you might imagine.
-For example, a 7970 running with the following settings:
---thread-concurrency 22392 --gpu-engine 1135 --gpu-memclock 1890
-was using 305W!
-
----
-TUNING AN AMD RADEON 7970
-Example tuning a 7970 for Scrypt mining:
-
-On linux run this command:
-export GPU_MAX_ALLOC_PERCENT=100
-or on windows this:
-setx GPU_MAX_ALLOC_PERCENT 100
-in the same console/bash/dos prompt/bat file/whatever you want to call it,
-before running cgminer.
-
-First, find the highest thread concurrency that you can start it at. They should
-all start at 8192 but some will go up to 3 times that. Don't go too high on the
-intensity while testing and don't change gpu threads. If you cannot go above
-8192, don't fret as you can still get a high hashrate.
-
-Delete any .bin files so you're starting from scratch and see what bins get
-generated.
-
-First try without any thread concurrency or even shaders, as cgminer will try to
-find an optimal value
-cgminer -I 13
-
-If that starts mining, see what bin was generated, it is likely the largest
-meaningful TC you can set.
-Starting it on mine I get:
-scrypt130302Tahitiglg2tc22392w64l8.bin
-
-See tc22392 that's telling you what thread concurrency it was. It should start
-without TC parameters, but you never know. So if it doesn't, start with
---thread-concurrency 8192 and add 2048 to it at a time till you find the highest
-value it will start successfully at.
-
-Then start overclocking the eyeballs off your memory, as 7970s are exquisitely
-sensitive to memory speed and amazingly overclockable but please make sure it
-keeps adequately cooled with --auto-fan! Do it while it's running from the GPU
-menu. Go up by 25 at a time every 30 seconds or so until your GPU crashes. Then
-reboot and start it 25 lower as a rough start. Mine runs stable at 1900 memory
-without overvolting. Overvolting is the only thing that can actually damage your
-GPU so I wouldn't recommend it at all.
-
-Then once you find the maximum memory clock speed, you need to find the sweet
-spot engine clock speed that matches it. It's a fine line where one more MHz
-will make the hashrate drop by 20%. It's somewhere in the .57 - 0.6 ratio range.
-Start your engine clock speed at half your memory clock speed and then increase
-it by 5 at a time. The hashrate should climb a little each rise in engine speed
-and then suddenly drop above a certain value. Decrease it by 1 then until you
-find it climbs dramatically. If your engine clock speed cannot get that high
-without crashing the GPU, you will have to use a lower memclock.
-
-Then, and only then, bother trying to increase intensity further.
-
-My final settings were:
---gpu-engine 1141 --gpu-memclock 1875 -I 20
-for a hashrate of 745kH.
-
-Note I did not bother setting a thread concurrency. Once you have the magic
-endpoint, look at what tc was chosen by the bin file generated and then hard
-code that in next time (eg --thread-concurrency 22392) as slight changes in
-thread concurrency will happen every time if you don't specify one, and the tc
-to clock ratios are critical!
-
-Good luck, and if this doesn't work for you, well same old magic discussion
-applies, I cannot debug every hardware combo out there.
-
-Your numbers will be your numbers depending on your hardware combination and OS,
-so don't expect to get exactly the same results!
-
----
-While BTC donations are preferred, if you wish to donate to the author, Con
-Kolivas, in LTC, please submit your donations to:
-
-Lc8TWMiKM7gRUrG8VB8pPNP1Yvt1SGZnoH
-
-Otherwise, please donate in BTC as per the main README.
diff --git a/adl.c b/adl.c
deleted file mode 100644
index 8d14c27..0000000
--- a/adl.c
+++ /dev/null
@@ -1,1442 +0,0 @@
-/*
- * Copyright 2011-2012 Con Kolivas
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version. See COPYING for more details.
- */
-
-#include "config.h"
-
-#if defined(HAVE_ADL) && (defined(__linux) || defined (WIN32))
-
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-#ifdef HAVE_CURSES
-#include <curses.h>
-#endif
-
-#include "miner.h"
-#include "ADL_SDK/adl_sdk.h"
-#include "compat.h"
-
-#if defined (__linux)
-#include <dlfcn.h>
-#include <stdlib.h>
-#include <unistd.h>
-#else /* WIN32 */
-#include <windows.h>
-#include <tchar.h>
-#endif
-#include "adl_functions.h"
-
-#ifndef HAVE_CURSES
-#define wlogprint(...) applog(LOG_WARNING, __VA_ARGS__)
-#endif
-
-bool adl_active;
-bool opt_reorder = false;
-
-int opt_hysteresis = 3;
-const int opt_targettemp = 75;
-const int opt_overheattemp = 85;
-static pthread_mutex_t adl_lock;
-
-struct gpu_adapters {
- int iAdapterIndex;
- int iBusNumber;
- int virtual_gpu;
- int id;
-};
-
-// Memory allocation function
-static void * __stdcall ADL_Main_Memory_Alloc(int iSize)
-{
- void *lpBuffer = malloc(iSize);
-
- return lpBuffer;
-}
-
-// Optional Memory de-allocation function
-static void __stdcall ADL_Main_Memory_Free (void **lpBuffer)
-{
- if (*lpBuffer) {
- free (*lpBuffer);
- *lpBuffer = NULL;
- }
-}
-
-#if defined (LINUX)
-// equivalent functions in linux
-static void *GetProcAddress(void *pLibrary, const char *name)
-{
- return dlsym( pLibrary, name);
-}
-#endif
-
-static ADL_MAIN_CONTROL_CREATE ADL_Main_Control_Create;
-static ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy;
-static ADL_ADAPTER_NUMBEROFADAPTERS_GET ADL_Adapter_NumberOfAdapters_Get;
-static ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get;
-static ADL_ADAPTER_ID_GET ADL_Adapter_ID_Get;
-static ADL_OVERDRIVE5_TEMPERATURE_GET ADL_Overdrive5_Temperature_Get;
-static ADL_OVERDRIVE5_CURRENTACTIVITY_GET ADL_Overdrive5_CurrentActivity_Get;
-static ADL_OVERDRIVE5_ODPARAMETERS_GET ADL_Overdrive5_ODParameters_Get;
-static ADL_OVERDRIVE5_FANSPEEDINFO_GET ADL_Overdrive5_FanSpeedInfo_Get;
-static ADL_OVERDRIVE5_FANSPEED_GET ADL_Overdrive5_FanSpeed_Get;
-static ADL_OVERDRIVE5_FANSPEED_SET ADL_Overdrive5_FanSpeed_Set;
-static ADL_OVERDRIVE5_ODPERFORMANCELEVELS_GET ADL_Overdrive5_ODPerformanceLevels_Get;
-static ADL_OVERDRIVE5_ODPERFORMANCELEVELS_SET ADL_Overdrive5_ODPerformanceLevels_Set;
-static ADL_MAIN_CONTROL_REFRESH ADL_Main_Control_Refresh;
-static ADL_OVERDRIVE5_POWERCONTROL_GET ADL_Overdrive5_PowerControl_Get;
-static ADL_OVERDRIVE5_POWERCONTROL_SET ADL_Overdrive5_PowerControl_Set;
-static ADL_OVERDRIVE5_FANSPEEDTODEFAULT_SET ADL_Overdrive5_FanSpeedToDefault_Set;
-
-#if defined (LINUX)
- static void *hDLL; // Handle to .so library
-#else
- HINSTANCE hDLL; // Handle to DLL
-#endif
-static int iNumberAdapters;
-static LPAdapterInfo lpInfo = NULL;
-
-int set_fanspeed(int gpu, int iFanSpeed);
-static float __gpu_temp(struct gpu_adl *ga);
-
-static inline void lock_adl(void)
-{
- mutex_lock(&adl_lock);
-}
-
-static inline void unlock_adl(void)
-{
- mutex_unlock(&adl_lock);
-}
-
-/* This looks for the twin GPU that has the fanspeed control of a non fanspeed
- * control GPU on dual GPU cards */
-static bool fanspeed_twin(struct gpu_adl *ga, struct gpu_adl *other_ga)
-{
- if (!other_ga->has_fanspeed)
- return false;
- if (abs(ga->iBusNumber - other_ga->iBusNumber) != 1)
- return false;
- if (strcmp(ga->strAdapterName, other_ga->strAdapterName))
- return false;
- return true;
-}
-
-static bool prepare_adl(void)
-{
- int result;
-
-#if defined (LINUX)
- hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL);
-#else
- hDLL = LoadLibrary("atiadlxx.dll");
- if (hDLL == NULL)
- // A 32 bit calling application on 64 bit OS will fail to LoadLIbrary.
- // Try to load the 32 bit library (atiadlxy.dll) instead
- hDLL = LoadLibrary("atiadlxy.dll");
-#endif
- if (hDLL == NULL) {
- applog(LOG_INFO, "Unable to load ati adl library");
- return false;
- }
- ADL_Main_Control_Create = (ADL_MAIN_CONTROL_CREATE) GetProcAddress(hDLL,"ADL_Main_Control_Create");
- ADL_Main_Control_Destroy = (ADL_MAIN_CONTROL_DESTROY) GetProcAddress(hDLL,"ADL_Main_Control_Destroy");
- ADL_Adapter_NumberOfAdapters_Get = (ADL_ADAPTER_NUMBEROFADAPTERS_GET) GetProcAddress(hDLL,"ADL_Adapter_NumberOfAdapters_Get");
- ADL_Adapter_AdapterInfo_Get = (ADL_ADAPTER_ADAPTERINFO_GET) GetProcAddress(hDLL,"ADL_Adapter_AdapterInfo_Get");
- ADL_Adapter_ID_Get = (ADL_ADAPTER_ID_GET) GetProcAddress(hDLL,"ADL_Adapter_ID_Get");
- ADL_Overdrive5_Temperature_Get = (ADL_OVERDRIVE5_TEMPERATURE_GET) GetProcAddress(hDLL,"ADL_Overdrive5_Temperature_Get");
- ADL_Overdrive5_CurrentActivity_Get = (ADL_OVERDRIVE5_CURRENTACTIVITY_GET) GetProcAddress(hDLL, "ADL_Overdrive5_CurrentActivity_Get");
- ADL_Overdrive5_ODParameters_Get = (ADL_OVERDRIVE5_ODPARAMETERS_GET) GetProcAddress(hDLL, "ADL_Overdrive5_ODParameters_Get");
- ADL_Overdrive5_FanSpeedInfo_Get = (ADL_OVERDRIVE5_FANSPEEDINFO_GET) GetProcAddress(hDLL, "ADL_Overdrive5_FanSpeedInfo_Get");
- ADL_Overdrive5_FanSpeed_Get = (ADL_OVERDRIVE5_FANSPEED_GET) GetProcAddress(hDLL, "ADL_Overdrive5_FanSpeed_Get");
- ADL_Overdrive5_FanSpeed_Set = (ADL_OVERDRIVE5_FANSPEED_SET) GetProcAddress(hDLL, "ADL_Overdrive5_FanSpeed_Set");
- ADL_Overdrive5_ODPerformanceLevels_Get = (ADL_OVERDRIVE5_ODPERFORMANCELEVELS_GET) GetProcAddress(hDLL, "ADL_Overdrive5_ODPerformanceLevels_Get");
- ADL_Overdrive5_ODPerformanceLevels_Set = (ADL_OVERDRIVE5_ODPERFORMANCELEVELS_SET) GetProcAddress(hDLL, "ADL_Overdrive5_ODPerformanceLevels_Set");
- ADL_Main_Control_Refresh = (ADL_MAIN_CONTROL_REFRESH) GetProcAddress(hDLL, "ADL_Main_Control_Refresh");
- ADL_Overdrive5_PowerControl_Get = (ADL_OVERDRIVE5_POWERCONTROL_GET) GetProcAddress(hDLL, "ADL_Overdrive5_PowerControl_Get");
- ADL_Overdrive5_PowerControl_Set = (ADL_OVERDRIVE5_POWERCONTROL_SET) GetProcAddress(hDLL, "ADL_Overdrive5_PowerControl_Set");
- ADL_Overdrive5_FanSpeedToDefault_Set = (ADL_OVERDRIVE5_FANSPEEDTODEFAULT_SET) GetProcAddress(hDLL, "ADL_Overdrive5_FanSpeedToDefault_Set");
-
- if (!ADL_Main_Control_Create || !ADL_Main_Control_Destroy ||
- !ADL_Adapter_NumberOfAdapters_Get || !ADL_Adapter_AdapterInfo_Get ||
- !ADL_Adapter_ID_Get || !ADL_Overdrive5_Temperature_Get ||
- !ADL_Overdrive5_CurrentActivity_Get ||
- !ADL_Overdrive5_ODParameters_Get || !ADL_Overdrive5_FanSpeedInfo_Get ||
- !ADL_Overdrive5_FanSpeed_Get || !ADL_Overdrive5_FanSpeed_Set ||
- !ADL_Overdrive5_ODPerformanceLevels_Get || !ADL_Overdrive5_ODPerformanceLevels_Set ||
- !ADL_Main_Control_Refresh || !ADL_Overdrive5_PowerControl_Get ||
- !ADL_Overdrive5_PowerControl_Set || !ADL_Overdrive5_FanSpeedToDefault_Set) {
- applog(LOG_WARNING, "ATI ADL's API is missing");
- return false;
- }
-
- // Initialise ADL. The second parameter is 1, which means:
- // retrieve adapter information only for adapters that are physically present and enabled in the system
- result = ADL_Main_Control_Create (ADL_Main_Memory_Alloc, 1);
- if (result != ADL_OK) {
- applog(LOG_INFO, "ADL Initialisation Error! Error %d!", result);
- return false;
- }
-
- result = ADL_Main_Control_Refresh();
- if (result != ADL_OK) {
- applog(LOG_INFO, "ADL Refresh Error! Error %d!", result);
- return false;
- }
-
- return true;
-}
-
-void init_adl(int nDevs)
-{
- int result, i, j, devices = 0, last_adapter = -1, gpu = 0, dummy = 0;
- struct gpu_adapters adapters[MAX_GPUDEVICES], vadapters[MAX_GPUDEVICES];
- bool devs_match = true;
-
- if (unlikely(pthread_mutex_init(&adl_lock, NULL))) {
- applog(LOG_ERR, "Failed to init adl_lock in init_adl");
- return;
- }
-
- if (!prepare_adl())
- return;
-
- // Obtain the number of adapters for the system
- result = ADL_Adapter_NumberOfAdapters_Get (&iNumberAdapters);
- if (result != ADL_OK) {
- applog(LOG_INFO, "Cannot get the number of adapters! Error %d!", result);
- return ;
- }
-
- if (iNumberAdapters > 0) {
- lpInfo = malloc ( sizeof (AdapterInfo) * iNumberAdapters );
- memset ( lpInfo,'\0', sizeof (AdapterInfo) * iNumberAdapters );
-
- lpInfo->iSize = sizeof(lpInfo);
- // Get the AdapterInfo structure for all adapters in the system
- result = ADL_Adapter_AdapterInfo_Get (lpInfo, sizeof (AdapterInfo) * iNumberAdapters);
- if (result != ADL_OK) {
- applog(LOG_INFO, "ADL_Adapter_AdapterInfo_Get Error! Error %d", result);
- return ;
- }
- } else {
- applog(LOG_INFO, "No adapters found");
- return;
- }
-
- /* Iterate over iNumberAdapters and find the lpAdapterID of real devices */
- for (i = 0; i < iNumberAdapters; i++) {
- int iAdapterIndex;
- int lpAdapterID;
-
- iAdapterIndex = lpInfo[i].iAdapterIndex;
- /* Get unique identifier of the adapter, 0 means not AMD */
- result = ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID);
- if (result != ADL_OK) {
- applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get. Error %d", result);
- if (result == -10)
- applog(LOG_INFO, "This error says the device is not enabled");
- continue;
- }
-
- /* Each adapter may have multiple entries */
- if (lpAdapterID == last_adapter)
- continue;
-
- applog(LOG_DEBUG, "GPU %d "
- "iAdapterIndex %d "
- "strUDID %s "
- "iBusNumber %d "
- "iDeviceNumber %d "
- "iFunctionNumber %d "
- "iVendorID %d "
- "strAdapterName %s ",
- devices,
- iAdapterIndex,
- lpInfo[i].strUDID,
- lpInfo[i].iBusNumber,
- lpInfo[i].iDeviceNumber,
- lpInfo[i].iFunctionNumber,
- lpInfo[i].iVendorID,
- lpInfo[i].strAdapterName);
-
- adapters[devices].iAdapterIndex = iAdapterIndex;
- adapters[devices].iBusNumber = lpInfo[i].iBusNumber;
- adapters[devices].id = i;
-
- /* We found a truly new adapter instead of a logical
- * one. Now since there's no way of correlating the
- * opencl enumerated devices and the ADL enumerated
- * ones, we have to assume they're in the same order.*/
- if (++devices > nDevs && devs_match) {
- applog(LOG_ERR, "ADL found more devices than opencl!");
- applog(LOG_ERR, "There is possibly at least one GPU that doesn't support OpenCL");
- applog(LOG_ERR, "Use the gpu map feature to reliably map OpenCL to ADL");
- devs_match = false;
- }
- last_adapter = lpAdapterID;
-
- if (!lpAdapterID) {
- applog(LOG_INFO, "Adapter returns ID 0 meaning not AMD. Card order might be confused");
- continue;
- }
- }
-
- if (devices < nDevs) {
- applog(LOG_ERR, "ADL found less devices than opencl!");
- applog(LOG_ERR, "There is possibly more than one display attached to a GPU");
- applog(LOG_ERR, "Use the gpu map feature to reliably map OpenCL to ADL");
- devs_match = false;
- }
-
- for (i = 0; i < devices; i++) {
- vadapters[i].virtual_gpu = i;
- vadapters[i].id = adapters[i].id;
- }
-
- /* Apply manually provided OpenCL to ADL mapping, if any */
- for (i = 0; i < nDevs; i++) {
- if (gpus[i].mapped) {
- vadapters[gpus[i].virtual_adl].virtual_gpu = i;
- applog(LOG_INFO, "Mapping OpenCL device %d to ADL device %d", i, gpus[i].virtual_adl);
- } else
- gpus[i].virtual_adl = i;
- }
-
- if (!devs_match) {
- applog(LOG_ERR, "WARNING: Number of OpenCL and ADL devices did not match!");
- applog(LOG_ERR, "Hardware monitoring may NOT match up with devices!");
- } else if (opt_reorder) {
- /* Windows has some kind of random ordering for bus number IDs and
- * ordering the GPUs according to ascending order fixes it. Linux
- * has usually sequential but decreasing order instead! */
- for (i = 0; i < devices; i++) {
- int j, virtual_gpu;
-
- virtual_gpu = 0;
- for (j = 0; j < devices; j++) {
- if (i == j)
- continue;
-#ifdef WIN32
- if (adapters[j].iBusNumber < adapters[i].iBusNumber)
-#else
- if (adapters[j].iBusNumber > adapters[i].iBusNumber)
-#endif
- virtual_gpu++;
- }
- if (virtual_gpu != i) {
- applog(LOG_INFO, "Mapping device %d to GPU %d according to Bus Number order",
- i, virtual_gpu);
- vadapters[virtual_gpu].virtual_gpu = i;
- vadapters[virtual_gpu].id = adapters[i].id;
- }
- }
- }
-
- if (devices > nDevs)
- devices = nDevs;
-
- for (gpu = 0; gpu < devices; gpu++) {
- struct gpu_adl *ga;
- int iAdapterIndex;
- int lpAdapterID;
- ADLODPerformanceLevels *lpOdPerformanceLevels;
- int lev, adlGpu;
-
- adlGpu = gpus[gpu].virtual_adl;
- i = vadapters[adlGpu].id;
- iAdapterIndex = lpInfo[i].iAdapterIndex;
- gpus[gpu].virtual_gpu = vadapters[adlGpu].virtual_gpu;
-
- /* Get unique identifier of the adapter, 0 means not AMD */
- result = ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID);
- if (result != ADL_OK) {
- applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get. Error %d", result);
- continue;
- }
-
- if (gpus[gpu].deven == DEV_DISABLED) {
- gpus[gpu].gpu_engine =
- gpus[gpu].gpu_memclock =
- gpus[gpu].gpu_vddc =
- gpus[gpu].gpu_fan =
- gpus[gpu].gpu_powertune = 0;
- continue;
- }
-
- applog(LOG_INFO, "GPU %d %s hardware monitoring enabled", gpu, lpInfo[i].strAdapterName);
- if (gpus[gpu].name)
- free(gpus[gpu].name);
- gpus[gpu].name = lpInfo[i].strAdapterName;
- gpus[gpu].has_adl = true;
- /* Flag adl as active if any card is successfully activated */
- adl_active = true;
-
- /* From here on we know this device is a discrete device and
- * should support ADL */
- ga = &gpus[gpu].adl;
- ga->gpu = gpu;
- ga->iAdapterIndex = iAdapterIndex;
- ga->lpAdapterID = lpAdapterID;
- strcpy(ga->strAdapterName, lpInfo[i].strAdapterName);
- ga->DefPerfLev = NULL;
- ga->twin = NULL;
-
- ga->lpOdParameters.iSize = sizeof(ADLODParameters);
- if (ADL_Overdrive5_ODParameters_Get(iAdapterIndex, &ga->lpOdParameters) != ADL_OK)
- applog(LOG_INFO, "Failed to ADL_Overdrive5_ODParameters_Get");
-
- lev = ga->lpOdParameters.iNumberOfPerformanceLevels - 1;
- /* We're only interested in the top performance level */
- lpOdPerformanceLevels = malloc(sizeof(ADLODPerformanceLevels) + (lev * sizeof(ADLODPerformanceLevel)));
- lpOdPerformanceLevels->iSize = sizeof(ADLODPerformanceLevels) + sizeof(ADLODPerformanceLevel) * lev;
-
- /* Get default performance levels first */
- if (ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 1, lpOdPerformanceLevels) != ADL_OK)
- applog(LOG_INFO, "Failed to ADL_Overdrive5_ODPerformanceLevels_Get");
- /* Set the limits we'd use based on default gpu speeds */
- ga->maxspeed = ga->minspeed = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
-
- ga->lpTemperature.iSize = sizeof(ADLTemperature);
- ga->lpFanSpeedInfo.iSize = sizeof(ADLFanSpeedInfo);
- ga->lpFanSpeedValue.iSize = ga->DefFanSpeedValue.iSize = sizeof(ADLFanSpeedValue);
- /* Now get the current performance levels for any existing overclock */
- ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 0, lpOdPerformanceLevels);
- /* Save these values as the defaults in case we wish to reset to defaults */
- ga->DefPerfLev = lpOdPerformanceLevels;
-
- if (gpus[gpu].gpu_engine) {
- int setengine = gpus[gpu].gpu_engine * 100;
-
- /* Lower profiles can't have a higher setting */
- for (j = 0; j < lev; j++) {
- if (lpOdPerformanceLevels->aLevels[j].iEngineClock > setengine)
- lpOdPerformanceLevels->aLevels[j].iEngineClock = setengine;
- }
- lpOdPerformanceLevels->aLevels[lev].iEngineClock = setengine;
- applog(LOG_INFO, "Setting GPU %d engine clock to %d", gpu, gpus[gpu].gpu_engine);
- ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels);
- ga->maxspeed = setengine;
- if (gpus[gpu].min_engine)
- ga->minspeed = gpus[gpu].min_engine * 100;
- ga->managed = true;
- if (gpus[gpu].gpu_memdiff)
- set_memoryclock(gpu, gpus[gpu].gpu_engine + gpus[gpu].gpu_memdiff);
- }
-
- if (gpus[gpu].gpu_memclock) {
- int setmem = gpus[gpu].gpu_memclock * 100;
-
- for (j = 0; j < lev; j++) {
- if (lpOdPerformanceLevels->aLevels[j].iMemoryClock > setmem)
- lpOdPerformanceLevels->aLevels[j].iMemoryClock = setmem;
- }
- lpOdPerformanceLevels->aLevels[lev].iMemoryClock = setmem;
- applog(LOG_INFO, "Setting GPU %d memory clock to %d", gpu, gpus[gpu].gpu_memclock);
- ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels);
- ga->managed = true;
- }
-
- if (gpus[gpu].gpu_vddc) {
- int setv = gpus[gpu].gpu_vddc * 1000;
-
- for (j = 0; j < lev; j++) {
- if (lpOdPerformanceLevels->aLevels[j].iVddc > setv)
- lpOdPerformanceLevels->aLevels[j].iVddc = setv;
- }
- lpOdPerformanceLevels->aLevels[lev].iVddc = setv;
- applog(LOG_INFO, "Setting GPU %d voltage to %.3f", gpu, gpus[gpu].gpu_vddc);
- ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels);
- ga->managed = true;
- }
-
- ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 0, lpOdPerformanceLevels);
- ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
- ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
- ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
- ga->iBusNumber = lpInfo[i].iBusNumber;
-
- if (ADL_Overdrive5_FanSpeedInfo_Get(iAdapterIndex, 0, &ga->lpFanSpeedInfo) != ADL_OK)
- applog(LOG_INFO, "Failed to ADL_Overdrive5_FanSpeedInfo_Get");
- else
- ga->has_fanspeed = true;
-
- /* Save the fanspeed values as defaults in case we reset later */
- ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue);
- if (gpus[gpu].gpu_fan)
- set_fanspeed(gpu, gpus[gpu].gpu_fan);
- else
- gpus[gpu].gpu_fan = 85; /* Set a nominal upper limit of 85% */
-
- /* Not fatal if powercontrol get fails */
- if (ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy) != ADL_OK)
- applog(LOG_INFO, "Failed to ADL_Overdrive5_PowerControl_get");
-
- if (gpus[gpu].gpu_powertune) {
- ADL_Overdrive5_PowerControl_Set(ga->iAdapterIndex, gpus[gpu].gpu_powertune);
- ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy);
- ga->managed = true;
- }
-
- /* Set some default temperatures for autotune when enabled */
- if (!ga->targettemp)
- ga->targettemp = opt_targettemp;
- if (!ga->overtemp)
- ga->overtemp = opt_overheattemp;
- if (!gpus[gpu].cutofftemp)
- gpus[gpu].cutofftemp = opt_cutofftemp;
- if (opt_autofan) {
- /* Set a safe starting default if we're automanaging fan speeds */
- int nominal = 50;
-
- ga->autofan = true;
- /* Clamp fanspeed values to range provided */
- if (nominal > gpus[gpu].gpu_fan)
- nominal = gpus[gpu].gpu_fan;
- if (nominal < gpus[gpu].min_fan)
- nominal = gpus[gpu].min_fan;
- set_fanspeed(gpu, nominal);
- }
- if (opt_autoengine) {
- ga->autoengine = true;
- ga->managed = true;
- }
- ga->lasttemp = __gpu_temp(ga);
- }
-
- for (gpu = 0; gpu < devices; gpu++) {
- struct gpu_adl *ga = &gpus[gpu].adl;
- int j;
-
- for (j = 0; j < devices; j++) {
- struct gpu_adl *other_ga;
-
- if (j == gpu)
- continue;
-
- other_ga = &gpus[j].adl;
-
- /* Search for twin GPUs on a single card. They will be
- * separated by one bus id and one will have fanspeed
- * while the other won't. */
- if (!ga->has_fanspeed) {
- if (fanspeed_twin(ga, other_ga)) {
- applog(LOG_INFO, "Dual GPUs detected: %d and %d",
- ga->gpu, other_ga->gpu);
- ga->twin = other_ga;
- other_ga->twin = ga;
- }
- }
- }
- }
-}
-
-static float __gpu_temp(struct gpu_adl *ga)
-{
- if (ADL_Overdrive5_Temperature_Get(ga->iAdapterIndex, 0, &ga->lpTemperature) != ADL_OK)
- return -1;
- return (float)ga->lpTemperature.iTemperature / 1000;
-}
-
-float gpu_temp(int gpu)
-{
- struct gpu_adl *ga;
- float ret = -1;
-
- if (!gpus[gpu].has_adl || !adl_active)
- return ret;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- ret = __gpu_temp(ga);
- unlock_adl();
- gpus[gpu].temp = ret;
- return ret;
-}
-
-static inline int __gpu_engineclock(struct gpu_adl *ga)
-{
- return ga->lpActivity.iEngineClock / 100;
-}
-
-int gpu_engineclock(int gpu)
-{
- struct gpu_adl *ga;
- int ret = -1;
-
- if (!gpus[gpu].has_adl || !adl_active)
- return ret;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- if (ADL_Overdrive5_CurrentActivity_Get(ga->iAdapterIndex, &ga->lpActivity) != ADL_OK)
- goto out;
- ret = __gpu_engineclock(ga);
-out:
- unlock_adl();
- return ret;
-}
-
-static inline int __gpu_memclock(struct gpu_adl *ga)
-{
- return ga->lpActivity.iMemoryClock / 100;
-}
-
-int gpu_memclock(int gpu)
-{
- struct gpu_adl *ga;
- int ret = -1;
-
- if (!gpus[gpu].has_adl || !adl_active)
- return ret;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- if (ADL_Overdrive5_CurrentActivity_Get(ga->iAdapterIndex, &ga->lpActivity) != ADL_OK)
- goto out;
- ret = __gpu_memclock(ga);
-out:
- unlock_adl();
- return ret;
-}
-
-static inline float __gpu_vddc(struct gpu_adl *ga)
-{
- return (float)ga->lpActivity.iVddc / 1000;
-}
-
-float gpu_vddc(int gpu)
-{
- struct gpu_adl *ga;
- float ret = -1;
-
- if (!gpus[gpu].has_adl || !adl_active)
- return ret;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- if (ADL_Overdrive5_CurrentActivity_Get(ga->iAdapterIndex, &ga->lpActivity) != ADL_OK)
- goto out;
- ret = __gpu_vddc(ga);
-out:
- unlock_adl();
- return ret;
-}
-
-static inline int __gpu_activity(struct gpu_adl *ga)
-{
- if (!ga->lpOdParameters.iActivityReportingSupported)
- return -1;
- return ga->lpActivity.iActivityPercent;
-}
-
-int gpu_activity(int gpu)
-{
- struct gpu_adl *ga;
- int ret = -1;
-
- if (!gpus[gpu].has_adl || !adl_active)
- return ret;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- ret = ADL_Overdrive5_CurrentActivity_Get(ga->iAdapterIndex, &ga->lpActivity);
- unlock_adl();
- if (ret != ADL_OK)
- return ret;
- if (!ga->lpOdParameters.iActivityReportingSupported)
- return ret;
- return ga->lpActivity.iActivityPercent;
-}
-
-static inline int __gpu_fanspeed(struct gpu_adl *ga)
-{
- if (!ga->has_fanspeed && ga->twin)
- return __gpu_fanspeed(ga->twin);
-
- if (!(ga->lpFanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_RPM_READ))
- return -1;
- ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_RPM;
- if (ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) != ADL_OK)
- return -1;
- return ga->lpFanSpeedValue.iFanSpeed;
-}
-
-int gpu_fanspeed(int gpu)
-{
- struct gpu_adl *ga;
- int ret = -1;
-
- if (!gpus[gpu].has_adl || !adl_active)
- return ret;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- ret = __gpu_fanspeed(ga);
- unlock_adl();
- return ret;
-}
-
-static int __gpu_fanpercent(struct gpu_adl *ga)
-{
- if (!ga->has_fanspeed && ga->twin)
- return __gpu_fanpercent(ga->twin);
-
- if (!(ga->lpFanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_READ ))
- return -1;
- ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
- if (ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) != ADL_OK)
- return -1;
- return ga->lpFanSpeedValue.iFanSpeed;
-}
-
-int gpu_fanpercent(int gpu)
-{
- struct gpu_adl *ga;
- int ret = -1;
-
- if (!gpus[gpu].has_adl || !adl_active)
- return ret;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- ret = __gpu_fanpercent(ga);
- unlock_adl();
- if (unlikely(ga->has_fanspeed && ret == -1)) {
-#if 0
- /* Recursive calling applog causes a hang, so disable messages */
- applog(LOG_WARNING, "GPU %d stopped reporting fanspeed due to driver corruption", gpu);
- if (opt_restart) {
- applog(LOG_WARNING, "Restart enabled, will attempt to restart cgminer");
- applog(LOG_WARNING, "You can disable this with the --no-restart option");
- app_restart();
- }
- applog(LOG_WARNING, "Disabling fanspeed monitoring on this device");
- ga->has_fanspeed = false;
- if (ga->twin) {
- applog(LOG_WARNING, "Disabling fanspeed linking on GPU twins");
- ga->twin->twin = NULL;;
- ga->twin = NULL;
- }
-#endif
- if (opt_restart)
- app_restart();
- ga->has_fanspeed = false;
- if (ga->twin) {
- ga->twin->twin = NULL;;
- ga->twin = NULL;
- }
- }
- return ret;
-}
-
-static inline int __gpu_powertune(struct gpu_adl *ga)
-{
- int dummy = 0;
-
- if (ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy) != ADL_OK)
- return -1;
- return ga->iPercentage;
-}
-
-int gpu_powertune(int gpu)
-{
- struct gpu_adl *ga;
- int ret = -1;
-
- if (!gpus[gpu].has_adl || !adl_active)
- return ret;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- ret = __gpu_powertune(ga);
- unlock_adl();
- return ret;
-}
-
-bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc,
- int *activity, int *fanspeed, int *fanpercent, int *powertune)
-{
- struct gpu_adl *ga;
-
- if (!gpus[gpu].has_adl || !adl_active)
- return false;
-
- ga = &gpus[gpu].adl;
-
- lock_adl();
- *temp = __gpu_temp(ga);
- if (ADL_Overdrive5_CurrentActivity_Get(ga->iAdapterIndex, &ga->lpActivity) != ADL_OK) {
- *engineclock = 0;
- *memclock = 0;
- *vddc = 0;
- *activity = 0;
- } else {
- *engineclock = __gpu_engineclock(ga);
- *memclock = __gpu_memclock(ga);
- *vddc = __gpu_vddc(ga);
- *activity = __gpu_activity(ga);
- }
- *fanspeed = __gpu_fanspeed(ga);
- *fanpercent = __gpu_fanpercent(ga);
- *powertune = __gpu_powertune(ga);
- unlock_adl();
-
- return true;
-}
-
-#ifdef HAVE_CURSES
-static void get_enginerange(int gpu, int *imin, int *imax)
-{
- struct gpu_adl *ga;
-
- if (!gpus[gpu].has_adl || !adl_active) {
- wlogprint("Get enginerange not supported\n");
- return;
- }
- ga = &gpus[gpu].adl;
- *imin = ga->lpOdParameters.sEngineClock.iMin / 100;
- *imax = ga->lpOdParameters.sEngineClock.iMax / 100;
-}
-#endif
-
-int set_engineclock(int gpu, int iEngineClock)
-{
- ADLODPerformanceLevels *lpOdPerformanceLevels;
- struct cgpu_info *cgpu;
- int i, lev, ret = 1;
- struct gpu_adl *ga;
-
- if (!gpus[gpu].has_adl || !adl_active) {
- wlogprint("Set engineclock not supported\n");
- return ret;
- }
-
- iEngineClock *= 100;
- ga = &gpus[gpu].adl;
-
- /* Keep track of intended engine clock in case the device changes
- * profile and drops while idle, not taking the new engine clock */
- ga->lastengine = iEngineClock;
-
- lev = ga->lpOdParameters.iNumberOfPerformanceLevels - 1;
- lpOdPerformanceLevels = alloca(sizeof(ADLODPerformanceLevels) + (lev * sizeof(ADLODPerformanceLevel)));
- lpOdPerformanceLevels->iSize = sizeof(ADLODPerformanceLevels) + sizeof(ADLODPerformanceLevel) * lev;
-
- lock_adl();
- if (ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels) != ADL_OK)
- goto out;
- for (i = 0; i < lev; i++) {
- if (lpOdPerformanceLevels->aLevels[i].iEngineClock > iEngineClock)
- lpOdPerformanceLevels->aLevels[i].iEngineClock = iEngineClock;
- }
- lpOdPerformanceLevels->aLevels[lev].iEngineClock = iEngineClock;
- ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels);
- ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels);
- if (lpOdPerformanceLevels->aLevels[lev].iEngineClock == iEngineClock)
- ret = 0;
- ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
- if (ga->iEngineClock > ga->maxspeed)
- ga->maxspeed = ga->iEngineClock;
- if (ga->iEngineClock < ga->minspeed)
- ga->minspeed = ga->iEngineClock;
- ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
- ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
- ga->managed = true;
-out:
- unlock_adl();
-
- cgpu = &gpus[gpu];
- if (cgpu->gpu_memdiff)
- set_memoryclock(gpu, iEngineClock / 100 + cgpu->gpu_memdiff);
-
- return ret;
-}
-
-#ifdef HAVE_CURSES
-static void get_memoryrange(int gpu, int *imin, int *imax)
-{
- struct gpu_adl *ga;
-
- if (!gpus[gpu].has_adl || !adl_active) {
- wlogprint("Get memoryrange not supported\n");
- return;
- }
- ga = &gpus[gpu].adl;
- *imin = ga->lpOdParameters.sMemoryClock.iMin / 100;
- *imax = ga->lpOdParameters.sMemoryClock.iMax / 100;
-}
-#endif
-
-int set_memoryclock(int gpu, int iMemoryClock)
-{
- ADLODPerformanceLevels *lpOdPerformanceLevels;
- int i, lev, ret = 1;
- struct gpu_adl *ga;
-
- if (!gpus[gpu].has_adl || !adl_active) {
- wlogprint("Set memoryclock not supported\n");
- return ret;
- }
-
- iMemoryClock *= 100;
- ga = &gpus[gpu].adl;
-
- lev = ga->lpOdParameters.iNumberOfPerformanceLevels - 1;
- lpOdPerformanceLevels = alloca(sizeof(ADLODPerformanceLevels) + (lev * sizeof(ADLODPerformanceLevel)));
- lpOdPerformanceLevels->iSize = sizeof(ADLODPerformanceLevels) + sizeof(ADLODPerformanceLevel) * lev;
-
- lock_adl();
- if (ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels) != ADL_OK)
- goto out;
- lpOdPerformanceLevels->aLevels[lev].iMemoryClock = iMemoryClock;
- for (i = 0; i < lev; i++) {
- if (lpOdPerformanceLevels->aLevels[i].iMemoryClock > iMemoryClock)
- lpOdPerformanceLevels->aLevels[i].iMemoryClock = iMemoryClock;
- }
- ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels);
- ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels);
- if (lpOdPerformanceLevels->aLevels[lev].iMemoryClock == iMemoryClock)
- ret = 0;
- ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
- ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
- ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
- ga->managed = true;
-out:
- unlock_adl();
- return ret;
-}
-
-#ifdef HAVE_CURSES
-static void get_vddcrange(int gpu, float *imin, float *imax)
-{
- struct gpu_adl *ga;
-
- if (!gpus[gpu].has_adl || !adl_active) {
- wlogprint("Get vddcrange not supported\n");
- return;
- }
- ga = &gpus[gpu].adl;
- *imin = (float)ga->lpOdParameters.sVddc.iMin / 1000;
- *imax = (float)ga->lpOdParameters.sVddc.iMax / 1000;
-}
-
-static float curses_float(const char *query)
-{
- float ret;
- char *cvar;
-
- cvar = curses_input(query);
- ret = atof(cvar);
- free(cvar);
- return ret;
-}
-#endif
-
-int set_vddc(int gpu, float fVddc)
-{
- ADLODPerformanceLevels *lpOdPerformanceLevels;
- int i, iVddc, lev, ret = 1;
- struct gpu_adl *ga;
-
- if (!gpus[gpu].has_adl || !adl_active) {
- wlogprint("Set vddc not supported\n");
- return ret;
- }
-
- iVddc = 1000 * fVddc;
- ga = &gpus[gpu].adl;
-
- lev = ga->lpOdParameters.iNumberOfPerformanceLevels - 1;
- lpOdPerformanceLevels = alloca(sizeof(ADLODPerformanceLevels) + (lev * sizeof(ADLODPerformanceLevel)));
- lpOdPerformanceLevels->iSize = sizeof(ADLODPerformanceLevels) + sizeof(ADLODPerformanceLevel) * lev;
-
- lock_adl();
- if (ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels) != ADL_OK)
- goto out;
- for (i = 0; i < lev; i++) {
- if (lpOdPerformanceLevels->aLevels[i].iVddc > iVddc)
- lpOdPerformanceLevels->aLevels[i].iVddc = iVddc;
- }
- lpOdPerformanceLevels->aLevels[lev].iVddc = iVddc;
- ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels);
- ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels);
- if (lpOdPerformanceLevels->aLevels[lev].iVddc == iVddc)
- ret = 0;
- ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
- ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
- ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
- ga->managed = true;
-out:
- unlock_adl();
- return ret;
-}
-
-static void get_fanrange(int gpu, int *imin, int *imax)
-{
- struct gpu_adl *ga;
-
- if (!gpus[gpu].has_adl || !adl_active) {
- wlogprint("Get fanrange not supported\n");
- return;
- }
- ga = &gpus[gpu].adl;
- *imin = ga->lpFanSpeedInfo.iMinPercent;
- *imax = ga->lpFanSpeedInfo.iMaxPercent;
-}
-
-int set_fanspeed(int gpu, int iFanSpeed)
-{
- struct gpu_adl *ga;
- int ret = 1;
-
- if (!gpus[gpu].has_adl || !adl_active) {
- wlogprint("Set fanspeed not supported\n");
- return ret;
- }
-
- ga = &gpus[gpu].adl;
- if (!(ga->lpFanSpeedInfo.iFlags & (ADL_DL_FANCTRL_SUPPORTS_RPM_WRITE | ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE ))) {
- applog(LOG_DEBUG, "GPU %d doesn't support rpm or percent write", gpu);
- return ret;
- }
-
- /* Store what fanspeed we're actually aiming for for re-entrant changes
- * in case this device does not support fine setting changes */
- ga->targetfan = iFanSpeed;
-
- lock_adl();
- if (ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) != ADL_OK) {
- applog(LOG_DEBUG, "GPU %d call to fanspeed get failed", gpu);
- }
- if (!(ga->lpFanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE)) {
- /* Must convert speed to an RPM */
- iFanSpeed = ga->lpFanSpeedInfo.iMaxRPM * iFanSpeed / 100;
- ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_RPM;
- } else
- ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
- if (!(ga->lpFanSpeedValue.iFlags & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED)) {
- /* If user defined is not already specified, set it first */
- ga->lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
- ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue);
- }
- ga->lpFanSpeedValue.iFanSpeed = iFanSpeed;
- ret = ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue);
- ga->managed = true;
- unlock_adl();
-
- return ret;
-}
-
-#ifdef HAVE_CURSES
-static int set_powertune(int gpu, int iPercentage)
-{
- struct gpu_adl *ga;
- int dummy, ret = 1;
-
- if (!gpus[gpu].has_adl || !adl_active) {
- wlogprint("Set powertune not supported\n");
- return ret;
- }
-
- ga = &gpus[gpu].adl;
-
- lock_adl();
- ADL_Overdrive5_PowerControl_Set(ga->iAdapterIndex, iPercentage);
- ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy);
- if (ga->iPercentage == iPercentage)
- ret = 0;
- ga->managed = true;
- unlock_adl();
- return ret;
-}
-#endif
-
-/* Returns whether the fanspeed is optimal already or not. The fan_window bool
- * tells us whether the current fanspeed is in the target range for fanspeeds.
- */
-static bool fan_autotune(int gpu, int temp, int fanpercent, int lasttemp, bool *fan_window)
-{
- struct cgpu_info *cgpu = &gpus[gpu];
- int tdiff = round(temp - lasttemp);
- struct gpu_adl *ga = &cgpu->adl;
- int top = gpus[gpu].gpu_fan;
- int bot = gpus[gpu].min_fan;
- int newpercent = fanpercent;
- int iMin = 0, iMax = 100;
-
- get_fanrange(gpu, &iMin, &iMax);
- if (temp > ga->overtemp && fanpercent < iMax) {
- applog(LOG_WARNING, "Overheat detected on GPU %d, increasing fan to 100%%", gpu);
- newpercent = iMax;
-
- dev_error(cgpu, REASON_DEV_OVER_HEAT);
- } else if (temp > ga->targettemp && fanpercent < top && tdiff >= 0) {
- applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
- if (temp > ga->targettemp + opt_hysteresis)
- newpercent = ga->targetfan + 10;
- else
- newpercent = ga->targetfan + 5;
- if (newpercent > top)
- newpercent = top;
- } else if (fanpercent > bot && temp < ga->targettemp - opt_hysteresis) {
- /* Detect large swings of 5 degrees or more and change fan by
- * a proportion more */
- if (tdiff <= 0) {
- applog(LOG_DEBUG, "Temperature %d degrees below target, decreasing fanspeed", opt_hysteresis);
- newpercent = ga->targetfan - 1 + tdiff / 5;
- } else if (tdiff >= 5) {
- applog(LOG_DEBUG, "Temperature climbed %d while below target, increasing fanspeed", tdiff);
- newpercent = ga->targetfan + tdiff / 5;
- }
- } else {
-
- /* We're in the optimal range, make minor adjustments if the
- * temp is still drifting */
- if (fanpercent > bot && tdiff < 0 && lasttemp < ga->targettemp) {
- applog(LOG_DEBUG, "Temperature dropping while in target range, decreasing fanspeed");
- newpercent = ga->targetfan + tdiff;
- } else if (fanpercent < top && tdiff > 0 && temp > ga->targettemp - opt_hysteresis) {
- applog(LOG_DEBUG, "Temperature rising while in target range, increasing fanspeed");
- newpercent = ga->targetfan + tdiff;
- }
- }
-
- if (newpercent > iMax)
- newpercent = iMax;
- else if (newpercent < iMin)
- newpercent = iMin;
-
- if (newpercent <= top)
- *fan_window = true;
- else
- *fan_window = false;
-
- if (newpercent != fanpercent) {
- applog(LOG_INFO, "Setting GPU %d fan percentage to %d", gpu, newpercent);
- set_fanspeed(gpu, newpercent);
- /* If the fanspeed is going down and we're below the top speed,
- * consider the fan optimal to prevent minute changes in
- * fanspeed delaying GPU engine speed changes */
- if (newpercent < fanpercent && *fan_window)
- return true;
- return false;
- }
- return true;
-}
-
-void gpu_autotune(int gpu, enum dev_enable *denable)
-{
- int temp, fanpercent, engine, newengine, twintemp = 0;
- bool fan_optimal = true, fan_window = true;
- struct cgpu_info *cgpu;
- struct gpu_adl *ga;
-
- cgpu = &gpus[gpu];
- ga = &cgpu->adl;
-
- lock_adl();
- ADL_Overdrive5_CurrentActivity_Get(ga->iAdapterIndex, &ga->lpActivity);
- temp = __gpu_temp(ga);
- if (ga->twin)
- twintemp = __gpu_temp(ga->twin);
- fanpercent = __gpu_fanpercent(ga);
- unlock_adl();
-
- newengine = engine = gpu_engineclock(gpu) * 100;
-
- if (temp && fanpercent >= 0 && ga->autofan) {
- if (!ga->twin)
- fan_optimal = fan_autotune(gpu, temp, fanpercent, ga->lasttemp, &fan_window);
- else if (ga->autofan && (ga->has_fanspeed || !ga->twin->autofan)) {
- /* On linked GPUs, we autotune the fan only once, based
- * on the highest temperature from either GPUs */
- int hightemp, fan_gpu;
- int lasttemp;
-
- if (twintemp > temp) {
- lasttemp = ga->twin->lasttemp;
- hightemp = twintemp;
- } else {
- lasttemp = ga->lasttemp;
- hightemp = temp;
- }
- if (ga->has_fanspeed)
- fan_gpu = gpu;
- else
- fan_gpu = ga->twin->gpu;
- fan_optimal = fan_autotune(fan_gpu, hightemp, fanpercent, lasttemp, &fan_window);
- }
- }
-
- if (engine && ga->autoengine) {
- if (temp > cgpu->cutofftemp) {
- applog(LOG_WARNING, "Hit thermal cutoff limit on GPU %d, disabling!", gpu);
- *denable = DEV_RECOVER;
- newengine = ga->minspeed;
- dev_error(cgpu, REASON_DEV_THERMAL_CUTOFF);
- } else if (temp > ga->overtemp && engine > ga->minspeed) {
- applog(LOG_WARNING, "Overheat detected, decreasing GPU %d clock speed", gpu);
- newengine = ga->minspeed;
-
- dev_error(cgpu, REASON_DEV_OVER_HEAT);
- } else if (temp > ga->targettemp + opt_hysteresis && engine > ga->minspeed && fan_optimal) {
- applog(LOG_DEBUG, "Temperature %d degrees over target, decreasing clock speed", opt_hysteresis);
- newengine = engine - ga->lpOdParameters.sEngineClock.iStep;
- /* Only try to tune engine speed up if this GPU is not disabled */
- } else if (temp < ga->targettemp && engine < ga->maxspeed && fan_window && *denable == DEV_ENABLED) {
- int iStep = ga->lpOdParameters.sEngineClock.iStep;
-
- applog(LOG_DEBUG, "Temperature below target, increasing clock speed");
- if (temp < ga->targettemp - opt_hysteresis)
- iStep *= 2;
- newengine = engine + iStep;
- } else if (temp < ga->targettemp && *denable == DEV_RECOVER && opt_restart) {
- applog(LOG_NOTICE, "Device recovered to temperature below target, re-enabling");
- *denable = DEV_ENABLED;
- }
-
- if (newengine > ga->maxspeed)
- newengine = ga->maxspeed;
- else if (newengine < ga->minspeed)
- newengine = ga->minspeed;
-
- /* Adjust engine clock speed if it's lower, or if it's higher
- * but higher than the last intended value as well as the
- * current speed, to avoid setting the engine clock speed to
- * a speed relateive to a lower profile during idle periods. */
- if (newengine < engine || (newengine > engine && newengine > ga->lastengine)) {
- newengine /= 100;
- applog(LOG_INFO, "Setting GPU %d engine clock to %d", gpu, newengine);
- set_engineclock(gpu, newengine);
- }
- }
- ga->lasttemp = temp;
-}
-
-void set_defaultfan(int gpu)
-{
- struct gpu_adl *ga;
- if (!gpus[gpu].has_adl || !adl_active)
- return;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue);
- unlock_adl();
-}
-
-void set_defaultengine(int gpu)
-{
- struct gpu_adl *ga;
- if (!gpus[gpu].has_adl || !adl_active)
- return;
-
- ga = &gpus[gpu].adl;
- lock_adl();
- ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, ga->DefPerfLev);
- unlock_adl();
-}
-
-#ifdef HAVE_CURSES
-void change_autosettings(int gpu)
-{
- struct gpu_adl *ga = &gpus[gpu].adl;
- char input;
- int val;
-
- wlogprint("Target temperature: %d\n", ga->targettemp);
- wlogprint("Overheat temperature: %d\n", ga->overtemp);
- wlogprint("Cutoff temperature: %d\n", gpus[gpu].cutofftemp);
- wlogprint("Toggle [F]an auto [G]PU auto\nChange [T]arget [O]verheat [C]utoff\n");
- wlogprint("Or press any other key to continue\n");
- input = getch();
- if (!strncasecmp(&input, "f", 1)) {
- ga->autofan ^= true;
- wlogprint("Fan autotune is now %s\n", ga->autofan ? "enabled" : "disabled");
- if (!ga->autofan) {
- wlogprint("Resetting fan to startup settings\n");
- set_defaultfan(gpu);
- }
- } else if (!strncasecmp(&input, "g", 1)) {
- ga->autoengine ^= true;
- wlogprint("GPU engine clock autotune is now %s\n", ga->autoengine ? "enabled" : "disabled");
- if (!ga->autoengine) {
- wlogprint("Resetting GPU engine clock to startup settings\n");
- set_defaultengine(gpu);
- }
- } else if (!strncasecmp(&input, "t", 1)) {
- val = curses_int("Enter target temperature for this GPU in C (0-200)");
- if (val < 0 || val > 200)
- wlogprint("Invalid temperature");
- else
- ga->targettemp = val;
- } else if (!strncasecmp(&input, "o", 1)) {
- wlogprint("Enter overheat temperature for this GPU in C (%d+)", ga->targettemp);
- val = curses_int("");
- if (val <= ga->targettemp || val > 200)
- wlogprint("Invalid temperature");
- else
- ga->overtemp = val;
- } else if (!strncasecmp(&input, "c", 1)) {
- wlogprint("Enter cutoff temperature for this GPU in C (%d+)", ga->overtemp);
- val = curses_int("");
- if (val <= ga->overtemp || val > 200)
- wlogprint("Invalid temperature");
- else
- gpus[gpu].cutofftemp = val;
- }
-}
-
-void change_gpusettings(int gpu)
-{
- struct gpu_adl *ga = &gpus[gpu].adl;
- float fval, fmin = 0, fmax = 0;
- int val, imin = 0, imax = 0;
- char input;
- int engineclock = 0, memclock = 0, activity = 0, fanspeed = 0, fanpercent = 0, powertune = 0;
- float temp = 0, vddc = 0;
-
-updated:
- if (gpu_stats(gpu, &temp, &engineclock, &memclock, &vddc, &activity, &fanspeed, &fanpercent, &powertune))
- wlogprint("Temp: %.1f C\n", temp);
- if (fanpercent >= 0 || fanspeed >= 0) {
- wlogprint("Fan Speed: ");
- if (fanpercent >= 0)
- wlogprint("%d%% ", fanpercent);
- if (fanspeed >= 0)
- wlogprint("(%d RPM)", fanspeed);
- wlogprint("\n");
- }
- wlogprint("Engine Clock: %d MHz\nMemory Clock: %d Mhz\nVddc: %.3f V\nActivity: %d%%\nPowertune: %d%%\n",
- engineclock, memclock, vddc, activity, powertune);
- wlogprint("Fan autotune is %s (%d-%d)\n", ga->autofan ? "enabled" : "disabled",
- gpus[gpu].min_fan, gpus[gpu].gpu_fan);
- wlogprint("GPU engine clock autotune is %s (%d-%d)\n", ga->autoengine ? "enabled" : "disabled",
- ga->minspeed / 100, ga->maxspeed / 100);
- wlogprint("Change [A]utomatic [E]ngine [F]an [M]emory [V]oltage [P]owertune\n");
- wlogprint("Or press any other key to continue\n");
- input = getch();
-
- if (!strncasecmp(&input, "a", 1)) {
- change_autosettings(gpu);
- } else if (!strncasecmp(&input, "e", 1)) {
- get_enginerange(gpu, &imin, &imax);
- wlogprint("Enter GPU engine clock speed (%d - %d Mhz)", imin, imax);
- val = curses_int("");
- if (val < imin || val > imax) {
- wlogprint("Value is outside safe range, are you sure?\n");
- input = getch();
- if (strncasecmp(&input, "y", 1))
- return;
- }
- if (!set_engineclock(gpu, val))
- wlogprint("Driver reports success but check values below\n");
- else
- wlogprint("Failed to modify engine clock speed\n");
- } else if (!strncasecmp(&input, "f", 1)) {
- get_fanrange(gpu, &imin, &imax);
- wlogprint("Enter fan percentage (%d - %d %%)", imin, imax);
- val = curses_int("");
- if (val < imin || val > imax) {
- wlogprint("Value is outside safe range, are you sure?\n");
- input = getch();
- if (strncasecmp(&input, "y", 1))
- return;
- }
- if (!set_fanspeed(gpu, val))
- wlogprint("Driver reports success but check values below\n");
- else
- wlogprint("Failed to modify fan speed\n");
- } else if (!strncasecmp(&input, "m", 1)) {
- get_memoryrange(gpu, &imin, &imax);
- wlogprint("Enter GPU memory clock speed (%d - %d Mhz)", imin, imax);
- val = curses_int("");
- if (val < imin || val > imax) {
- wlogprint("Value is outside safe range, are you sure?\n");
- input = getch();
- if (strncasecmp(&input, "y", 1))
- return;
- }
- if (!set_memoryclock(gpu, val))
- wlogprint("Driver reports success but check values below\n");
- else
- wlogprint("Failed to modify memory clock speed\n");
- } else if (!strncasecmp(&input, "v", 1)) {
- get_vddcrange(gpu, &fmin, &fmax);
- wlogprint("Enter GPU voltage (%.3f - %.3f V)", fmin, fmax);
- fval = curses_float("");
- if (fval < fmin || fval > fmax) {
- wlogprint("Value is outside safe range, are you sure?\n");
- input = getch();
- if (strncasecmp(&input, "y", 1))
- return;
- }
- if (!set_vddc(gpu, fval))
- wlogprint("Driver reports success but check values below\n");
- else
- wlogprint("Failed to modify voltage\n");
- } else if (!strncasecmp(&input, "p", 1)) {
- val = curses_int("Enter powertune value (-20 - 20)");
- if (val < -20 || val > 20) {
- wlogprint("Value is outside safe range, are you sure?\n");
- input = getch();
- if (strncasecmp(&input, "y", 1))
- return;
- }
- if (!set_powertune(gpu, val))
- wlogprint("Driver reports success but check values below\n");
- else
- wlogprint("Failed to modify powertune value\n");
- } else {
- clear_logwin();
- return;
- }
- cgsleep_ms(1000);
- goto updated;
-}
-#endif
-
-static void free_adl(void)
-{
- ADL_Main_Memory_Free ((void **)&lpInfo);
- ADL_Main_Control_Destroy ();
-#if defined (LINUX)
- dlclose(hDLL);
-#else
- FreeLibrary(hDLL);
-#endif
-}
-
-void clear_adl(int nDevs)
-{
- struct gpu_adl *ga;
- int i;
-
- if (!adl_active)
- return;
-
- lock_adl();
- /* Try to reset values to their defaults */
- for (i = 0; i < nDevs; i++) {
- ga = &gpus[i].adl;
- /* Only reset the values if we've changed them at any time */
- if (!gpus[i].has_adl || !ga->managed)
- continue;
- ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, ga->DefPerfLev);
- free(ga->DefPerfLev);
- ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue);
- ADL_Overdrive5_FanSpeedToDefault_Set(ga->iAdapterIndex, 0);
- }
- adl_active = false;
- unlock_adl();
- free_adl();
-}
-#endif /* HAVE_ADL */
diff --git a/adl.h b/adl.h
deleted file mode 100644
index ca67550..0000000
--- a/adl.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __ADL_H__
-#define __ADL_H__
-#ifdef HAVE_ADL
-bool adl_active;
-bool opt_reorder;
-int opt_hysteresis;
-const int opt_targettemp;
-const int opt_overheattemp;
-void init_adl(int nDevs);
-float gpu_temp(int gpu);
-int gpu_engineclock(int gpu);
-int gpu_memclock(int gpu);
-float gpu_vddc(int gpu);
-int gpu_activity(int gpu);
-int gpu_fanspeed(int gpu);
-int gpu_fanpercent(int gpu);
-bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc,
- int *activity, int *fanspeed, int *fanpercent, int *powertune);
-void change_gpusettings(int gpu);
-void gpu_autotune(int gpu, enum dev_enable *denable);
-void clear_adl(int nDevs);
-#else /* HAVE_ADL */
-#define adl_active (0)
-static inline void init_adl(__maybe_unused int nDevs) {}
-static inline void change_gpusettings(__maybe_unused int gpu) { }
-static inline void clear_adl(__maybe_unused int nDevs) {}
-#endif
-#endif
diff --git a/adl_functions.h b/adl_functions.h
deleted file mode 100644
index 6d4a9a1..0000000
--- a/adl_functions.h
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
-
- * This program reads HW information from your ATI Radeon card and displays them
- * You can also change frequencies and voltages.
-
- * THIS PROGRAM MAY DAMAGE YOUR VIDEO CARD, IF YOU APPLY NONSENSIAL VALUES.
- * e.g. INCREASING THE VOLTAGES AND FREQUENCIES IN CONJUNCTION WITH LOWERING THE
- * FAN SPEED IS NOT ADVISABLE!
-
- * Copyright(C) Thorsten Gilling (tgilling@web.de)
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*******************************************************************************/
-
-// ------------------------------------------------------------------------------------------------------------
-// AMD ADL function types from Version 3.0
-// ------------------------------------------------------------------------------------------------------------
-
-#if defined (linux)
- #include <dlfcn.h> //dyopen, dlsym, dlclose
- #include <stdlib.h>
- #include <string.h> //memeset
-#else
- #include <windows.h>
- #include <tchar.h>
-#endif
-
-#include "ADL_SDK/adl_sdk.h"
-
-// Definitions of the used function pointers. Add more if you use other ADL APIs
-
-// ------------------------------------------------------------------------------------------------------------
-
-// ADL Main
-typedef int ( *ADL_MAIN_CONTROL_CREATE ) (ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters);
-typedef int ( *ADL_MAIN_CONTROL_REFRESH ) ();
-typedef int ( *ADL_MAIN_CONTROL_DESTROY ) ();
-typedef int ( *ADL_GRAPHICS_PLATFORM_GET ) (int *lpPlatForm);
-
-// ------------------------------------------------------------------------------------------------------------
-
-// ADL Adapter/General
-typedef int ( *ADL_ADAPTER_ACTIVE_GET ) (int iAdapterIndex, int *lpStatus);
-typedef int ( *ADL_ADAPTER_NUMBEROFADAPTERS_GET ) (int *lpNumAdapters);
-typedef int ( *ADL_ADAPTER_ADAPTERINFO_GET ) (LPAdapterInfo lpInfo, int iInputSize);
-typedef int ( *ADL_ADAPTER_ASICFAMILYTYPE_GET ) (int iAdapterIndex, int *lpAsicTypes, int *lpValids);
-typedef int ( *ADL_ADAPTER_SPEED_CAPS ) (int iAdapterIndex, int *lpCaps, int *lpValid);
-typedef int ( *ADL_ADAPTER_SPEED_GET ) (int iAdapterIndex, int *lpCurrent, int *lpDefault);
-typedef int ( *ADL_ADAPTER_SPEED_SET ) (int iAdapterIndex, int iSpeed);
-typedef int ( *ADL_ADAPTER_ACCESSIBILITY_GET ) (int iAdapterIndex, int *lpAccessibility);
-typedef int ( *ADL_ADAPTER_VIDEOBIOSINFO_GET ) (int iAdapterIndex, ADLBiosInfo *lpBiosInfo);
-typedef int ( *ADL_ADAPTER_ID_GET ) (int iAdapterIndex, int *lpAdapterID);
-
-// ADL Adapter/CrossDisplay
-typedef int ( *ADL_ADAPTER_CROSSDISPLAYADAPTERROLE_CAPS ) (int iAdapterIndex, int *lpCrossDisplaySupport, int *lpAdapterRole, int *lpNumPossDisplayAdapters, int **lppPossDisplayAdapters, int *lpNnumPosRenderingAdapters, int **lppPosRenderingAdapters, int *lpErrorStatus);
-typedef int ( *ADL_ADAPTER_CROSSDISPLAYINFO_GET ) (int iAdapterIndex, int *lpAdapterRole, int *lpCrossdisplayMode, int *lpNumDisplayAdapters, int **lppDisplayAdapters, int *lpNumRenderingAdapters, int **lppRenderingAdapters, int *lpErrorCodeStatus);
-typedef int ( *ADL_ADAPTER_CROSSDISPLAYINFO_SET ) (int iAdapterIndex, int iDisplayAdapterIndex, int iRenderingAdapterIndex, int crossdisplayMode, int *lpErrorCode);
-
-// ADL Adapter/CrossFire
-typedef int ( *ADL_ADAPTER_CROSSFIRE_CAPS ) (int iAdapterIndex, int *lpPreferred, int *lpNumComb, ADLCrossfireComb **ppCrossfireComb);
-typedef int ( *ADL_ADAPTER_CROSSFIRE_GET ) (int iAdapterIndex, ADLCrossfireComb *lpCrossfireComb, ADLCrossfireInfo *lpCrossfireInfo);
-typedef int ( *ADL_ADAPTER_CROSSFIRE_SET ) (int iAdapterIndex, ADLCrossfireComb *lpCrossfireComb);
-
-// ------------------------------------------------------------------------------------------------------------
-
-// ADL Display/Misc
-
-typedef int ( *ADL_DISPLAY_DISPLAYINFO_GET ) (int iAdapterIndex, int *lpNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect);
-typedef int ( *ADL_DISPLAY_NUMBEROFDISPLAYS_GET ) (int iAdapterIndex, int *lpNumDisplays);
-typedef int ( *ADL_DISPLAY_PRESERVEDASPECTRATIO_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpSupport, int *lpCurrent, int *lpDefault);
-typedef int ( *ADL_DISPLAY_PRESERVEDASPECTRATIO_SET ) (int iAdapterIndex, int iDisplayIndex, int iCurrent);
-typedef int ( *ADL_DISPLAY_IMAGEEXPANSION_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpSupport, int *lpCurrent, int *lpDefault);
-typedef int ( *ADL_DISPLAY_IMAGEEXPANSION_SET ) (int iAdapterIndex, int iDisplayIndex, int iCurrent);
-typedef int ( *ADL_DISPLAY_POSITION_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpX, int *lpY, int *lpXDefault, int *lpYDefault, int *lpMinX, int *lpMinY, int *lpMaxX, int *lpMaxY, int *lpStepX, int *lpStepY);
-typedef int ( *ADL_DISPLAY_POSITION_SET ) (int iAdapterIndex, int iDisplayIndex, int iX, int iY);
-typedef int ( *ADL_DISPLAY_SIZE_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpWidth, int *lpHeight, int *lpDefaultWidth, int *lpDefaultHeight, int *lpMinWidth, int *lpMinHeight, int *lpMaxWidth, int *lpMaxHeight, int *lpStepWidth, int *lpStepHeight);
-typedef int ( *ADL_DISPLAY_SIZE_SET ) (int iAdapterIndex, int iDisplayIndex, int iWidth, int iHeight);
-typedef int ( *ADL_DISPLAY_ADJUSTCAPS_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpInfo);
-typedef int ( *ADL_DISPLAY_CAPABILITIES_GET ) (int iAdapterIndex, int *lpNumberOfControlers, int *lpNumberOfDisplays);
-typedef int ( *ADL_DISPLAY_CONNECTEDDISPLAYS_GET ) (int iAdapterIndex, int *lpConnections);
-typedef int ( *ADL_DISPLAY_DEVICECONFIG_GET ) (int iAdapterIndex, int iDisplayIndex, ADLDisplayConfig *lpDisplayConfig);
-typedef int ( *ADL_DISPLAY_PROPERTY_GET ) (int iAdapterIndex, int iDisplayIndex, ADLDisplayProperty *lpDisplayProperty);
-typedef int ( *ADL_DISPLAY_PROPERTY_SET ) (int iAdapterIndex, int iDisplayIndex, ADLDisplayProperty *lpDisplayProperty);
-typedef int ( *ADL_DISPLAY_SWITCHINGCAPABILITY_GET ) (int iAdapterIndex, int *lpResult);
-typedef int ( *ADL_DISPLAY_DITHERSTATE_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpDitherState);
-typedef int ( *ADL_DISPLAY_DITHERSTATE_SET ) (int iAdapterIndex, int iDisplayIndex, int iDitherState);
-typedef int ( *ADL_DISPLAY_SUPPORTEDPIXELFORMAT_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpPixelFormat);
-typedef int ( *ADL_DISPLAY_PIXELFORMAT_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpPixelFormat);
-typedef int ( *ADL_DISPLAY_PIXELFORMAT_SET ) (int iAdapterIndex, int iDisplayIndex, int iPixelFormat);
-typedef int ( *ADL_DISPLAY_ODCLOCKINFO_GET ) (int iAdapterIndex, ADLAdapterODClockInfo *lpOdClockInfo);
-typedef int ( *ADL_DISPLAY_ODCLOCKCONFIG_SET ) (int iAdapterIndex, ADLAdapterODClockConfig *lpOdClockConfig);
-typedef int ( *ADL_DISPLAY_ADJUSTMENTCOHERENT_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpAdjustmentCoherentCurrent, int *lpAdjustmentCoherentDefault);
-typedef int ( *ADL_DISPLAY_ADJUSTMENTCOHERENT_SET ) (int iAdapterIndex, int iDisplayIndex, int iAdjustmentCoherent);
-typedef int ( *ADL_DISPLAY_REDUCEDBLANKING_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpReducedBlankingCurrent, int *lpReducedBlankingDefault);
-typedef int ( *ADL_DISPLAY_REDUCEDBLANKING_SET ) (int iAdapterIndex, int iDisplayIndex, int iReducedBlanking);
-typedef int ( *ADL_DISPLAY_FORMATSOVERRIDE_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpSettingsSupported, int *lpSettingsSupportedEx, int *lpCurSettings);
-typedef int ( *ADL_DISPLAY_FORMATSOVERRIDE_SET ) (int iAdapterIndex, int iDisplayIndex, int iOverrideSettings);
-typedef int ( *ADL_DISPLAY_MVPUCAPS_GET ) (int iAdapterIndex, ADLMVPUCaps *lpMvpuCaps);
-typedef int ( *ADL_DISPLAY_MVPUSTATUS_GET ) (int iAdapterIndex, ADLMVPUStatus *lpMvpuStatus);
-
-// ADL Display/Eyefinity
-typedef int ( *ADL_ADAPTER_ACTIVE_SET ) (int iAdapterIndex, int iStatus, int *lpNewlyActivate);
-typedef int ( *ADL_ADAPTER_ACTIVE_SETPREFER ) (int iAdapterIndex, int iStatus, int iNumPreferTarget, ADLDisplayTarget *lpPreferTarget, int *lpNewlyActivate);
-typedef int ( *ADL_ADAPTER_PRIMARY_GET ) (int *lpPrimaryAdapterIndex);
-typedef int ( *ADL_ADAPTER_PRIMARY_SET ) (int iAdapterIndex);
-typedef int ( *ADL_ADAPTER_MODESWITCH ) (int iAdapterIndex);
-typedef int ( *ADL_DISPLAY_MODES_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpNumModes, ADLMode **lppModes);
-typedef int ( *ADL_DISPLAY_MODES_SET ) (int iAdapterIndex, int iDisplayIndex, int iNumModes, ADLMode *lpModes);
-typedef int ( *ADL_DISPLAY_POSSIBLEMODE_GET ) (int iAdapterIndex, int *lpNumModes, ADLMode **lppModes);
-typedef int ( *ADL_DISPLAY_FORCIBLEDISPLAY_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpStatus);
-typedef int ( *ADL_DISPLAY_FORCIBLEDISPLAY_SET ) (int iAdapterIndex, int iDisplayIndex, int iStatus);
-typedef int ( *ADL_ADAPTER_NUMBEROFACTIVATABLESOURCES_GET ) (int iAdapterIndex, int *lpNumSources, ADLActivatableSource **lppSources);
-typedef int ( *ADL_ADAPTER_DISPLAY_CAPS ) (int iAdapterIndex, int *lpNumDisplayCaps, ADLAdapterDisplayCap **lppAdapterDisplayCaps);
-typedef int ( *ADL_DISPLAY_DISPLAYMAPCONFIG_GET ) (int iAdapterIndex, int *lpNumDisplayMap, ADLDisplayMap **lppDisplayMap, int *lpNumDisplayTarget, ADLDisplayTarget **lppDisplayTarget, int iOptions);
-typedef int ( *ADL_DISPLAY_DISPLAYMAPCONFIG_SET ) (int iAdapterIndex, int iNumDisplayMap, ADLDisplayMap *lpDisplayMap, int iNumDisplayTarget, ADLDisplayTarget *lpDisplayTarget);
-typedef int ( *ADL_DISPLAY_POSSIBLEMAPPING_GET ) (int iAdapterIndex, int iNumberOfPresetMapping, ADLPossibleMapping *lpPresetMappings, int iEnquiryControllerIndex, int *lpNumberOfEnquiryPossibleMappings, ADLPossibleMapping **lppEnquiryPossibleMappings);
-typedef int ( *ADL_DISPLAY_DISPLAYMAPCONFIG_VALIDATE ) (int iAdapterIndex, int iNumPossibleMap, ADLPossibleMap *lpPossibleMaps, int *lpNumPossibleMapResult, ADLPossibleMapResult **lppPossibleMapResult);
-typedef int ( *ADL_DISPLAY_DISPLAYMAPCONFIG_POSSIBLEADDANDREMOVE ) (int iAdapterIndex, int iNumDisplayMap, ADLDisplayMap *lpDisplayMap, int iNumDisplayTarget, ADLDisplayTarget *lpDisplayTarget, int *lpNumPossibleAddTarget, ADLDisplayTarget **lppPossibleAddTarget, int *lpNumPossibleRemoveTarget, ADLDisplayTarget **lppPossibleRemoveTarget);
-typedef int ( *ADL_DISPLAY_SLSGRID_CAPS ) (int iAdapterIndex, int *lpNumSLSGrid, ADLSLSGrid **lppSLSGrid, int iOption);
-typedef int ( *ADL_DISPLAY_SLSMAPINDEXLIST_GET ) (int iAdapterIndex, int *lpNumSLSMapIndexList, int **lppSLSMapIndexList, int iOptions);
-typedef int ( *ADL_DISPLAY_SLSMAPINDEX_GET ) (int iAdapterIndex, int iADLNumDisplayTarget, ADLDisplayTarget *lpDisplayTarget, int *lpSLSMapIndex);
-typedef int ( *ADL_DISPLAY_SLSMAPCONFIG_GET ) (int iAdapterIndex, int iSLSMapIndex, ADLSLSMap *lpSLSMap, int *lpNumSLSTarget, ADLSLSTarget **lppSLSTarget, int *lpNumNativeMode, ADLSLSMode **lppNativeMode, int *lpNumBezelMode, ADLBezelTransientMode **lppBezelMode, int *lpNumTransientMode, ADLBezelTransientMode **lppTransientMode, int *lpNumSLSOffset, ADLSLSOffset **lppSLSOffset, int iOption);
-typedef int ( *ADL_DISPLAY_SLSMAPCONFIG_CREATE ) (int iAdapterIndex, ADLSLSMap SLSMap, int iNumTargetTarget, ADLSLSTarget *lpSLSTarget, int iBezelModePercent, int *lpSLSMapIndex, int iOption);
-typedef int ( *ADL_DISPLAY_SLSMAPCONFIG_DELETE ) (int iAdapterIndex, int iSLSMapIndex);
-typedef int ( *ADL_DISPLAY_SLSMAPCONFIG_SETSTATE ) (int iAdapterIndex, int iSLSMapIndex, int iState);
-typedef int ( *ADL_DISPLAY_SLSMAPCONFIG_REARRANGE ) (int iAdapterIndex, int iSLSMapIndex, int iNumDisplayTarget, ADLSLSTarget *lpSLSTarget, ADLSLSMap slsMap, int iOption);
-typedef int ( *ADL_DISPLAY_POSSIBLEMODE_WINXP_GET ) (int iAdapterIndex, int iNumDisplayTargets, ADLDisplayTarget *lpDisplayTargets, int iLargeDesktopSupportedType, int iDevicePanningControl, int *lpNumModes, ADLMode **lppModes);
-typedef int ( *ADL_DISPLAY_BEZELOFFSETSTEPPINGSIZE_GET ) (int iAdapterIndex, int *lpNumBezelOffsetSteppingSize, ADLBezelOffsetSteppingSize **lppBezelOffsetSteppingSize);
-typedef int ( *ADL_DISPLAY_BEZELOFFSET_SET ) (int iAdapterIndex, int iSLSMapIndex, int iNumBezelOffset, LPADLSLSOffset lpBezelOffset, ADLSLSMap SLSMap, int iOption);
-typedef int ( *ADL_DISPLAY_BEZELSUPPORTED_VALIDATE ) (int iAdapterIndex, int iNumPossibleSLSMap, LPADLPossibleSLSMap lpPossibleSLSMaps, int *lpNumPossibleSLSMapResult, LPADLPossibleMapResult *lppPossibleMapResult);
-
-// ADL Display/Color
-typedef int ( *ADL_DISPLAY_COLORCAPS_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpCaps, int *lpValids);
-typedef int ( *ADL_DISPLAY_COLOR_SET ) (int iAdapterIndex, int iDisplayIndex, int iColorType, int iCurrent);
-typedef int ( *ADL_DISPLAY_COLOR_GET ) (int iAdapterIndex, int iDisplayIndex, int iColorType, int *lpCurrent, int *lpDefault, int *lpMin, int *lpMax, int *lpStep);
-typedef int ( *ADL_DISPLAY_COLORTEMPERATURESOURCE_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpTempSource);
-typedef int ( *ADL_DISPLAY_COLORTEMPERATURESOURCE_SET ) (int iAdapterIndex, int iDisplayIndex, int iTempSource);
-
-// ADL Display/Timing
-typedef int ( *ADL_DISPLAY_MODETIMINGOVERRIDE_GET ) (int iAdapterIndex, int iDisplayIndex, ADLDisplayMode *lpModeIn, ADLDisplayModeInfo *lpModeInfoOut);
-typedef int ( *ADL_DISPLAY_MODETIMINGOVERRIDE_SET ) (int iAdapterIndex, int iDisplayIndex, ADLDisplayModeInfo *lpMode, int iForceUpdate);
-typedef int ( *ADL_DISPLAY_MODETIMINGOVERRIDELIST_GET ) (int iAdapterIndex, int iDisplayIndex, int iMaxNumOfOverrides, ADLDisplayModeInfo *lpModeInfoList, int *lpNumOfOverrides);
-
-// ADL Display/Customize
-typedef int ( *ADL_DISPLAY_CUSTOMIZEDMODELISTNUM_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpListNum);
-typedef int ( *ADL_DISPLAY_CUSTOMIZEDMODELIST_GET ) (int iAdapterIndex, int iDisplayIndex, ADLCustomMode *lpCustomModeList, int iBuffSize);
-typedef int ( *ADL_DISPLAY_CUSTOMIZEDMODE_ADD ) (int iAdapterIndex, int iDisplayIndex, ADLCustomMode customMode);
-typedef int ( *ADL_DISPLAY_CUSTOMIZEDMODE_DELETE ) (int iAdapterIndex, int iDisplayIndex, int iIndex);
-typedef int ( *ADL_DISPLAY_CUSTOMIZEDMODE_VALIDATE ) (int iAdapterIndex, int iDisplayIndex, ADLCustomMode customMode, int *lpValid);
-
-// ADL Display/Over-Underscan
-typedef int ( *ADL_DISPLAY_UNDERSCAN_SET ) (int iAdapterIndex, int iDisplayIndex, int iCurrent);
-typedef int ( *ADL_DISPLAY_UNDERSCAN_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpMin, int *lpMax, int *lpStep);
-typedef int ( *ADL_DISPLAY_OVERSCAN_SET ) (int iAdapterIndex, int iDisplayIndex, int iCurrent);
-typedef int ( *ADL_DISPLAY_OVERSCAN_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefualt, int *lpMin, int *lpMax, int *lpStep);
-
-// ADL Display/Overlay
-typedef int ( *ADL_DISPLAY_CONTROLLEROVERLAYADJUSTMENTCAPS_GET ) (int iAdapterIndex, ADLControllerOverlayInput *lpOverlayInput, ADLControllerOverlayInfo *lpCapsInfo);
-typedef int ( *ADL_DISPLAY_CONTROLLEROVERLAYADJUSTMENTDATA_GET ) (int iAdapterIndex, ADLControllerOverlayInput *lpOverlay);
-typedef int ( *ADL_DISPLAY_CONTROLLEROVERLAYADJUSTMENTDATA_SET ) (int iAdapterIndex, ADLControllerOverlayInput *lpOverlay);
-
-// ADL Display/PowerXpress
-typedef int ( *ADL_DISPLAY_POWERXPRESSVERSION_GET ) (int iAdapterIndex, int *lpVersion);
-typedef int ( *ADL_DISPLAY_POWERXPRESSACTIVEGPU_GET ) (int iAdapterIndex, int *lpActiveGPU);
-typedef int ( *ADL_DISPLAY_POWERXPRESSACTIVEGPU_SET ) (int iAdapterIndex, int iActiveGPU, int *lpOperationResult);
-typedef int ( *ADL_DISPLAY_POWERXPRESS_AUTOSWITCHCONFIG_GET ) (int iAdapterIndex, int *lpAutoSwitchOnACDCEvent, int *lpAutoSwitchOnDCACEvent);
-typedef int ( *ADL_DISPLAY_POWERXPRESS_AUTOSWITCHCONFIG_SET ) (int iAdapterIndex, int iAutoSwitchOnACDCEvent, int iAutoSwitchOnDCACEvent);
-
-// ------------------------------------------------------------------------------------------------------------
-
-// ADL DFP
-typedef int ( *ADL_DFP_BASEAUDIOSUPPORT_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpSupport);
-typedef int ( *ADL_DFP_HDMISUPPORT_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpSupport);
-typedef int ( *ADL_DFP_MVPUANALOGSUPPORT_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpSupport);
-typedef int ( *ADL_DFP_PIXELFORMAT_CAPS ) (int iAdapterIndex, int iDisplayIndex, int *lpValidBits, int *lpValidCaps);
-typedef int ( *ADL_DFP_PIXELFORMAT_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpCurState, int *lpDefault);
-typedef int ( *ADL_DFP_PIXELFORMAT_SET ) (int iAdapterIndex, int iDisplayIndex, int iState);
-typedef int ( *ADL_DFP_GPUSCALINGENABLE_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpSupport, int *lpCurrent, int *lpDefault);
-typedef int ( *ADL_DFP_GPUSCALINGENABLE_SET ) (int iAdapterIndex, int iDisplayIndex, int iCurrent);
-typedef int ( *ADL_DFP_ALLOWONLYCETIMINGS_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpSupport, int *lpCurrent, int *lpDefault);
-typedef int ( *ADL_DFP_ALLOWONLYCETIMINGS_SET ) (int iAdapterIndex, int iDisplayIndex, int iCurrent);
-
-// ADl TV
-typedef int ( *ADL_DISPLAY_TVCAPS_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpcaps);
-typedef int ( *ADL_TV_STANDARD_SET ) (int iAdapterIndex, int iDisplayIndex, int iCurrent);
-typedef int ( *ADL_TV_STANDARD_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpCurrent, int *lpDefault, int *lpSupportedStandards);
-
-// ADL Component Video
-typedef int ( *ADL_CV_DONGLESETTINGS_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpDongleSetting, int *lpOverrideSettingsSupported, int *lpCurOverrideSettings);
-typedef int ( *ADL_CV_DONGLESETTINGS_SET ) (int iAdapterIndex, int iDisplayIndex, int iOverrideSettings);
-typedef int ( *ADL_CV_DONGLESETTINGS_RESET ) (int iAdapterIndex, int iDisplayIndex);
-
-// ------------------------------------------------------------------------------------------------------------
-
-// ADL Overdrive 5
-typedef int ( *ADL_OVERDRIVE5_CURRENTACTIVITY_GET ) (int iAdapterIndex, ADLPMActivity *lpActivity);
-typedef int ( *ADL_OVERDRIVE5_THERMALDEVICES_ENUM ) (int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo);
-typedef int ( *ADL_OVERDRIVE5_TEMPERATURE_GET ) (int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature);
-typedef int ( *ADL_OVERDRIVE5_FANSPEEDINFO_GET ) (int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo);
-typedef int ( *ADL_OVERDRIVE5_FANSPEED_GET ) (int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue);
-typedef int ( *ADL_OVERDRIVE5_FANSPEED_SET ) (int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue);
-typedef int ( *ADL_OVERDRIVE5_FANSPEEDTODEFAULT_SET ) (int iAdapterIndex, int iThermalControllerIndex);
-typedef int ( *ADL_OVERDRIVE5_ODPARAMETERS_GET ) (int iAdapterIndex, ADLODParameters *lpOdParameters);
-typedef int ( *ADL_OVERDRIVE5_ODPERFORMANCELEVELS_GET ) (int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels);
-typedef int ( *ADL_OVERDRIVE5_ODPERFORMANCELEVELS_SET ) (int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels);
-
-// ------------------------------------------------------------------------------------------------------------
-
-// ADL I2C
-typedef int ( *ADL_DISPLAY_WRITEANDREADI2CREV_GET ) (int iAdapterIndex, int *lpMajor, int *lpMinor);
-typedef int ( *ADL_DISPLAY_WRITEANDREADI2C ) (int iAdapterIndex, ADLI2C *plI2C);
-typedef int ( *ADL_DISPLAY_DDCBLOCKACCESS_GET ) (int iAdapterIndex, int iDisplayIndex, int iOption, int iCommandIndex, int iSendMsgLen, char *lpucSendMsgBuf, int *lpulRecvMsgLen, char *lpucRecvMsgBuf);
-typedef int ( *ADL_DISPLAY_DDCINFO_GET ) (int iAdapterIndex, int iDisplayIndex, ADLDDCInfo *lpInfo);
-typedef int ( *ADL_DISPLAY_EDIDDATA_GET ) (int iAdapterIndex, int iDisplayIndex, ADLDisplayEDIDData *lpEDIDData);
-
-// ------------------------------------------------------------------------------------------------------------
-
-// ADL Workstation
-typedef int ( *ADL_WORKSTATION_CAPS ) (int iAdapterIndex, int *lpValidBits, int *lpCaps);
-typedef int ( *ADL_WORKSTATION_STEREO_GET ) (int iAdapterIndex, int *lpDefState, int *lpCurState);
-typedef int ( *ADL_WORKSTATION_STEREO_SET ) (int iAdapterIndex, int iCurState);
-typedef int ( *ADL_WORKSTATION_ADAPTERNUMOFGLSYNCCONNECTORS_GET ) (int iAdapterIndex, int *lpNumOfGLSyncConnectors);
-typedef int ( *ADL_WORKSTATION_DISPLAYGENLOCKCAPABLE_GET ) (int iAdapterIndex, int iDisplayIndex, int *lpCanGenlock);
-typedef int ( *ADL_WORKSTATION_GLSYNCMODULEDETECT_GET ) (int iAdapterIndex, int iGlSyncConnector, ADLGLSyncModuleID *lpGlSyncModuleID);
-typedef int ( *ADL_WORKSTATION_GLSYNCMODULEINFO_GET ) (int iAdapterIndex, int iGlSyncConnector, int *lpNumGLSyncGPUPorts, int *lpNumGlSyncPorts, int *lpMaxSyncDelay, int *lpMaxSampleRate, ADLGLSyncPortCaps **ppGlSyncPorts);
-typedef int ( *ADL_WORKSTATION_GLSYNCGENLOCKCONFIGURATION_GET ) (int iAdapterIndex, int iGlSyncConnector, int iGlValidMask, ADLGLSyncGenlockConfig *lpGlSyncGenlockConfig);
-typedef int ( *ADL_WORKSTATION_GLSYNCGENLOCKCONFIGURATION_SET ) (int iAdapterIndex, int iGlSyncConnector, ADLGLSyncGenlockConfig glSyncGenlockConfig);
-typedef int ( *ADL_WORKSTATION_GLSYNCPORTSTATE_GET ) (int iAdapterIndex, int iGlSyncConnector, int iGlSyncPortType, int iNumLEDs, ADLGlSyncPortInfo *lpGlSyncPortInfo, int **ppGlSyncLEDs);
-typedef int ( *ADL_WORKSTATION_GLSYNCPORTSTATE_SET ) (int iAdapterIndex, int iGlSyncConnector, ADLGlSyncPortControl glSyncPortControl);
-typedef int ( *ADL_WORKSTATION_DISPLAYGLSYNCMODE_GET ) (int iAdapterIndex, int iDisplayIndex, ADLGlSyncMode *lpGlSyncMode);
-typedef int ( *ADL_WORKSTATION_DISPLAYGLSYNCMODE_SET ) (int iAdapterIndex, int iDisplayIndex, ADLGlSyncMode glSyncMode);
-typedef int ( *ADL_WORKSTATION_GLSYNCSUPPORTEDTOPOLOGY_GET ) (int iAdapterIndex, int iNumSyncModes, ADLGlSyncMode2 *glSyncModes, int *iNumSugSyncModes, ADLGlSyncMode2 **glSugSyncModes);
-typedef int ( *ADL_WORKSTATION_LOADBALANCING_GET ) (int *lpResultMask, int *lpCurResultValue, int *lpDefResultValue);
-typedef int ( *ADL_WORKSTATION_LOADBALANCING_SET ) (int iCurState);
-typedef int ( *ADL_WORKSTATION_LOADBALANCING_CAPS ) (int iAdapterIndex, int *lpResultMask, int *lpResultValue);
-
-// ------------------------------------------------------------------------------------------------------------
-
-#ifdef LINUX
-// ADL Linux
-typedef int ( *ADL_ADAPTER_MEMORYINFO_GET ) (int iAdapterIndex, ADLMemoryInfo *lpMemoryInfo);
-typedef int ( *ADL_CONTROLLER_COLOR_SET ) (int iAdapterIndex, int iControllerIndex, ADLGamma adlGamma);
-typedef int ( *ADL_CONTROLLER_COLOR_GET ) (int iAdapterIndex, int iControllerIndex, ADLGamma *lpGammaCurrent, ADLGamma *lpGammaDefault, ADLGamma *lpGammaMin, ADLGamma *lpGammaMax);
-typedef int ( *ADL_DESKTOPCONFIG_GET ) (int iAdapterIndex, int *lpDesktopConfig);
-typedef int ( *ADL_DESKTOPCONFIG_SET ) (int iAdapterIndex, int iDesktopConfig);
-typedef int ( *ADL_NUMBEROFDISPLAYENABLE_GET ) (int iAdapterIndex, int *lpNumberOfDisplays);
-typedef int ( *ADL_DISPLAYENABLE_SET ) (int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly);
-typedef int ( *ADL_DISPLAY_IDENTIFYDISPLAY ) (int iAdapterIndex, int iDisplayIndex, int iDisplayControllerIndex, int iShow, int iDisplayNum, int iPosX, int iPosY);
-typedef int ( *ADL_DISPLAY_LUTCOLOR_SET ) (int iAdapterIndex, int iDisplayIndex, ADLGamma adlGamma);
-typedef int ( *ADL_DISPLAY_LUTCOLOR_GET ) (int iAdapterIndex, int iDisplayIndex, ADLGamma *lpGammaCurrent, ADLGamma *lpGammaDefault, ADLGamma *lpGammaMin, ADLGamma *lpGammaMax);
-typedef int ( *ADL_ADAPTER_XSCREENINFO_GET ) (LPXScreenInfo lpXScreenInfo, int iInputSize);
-typedef int ( *ADL_DISPLAY_XRANDRDISPLAYNAME_GET ) (int iAdapterIndex, int iDisplayIndex, char *lpXrandrDisplayName, int iBuffSize);
-#endif
-// ------------------------------------------------------------------------------------------------------------
-
-
-// experimental undocumented
-typedef int ( *ADL_OVERDRIVE5_POWERCONTROL_GET ) (int iAdapterIndex, int* iPercentage, int* whatever);
-typedef int ( *ADL_OVERDRIVE5_POWERCONTROL_SET ) (int iAdapterIndex, int iPercentage);
-//typedef int ( *ADL_OVERDRIVE5_POWERCONTROL_CAPS ) (int iAdapterIndex, int* lpCaps, int* lpValid);
-//typedef int ( *ADL_OVERDRIVE5_POWERCONTROLINFO_GET) (int iAdapterIndex, ...)
\ No newline at end of file
diff --git a/api.c b/api.c
index 3ceaa8e..302196d 100644
--- a/api.c
+++ b/api.c
@@ -6,10 +6,6 @@
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version. See COPYING for more details.
- *
- * Note: the code always includes GPU support even if there are no GPUs
- * this simplifies handling multiple other device code being included
- * depending on compile options
*/
#define _MEMORY_DEBUG_MASTER 1
@@ -29,7 +25,7 @@
#include "miner.h"
#include "util.h"
-#if defined(USE_BFLSC) || defined(USE_AVALON) || defined(USE_HASHFAST) || defined(USE_BITFURY) || defined(USE_KLONDIKE) || defined(USE_KNC)
+#if defined(USE_BFLSC) || defined(USE_AVALON) || defined(USE_HASHFAST) || defined(USE_BITFURY) || defined(USE_KLONDIKE) || defined(USE_KNC) || defined(USE_BAB)
#define HAVE_AN_ASIC 1
#endif
@@ -134,23 +130,16 @@ static const char *COMMA = ",";
#define COMSTR ","
static const char SEPARATOR = '|';
#define SEPSTR "|"
-static const char GPUSEP = ',';
-static const char *APIVERSION = "1.32";
+static const char *APIVERSION = "2.0";
static const char *DEAD = "Dead";
-#if defined(HAVE_OPENCL) || defined(HAVE_AN_FPGA) || defined(HAVE_AN_ASIC)
static const char *SICK = "Sick";
static const char *NOSTART = "NoStart";
static const char *INIT = "Initialising";
-#endif
static const char *DISABLED = "Disabled";
static const char *ALIVE = "Alive";
static const char *REJECTING = "Rejecting";
static const char *UNKNOWN = "Unknown";
-#define _DYNAMIC "D"
-#ifdef HAVE_OPENCL
-static const char *DYNAMIC = _DYNAMIC;
-#endif
static __maybe_unused const char *NONE = "None";
@@ -161,9 +150,6 @@ static const char *NULLSTR = "(null)";
static const char *TRUESTR = "true";
static const char *FALSESTR = "false";
-#ifdef USE_SCRYPT
-static const char *SCRYPTSTR = "scrypt";
-#endif
static const char *SHA256STR = "sha256";
static const char *DEVICECODE = ""
@@ -179,9 +165,6 @@ static const char *DEVICECODE = ""
#ifdef USE_BITFURY
"BFU "
#endif
-#ifdef HAVE_OPENCL
- "GPU "
-#endif
#ifdef USE_HASHFAST
"HFA "
#endif
@@ -194,6 +177,9 @@ static const char *DEVICECODE = ""
#ifdef USE_KNC
"KnC "
#endif
+#ifdef USE_BAB
+ "BaB "
+#endif
#ifdef USE_MODMINER
"MMQ "
#endif
@@ -224,7 +210,6 @@ static const char *OSINFO =
#define _STATUS "STATUS"
#define _VERSION "VERSION"
#define _MINECONFIG "CONFIG"
-#define _GPU "GPU"
#ifdef HAVE_AN_FPGA
#define _PGA "PGA"
@@ -234,7 +219,6 @@ static const char *OSINFO =
#define _ASC "ASC"
#endif
-#define _GPUS "GPUS"
#define _PGAS "PGAS"
#define _ASCS "ASCS"
#define _NOTIFY "NOTIFY"
@@ -265,7 +249,6 @@ static const char ISJSON = '{';
#define JSON_STATUS JSON1 _STATUS JSON2
#define JSON_VERSION JSON1 _VERSION JSON2
#define JSON_MINECONFIG JSON1 _MINECONFIG JSON2
-#define JSON_GPU JSON1 _GPU JSON2
#ifdef HAVE_AN_FPGA
#define JSON_PGA JSON1 _PGA JSON2
@@ -275,7 +258,6 @@ static const char ISJSON = '{';
#define JSON_ASC JSON1 _ASC JSON2
#endif
-#define JSON_GPUS JSON1 _GPUS JSON2
#define JSON_PGAS JSON1 _PGAS JSON2
#define JSON_ASCS JSON1 _ASCS JSON2
#define JSON_NOTIFY JSON1 _NOTIFY JSON2
@@ -295,24 +277,13 @@ static const char ISJSON = '{';
static const char *JSON_COMMAND = "command";
static const char *JSON_PARAMETER = "parameter";
-#define MSG_INVGPU 1
-#define MSG_ALRENA 2
-#define MSG_ALRDIS 3
-#define MSG_GPUMRE 4
-#define MSG_GPUREN 5
-#define MSG_GPUNON 6
#define MSG_POOL 7
#define MSG_NOPOOL 8
#define MSG_DEVS 9
#define MSG_NODEVS 10
#define MSG_SUMM 11
-#define MSG_GPUDIS 12
-#define MSG_GPUREI 13
#define MSG_INVCMD 14
#define MSG_MISID 15
-#define MSG_GPUDEV 17
-
-#define MSG_NUMGPU 20
#define MSG_VERSION 22
#define MSG_INVJSON 23
@@ -322,18 +293,8 @@ static const char *JSON_PARAMETER = "parameter";
#define MSG_SWITCHP 27
#define MSG_MISVAL 28
#define MSG_NOADL 29
-#define MSG_NOGPUADL 30
#define MSG_INVINT 31
-#define MSG_GPUINT 32
#define MSG_MINECONFIG 33
-#define MSG_GPUMERR 34
-#define MSG_GPUMEM 35
-#define MSG_GPUEERR 36
-#define MSG_GPUENG 37
-#define MSG_GPUVERR 38
-#define MSG_GPUVDDC 39
-#define MSG_GPUFERR 40
-#define MSG_GPUFAN 41
#define MSG_MISFN 42
#define MSG_BADFN 43
#define MSG_SAVED 44
@@ -446,11 +407,9 @@ enum code_severity {
};
enum code_parameters {
- PARAM_GPU,
PARAM_PGA,
PARAM_ASC,
PARAM_PID,
- PARAM_GPUMAX,
PARAM_PGAMAX,
PARAM_ASCMAX,
PARAM_PMAX,
@@ -475,57 +434,36 @@ struct CODES {
const enum code_parameters params;
const char *description;
} codes[] = {
-#ifdef HAVE_OPENCL
- { SEVERITY_ERR, MSG_INVGPU, PARAM_GPUMAX, "Invalid GPU id %d - range is 0 - %d" },
- { SEVERITY_INFO, MSG_ALRENA, PARAM_GPU, "GPU %d already enabled" },
- { SEVERITY_INFO, MSG_ALRDIS, PARAM_GPU, "GPU %d already disabled" },
- { SEVERITY_WARN, MSG_GPUMRE, PARAM_GPU, "GPU %d must be restarted first" },
- { SEVERITY_INFO, MSG_GPUREN, PARAM_GPU, "GPU %d sent enable message" },
-#endif
- { SEVERITY_ERR, MSG_GPUNON, PARAM_NONE, "No GPUs" },
{ SEVERITY_SUCC, MSG_POOL, PARAM_PMAX, "%d Pool(s)" },
{ SEVERITY_ERR, MSG_NOPOOL, PARAM_NONE, "No pools" },
{ SEVERITY_SUCC, MSG_DEVS, PARAM_DMAX,
-#ifdef HAVE_OPENCL
- "%d GPU(s)"
-#endif
-#if defined(HAVE_AN_ASIC) && defined(HAVE_OPENCL)
- " - "
-#endif
#ifdef HAVE_AN_ASIC
"%d ASC(s)"
#endif
-#if defined(HAVE_AN_FPGA) && (defined(HAVE_OPENCL) || defined(HAVE_AN_ASIC))
+#if defined(HAVE_AN_ASIC) && defined(HAVE_AN_FPGA)
" - "
#endif
#ifdef HAVE_AN_FPGA
"%d PGA(s)"
#endif
-#if (defined(HAVE_OPENCL) || defined(HAVE_AN_ASIC) || defined(HAVE_AN_FPGA))
- " - "
-#endif
},
- { SEVERITY_ERR, MSG_NODEVS, PARAM_NONE, "No GPUs"
+ { SEVERITY_ERR, MSG_NODEVS, PARAM_NONE, "No "
#ifdef HAVE_AN_ASIC
- "/ASCs"
+ "ASCs"
+#endif
+#if defined(HAVE_AN_ASIC) && defined(HAVE_AN_FPGA)
+ "/"
#endif
#ifdef HAVE_AN_FPGA
- "/PGAs"
+ "PGAs"
#endif
},
{ SEVERITY_SUCC, MSG_SUMM, PARAM_NONE, "Summary" },
-#ifdef HAVE_OPENCL
- { SEVERITY_INFO, MSG_GPUDIS, PARAM_GPU, "GPU %d set disable flag" },
- { SEVERITY_INFO, MSG_GPUREI, PARAM_GPU, "GPU %d restart attempted" },
-#endif
{ SEVERITY_ERR, MSG_INVCMD, PARAM_NONE, "Invalid command" },
{ SEVERITY_ERR, MSG_MISID, PARAM_NONE, "Missing device id parameter" },
-#ifdef HAVE_OPENCL
- { SEVERITY_SUCC, MSG_GPUDEV, PARAM_GPU, "GPU%d" },
-#endif
#ifdef HAVE_AN_FPGA
{ SEVERITY_ERR, MSG_PGANON, PARAM_NONE, "No PGAs" },
{ SEVERITY_SUCC, MSG_PGADEV, PARAM_PGA, "PGA%d" },
@@ -536,7 +474,6 @@ struct CODES {
{ SEVERITY_INFO, MSG_PGADIS, PARAM_PGA, "PGA %d set disable flag" },
{ SEVERITY_ERR, MSG_PGAUNW, PARAM_PGA, "PGA %d is not flagged WELL, cannot enable" },
#endif
- { SEVERITY_SUCC, MSG_NUMGPU, PARAM_NONE, "GPU count" },
{ SEVERITY_SUCC, MSG_NUMPGA, PARAM_NONE, "PGA count" },
{ SEVERITY_SUCC, MSG_NUMASC, PARAM_NONE, "ASC count" },
{ SEVERITY_SUCC, MSG_VERSION, PARAM_NONE, "CGMiner versions" },
@@ -545,22 +482,7 @@ struct CODES {
{ SEVERITY_ERR, MSG_MISPID, PARAM_NONE, "Missing pool id parameter" },
{ SEVERITY_ERR, MSG_INVPID, PARAM_POOLMAX, "Invalid pool id %d - range is 0 - %d" },
{ SEVERITY_SUCC, MSG_SWITCHP, PARAM_POOL, "Switching to pool %d:'%s'" },
- { SEVERITY_ERR, MSG_MISVAL, PARAM_NONE, "Missing comma after GPU number" },
- { SEVERITY_ERR, MSG_NOADL, PARAM_NONE, "ADL is not available" },
- { SEVERITY_ERR, MSG_NOGPUADL,PARAM_GPU, "GPU %d does not have ADL" },
- { SEVERITY_ERR, MSG_INVINT, PARAM_STR, "Invalid intensity (%s) - must be '" _DYNAMIC "' or range " MIN_SHA_INTENSITY_STR " - " MAX_SCRYPT_INTENSITY_STR },
- { SEVERITY_INFO, MSG_GPUINT, PARAM_BOTH, "GPU %d set new intensity to %s" },
{ SEVERITY_SUCC, MSG_MINECONFIG,PARAM_NONE, "CGMiner config" },
-#ifdef HAVE_OPENCL
- { SEVERITY_ERR, MSG_GPUMERR, PARAM_BOTH, "Setting GPU %d memoryclock to (%s) reported failure" },
- { SEVERITY_SUCC, MSG_GPUMEM, PARAM_BOTH, "Setting GPU %d memoryclock to (%s) reported success" },
- { SEVERITY_ERR, MSG_GPUEERR, PARAM_BOTH, "Setting GPU %d clock to (%s) reported failure" },
- { SEVERITY_SUCC, MSG_GPUENG, PARAM_BOTH, "Setting GPU %d clock to (%s) reported success" },
- { SEVERITY_ERR, MSG_GPUVERR, PARAM_BOTH, "Setting GPU %d vddc to (%s) reported failure" },
- { SEVERITY_SUCC, MSG_GPUVDDC, PARAM_BOTH, "Setting GPU %d vddc to (%s) reported success" },
- { SEVERITY_ERR, MSG_GPUFERR, PARAM_BOTH, "Setting GPU %d fan to (%s) reported failure" },
- { SEVERITY_SUCC, MSG_GPUFAN, PARAM_BOTH, "Setting GPU %d fan to (%s) reported success" },
-#endif
{ SEVERITY_ERR, MSG_MISFN, PARAM_NONE, "Missing save filename parameter" },
{ SEVERITY_ERR, MSG_BADFN, PARAM_STR, "Can't open or create save file '%s'" },
{ SEVERITY_SUCC, MSG_SAVED, PARAM_STR, "Configuration saved to file '%s'" },
@@ -1364,7 +1286,6 @@ static void message(struct io_data *io_data, int messageid, int paramid, char *p
severity[1] = '\0';
switch(codes[i].params) {
- case PARAM_GPU:
case PARAM_PGA:
case PARAM_ASC:
case PARAM_PID:
@@ -1374,11 +1295,6 @@ static void message(struct io_data *io_data, int messageid, int paramid, char *p
case PARAM_POOL:
sprintf(buf, codes[i].description, paramid, pools[paramid]->rpc_url);
break;
-#ifdef HAVE_OPENCL
- case PARAM_GPUMAX:
- sprintf(buf, codes[i].description, paramid, nDevs - 1);
- break;
-#endif
#ifdef HAVE_AN_FPGA
case PARAM_PGAMAX:
pga = numpgas();
@@ -1406,9 +1322,6 @@ static void message(struct io_data *io_data, int messageid, int paramid, char *p
#endif
sprintf(buf, codes[i].description
-#ifdef HAVE_OPENCL
- , nDevs
-#endif
#ifdef HAVE_AN_ASIC
, asc
#endif
@@ -1712,10 +1625,14 @@ uint64_t api_trylock(void *lock, const char *file, const char *func, const int l
LOCKINFO *info;
uint64_t id;
+ locklock();
+
info = findlock(lock, CGLOCK_UNKNOWN, file, func, linenum);
id = lock_id++;
addgettry(info, id, file, func, linenum, false);
+ lockunlock();
+
return id;
}
@@ -1881,27 +1798,8 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __
struct api_data *root = NULL;
char buf[TMPBUFSIZ];
bool io_open;
- int gpucount = 0;
int asccount = 0;
int pgacount = 0;
- char *adlinuse = (char *)NO;
-#ifdef HAVE_ADL
- const char *adl = YES;
- int i;
-
- for (i = 0; i < nDevs; i++) {
- if (gpus[i].has_adl) {
- adlinuse = (char *)YES;
- break;
- }
- }
-#else
- const char *adl = NO;
-#endif
-
-#ifdef HAVE_OPENCL
- gpucount = nDevs;
-#endif
#ifdef HAVE_AN_ASIC
asccount = numascs();
@@ -1914,12 +1812,9 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __
message(io_data, MSG_MINECONFIG, 0, NULL, isjson);
io_open = io_add(io_data, isjson ? COMSTR JSON_MINECONFIG : _MINECONFIG COMSTR);
- root = api_add_int(root, "GPU Count", &gpucount, false);
root = api_add_int(root, "ASC Count", &asccount, false);
root = api_add_int(root, "PGA Count", &pgacount, false);
root = api_add_int(root, "Pool Count", &total_pools, false);
- root = api_add_const(root, "ADL", (char *)adl, false);
- root = api_add_string(root, "ADL in use", adlinuse, false);
root = api_add_const(root, "Strategy", strategies[pool_strategy].s, false);
root = api_add_int(root, "Log Interval", &opt_log_interval, false);
root = api_add_const(root, "Device Code", DEVICECODE, false);
@@ -1943,7 +1838,6 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __
io_close(io_data);
}
-#if defined(HAVE_OPENCL) || defined(HAVE_AN_FPGA) || defined(HAVE_AN_ASIC)
static const char *status2str(enum alive status)
{
switch (status) {
@@ -1961,85 +1855,6 @@ static const char *status2str(enum alive status)
return UNKNOWN;
}
}
-#endif
-
-#ifdef HAVE_OPENCL
-static void gpustatus(struct io_data *io_data, int gpu, bool isjson, bool precom)
-{
- struct api_data *root = NULL;
- char intensity[20];
- char buf[TMPBUFSIZ];
- char *enabled;
- char *status;
- float gt, gv;
- int ga, gf, gp, gc, gm, pt;
-
- if (gpu >= 0 && gpu < nDevs) {
- struct cgpu_info *cgpu = &gpus[gpu];
-
- cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
-
-#ifdef HAVE_ADL
- if (!gpu_stats(gpu, >, &gc, &gm, &gv, &ga, &gf, &gp, &pt))
-#endif
- gt = gv = gm = gc = ga = gf = gp = pt = 0;
-
- if (cgpu->deven != DEV_DISABLED)
- enabled = (char *)YES;
- else
- enabled = (char *)NO;
-
- status = (char *)status2str(cgpu->status);
-
- if (cgpu->dynamic)
- strcpy(intensity, DYNAMIC);
- else
- sprintf(intensity, "%d", cgpu->intensity);
-
- root = api_add_int(root, "GPU", &gpu, false);
- root = api_add_string(root, "Enabled", enabled, false);
- root = api_add_string(root, "Status", status, false);
- root = api_add_temp(root, "Temperature", >, false);
- root = api_add_int(root, "Fan Speed", &gf, false);
- root = api_add_int(root, "Fan Percent", &gp, false);
- root = api_add_int(root, "GPU Clock", &gc, false);
- root = api_add_int(root, "Memory Clock", &gm, false);
- root = api_add_volts(root, "GPU Voltage", &gv, false);
- root = api_add_int(root, "GPU Activity", &ga, false);
- root = api_add_int(root, "Powertune", &pt, false);
- double mhs = cgpu->total_mhashes / total_secs;
- root = api_add_mhs(root, "MHS av", &mhs, false);
- char mhsname[27];
- sprintf(mhsname, "MHS %ds", opt_log_interval);
- root = api_add_mhs(root, mhsname, &(cgpu->rolling), false);
- root = api_add_int(root, "Accepted", &(cgpu->accepted), false);
- root = api_add_int(root, "Rejected", &(cgpu->rejected), false);
- root = api_add_int(root, "Hardware Errors", &(cgpu->hw_errors), false);
- root = api_add_utility(root, "Utility", &(cgpu->utility), false);
- root = api_add_string(root, "Intensity", intensity, false);
- int last_share_pool = cgpu->last_share_pool_time > 0 ?
- cgpu->last_share_pool : -1;
- root = api_add_int(root, "Last Share Pool", &last_share_pool, false);
- root = api_add_time(root, "Last Share Time", &(cgpu->last_share_pool_time), false);
- root = api_add_mhtotal(root, "Total MH", &(cgpu->total_mhashes), false);
- root = api_add_int(root, "Diff1 Work", &(cgpu->diff1), false);
- root = api_add_diff(root, "Difficulty Accepted", &(cgpu->diff_accepted), false);
- root = api_add_diff(root, "Difficulty Rejected", &(cgpu->diff_rejected), false);
- root = api_add_diff(root, "Last Share Difficulty", &(cgpu->last_share_diff), false);
- root = api_add_time(root, "Last Valid Work", &(cgpu->last_device_valid_work), false);
- double hwp = (cgpu->hw_errors + cgpu->diff1) ?
- (double)(cgpu->hw_errors) / (double)(cgpu->hw_errors + cgpu->diff1) : 0;
- root = api_add_percent(root, "Device Hardware%", &hwp, false);
- double rejp = cgpu->diff1 ?
- (double)(cgpu->diff_rejected) / (double)(cgpu->diff1) : 0;
- root = api_add_percent(root, "Device Rejected%", &rejp, false);
- root = api_add_elapsed(root, "Device Elapsed", &(total_secs), true); // GPUs don't hotplug
-
- root = print_data(root, buf, isjson, precom);
- io_add(io_data, buf);
- }
-}
-#endif
#ifdef HAVE_AN_ASIC
static void ascstatus(struct io_data *io_data, int asc, bool isjson, bool precom)
@@ -2212,15 +2027,10 @@ static void devstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __ma
{
bool io_open = false;
int devcount = 0;
- int numgpu = 0;
int numasc = 0;
int numpga = 0;
int i;
-#ifdef HAVE_OPENCL
- numgpu = nDevs;
-#endif
-
#ifdef HAVE_AN_ASIC
numasc = numascs();
#endif
@@ -2229,7 +2039,7 @@ static void devstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __ma
numpga = numpgas();
#endif
- if (numgpu == 0 && numpga == 0 && numasc == 0) {
+ if (numpga == 0 && numasc == 0) {
message(io_data, MSG_NODEVS, 0, NULL, isjson);
return;
}
@@ -2239,13 +2049,6 @@ static void devstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __ma
if (isjson)
io_open = io_add(io_data, COMSTR JSON_DEVS);
-#ifdef HAVE_OPENCL
- for (i = 0; i < nDevs; i++) {
- gpustatus(io_data, i, isjson, isjson && devcount > 0);
-
- devcount++;
- }
-#endif
#ifdef HAVE_AN_ASIC
if (numasc > 0) {
for (i = 0; i < numasc; i++) {
@@ -2270,40 +2073,6 @@ static void devstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __ma
io_close(io_data);
}
-#ifdef HAVE_OPENCL
-static void gpudev(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
-{
- bool io_open = false;
- int id;
-
- if (nDevs == 0) {
- message(io_data, MSG_GPUNON, 0, NULL, isjson);
- return;
- }
-
- if (param == NULL || *param == '\0') {
- message(io_data, MSG_MISID, 0, NULL, isjson);
- return;
- }
-
- id = atoi(param);
- if (id < 0 || id >= nDevs) {
- message(io_data, MSG_INVGPU, id, NULL, isjson);
- return;
- }
-
- message(io_data, MSG_GPUDEV, id, NULL, isjson);
-
- if (isjson)
- io_open = io_add(io_data, COMSTR JSON_GPU);
-
- gpustatus(io_data, id, isjson, false);
-
- if (isjson && io_open)
- io_close(io_data);
-}
-#endif
-
#ifdef HAVE_AN_FPGA
static void pgadev(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
{
@@ -2649,136 +2418,6 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb
io_close(io_data);
}
-#ifdef HAVE_OPENCL
-static void gpuenable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
-{
- struct thr_info *thr;
- int gpu;
- int id;
- int i;
-
- if (gpu_threads == 0) {
- message(io_data, MSG_GPUNON, 0, NULL, isjson);
- return;
- }
-
- if (param == NULL || *param == '\0') {
- message(io_data, MSG_MISID, 0, NULL, isjson);
- return;
- }
-
- id = atoi(param);
- if (id < 0 || id >= nDevs) {
- message(io_data, MSG_INVGPU, id, NULL, isjson);
- return;
- }
-
- applog(LOG_DEBUG, "API: request to gpuenable gpuid %d %s%u",
- id, gpus[id].drv->name, gpus[id].device_id);
-
- if (gpus[id].deven != DEV_DISABLED) {
- message(io_data, MSG_ALRENA, id, NULL, isjson);
- return;
- }
-
- for (i = 0; i < gpu_threads; i++) {
- thr = get_thread(i);
- gpu = thr->cgpu->device_id;
- if (gpu == id) {
- if (thr->cgpu->status != LIFE_WELL) {
- message(io_data, MSG_GPUMRE, id, NULL, isjson);
- return;
- }
- gpus[id].deven = DEV_ENABLED;
- applog(LOG_DEBUG, "API Pushing sem post to thread %d", thr->id);
- cgsem_post(&thr->sem);
- }
- }
-
- message(io_data, MSG_GPUREN, id, NULL, isjson);
-}
-
-static void gpudisable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
-{
- int id;
-
- if (nDevs == 0) {
- message(io_data, MSG_GPUNON, 0, NULL, isjson);
- return;
- }
-
- if (param == NULL || *param == '\0') {
- message(io_data, MSG_MISID, 0, NULL, isjson);
- return;
- }
-
- id = atoi(param);
- if (id < 0 || id >= nDevs) {
- message(io_data, MSG_INVGPU, id, NULL, isjson);
- return;
- }
-
- applog(LOG_DEBUG, "API: request to gpudisable gpuid %d %s%u",
- id, gpus[id].drv->name, gpus[id].device_id);
-
- if (gpus[id].deven == DEV_DISABLED) {
- message(io_data, MSG_ALRDIS, id, NULL, isjson);
- return;
- }
-
- gpus[id].deven = DEV_DISABLED;
-
- message(io_data, MSG_GPUDIS, id, NULL, isjson);
-}
-
-static void gpurestart(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
-{
- int id;
-
- if (nDevs == 0) {
- message(io_data, MSG_GPUNON, 0, NULL, isjson);
- return;
- }
-
- if (param == NULL || *param == '\0') {
- message(io_data, MSG_MISID, 0, NULL, isjson);
- return;
- }
-
- id = atoi(param);
- if (id < 0 || id >= nDevs) {
- message(io_data, MSG_INVGPU, id, NULL, isjson);
- return;
- }
-
- reinit_device(&gpus[id]);
-
- message(io_data, MSG_GPUREI, id, NULL, isjson);
-}
-#endif
-
-static void gpucount(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
-{
- struct api_data *root = NULL;
- char buf[TMPBUFSIZ];
- bool io_open;
- int numgpu = 0;
-
-#ifdef HAVE_OPENCL
- numgpu = nDevs;
-#endif
-
- message(io_data, MSG_NUMGPU, 0, NULL, isjson);
- io_open = io_add(io_data, isjson ? COMSTR JSON_GPUS : _GPUS COMSTR);
-
- root = api_add_int(root, "Count", &numgpu, false);
-
- root = print_data(root, buf, isjson, false);
- io_add(io_data, buf);
- if (isjson && io_open)
- io_close(io_data);
-}
-
static void pgacount(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
{
struct api_data *root = NULL;
@@ -3150,156 +2789,6 @@ static void removepool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
rpc_url = NULL;
}
-#ifdef HAVE_OPENCL
-static bool splitgpuvalue(struct io_data *io_data, char *param, int *gpu, char **value, bool isjson)
-{
- int id;
- char *gpusep;
-
- if (nDevs == 0) {
- message(io_data, MSG_GPUNON, 0, NULL, isjson);
- return false;
- }
-
- if (param == NULL || *param == '\0') {
- message(io_data, MSG_MISID, 0, NULL, isjson);
- return false;
- }
-
- gpusep = strchr(param, GPUSEP);
- if (gpusep == NULL) {
- message(io_data, MSG_MISVAL, 0, NULL, isjson);
- return false;
- }
-
- *(gpusep++) = '\0';
-
- id = atoi(param);
- if (id < 0 || id >= nDevs) {
- message(io_data, MSG_INVGPU, id, NULL, isjson);
- return false;
- }
-
- *gpu = id;
- *value = gpusep;
-
- return true;
-}
-
-static void gpuintensity(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
-{
- int id;
- char *value;
- int intensity;
- char intensitystr[7];
-
- if (!splitgpuvalue(io_data, param, &id, &value, isjson))
- return;
-
- if (!strncasecmp(value, DYNAMIC, 1)) {
- gpus[id].dynamic = true;
- strcpy(intensitystr, DYNAMIC);
- }
- else {
- intensity = atoi(value);
- if (intensity < MIN_INTENSITY || intensity > MAX_INTENSITY) {
- message(io_data, MSG_INVINT, 0, value, isjson);
- return;
- }
-
- gpus[id].dynamic = false;
- gpus[id].intensity = intensity;
- sprintf(intensitystr, "%d", intensity);
- }
-
- message(io_data, MSG_GPUINT, id, intensitystr, isjson);
-}
-
-static void gpumem(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
-{
-#ifdef HAVE_ADL
- int id;
- char *value;
- int clock;
-
- if (!splitgpuvalue(io_data, param, &id, &value, isjson))
- return;
-
- clock = atoi(value);
-
- if (set_memoryclock(id, clock))
- message(io_data, MSG_GPUMERR, id, value, isjson);
- else
- message(io_data, MSG_GPUMEM, id, value, isjson);
-#else
- message(io_data, MSG_NOADL, 0, NULL, isjson);
-#endif
-}
-
-static void gpuengine(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
-{
-#ifdef HAVE_ADL
- int id;
- char *value;
- int clock;
-
- if (!splitgpuvalue(io_data, param, &id, &value, isjson))
- return;
-
- clock = atoi(value);
-
- if (set_engineclock(id, clock))
- message(io_data, MSG_GPUEERR, id, value, isjson);
- else
- message(io_data, MSG_GPUENG, id, value, isjson);
-#else
- message(io_data, MSG_NOADL, 0, NULL, isjson);
-#endif
-}
-
-static void gpufan(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
-{
-#ifdef HAVE_ADL
- int id;
- char *value;
- int fan;
-
- if (!splitgpuvalue(io_data, param, &id, &value, isjson))
- return;
-
- fan = atoi(value);
-
- if (set_fanspeed(id, fan))
- message(io_data, MSG_GPUFERR, id, value, isjson);
- else
- message(io_data, MSG_GPUFAN, id, value, isjson);
-#else
- message(io_data, MSG_NOADL, 0, NULL, isjson);
-#endif
-}
-
-static void gpuvddc(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
-{
-#ifdef HAVE_ADL
- int id;
- char *value;
- float vddc;
-
- if (!splitgpuvalue(io_data, param, &id, &value, isjson))
- return;
-
- vddc = atof(value);
-
- if (set_vddc(id, vddc))
- message(io_data, MSG_GPUVERR, id, value, isjson);
- else
- message(io_data, MSG_GPUVDDC, id, value, isjson);
-#else
- message(io_data, MSG_NOADL, 0, NULL, isjson);
-#endif
-}
-#endif
-
void doquit(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
{
if (isjson)
@@ -3658,12 +3147,7 @@ static void minecoin(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __may
message(io_data, MSG_MINECOIN, 0, NULL, isjson);
io_open = io_add(io_data, isjson ? COMSTR JSON_MINECOIN : _MINECOIN COMSTR);
-#ifdef USE_SCRYPT
- if (opt_scrypt)
- root = api_add_const(root, "Hash Method", SCRYPTSTR, false);
- else
-#endif
- root = api_add_const(root, "Hash Method", SHA256STR, false);
+ root = api_add_const(root, "Hash Method", SHA256STR, false);
cg_rlock(&ch_lock);
root = api_add_timeval(root, "Current Block Time", &block_timeval, true);
@@ -4251,19 +3735,12 @@ struct CMDS {
{ "devs", devstatus, false },
{ "pools", poolstatus, false },
{ "summary", summary, false },
-#ifdef HAVE_OPENCL
- { "gpuenable", gpuenable, true },
- { "gpudisable", gpudisable, true },
- { "gpurestart", gpurestart, true },
- { "gpu", gpudev, false },
-#endif
#ifdef HAVE_AN_FPGA
{ "pga", pgadev, false },
{ "pgaenable", pgaenable, true },
{ "pgadisable", pgadisable, true },
{ "pgaidentify", pgaidentify, true },
#endif
- { "gpucount", gpucount, false },
{ "pgacount", pgacount, false },
{ "switchpool", switchpool, true },
{ "addpool", addpool, true },
@@ -4272,13 +3749,6 @@ struct CMDS {
{ "enablepool", enablepool, true },
{ "disablepool", disablepool, true },
{ "removepool", removepool, true },
-#ifdef HAVE_OPENCL
- { "gpuintensity", gpuintensity, true },
- { "gpumem", gpumem, true },
- { "gpuengine", gpuengine, true },
- { "gpufan", gpufan, true },
- { "gpuvddc", gpuvddc, true },
-#endif
{ "save", dosave, true },
{ "quit", doquit, true },
{ "privileged", privileged, true },
diff --git a/cgminer.c b/cgminer.c
index 4e0e490..ca5e345 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -53,11 +53,7 @@ char *curly = ":D";
#include "compat.h"
#include "miner.h"
-#include "findnonce.h"
-#include "adl.h"
-#include "driver-opencl.h"
#include "bench_block.h"
-#include "scrypt.h"
#ifdef USE_USBUTILS
#include "usbutils.h"
#endif
@@ -113,17 +109,9 @@ static const bool opt_time = true;
unsigned long long global_hashrate;
unsigned long global_quota_gcd = 1;
-#if defined(HAVE_OPENCL) || defined(USE_USBUTILS)
+#if defined(USE_USBUTILS)
int nDevs;
#endif
-#ifdef HAVE_OPENCL
-int opt_dynamic_interval = 7;
-int opt_g_threads = -1;
-int gpu_threads;
-#ifdef USE_SCRYPT
-bool opt_scrypt;
-#endif
-#endif
bool opt_restart = true;
bool opt_nogpu;
@@ -136,7 +124,6 @@ int total_devices;
int zombie_devs;
static int most_devices;
struct cgpu_info **devices;
-bool have_opencl;
int mining_threads;
int num_processors;
#ifdef HAVE_CURSES
@@ -1158,14 +1145,6 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--device|-d",
set_devices, NULL, NULL,
"Select device to use, one value, range and/or comma separated (e.g. 0-2,4) default: all"),
- OPT_WITHOUT_ARG("--disable-gpu|-G",
- opt_set_bool, &opt_nogpu,
-#ifdef HAVE_OPENCL
- "Disable GPU mining even if suitable devices exist"
-#else
- opt_hidden
-#endif
- ),
OPT_WITHOUT_ARG("--disable-rejecting",
opt_set_bool, &opt_disable_pool,
"Automatically disable pools that continually reject shares"),
@@ -1178,59 +1157,6 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--fix-protocol",
opt_set_bool, &opt_fix_protocol,
"Do not redirect to a different getwork protocol (eg. stratum)"),
-#ifdef HAVE_OPENCL
- OPT_WITH_ARG("--gpu-dyninterval",
- set_int_1_to_65535, opt_show_intval, &opt_dynamic_interval,
- "Set the refresh interval in ms for GPUs using dynamic intensity"),
- OPT_WITH_ARG("--gpu-platform",
- set_int_0_to_9999, opt_show_intval, &opt_platform_id,
- "Select OpenCL platform ID to use for GPU mining"),
- OPT_WITH_ARG("--gpu-threads|-g",
- set_int_1_to_10, opt_show_intval, &opt_g_threads,
- "Number of threads per GPU (1 - 10)"),
-#ifdef HAVE_ADL
- OPT_WITH_ARG("--gpu-engine",
- set_gpu_engine, NULL, NULL,
- "GPU engine (over)clock range in Mhz - one value, range and/or comma separated list (e.g. 850-900,900,750-850)"),
- OPT_WITH_ARG("--gpu-fan",
- set_gpu_fan, NULL, NULL,
- "GPU fan percentage range - one value, range and/or comma separated list (e.g. 0-85,85,65)"),
- OPT_WITH_ARG("--gpu-map",
- set_gpu_map, NULL, NULL,
- "Map OpenCL to ADL device order manually, paired CSV (e.g. 1:0,2:1 maps OpenCL 1 to ADL 0, 2 to 1)"),
- OPT_WITH_ARG("--gpu-memclock",
- set_gpu_memclock, NULL, NULL,
- "Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card"),
- OPT_WITH_ARG("--gpu-memdiff",
- set_gpu_memdiff, NULL, NULL,
- "Set a fixed difference in clock speed between the GPU and memory in auto-gpu mode"),
- OPT_WITH_ARG("--gpu-powertune",
- set_gpu_powertune, NULL, NULL,
- "Set the GPU powertune percentage - one value for all or separate by commas for per card"),
- OPT_WITHOUT_ARG("--gpu-reorder",
- opt_set_bool, &opt_reorder,
- "Attempt to reorder GPU devices according to PCI Bus ID"),
- OPT_WITH_ARG("--gpu-vddc",
- set_gpu_vddc, NULL, NULL,
- "Set the GPU voltage in Volts - one value for all or separate by commas for per card"),
-#endif
-#ifdef USE_SCRYPT
- OPT_WITH_ARG("--lookup-gap",
- set_lookup_gap, NULL, NULL,
- "Set GPU lookup gap for scrypt mining, comma separated"),
- OPT_WITH_ARG("--intensity|-I",
- set_intensity, NULL, NULL,
- "Intensity of GPU scanning (d or " MIN_SHA_INTENSITY_STR
- " -> " MAX_SCRYPT_INTENSITY_STR
- ",default: d to maintain desktop interactivity)"),
-#else
- OPT_WITH_ARG("--intensity|-I",
- set_intensity, NULL, NULL,
- "Intensity of GPU scanning (d or " MIN_SHA_INTENSITY_STR
- " -> " MAX_SHA_INTENSITY_STR
- ",default: d to maintain desktop interactivity)"),
-#endif
-#endif
OPT_WITH_ARG("--hotplug",
set_int_0_to_9999, NULL, &hotplug_time,
#ifdef USE_USBUTILS
@@ -1239,15 +1165,10 @@ static struct opt_table opt_config_table[] = {
opt_hidden
#endif
),
-#if defined(HAVE_OPENCL) || defined(HAVE_MODMINER)
+#if defined(HAVE_MODMINER)
OPT_WITH_ARG("--kernel-path|-K",
opt_set_charp, opt_show_charp, &opt_kernel_path,
- "Specify a path to where bitstream and kernel files are"),
-#endif
-#ifdef HAVE_OPENCL
- OPT_WITH_ARG("--kernel|-k",
- set_kernel, NULL, NULL,
- "Override sha256 kernel to use (diablo, poclbm, phatk or diakgcn) - one value or comma separated"),
+ "Specify a path to where bitstream files are"),
#endif
#ifdef USE_ICARUS
OPT_WITH_ARG("--icarus-options",
@@ -1324,14 +1245,6 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--no-pool-disable",
opt_set_invbool, &opt_disable_pool,
opt_hidden),
- OPT_WITHOUT_ARG("--no-restart",
- opt_set_invbool, &opt_restart,
-#ifdef HAVE_OPENCL
- "Do not attempt to restart GPUs that hang"
-#else
- opt_hidden
-#endif
- ),
OPT_WITHOUT_ARG("--no-submit-stale",
opt_set_invbool, &opt_submit_stale,
"Don't submit shares if they are detected as stale"),
@@ -1385,14 +1298,6 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--sched-stop",
set_schedtime, NULL, &schedstop,
"Set a time of day in HH:MM to stop mining (will quit without a start time)"),
-#ifdef USE_SCRYPT
- OPT_WITHOUT_ARG("--scrypt",
- opt_set_bool, &opt_scrypt,
- "Use the scrypt algorithm for mining (litecoin only)"),
- OPT_WITH_ARG("--shaders",
- set_shaders, NULL, NULL,
- "GPU shaders per card for tuning scrypt, comma separated"),
-#endif
OPT_WITH_ARG("--sharelog",
set_sharelog, NULL, NULL,
"Append share log to file"),
@@ -1453,19 +1358,9 @@ static struct opt_table opt_config_table[] = {
opt_set_bool, &opt_usb_list_all,
opt_hidden),
#endif
-#ifdef HAVE_OPENCL
- OPT_WITH_ARG("--vectors|-v",
- set_vector, NULL, NULL,
- "Override detected optimal vector (1, 2 or 4) - one value or comma separated list"),
-#endif
OPT_WITHOUT_ARG("--verbose",
opt_set_bool, &opt_log_output,
"Log verbose output to stderr as well as status output"),
-#ifdef HAVE_OPENCL
- OPT_WITH_ARG("--worksize|-w",
- set_worksize, NULL, NULL,
- "Override detected optimal worksize - one value or comma separated list"),
-#endif
OPT_WITH_ARG("--userpass|-O",
set_userpass, NULL, NULL,
"Username:Password pair for bitcoin JSON-RPC server"),
@@ -1633,9 +1528,6 @@ static char *opt_verusage_and_exit(const char *extra)
#ifdef USE_DRILLBIT
"drillbit "
#endif
-#ifdef HAVE_OPENCL
- "GPU "
-#endif
#ifdef USE_HASHFAST
"hashfast "
#endif
@@ -1648,12 +1540,12 @@ static char *opt_verusage_and_exit(const char *extra)
#ifdef USE_KNC
"KnC "
#endif
+#ifdef USE_BAB
+ "BaB "
+#endif
#ifdef USE_MODMINER
"modminer "
#endif
-#ifdef USE_SCRYPT
- "scrypt "
-#endif
"mining support.\n"
, packagename);
printf("%s", opt_usage(opt_argv0, extra));
@@ -1661,16 +1553,11 @@ static char *opt_verusage_and_exit(const char *extra)
exit(0);
}
-#if defined(HAVE_OPENCL) || defined(USE_USBUTILS)
+#if defined(USE_USBUTILS)
char *display_devs(int *ndevs)
{
*ndevs = 0;
-#ifdef HAVE_OPENCL
- print_ndevs(ndevs);
-#endif
-#ifdef USE_USBUTILS
usb_all(0);
-#endif
exit(*ndevs);
}
#endif
@@ -1688,17 +1575,10 @@ static struct opt_table opt_cmdline_table[] = {
OPT_WITHOUT_ARG("--help|-h",
opt_verusage_and_exit, NULL,
"Print this message"),
-#if defined(HAVE_OPENCL) || defined(USE_USBUTILS)
+#if defined(USE_USBUTILS)
OPT_WITHOUT_ARG("--ndevs|-n",
display_devs, &nDevs,
- "Display "
-#ifdef HAVE_OPENCL
- "number of detected GPUs, OpenCL platform information, "
-#endif
-#ifdef USE_USBUTILS
- "all USB devices, "
-#endif
- "and exit"),
+ "Display all USB devices and exit"),
#endif
OPT_WITHOUT_ARG("--version|-V",
opt_version_and_exit, packagename,
@@ -2163,9 +2043,6 @@ static int devcursor, logstart, logcursor;
/* statusy is where the status window goes up to in cases where it won't fit at startup */
static int statusy;
#endif
-#ifdef HAVE_OPENCL
-struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
-#endif
#ifdef HAVE_CURSES
static inline void unlock_curses(void)
@@ -2333,8 +2210,7 @@ static void curses_print_status(void)
prev_block, block_diff, blocktime, best_share);
mvwhline(statuswin, 6, 0, '-', 80);
mvwhline(statuswin, statusy - 1, 0, '-', 80);
- cg_mvwprintw(statuswin, devcursor - 1, 1, "[P]ool management %s[S]ettings [D]isplay options [Q]uit",
- have_opencl ? "[G]PU management " : "");
+ cg_mvwprintw(statuswin, devcursor - 1, 1, "[P]ool management [S]ettings [D]isplay options [Q]uit");
}
static void adj_width(int var, int *length)
@@ -2628,7 +2504,7 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work,
hashshow, cgpu->drv->name, cgpu->device_id, resubmit ? "(resubmit)" : "", worktime);
}
sharelog("accept", work);
- if (opt_shares && total_accepted >= opt_shares) {
+ if (opt_shares && total_diff_accepted >= opt_shares) {
applog(LOG_WARNING, "Successfully mined %d accepted shares as requested and exiting.", opt_shares);
kill_work();
return;
@@ -2888,8 +2764,8 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
snprintf(worktime, sizeof(worktime),
" <-%08lx.%08lx M:%c D:%1.*f G:%02d:%02d:%02d:%1.3f %s (%1.3f) W:%1.3f (%1.3f) S:%1.3f R:%02d:%02d:%02d",
- (unsigned long)be32toh(*(uint32_t *)&(work->data[opt_scrypt ? 32 : 28])),
- (unsigned long)be32toh(*(uint32_t *)&(work->data[opt_scrypt ? 28 : 24])),
+ (unsigned long)be32toh(*(uint32_t *)&(work->data[28])),
+ (unsigned long)be32toh(*(uint32_t *)&(work->data[24])),
work->getwork_mode, diffplaces, work->work_difficulty,
tm_getwork.tm_hour, tm_getwork.tm_min,
tm_getwork.tm_sec, getwork_time, workclone,
@@ -3147,8 +3023,6 @@ static void calc_diff(struct work *work, double known)
double d64, dcut64;
d64 = truediffone;
- if (opt_scrypt)
- d64 *= (double)65536;
dcut64 = le256todouble(work->target);
if (unlikely(!dcut64))
dcut64 = 1;
@@ -3285,11 +3159,9 @@ static void __kill_work(void)
#ifdef USE_USBUTILS
/* Best to get rid of it first so it doesn't
* try to create any new devices */
- if (!opt_scrypt) {
- forcelog(LOG_DEBUG, "Killing off HotPlug thread");
- thr = &control_thr[hotplug_thr_id];
- kill_timeout(thr);
- }
+ forcelog(LOG_DEBUG, "Killing off HotPlug thread");
+ thr = &control_thr[hotplug_thr_id];
+ kill_timeout(thr);
#endif
forcelog(LOG_DEBUG, "Killing off watchpool thread");
@@ -3328,14 +3200,12 @@ static void __kill_work(void)
#ifdef USE_USBUTILS
/* Release USB resources in case it's a restart
* and not a QUIT */
- if (!opt_scrypt) {
- forcelog(LOG_DEBUG, "Releasing all USB devices");
- cg_completion_timeout(&usb_cleanup, NULL, 1000);
+ forcelog(LOG_DEBUG, "Releasing all USB devices");
+ cg_completion_timeout(&usb_cleanup, NULL, 1000);
- forcelog(LOG_DEBUG, "Killing off usbres thread");
- thr = &control_thr[usbres_thr_id];
- kill_timeout(thr);
- }
+ forcelog(LOG_DEBUG, "Killing off usbres thread");
+ thr = &control_thr[usbres_thr_id];
+ kill_timeout(thr);
#endif
}
@@ -3487,7 +3357,7 @@ static void roll_work(struct work *work)
*work_ntime = htobe32(ntime);
local_work++;
work->rolls++;
- work->blk.nonce = 0;
+ work->nonce = 0;
applog(LOG_DEBUG, "Successfully rolled work");
/* This is now a different work item so it needs a different ID for the
@@ -3779,8 +3649,6 @@ static uint64_t share_diff(const struct work *work)
uint64_t ret;
d64 = truediffone;
- if (opt_scrypt)
- d64 *= (double)65536;
s64 = le256todouble(work->hash);
if (unlikely(!s64))
s64 = 0;
@@ -3815,14 +3683,6 @@ static void regen_hash(struct work *work)
sha256(hash1, 32, (unsigned char *)(work->hash));
}
-static void rebuild_hash(struct work *work)
-{
- if (opt_scrypt)
- scrypt_regenhash(work);
- else
- regen_hash(work);
-}
-
static bool cnx_needed(struct pool *pool);
/* Find the pool that currently has the highest priority */
@@ -4424,94 +4284,6 @@ void write_config(FILE *fcfg)
}
fputs("\n]\n", fcfg);
-#ifdef HAVE_OPENCL
- if (nDevs) {
- /* Write GPU device values */
- fputs(",\n\"intensity\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, gpus[i].dynamic ? "%sd" : "%s%d", i > 0 ? "," : "", gpus[i].intensity);
- fputs("\",\n\"vectors\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "",
- gpus[i].vwidth);
- fputs("\",\n\"worksize\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "",
- (int)gpus[i].work_size);
- fputs("\",\n\"kernel\" : \"", fcfg);
- for(i = 0; i < nDevs; i++) {
- fprintf(fcfg, "%s", i > 0 ? "," : "");
- switch (gpus[i].kernel) {
- case KL_NONE: // Shouldn't happen
- break;
- case KL_POCLBM:
- fprintf(fcfg, "poclbm");
- break;
- case KL_PHATK:
- fprintf(fcfg, "phatk");
- break;
- case KL_DIAKGCN:
- fprintf(fcfg, "diakgcn");
- break;
- case KL_DIABLO:
- fprintf(fcfg, "diablo");
- break;
- case KL_SCRYPT:
- fprintf(fcfg, "scrypt");
- break;
- }
- }
-#ifdef USE_SCRYPT
- fputs("\",\n\"lookup-gap\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "",
- (int)gpus[i].opt_lg);
- fputs("\",\n\"thread-concurrency\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "",
- (int)gpus[i].opt_tc);
- fputs("\",\n\"shaders\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "",
- (int)gpus[i].shaders);
-#endif
-#ifdef HAVE_ADL
- fputs("\",\n\"gpu-engine\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d-%d", i > 0 ? "," : "", gpus[i].min_engine, gpus[i].gpu_engine);
- fputs("\",\n\"gpu-fan\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d-%d", i > 0 ? "," : "", gpus[i].min_fan, gpus[i].gpu_fan);
- fputs("\",\n\"gpu-memclock\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].gpu_memclock);
- fputs("\",\n\"gpu-memdiff\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].gpu_memdiff);
- fputs("\",\n\"gpu-powertune\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].gpu_powertune);
- fputs("\",\n\"gpu-vddc\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%1.3f", i > 0 ? "," : "", gpus[i].gpu_vddc);
- fputs("\",\n\"temp-cutoff\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].cutofftemp);
- fputs("\",\n\"temp-overheat\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.overtemp);
- fputs("\",\n\"temp-target\" : \"", fcfg);
- for(i = 0; i < nDevs; i++)
- fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.targettemp);
-#endif
- fputs("\"", fcfg);
- }
-#endif
-#ifdef HAVE_ADL
- if (opt_reorder)
- fprintf(fcfg, ",\n\"gpu-reorder\" : true");
-#endif
-
/* Simple bool and int options */
struct opt_table *opt;
for (opt = opt_config_table; opt->type != OPT_END; opt++) {
@@ -5074,10 +4846,6 @@ static void *input_thread(void __maybe_unused *userdata)
display_pools();
else if (!strncasecmp(&input, "s", 1))
set_options();
-#if HAVE_OPENCL
- else if (have_opencl && !strncasecmp(&input, "g", 1))
- manage_gpu();
-#endif
if (opt_realquiet) {
disable_curses();
break;
@@ -5759,7 +5527,7 @@ retry_stratum:
}
/* Probe for GBT support on first pass */
- if (!pool->probed && !opt_fix_protocol) {
+ if (!pool->probed) {
applog(LOG_DEBUG, "Probing for GBT support");
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass,
gbt_req, true, false, &rolltime, pool, false);
@@ -5985,8 +5753,6 @@ void set_target(unsigned char *dest_target, double diff)
}
d64 = truediffone;
- if (opt_scrypt)
- d64 *= (double)65536;
d64 /= diff;
dcut64 = d64 / bits192;
@@ -6089,7 +5855,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
local_work++;
work->pool = pool;
work->stratum = true;
- work->blk.nonce = 0;
+ work->nonce = 0;
work->id = total_work++;
work->longpoll = false;
work->getwork_mode = GETWORK_MODE_STRATUM;
@@ -6187,19 +5953,16 @@ static void rebuild_nonce(struct work *work, uint32_t nonce)
*work_nonce = htole32(nonce);
- rebuild_hash(work);
+ regen_hash(work);
}
/* For testing a nonce against diff 1 */
bool test_nonce(struct work *work, uint32_t nonce)
{
uint32_t *hash_32 = (uint32_t *)(work->hash + 28);
- uint32_t diff1targ;
rebuild_nonce(work, nonce);
- diff1targ = opt_scrypt ? 0x0000ffffUL : 0;
-
- return (le32toh(*hash_32) <= diff1targ);
+ return (*hash_32 == 0);
}
/* For testing a nonce against an arbitrary diff */
@@ -6208,7 +5971,7 @@ bool test_nonce_diff(struct work *work, uint32_t nonce, double diff)
uint64_t *hash64 = (uint64_t *)(work->hash + 24), diff64;
rebuild_nonce(work, nonce);
- diff64 = opt_scrypt ? 0x0000ffff00000000ULL : 0x00000000ffff0000ULL;
+ diff64 = 0x00000000ffff0000ULL;
diff64 /= diff;
return (le64toh(*hash64) <= diff64);
@@ -6220,9 +5983,6 @@ static void update_work_stats(struct thr_info *thr, struct work *work)
work->share_diff = share_diff(work);
- if (opt_scrypt)
- test_diff *= 65536;
-
if (unlikely(work->share_diff >= test_diff)) {
work->block = true;
work->pool->solved++;
@@ -6298,9 +6058,7 @@ out:
static inline bool abandon_work(struct work *work, struct timeval *wdiff, uint64_t hashes)
{
- if (wdiff->tv_sec > opt_scantime ||
- work->blk.nonce >= MAXTHREADS - hashes ||
- hashes >= 0xfffffffe ||
+ if (wdiff->tv_sec > opt_scantime || hashes >= 0xfffffffe ||
stale_work(work, false))
return true;
return false;
@@ -6348,7 +6106,7 @@ static void hash_sole_work(struct thr_info *mythr)
cgpu->new_work = true;
cgtime(&tv_workstart);
- work->blk.nonce = 0;
+ work->nonce = 0;
cgpu->max_hashes = 0;
if (!drv->prepare_work(mythr, work)) {
applog(LOG_ERR, "work prepare failed, exiting "
@@ -6356,25 +6114,6 @@ static void hash_sole_work(struct thr_info *mythr)
break;
}
work->device_diff = MIN(drv->working_diff, work->work_difficulty);
-#ifdef USE_SCRYPT
- /* Dynamically adjust the working diff even if the target
- * diff is very high to ensure we can still validate scrypt is
- * returning shares. */
- if (opt_scrypt) {
- double wu;
-
- wu = total_diff1 / total_secs * 60;
- if (wu > 30 && drv->working_diff < drv->max_diff &&
- drv->working_diff < work->work_difficulty) {
- drv->working_diff++;
- applog(LOG_DEBUG, "Driver %s working diff changed to %.0f",
- drv->dname, drv->working_diff);
- work->device_diff = MIN(drv->working_diff, work->work_difficulty);
- } else if (drv->working_diff > work->work_difficulty)
- drv->working_diff = work->work_difficulty;
- set_target(work->device_target, work->device_diff);
- }
-#endif
do {
cgtime(&tv_start);
@@ -6404,7 +6143,7 @@ static void hash_sole_work(struct thr_info *mythr)
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
thread_reportin(mythr);
- hashes = drv->scanhash(mythr, work, work->blk.nonce + max_nonce);
+ hashes = drv->scanhash(mythr, work, work->nonce + max_nonce);
thread_reportout(mythr);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
@@ -7397,9 +7136,9 @@ void print_summary(void)
}
if (opt_shares) {
- applog(LOG_WARNING, "Mined %d accepted shares of %d requested\n", total_accepted, opt_shares);
- if (opt_shares > total_accepted)
- applog(LOG_WARNING, "WARNING - Mined only %d shares of %d requested.", total_accepted, opt_shares);
+ applog(LOG_WARNING, "Mined %.0f accepted shares of %d requested\n", total_diff_accepted, opt_shares);
+ if (opt_shares > total_diff_accepted)
+ applog(LOG_WARNING, "WARNING - Mined only %.0f shares of %d requested.", total_diff_accepted, opt_shares);
}
applog(LOG_WARNING, " ");
@@ -7409,9 +7148,6 @@ void print_summary(void)
static void clean_up(bool restarting)
{
-#ifdef HAVE_OPENCL
- clear_adl(nDevs);
-#endif
#ifdef USE_USBUTILS
usb_polling = false;
pthread_join(usb_poll_thread, NULL);
@@ -7800,11 +7536,6 @@ void enable_device(struct cgpu_info *cgpu)
adj_width(mining_threads, &dev_width);
#endif
}
-#ifdef HAVE_OPENCL
- if (cgpu->drv->drv_id == DRIVER_opencl) {
- gpu_threads += cgpu->threads;
- }
-#endif
rwlock_init(&cgpu->qlock);
cgpu->queued_work = NULL;
}
@@ -8073,6 +7804,13 @@ int main(int argc, char *argv[])
if (unlikely(pthread_cond_init(&gws_cond, NULL)))
quit(1, "Failed to pthread_cond_init gws_cond");
+ /* Create a unique get work queue */
+ getq = tq_new();
+ if (!getq)
+ quit(1, "Failed to create getq");
+ /* We use the getq mutex as the staged lock */
+ stgd_lock = &getq->mutex;
+
initialise_usb();
snprintf(packagename, sizeof(packagename), "%s %s", PACKAGE, VERSION);
@@ -8109,12 +7847,6 @@ int main(int argc, char *argv[])
INIT_LIST_HEAD(&scan_devices);
-#ifdef HAVE_OPENCL
- memset(gpus, 0, sizeof(gpus));
- for (i = 0; i < MAX_GPUDEVICES; i++)
- gpus[i].dynamic = true;
-#endif
-
/* parse command line */
opt_register_table(opt_config_table,
"Options for both config file and command line");
@@ -8131,8 +7863,6 @@ int main(int argc, char *argv[])
if (opt_benchmark) {
struct pool *pool;
- if (opt_scrypt)
- quit(1, "Cannot use benchmark mode with scrypt");
pool = add_pool();
pool->rpc_url = malloc(255);
strcpy(pool->rpc_url, "Benchmark");
@@ -8176,9 +7906,8 @@ int main(int argc, char *argv[])
if (want_per_device_stats)
opt_log_output = true;
- /* Use a shorter scantime for scrypt */
if (opt_scantime < 0)
- opt_scantime = opt_scrypt ? 30 : 60;
+ opt_scantime = 60;
total_control_threads = 8;
control_thr = calloc(total_control_threads, sizeof(*thr));
@@ -8191,25 +7920,19 @@ int main(int argc, char *argv[])
usb_initialise();
// before device detection
- if (!opt_scrypt) {
- cgsem_init(&usb_resource_sem);
- usbres_thr_id = 1;
- thr = &control_thr[usbres_thr_id];
- if (thr_info_create(thr, NULL, usb_resource_thread, thr))
- quit(1, "usb resource thread create failed");
- pthread_detach(thr->pth);
- }
+ cgsem_init(&usb_resource_sem);
+ usbres_thr_id = 1;
+ thr = &control_thr[usbres_thr_id];
+ if (thr_info_create(thr, NULL, usb_resource_thread, thr))
+ quit(1, "usb resource thread create failed");
+ pthread_detach(thr->pth);
#endif
/* Use the DRIVER_PARSE_COMMANDS macro to fill all the device_drvs */
DRIVER_PARSE_COMMANDS(DRIVER_FILL_DEVICE_DRV)
- if (opt_scrypt)
- opencl_drv.drv_detect(false);
- else {
/* Use the DRIVER_PARSE_COMMANDS macro to detect all devices */
- DRIVER_PARSE_COMMANDS(DRIVER_DRV_DETECT_ALL)
- }
+ DRIVER_PARSE_COMMANDS(DRIVER_DRV_DETECT_ALL)
if (opt_display_devs) {
applog(LOG_ERR, "Devices detected:");
@@ -8314,13 +8037,6 @@ int main(int argc, char *argv[])
quit(1, "Failed to calloc mining_thr[%d]", i);
}
- /* Create a unique get work queue */
- getq = tq_new();
- if (!getq)
- quit(1, "Failed to create getq");
- /* We use the getq mutex as the staged lock */
- stgd_lock = &getq->mutex;
-
if (opt_benchmark)
goto begin_bench;
@@ -8409,12 +8125,6 @@ begin_bench:
}
}
-#ifdef HAVE_OPENCL
- applog(LOG_INFO, "%d gpu miner threads started", gpu_threads);
- for (i = 0; i < nDevs; i++)
- pause_dynamic_threads(i);
-#endif
-
cgtime(&total_tv_start);
cgtime(&total_tv_end);
@@ -8432,17 +8142,6 @@ begin_bench:
quit(1, "watchdog thread create failed");
pthread_detach(thr->pth);
-#ifdef HAVE_OPENCL
- /* Create reinit gpu thread */
- gpur_thr_id = 4;
- thr = &control_thr[gpur_thr_id];
- thr->q = tq_new();
- if (!thr->q)
- quit(1, "tq_new failed for gpur_thr_id");
- if (thr_info_create(thr, NULL, reinit_gpu, thr))
- quit(1, "reinit_gpu thread create failed");
-#endif
-
/* Create API socket thread */
api_thr_id = 5;
thr = &control_thr[api_thr_id];
@@ -8450,13 +8149,11 @@ begin_bench:
quit(1, "API thread create failed");
#ifdef USE_USBUTILS
- if (!opt_scrypt) {
- hotplug_thr_id = 6;
- thr = &control_thr[hotplug_thr_id];
- if (thr_info_create(thr, NULL, hotplug_thread, thr))
- quit(1, "hotplug thread create failed");
- pthread_detach(thr->pth);
- }
+ hotplug_thr_id = 6;
+ thr = &control_thr[hotplug_thr_id];
+ if (thr_info_create(thr, NULL, hotplug_thread, thr))
+ quit(1, "hotplug thread create failed");
+ pthread_detach(thr->pth);
#endif
#ifdef HAVE_CURSES
diff --git a/compat/libusb-1.0/libusb/os/windows_usb.c b/compat/libusb-1.0/libusb/os/windows_usb.c
index afc4dfc..ac359c4 100644
--- a/compat/libusb-1.0/libusb/os/windows_usb.c
+++ b/compat/libusb-1.0/libusb/os/windows_usb.c
@@ -1822,9 +1822,6 @@ static int windows_submit_transfer(struct usbi_transfer *itransfer)
return submit_control_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_BULK:
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
- if (IS_XFEROUT(transfer) &&
- transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET)
- return LIBUSB_ERROR_NOT_SUPPORTED;
return submit_bulk_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return submit_iso_transfer(itransfer);
@@ -2391,20 +2388,8 @@ static int winusb_configure_endpoints(struct libusb_device_handle *dev_handle, i
PIPE_TRANSFER_TIMEOUT, sizeof(ULONG), &timeout)) {
usbi_dbg("failed to set PIPE_TRANSFER_TIMEOUT for control endpoint %02X", endpoint_address);
}
- if (i == -1) continue; // Other policies don't apply to control endpoint
- policy = false;
- if (!WinUsb_SetPipePolicy(winusb_handle, endpoint_address,
- SHORT_PACKET_TERMINATE, sizeof(UCHAR), &policy)) {
- usbi_dbg("failed to disable SHORT_PACKET_TERMINATE for endpoint %02X", endpoint_address);
- }
- if (!WinUsb_SetPipePolicy(winusb_handle, endpoint_address,
- IGNORE_SHORT_PACKETS, sizeof(UCHAR), &policy)) {
- usbi_dbg("failed to disable IGNORE_SHORT_PACKETS for endpoint %02X", endpoint_address);
- }
- if (!WinUsb_SetPipePolicy(winusb_handle, endpoint_address,
- ALLOW_PARTIAL_READS, sizeof(UCHAR), &policy)) {
- usbi_dbg("failed to disable ALLOW_PARTIAL_READS for endpoint %02X", endpoint_address);
- }
+ if (i == -1)
+ continue; // Other policies don't apply to control endpoint
policy = true;
if (!WinUsb_SetPipePolicy(winusb_handle, endpoint_address,
AUTO_CLEAR_STALL, sizeof(UCHAR), &policy)) {
@@ -2649,6 +2634,8 @@ static int winusb_submit_bulk_transfer(struct usbi_transfer *itransfer)
bool ret;
int current_interface;
struct winfd wfd;
+ ULONG ppolicy = sizeof(UCHAR);
+ UCHAR policy;
CHECK_WINUSB_AVAILABLE;
@@ -2671,9 +2658,20 @@ static int winusb_submit_bulk_transfer(struct usbi_transfer *itransfer)
}
if (IS_XFERIN(transfer)) {
- usbi_dbg("reading %d bytes", transfer->length);
+ WinUsb_GetPipePolicy(wfd.handle, transfer->endpoint, AUTO_CLEAR_STALL, &ppolicy, &policy);
+ if (!policy) {
+ policy = TRUE;
+ WinUsb_SetPipePolicy(wfd.handle, transfer->endpoint, AUTO_CLEAR_STALL, ppolicy, &policy);
+ }
ret = WinUsb_ReadPipe(wfd.handle, transfer->endpoint, transfer->buffer, transfer->length, NULL, wfd.overlapped);
} else {
+ if (transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET) {
+ WinUsb_GetPipePolicy(wfd.handle, transfer->endpoint, SHORT_PACKET_TERMINATE, &ppolicy, &policy);
+ if (!policy) {
+ policy = TRUE;
+ WinUsb_SetPipePolicy(wfd.handle, transfer->endpoint, SHORT_PACKET_TERMINATE, ppolicy, &policy);
+ }
+ }
usbi_dbg("writing %d bytes", transfer->length);
ret = WinUsb_WritePipe(wfd.handle, transfer->endpoint, transfer->buffer, transfer->length, NULL, wfd.overlapped);
}
diff --git a/configure.ac b/configure.ac
index f653944..a39bdbf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,8 @@
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
m4_define([v_maj], [3])
-m4_define([v_min], [7])
-m4_define([v_mic], [2])
+m4_define([v_min], [8])
+m4_define([v_mic], [1])
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
m4_define([v_ver], [v_maj.v_min.v_mic])
m4_define([lt_rev], m4_eval(v_maj + v_min))
@@ -63,7 +63,6 @@ AC_FUNC_ALLOCA
have_win32=false
PTHREAD_FLAGS="-lpthread"
DLOPEN_FLAGS="-ldl"
-OPENCL_LIBS="-lOpenCL"
WS2_LIBS=""
MM_LIBS=""
MATH_LIBS="-lm"
@@ -97,37 +96,16 @@ case $target in
powerpc-*-darwin*)
have_darwin=true
CFLAGS="$CFLAGS -faltivec"
- OPENCL_LIBS=""
PTHREAD_FLAGS=""
RT_LIBS=""
;;
*-*-darwin*)
have_darwin=true
- OPENCL_LIBS="-framework OpenCL"
PTHREAD_FLAGS=""
RT_LIBS=""
;;
esac
-
-if test "x$have_win32" != xtrue; then
- if test "x$have_x86_64" = xtrue; then
- ARCH_DIR=x86_64
- else
- ARCH_DIR=x86
- fi
-
- if test "x$ATISTREAMSDKROOT" != x; then
- OPENCL_FLAGS="-I$ATISTREAMSDKROOT/include $OPENCL_FLAGS"
- OPENCL_LIBS="-L$ATISTREAMSDKROOT/lib/$ARCH_DIR $OPENCL_LIBS"
- fi
-
- if test "x$AMDAPPSDKROOT" != x; then
- OPENCL_FLAGS="-I$AMDAPPSDKROOT/include $OPENCL_FLAGS"
- OPENCL_LIBS="-L$AMDAPPSDKROOT/lib/$ARCH_DIR $OPENCL_LIBS"
- fi
-fi
-
have_cgminer_sdk=false
if test -n "$CGMINER_SDK"; then
have_cgminer_sdk=true
@@ -135,44 +113,6 @@ if test -n "$CGMINER_SDK"; then
LDFLAGS="-L$CGMINER_SDK/lib/$target $LDFLAGS"
fi
-opencl="no"
-
-AC_ARG_ENABLE([opencl],
- [AC_HELP_STRING([--enable-opencl],[Enable support for GPU mining with opencl])],
- [opencl=$enableval]
- )
-if test "x$opencl" != xno; then
- # Check for OpenCL (the long way needed on mingw32 due to calling conventions)
- AC_MSG_CHECKING([for OpenCL])
- SAVED_LIBS=$LIBS
- SAVED_CFLAGS=$CFLAGS
- LIBS="$LIBS $OPENCL_LIBS"
- CFLAGS="$CFLAGS $OPENCL_FLAGS"
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[
- #ifdef __APPLE_CC__
- #include <OpenCL/opencl.h>
- #else
- #include <CL/cl.h>
- #endif
- ]],
- [[return clSetKernelArg(0, 0, 0, 0); ]])],
- [AC_MSG_RESULT(yes)
- AC_DEFINE([HAVE_OPENCL], [1], [Defined to 1 if OpenCL is present on the system.])
- found_opencl=1
- ],
- [AC_MSG_RESULT(no)
- OPENCL_FLAGS=
- OPENCL_LIBS=
- found_opencl=0])
- LIBS=$SAVED_LIBS
- CFLAGS=$SAVED_CFLAGS
-else
- OPENCL_FLAGS=""
- OPENCL_LIBS=""
-fi
-AM_CONDITIONAL([HAS_OPENCL], [test x$opencl = xyes])
-
has_winpthread=false
if test "x$have_win32" = xtrue; then
has_winpthread=true
@@ -186,41 +126,6 @@ if test "x$has_winpthread" != xtrue; then
PTHREAD_LIBS=-lpthread
fi
-AC_ARG_ENABLE([adl],
- [AC_HELP_STRING([--disable-adl],[Override detection and disable building with adl])],
- [adl=$enableval]
- )
-
-scrypt="no"
-
-if test "$found_opencl" = 1; then
- if test "x$adl" != xno; then
- ADL_CPPFLAGS=
- AC_CHECK_FILE([$srcdir/ADL_SDK/adl_sdk.h], [have_adl=true; ADL_CPPFLAGS=-I$srcdir], have_adl=false,)
- if test x$have_adl+$have_cgminer_sdk = xfalse+true; then
- AC_CHECK_FILE([$CGMINER_SDK/include/ADL_SDK/adl_sdk.h], [have_adl=true; ADL_CPPFLAGS=-I$CGMINER_SDK/include], have_adl=false,)
- fi
- if test x$have_adl = xtrue
- then
- AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found])
- else
- DLOPEN_FLAGS=""
- fi
- fi
-
- AC_ARG_ENABLE([scrypt],
- [AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt litecoin mining (default disabled)])],
- [scrypt=$enableval]
- )
- if test "x$scrypt" = xyes; then
- AC_DEFINE([USE_SCRYPT], [1], [Defined to 1 if scrypt support is wanted])
- fi
-else
- DLOPEN_FLAGS=""
-fi
-
-AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes])
-
avalon="no"
AC_ARG_ENABLE([avalon],
@@ -232,16 +137,16 @@ if test "x$avalon" = xyes; then
fi
AM_CONDITIONAL([HAS_AVALON], [test x$avalon = xyes])
-knc="no"
+bab="no"
-AC_ARG_ENABLE([knc],
- [AC_HELP_STRING([--enable-knc],[Compile support for KnC miners (default disabled)])],
- [knc=$enableval]
+AC_ARG_ENABLE([bab],
+ [AC_HELP_STRING([--enable-bab],[Compile support for BlackArrow Bitfury (default disabled)])],
+ [bab=$enableval]
)
-if test "x$knc" = xyes; then
- AC_DEFINE([USE_KNC], [1], [Defined to 1 if KnC miner support is wanted])
+if test "x$bab" = xyes; then
+ AC_DEFINE([USE_BAB], [1], [Defined to 1 if BlackArrow Bitfury support is wanted])
fi
-AM_CONDITIONAL([HAS_KNC], [test x$knc = xyes])
+AM_CONDITIONAL([HAS_BAB], [test x$bab = xyes])
bflsc="no"
@@ -320,6 +225,17 @@ if test "x$klondike" = xyes; then
fi
AM_CONDITIONAL([HAS_KLONDIKE], [test x$klondike = xyes])
+knc="no"
+
+AC_ARG_ENABLE([knc],
+ [AC_HELP_STRING([--enable-knc],[Compile support for KnC miners (default disabled)])],
+ [knc=$enableval]
+ )
+if test "x$knc" = xyes; then
+ AC_DEFINE([USE_KNC], [1], [Defined to 1 if KnC miner support is wanted])
+fi
+AM_CONDITIONAL([HAS_KNC], [test x$knc = xyes])
+
modminer="no"
AC_ARG_ENABLE([modminer],
@@ -494,8 +410,6 @@ AC_DEFINE_UNQUOTED([DIABLO_KERNNAME], ["diablo130302"], [Filename for diablo ker
AC_DEFINE_UNQUOTED([SCRYPT_KERNNAME], ["scrypt130511"], [Filename for scrypt kernel])
-AC_SUBST(OPENCL_LIBS)
-AC_SUBST(OPENCL_FLAGS)
AC_SUBST(JANSSON_LIBS)
AC_SUBST(PTHREAD_FLAGS)
AC_SUBST(DLOPEN_FLAGS)
@@ -537,40 +451,6 @@ fi
echo " curses.TUI...........: $cursesmsg"
-if test "x$opencl" != xno; then
- if test $found_opencl = 1; then
- echo " OpenCL...............: FOUND. GPU mining support enabled"
- if test "x$scrypt" != xno; then
- echo " scrypt...............: Enabled"
- else
- echo " scrypt...............: Disabled"
- fi
-
- else
- echo " OpenCL...............: NOT FOUND. GPU mining support DISABLED"
- if test "x$avalon$bitforce$bitfury$icarus$modminer$bflsc$hashfast$klondike$knc$drillbit" = xnononononononononono; then
- AC_MSG_ERROR([No mining configured in])
- fi
- echo " scrypt...............: Disabled (needs OpenCL)"
- fi
-else
- echo " OpenCL...............: Detection overrided. GPU mining support DISABLED"
- if test "x$avalon$bitforce$bitfury$icarus$modminer$bflsc$hashfast$klondike$knc$drillbit" = xnononononononononono; then
- AC_MSG_ERROR([No mining configured in])
- fi
- echo " scrypt...............: Disabled (needs OpenCL)"
-fi
-
-if test "x$adl" != xno; then
- if test x$have_adl = xtrue; then
- echo " ADL..................: SDK found, GPU monitoring support enabled"
- else
- echo " ADL..................: SDK NOT found, GPU monitoring support DISABLED"
- fi
-else
- echo " ADL..................: Detection overrided. GPU monitoring support DISABLED"
-fi
-
echo
if test "x$avalon" = xyes; then
echo " Avalon.ASICs.........: Enabled"
@@ -578,16 +458,16 @@ else
echo " Avalon.ASICs.........: Disabled"
fi
-if test "x$bflsc" = xyes; then
- echo " BFL.ASICs............: Enabled"
+if test "x$bab" = xyes; then
+ echo " BlackArrow.ASICs.....: Enabled"
else
- echo " BFL.ASICs............: Disabled"
+ echo " BlackArrow.ASICs.....: Disabled"
fi
-if test "x$knc" = xyes; then
- echo " KnC.ASICs............: Enabled"
+if test "x$bflsc" = xyes; then
+ echo " BFL.ASICs............: Enabled"
else
- echo " KnC.ASICs............: Disabled"
+ echo " BFL.ASICs............: Disabled"
fi
if test "x$bitforce" = xyes; then
@@ -626,18 +506,28 @@ else
echo " Klondike.ASICs.......: Disabled"
fi
+if test "x$knc" = xyes; then
+ echo " KnC.ASICs............: Enabled"
+else
+ echo " KnC.ASICs............: Disabled"
+fi
+
if test "x$modminer" = xyes; then
echo " ModMiner.FPGAs.......: Enabled"
else
echo " ModMiner.FPGAs.......: Disabled"
fi
+if test "x$avalon$bab$bflsc$bitforce$bitfury$hashfast$icarus$klondike$knc$modminer" = xnononononononononono; then
+ AC_MSG_ERROR([No mining configured in])
+fi
+
echo
echo "Compilation............: make (or gmake)"
echo " CPPFLAGS.............: $CPPFLAGS"
echo " CFLAGS...............: $CFLAGS"
echo " LDFLAGS..............: $LDFLAGS $PTHREAD_FLAGS"
-echo " LDADD................: $DLOPEN_FLAGS $LIBCURL_LIBS $JANSSON_LIBS $PTHREAD_LIBS $OPENCL_LIBS $NCURSES_LIBS $PDCURSES_LIBS $WS2_LIBS $MATH_LIBS $LIBUSB_LIBS $RT_LIBS"
+echo " LDADD................: $DLOPEN_FLAGS $LIBCURL_LIBS $JANSSON_LIBS $PTHREAD_LIBS $NCURSES_LIBS $PDCURSES_LIBS $WS2_LIBS $MATH_LIBS $LIBUSB_LIBS $RT_LIBS"
echo
echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
echo " prefix...............: $prefix"
diff --git a/diablo130302.cl b/diablo130302.cl
deleted file mode 100644
index a721803..0000000
--- a/diablo130302.cl
+++ /dev/null
@@ -1,1361 +0,0 @@
-/*
- * DiabloMiner - OpenCL miner for BitCoin
- * Copyright (C) 2012, 2013 Con Kolivas <kernel@kolivas.org>
- * Copyright (C) 2010, 2011, 2012 Patrick McFarland <diablod3@gmail.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more detail).
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef VECTORS4
- typedef uint4 z;
-#elif defined(VECTORS2)
- typedef uint2 z;
-#else
- typedef uint z;
-#endif
-
-#ifdef BITALIGN
-#pragma OPENCL EXTENSION cl_amd_media_ops : enable
-#define Zrotr(a, b) amd_bitalign((z)a, (z)a, (z)(32 - b))
-#else
-#define Zrotr(a, b) rotate((z)a, (z)b)
-#endif
-
-#ifdef BFI_INT
-#define ZCh(a, b, c) amd_bytealign(a, b, c)
-#define ZMa(a, b, c) amd_bytealign((c ^ a), (b), (a))
-#else
-#define ZCh(a, b, c) bitselect((z)c, (z)b, (z)a)
-#define ZMa(a, b, c) bitselect((z)a, (z)b, (z)c ^ (z)a)
-#endif
-
-/* These constants are not the classic SHA256 constants but the order that
- * constants are used in this kernel.
- */
-__constant uint K[] = {
- 0xd807aa98U,
- 0x12835b01U,
- 0x243185beU,
- 0x550c7dc3U,
- 0x72be5d74U,
- 0x80deb1feU,
- 0x9bdc06a7U,
- 0xc19bf3f4U,
- 0x0fc19dc6U,
- 0x240ca1ccU,
- 0x80000000U, // 10
- 0x2de92c6fU,
- 0x4a7484aaU,
- 0x00000280U,
- 0x5cb0a9dcU,
- 0x76f988daU,
- 0x983e5152U,
- 0xa831c66dU,
- 0xb00327c8U,
- 0xbf597fc7U,
- 0xc6e00bf3U, // 20
- 0x00A00055U,
- 0xd5a79147U,
- 0x06ca6351U,
- 0x14292967U,
- 0x27b70a85U,
- 0x2e1b2138U,
- 0x4d2c6dfcU,
- 0x53380d13U,
- 0x650a7354U,
- 0x766a0abbU, // 30
- 0x81c2c92eU,
- 0x92722c85U,
- 0xa2bfe8a1U,
- 0xa81a664bU,
- 0xc24b8b70U,
- 0xc76c51a3U,
- 0xd192e819U,
- 0xd6990624U,
- 0xf40e3585U,
- 0x106aa070U, // 40
- 0x19a4c116U,
- 0x1e376c08U,
- 0x2748774cU,
- 0x34b0bcb5U,
- 0x391c0cb3U,
- 0x4ed8aa4aU,
- 0x5b9cca4fU,
- 0x682e6ff3U,
- 0x748f82eeU,
- 0x78a5636fU, // 50
- 0x84c87814U,
- 0x8cc70208U,
- 0x90befffaU,
- 0xa4506cebU,
- 0xbef9a3f7U,
- 0xc67178f2U,
- 0x98c7e2a2U,
- 0x90bb1e3cU,
- 0x510e527fU,
- 0x9b05688cU, // 60
- 0xfc08884dU,
- 0x3c6ef372U,
- 0x50c6645bU,
- 0x6a09e667U,
- 0xbb67ae85U,
- 0x3ac42e24U,
- 0xd21ea4fdU,
- 0x59f111f1U,
- 0x923f82a4U,
- 0xab1c5ed5U, // 70
- 0x5807aa98U,
- 0xc19bf274U,
- 0xe49b69c1U,
- 0x00a00000U,
- 0xefbe4786U,
- 0x00000100U,
- 0x11002000U,
- 0x00400022U,
- 0x136032EDU
-};
-
-#define ZR25(n) ((Zrotr((n), 25) ^ Zrotr((n), 14) ^ ((n) >> 3U)))
-#define ZR15(n) ((Zrotr((n), 15) ^ Zrotr((n), 13) ^ ((n) >> 10U)))
-#define ZR26(n) ((Zrotr((n), 26) ^ Zrotr((n), 21) ^ Zrotr((n), 7)))
-#define ZR30(n) ((Zrotr((n), 30) ^ Zrotr((n), 19) ^ Zrotr((n), 10)))
-
-__kernel
-__attribute__((vec_type_hint(z)))
-__attribute__((reqd_work_group_size(WORKSIZE, 1, 1)))
-void search(
-#ifndef GOFFSET
- const z base,
-#endif
- const uint PreVal4_state0, const uint PreVal4_state0_k7,
- const uint PreVal4_T1,
- const uint W18, const uint W19,
- const uint W16, const uint W17,
- const uint W16_plus_K16, const uint W17_plus_K17,
- const uint W31, const uint W32,
- const uint d1, const uint b1, const uint c1,
- const uint h1, const uint f1, const uint g1,
- const uint c1_plus_k5, const uint b1_plus_k6,
- const uint state0, const uint state1, const uint state2, const uint state3,
- const uint state4, const uint state5, const uint state6, const uint state7,
- volatile __global uint * output)
-{
-
- z ZA[930];
-
-#ifdef GOFFSET
- const z Znonce = (uint)(get_global_id(0));
-#else
- const z Znonce = base + (uint)(get_global_id(0));
-#endif
-
- ZA[15] = Znonce + PreVal4_state0;
-
- ZA[16] = (ZCh(ZA[15], b1, c1) + d1) + ZR26(ZA[15]);
- ZA[26] = Znonce + PreVal4_T1;
-
- ZA[27] = ZMa(f1, g1, ZA[26]) + ZR30(ZA[26]);
- ZA[17] = ZA[16] + h1;
-
- ZA[19] = (ZCh(ZA[17], ZA[15], b1) + c1_plus_k5) + ZR26(ZA[17]);
- ZA[28] = ZA[27] + ZA[16];
-
- ZA[548] = ZMa(ZA[26], f1, ZA[28]) + ZR30(ZA[28]);
- ZA[20] = ZA[19] + g1;
-
- ZA[22] = (ZCh(ZA[20], ZA[17], ZA[15]) + b1_plus_k6) + ZR26(ZA[20]);
- ZA[29] = ZA[548] + ZA[19];
-
- ZA[549] = ZMa(ZA[28], ZA[26], ZA[29]) + ZR30(ZA[29]);
- ZA[23] = ZA[22] + f1;
-
- ZA[24] = ZCh(ZA[23], ZA[20], ZA[17]) + ZR26(ZA[23]);
- ZA[180] = Znonce + PreVal4_state0_k7;
- ZA[30] = ZA[549] + ZA[22];
-
- ZA[31] = ZMa(ZA[29], ZA[28], ZA[30]) + ZR30(ZA[30]);
- ZA[181] = ZA[180] + ZA[24];
-
- ZA[182] = ZA[181] + ZA[26];
- ZA[183] = ZA[181] + ZA[31];
- ZA[18] = ZA[17] + K[0];
-
- ZA[186] = (ZCh(ZA[182], ZA[23], ZA[20]) + ZA[18]) + ZR26(ZA[182]);
- ZA[184] = ZMa(ZA[30], ZA[29], ZA[183]) + ZR30(ZA[183]);
-
- ZA[187] = ZA[186] + ZA[28];
- ZA[188] = ZA[186] + ZA[184];
- ZA[21] = ZA[20] + K[1];
-
- ZA[191] = (ZCh(ZA[187], ZA[182], ZA[23]) + ZA[21]) + ZR26(ZA[187]);
- ZA[189] = ZMa(ZA[183], ZA[30], ZA[188]) + ZR30(ZA[188]);
-
- ZA[192] = ZA[191] + ZA[29];
- ZA[193] = ZA[191] + ZA[189];
- ZA[25] = ZA[23] + K[2];
-
- ZA[196] = (ZCh(ZA[192], ZA[187], ZA[182]) + ZA[25]) + ZR26(ZA[192]);
- ZA[194] = ZMa(ZA[188], ZA[183], ZA[193]) + ZR30(ZA[193]);
-
- ZA[197] = ZA[196] + ZA[30];
- ZA[198] = ZA[196] + ZA[194];
- ZA[185] = ZA[182] + K[3];
-
- ZA[201] = (ZCh(ZA[197], ZA[192], ZA[187]) + ZA[185]) + ZR26(ZA[197]);
- ZA[199] = ZMa(ZA[193], ZA[188], ZA[198]) + ZR30(ZA[198]);
-
- ZA[202] = ZA[201] + ZA[183];
- ZA[203] = ZA[201] + ZA[199];
- ZA[190] = ZA[187] + K[4];
-
- ZA[206] = (ZCh(ZA[202], ZA[197], ZA[192]) + ZA[190]) + ZR26(ZA[202]);
- ZA[204] = ZMa(ZA[198], ZA[193], ZA[203]) + ZR30(ZA[203]);
-
- ZA[207] = ZA[206] + ZA[188];
- ZA[208] = ZA[206] + ZA[204];
- ZA[195] = ZA[192] + K[5];
-
- ZA[211] = (ZCh(ZA[207], ZA[202], ZA[197]) + ZA[195]) + ZR26(ZA[207]);
- ZA[209] = ZMa(ZA[203], ZA[198], ZA[208]) + ZR30(ZA[208]);
-
- ZA[212] = ZA[193] + ZA[211];
- ZA[213] = ZA[211] + ZA[209];
- ZA[200] = ZA[197] + K[6];
-
- ZA[216] = (ZCh(ZA[212], ZA[207], ZA[202]) + ZA[200]) + ZR26(ZA[212]);
- ZA[214] = ZMa(ZA[208], ZA[203], ZA[213]) + ZR30(ZA[213]);
-
- ZA[217] = ZA[198] + ZA[216];
- ZA[218] = ZA[216] + ZA[214];
- ZA[205] = ZA[202] + K[7];
-
- ZA[220] = (ZCh(ZA[217], ZA[212], ZA[207]) + ZA[205]) + ZR26(ZA[217]);
- ZA[219] = ZMa(ZA[213], ZA[208], ZA[218]) + ZR30(ZA[218]);
-
- ZA[222] = ZA[203] + ZA[220];
- ZA[223] = ZA[220] + ZA[219];
- ZA[210] = ZA[207] + W16_plus_K16;
-
- ZA[226] = (ZCh(ZA[222], ZA[217], ZA[212]) + ZA[210]) + ZR26(ZA[222]);
- ZA[225] = ZMa(ZA[218], ZA[213], ZA[223]) + ZR30(ZA[223]);
-
- ZA[0] = ZR25(Znonce) + W18;
- ZA[228] = ZA[226] + ZA[225];
- ZA[227] = ZA[208] + ZA[226];
- ZA[215] = ZA[212] + W17_plus_K17;
-
- ZA[231] = (ZCh(ZA[227], ZA[222], ZA[217]) + ZA[215]) + ZR26(ZA[227]);
- ZA[229] = ZMa(ZA[223], ZA[218], ZA[228]) + ZR30(ZA[228]);
- ZA[1] = ZA[0] + K[8];
-
- ZA[232] = ZA[213] + ZA[231];
- ZA[233] = ZA[231] + ZA[229];
- ZA[221] = ZA[217] + ZA[1];
- ZA[32] = Znonce + W19;
-
- ZA[236] = (ZCh(ZA[232], ZA[227], ZA[222]) + ZA[221]) + ZR26(ZA[232]);
- ZA[234] = ZMa(ZA[228], ZA[223], ZA[233]) + ZR30(ZA[233]);
- ZA[33] = ZA[32] + K[9];
-
- ZA[3] = ZR15(ZA[0]) + K[10];
- ZA[238] = ZA[236] + ZA[234];
- ZA[237] = ZA[218] + ZA[236];
- ZA[224] = ZA[222] + ZA[33];
-
- ZA[241] = (ZCh(ZA[237], ZA[232], ZA[227]) + ZA[224]) + ZR26(ZA[237]);
- ZA[239] = ZMa(ZA[233], ZA[228], ZA[238]) + ZR30(ZA[238]);
- ZA[4] = ZA[3] + K[11];
-
- ZA[35] = ZR15(ZA[32]);
- ZA[243] = ZA[241] + ZA[239];
- ZA[242] = ZA[223] + ZA[241];
- ZA[230] = ZA[227] + ZA[4];
-
- ZA[246] = (ZCh(ZA[242], ZA[237], ZA[232]) + ZA[230]) + ZR26(ZA[242]);
- ZA[244] = ZMa(ZA[238], ZA[233], ZA[243]) + ZR30(ZA[243]);
- ZA[36] = ZA[35] + K[12];
-
- ZA[7] = ZR15(ZA[3]) + K[13];
- ZA[248] = ZA[246] + ZA[244];
- ZA[247] = ZA[228] + ZA[246];
- ZA[235] = ZA[232] + ZA[36];
-
- ZA[251] = (ZCh(ZA[247], ZA[242], ZA[237]) + ZA[235]) + ZR26(ZA[247]);
- ZA[249] = ZMa(ZA[243], ZA[238], ZA[248]) + ZR30(ZA[248]);
- ZA[8] = ZA[7] + K[14];
-
- ZA[38] = ZR15(ZA[35]) + W16;
- ZA[253] = ZA[251] + ZA[249];
- ZA[252] = ZA[233] + ZA[251];
- ZA[240] = ZA[237] + ZA[8];
-
- ZA[256] = (ZCh(ZA[252], ZA[247], ZA[242]) + ZA[240]) + ZR26(ZA[252]);
- ZA[254] = ZMa(ZA[248], ZA[243], ZA[253]) + ZR30(ZA[253]);
- ZA[40] = ZA[38] + K[15];
-
- ZA[10] = ZR15(ZA[7]) + W17;
- ZA[258] = ZA[256] + ZA[254];
- ZA[257] = ZA[238] + ZA[256];
- ZA[245] = ZA[242] + ZA[40];
-
- ZA[261] = (ZCh(ZA[257], ZA[252], ZA[247]) + ZA[245]) + ZR26(ZA[257]);
- ZA[259] = ZMa(ZA[253], ZA[248], ZA[258]) + ZR30(ZA[258]);
- ZA[13] = ZA[10] + K[16];
-
- ZA[43] = ZR15(ZA[38]) + ZA[0];
- ZA[263] = ZA[261] + ZA[259];
- ZA[262] = ZA[243] + ZA[261];
- ZA[250] = ZA[247] + ZA[13];
-
- ZA[266] = (ZCh(ZA[262], ZA[257], ZA[252]) + ZA[250]) + ZR26(ZA[262]);
- ZA[264] = ZMa(ZA[258], ZA[253], ZA[263]) + ZR30(ZA[263]);
- ZA[11] = ZR15(ZA[10]);
- ZA[45] = ZA[43] + K[17];
-
- ZA[52] = ZA[11] + ZA[32];
- ZA[267] = ZA[248] + ZA[266];
- ZA[255] = ZA[252] + ZA[45];
- ZA[268] = ZA[266] + ZA[264];
-
- ZA[271] = (ZCh(ZA[267], ZA[262], ZA[257]) + ZA[255]) + ZR26(ZA[267]);
- ZA[269] = ZMa(ZA[263], ZA[258], ZA[268]) + ZR30(ZA[268]);
- ZA[54] = ZA[52] + K[18];
-
- ZA[48] = ZR15(ZA[43]) + ZA[3];
- ZA[273] = ZA[271] + ZA[269];
- ZA[272] = ZA[253] + ZA[271];
- ZA[260] = ZA[257] + ZA[54];
-
- ZA[276] = (ZCh(ZA[272], ZA[267], ZA[262]) + ZA[260]) + ZR26(ZA[272]);
- ZA[274] = ZMa(ZA[268], ZA[263], ZA[273]) + ZR30(ZA[273]);
- ZA[49] = ZA[48] + K[19];
-
- ZA[61] = ZR15(ZA[52]) + ZA[35];
- ZA[278] = ZA[276] + ZA[274];
- ZA[277] = ZA[258] + ZA[276];
- ZA[265] = ZA[262] + ZA[49];
-
- ZA[281] = (ZCh(ZA[277], ZA[272], ZA[267]) + ZA[265]) + ZR26(ZA[277]);
- ZA[279] = ZMa(ZA[273], ZA[268], ZA[278]) + ZR30(ZA[278]);
- ZA[62] = ZA[61] + K[20];
-
- ZA[53] = ZR15(ZA[48]) + ZA[7];
- ZA[283] = ZA[281] + ZA[279];
- ZA[282] = ZA[263] + ZA[281];
- ZA[270] = ZA[267] + ZA[62];
-
- ZA[286] = (ZCh(ZA[282], ZA[277], ZA[272]) + ZA[270]) + ZR26(ZA[282]);
- ZA[284] = ZMa(ZA[278], ZA[273], ZA[283]) + ZR30(ZA[283]);
- ZA[39] = ZA[38] + K[21];
- ZA[55] = ZA[53] + K[22];
-
- ZA[66] = ZR15(ZA[61]) + ZA[39];
- ZA[288] = ZA[286] + ZA[284];
- ZA[287] = ZA[268] + ZA[286];
- ZA[275] = ZA[272] + ZA[55];
-
- ZA[291] = (ZCh(ZA[287], ZA[282], ZA[277]) + ZA[275]) + ZR26(ZA[287]);
- ZA[289] = ZMa(ZA[283], ZA[278], ZA[288]) + ZR30(ZA[288]);
- ZA[12] = ZA[10] + W31;
- ZA[68] = ZA[66] + K[23];
-
- ZA[67] = ZR15(ZA[53]) + ZA[12];
- ZA[293] = ZA[291] + ZA[289];
- ZA[292] = ZA[273] + ZA[291];
- ZA[280] = ZA[277] + ZA[68];
-
- ZA[296] = (ZCh(ZA[292], ZA[287], ZA[282]) + ZA[280]) + ZR26(ZA[292]);
- ZA[294] = ZMa(ZA[288], ZA[283], ZA[293]) + ZR30(ZA[293]);
- ZA[2] = ZR25(ZA[0]);
- ZA[69] = ZA[67] + K[24];
- ZA[44] = ZA[43] + W32;
-
- ZA[75] = ZR15(ZA[66]) + ZA[44];
- ZA[298] = ZA[296] + ZA[294];
- ZA[297] = ZA[278] + ZA[296];
- ZA[285] = ZA[282] + ZA[69];
- ZA[5] = ZA[2] + W17;
-
- ZA[301] = (ZCh(ZA[297], ZA[292], ZA[287]) + ZA[285]) + ZR26(ZA[297]);
- ZA[299] = ZMa(ZA[293], ZA[288], ZA[298]) + ZR30(ZA[298]);
- ZA[56] = ZA[52] + ZA[5];
- ZA[76] = ZA[75] + K[25];
-
- ZA[34] = ZR25(ZA[32]) + ZA[0];
- ZA[70] = ZR15(ZA[67]) + ZA[56];
- ZA[302] = ZA[283] + ZA[301];
- ZA[303] = ZA[301] + ZA[299];
- ZA[290] = ZA[287] + ZA[76];
-
- ZA[306] = (ZCh(ZA[302], ZA[297], ZA[292]) + ZA[290]) + ZR26(ZA[302]);
- ZA[304] = ZMa(ZA[298], ZA[293], ZA[303]) + ZR30(ZA[303]);
- ZA[6] = ZR25(ZA[3]);
- ZA[77] = ZA[70] + K[26];
- ZA[50] = ZA[34] + ZA[48];
-
- ZA[78] = ZR15(ZA[75]) + ZA[50];
- ZA[308] = ZA[306] + ZA[304];
- ZA[307] = ZA[288] + ZA[306];
- ZA[295] = ZA[292] + ZA[77];
- ZA[41] = ZA[32] + ZA[6];
-
- ZA[311] = (ZCh(ZA[307], ZA[302], ZA[297]) + ZA[295]) + ZR26(ZA[307]);
- ZA[309] = ZMa(ZA[303], ZA[298], ZA[308]) + ZR30(ZA[308]);
- ZA[63] = ZA[41] + ZA[61];
- ZA[85] = ZA[78] + K[27];
-
- ZA[37] = ZR25(ZA[35]) + ZA[3];
- ZA[79] = ZR15(ZA[70]) + ZA[63];
- ZA[312] = ZA[293] + ZA[311];
- ZA[313] = ZA[311] + ZA[309];
- ZA[300] = ZA[297] + ZA[85];
-
- ZA[316] = (ZCh(ZA[312], ZA[307], ZA[302]) + ZA[300]) + ZR26(ZA[312]);
- ZA[314] = ZMa(ZA[308], ZA[303], ZA[313]) + ZR30(ZA[313]);
- ZA[9] = ZR25(ZA[7]);
- ZA[86] = ZA[79] + K[28];
- ZA[57] = ZA[37] + ZA[53];
-
- ZA[87] = ZR15(ZA[78]) + ZA[57];
- ZA[318] = ZA[316] + ZA[314];
- ZA[317] = ZA[298] + ZA[316];
- ZA[305] = ZA[302] + ZA[86];
- ZA[46] = ZA[35] + ZA[9];
-
- ZA[321] = (ZCh(ZA[317], ZA[312], ZA[307]) + ZA[305]) + ZR26(ZA[317]);
- ZA[319] = ZMa(ZA[313], ZA[308], ZA[318]) + ZR30(ZA[318]);
- ZA[71] = ZA[46] + ZA[66];
- ZA[92] = ZA[87] + K[29];
-
- ZA[42] = ZR25(ZA[38]) + ZA[7];
- ZA[88] = ZR15(ZA[79]) + ZA[71];
- ZA[322] = ZA[303] + ZA[321];
- ZA[323] = ZA[321] + ZA[319];
- ZA[310] = ZA[307] + ZA[92];
-
- ZA[326] = (ZCh(ZA[322], ZA[317], ZA[312]) + ZA[310]) + ZR26(ZA[322]);
- ZA[324] = ZMa(ZA[318], ZA[313], ZA[323]) + ZR30(ZA[323]);
- ZA[14] = ZR25(ZA[10]);
- ZA[93] = ZA[88] + K[30];
- ZA[72] = ZA[42] + ZA[67];
-
- ZA[94] = ZR15(ZA[87]) + ZA[72];
- ZA[328] = ZA[326] + ZA[324];
- ZA[327] = ZA[308] + ZA[326];
- ZA[315] = ZA[312] + ZA[93];
- ZA[51] = ZA[38] + ZA[14];
-
- ZA[331] = (ZCh(ZA[327], ZA[322], ZA[317]) + ZA[315]) + ZR26(ZA[327]);
- ZA[329] = ZMa(ZA[323], ZA[318], ZA[328]) + ZR30(ZA[328]);
- ZA[80] = ZA[51] + ZA[75];
- ZA[100] = ZA[94] + K[31];
-
- ZA[47] = ZR25(ZA[43]) + ZA[10];
- ZA[95] = ZR15(ZA[88]) + ZA[80];
- ZA[332] = ZA[313] + ZA[331];
- ZA[333] = ZA[331] + ZA[329];
- ZA[320] = ZA[317] + ZA[100];
-
- ZA[336] = (ZCh(ZA[332], ZA[327], ZA[322]) + ZA[320]) + ZR26(ZA[332]);
- ZA[334] = ZMa(ZA[328], ZA[323], ZA[333]) + ZR30(ZA[333]);
- ZA[81] = ZA[47] + ZA[70];
- ZA[101] = ZA[95] + K[32];
-
- ZA[58] = ZR25(ZA[52]) + ZA[43];
- ZA[102] = ZR15(ZA[94]) + ZA[81];
- ZA[337] = ZA[318] + ZA[336];
- ZA[338] = ZA[336] + ZA[334];
- ZA[325] = ZA[322] + ZA[101];
-
- ZA[341] = (ZCh(ZA[337], ZA[332], ZA[327]) + ZA[325]) + ZR26(ZA[337]);
- ZA[339] = ZMa(ZA[333], ZA[328], ZA[338]) + ZR30(ZA[338]);
- ZA[89] = ZA[58] + ZA[78];
- ZA[108] = ZA[102] + K[33];
-
- ZA[59] = ZR25(ZA[48]) + ZA[52];
- ZA[103] = ZR15(ZA[95]) + ZA[89];
- ZA[342] = ZA[323] + ZA[341];
- ZA[343] = ZA[341] + ZA[339];
- ZA[330] = ZA[327] + ZA[108];
-
- ZA[346] = (ZCh(ZA[342], ZA[337], ZA[332]) + ZA[330]) + ZR26(ZA[342]);
- ZA[344] = ZMa(ZA[338], ZA[333], ZA[343]) + ZR30(ZA[343]);
- ZA[90] = ZA[59] + ZA[79];
- ZA[109] = ZA[103] + K[34];
-
- ZA[64] = ZR25(ZA[61]) + ZA[48];
- ZA[110] = ZR15(ZA[102]) + ZA[90];
- ZA[347] = ZA[328] + ZA[346];
- ZA[348] = ZA[346] + ZA[344];
- ZA[335] = ZA[332] + ZA[109];
-
- ZA[351] = (ZCh(ZA[347], ZA[342], ZA[337]) + ZA[335]) + ZR26(ZA[347]);
- ZA[349] = ZMa(ZA[343], ZA[338], ZA[348]) + ZR30(ZA[348]);
- ZA[60] = ZR25(ZA[53]);
- ZA[116] = ZA[110] + K[35];
- ZA[96] = ZA[87] + ZA[64];
-
- ZA[111] = ZR15(ZA[103]) + ZA[96];
- ZA[353] = ZA[351] + ZA[349];
- ZA[352] = ZA[333] + ZA[351];
- ZA[340] = ZA[337] + ZA[116];
- ZA[65] = ZA[60] + ZA[61];
-
- ZA[356] = (ZCh(ZA[352], ZA[347], ZA[342]) + ZA[340]) + ZR26(ZA[352]);
- ZA[354] = ZMa(ZA[348], ZA[343], ZA[353]) + ZR30(ZA[353]);
- ZA[97] = ZA[88] + ZA[65];
- ZA[117] = ZA[111] + K[36];
-
- ZA[73] = ZR25(ZA[66]) + ZA[53];
- ZA[118] = ZR15(ZA[110]) + ZA[97];
- ZA[357] = ZA[338] + ZA[356];
- ZA[358] = ZA[356] + ZA[354];
- ZA[345] = ZA[342] + ZA[117];
-
- ZA[361] = (ZCh(ZA[357], ZA[352], ZA[347]) + ZA[345]) + ZR26(ZA[357]);
- ZA[359] = ZMa(ZA[353], ZA[348], ZA[358]) + ZR30(ZA[358]);
- ZA[104] = ZA[73] + ZA[94];
- ZA[124] = ZA[118] + K[37];
-
- ZA[74] = ZR25(ZA[67]) + ZA[66];
- ZA[119] = ZR15(ZA[111]) + ZA[104];
- ZA[362] = ZA[343] + ZA[361];
- ZA[363] = ZA[361] + ZA[359];
- ZA[350] = ZA[347] + ZA[124];
-
- ZA[366] = (ZCh(ZA[362], ZA[357], ZA[352]) + ZA[350]) + ZR26(ZA[362]);
- ZA[364] = ZMa(ZA[358], ZA[353], ZA[363]) + ZR30(ZA[363]);
- ZA[105] = ZA[74] + ZA[95];
- ZA[125] = ZA[119] + K[38];
-
- ZA[82] = ZR25(ZA[75]) + ZA[67];
- ZA[126] = ZR15(ZA[118]) + ZA[105];
- ZA[367] = ZA[348] + ZA[366];
- ZA[368] = ZA[366] + ZA[364];
- ZA[355] = ZA[352] + ZA[125];
-
- ZA[371] = (ZCh(ZA[367], ZA[362], ZA[357]) + ZA[355]) + ZR26(ZA[367]);
- ZA[369] = ZMa(ZA[363], ZA[358], ZA[368]) + ZR30(ZA[368]);
- ZA[112] = ZA[102] + ZA[82];
- ZA[132] = ZA[126] + K[39];
-
- ZA[83] = ZR25(ZA[70]) + ZA[75];
- ZA[127] = ZR15(ZA[119]) + ZA[112];
- ZA[372] = ZA[353] + ZA[371];
- ZA[373] = ZA[371] + ZA[369];
- ZA[360] = ZA[357] + ZA[132];
-
- ZA[376] = (ZCh(ZA[372], ZA[367], ZA[362]) + ZA[360]) + ZR26(ZA[372]);
- ZA[374] = ZMa(ZA[368], ZA[363], ZA[373]) + ZR30(ZA[373]);
- ZA[113] = ZA[103] + ZA[83];
- ZA[133] = ZA[127] + K[40];
-
- ZA[84] = ZR25(ZA[78]) + ZA[70];
- ZA[134] = ZR15(ZA[126]) + ZA[113];
- ZA[377] = ZA[358] + ZA[376];
- ZA[378] = ZA[376] + ZA[374];
- ZA[365] = ZA[362] + ZA[133];
-
- ZA[381] = (ZCh(ZA[377], ZA[372], ZA[367]) + ZA[365]) + ZR26(ZA[377]);
- ZA[379] = ZMa(ZA[373], ZA[368], ZA[378]) + ZR30(ZA[378]);
- ZA[120] = ZA[110] + ZA[84];
- ZA[140] = ZA[134] + K[41];
-
- ZA[91] = ZR25(ZA[79]) + ZA[78];
- ZA[135] = ZR15(ZA[127]) + ZA[120];
- ZA[382] = ZA[363] + ZA[381];
- ZA[383] = ZA[381] + ZA[379];
- ZA[370] = ZA[367] + ZA[140];
-
- ZA[386] = (ZCh(ZA[382], ZA[377], ZA[372]) + ZA[370]) + ZR26(ZA[382]);
- ZA[384] = ZMa(ZA[378], ZA[373], ZA[383]) + ZR30(ZA[383]);
- ZA[121] = ZA[111] + ZA[91];
- ZA[141] = ZA[135] + K[42];
-
- ZA[98] = ZR25(ZA[87]) + ZA[79];
- ZA[142] = ZR15(ZA[134]) + ZA[121];
- ZA[387] = ZA[368] + ZA[386];
- ZA[388] = ZA[386] + ZA[384];
- ZA[375] = ZA[372] + ZA[141];
-
- ZA[391] = (ZCh(ZA[387], ZA[382], ZA[377]) + ZA[375]) + ZR26(ZA[387]);
- ZA[389] = ZMa(ZA[383], ZA[378], ZA[388]) + ZR30(ZA[388]);
- ZA[128] = ZA[118] + ZA[98];
- ZA[147] = ZA[142] + K[43];
-
- ZA[99] = ZR25(ZA[88]) + ZA[87];
- ZA[143] = ZR15(ZA[135]) + ZA[128];
- ZA[392] = ZA[373] + ZA[391];
- ZA[393] = ZA[391] + ZA[389];
- ZA[380] = ZA[377] + ZA[147];
-
- ZA[396] = (ZCh(ZA[392], ZA[387], ZA[382]) + ZA[380]) + ZR26(ZA[392]);
- ZA[394] = ZMa(ZA[388], ZA[383], ZA[393]) + ZR30(ZA[393]);
- ZA[129] = ZA[119] + ZA[99];
- ZA[148] = ZA[143] + K[44];
-
- ZA[106] = ZR25(ZA[94]) + ZA[88];
- ZA[149] = ZR15(ZA[142]) + ZA[129];
- ZA[397] = ZA[378] + ZA[396];
- ZA[398] = ZA[396] + ZA[394];
- ZA[385] = ZA[382] + ZA[148];
-
- ZA[401] = (ZCh(ZA[397], ZA[392], ZA[387]) + ZA[385]) + ZR26(ZA[397]);
- ZA[399] = ZMa(ZA[393], ZA[388], ZA[398]) + ZR30(ZA[398]);
- ZA[136] = ZA[126] + ZA[106];
- ZA[153] = ZA[149] + K[45];
-
- ZA[107] = ZR25(ZA[95]) + ZA[94];
- ZA[150] = ZR15(ZA[143]) + ZA[136];
- ZA[402] = ZA[383] + ZA[401];
- ZA[403] = ZA[401] + ZA[399];
- ZA[390] = ZA[387] + ZA[153];
-
- ZA[406] = (ZCh(ZA[402], ZA[397], ZA[392]) + ZA[390]) + ZR26(ZA[402]);
- ZA[404] = ZMa(ZA[398], ZA[393], ZA[403]) + ZR30(ZA[403]);
- ZA[137] = ZA[127] + ZA[107];
- ZA[154] = ZA[150] + K[46];
-
- ZA[114] = ZR25(ZA[102]) + ZA[95];
- ZA[155] = ZR15(ZA[149]) + ZA[137];
- ZA[407] = ZA[388] + ZA[406];
- ZA[408] = ZA[406] + ZA[404];
- ZA[395] = ZA[392] + ZA[154];
-
- ZA[411] = (ZCh(ZA[407], ZA[402], ZA[397]) + ZA[395]) + ZR26(ZA[407]);
- ZA[409] = ZMa(ZA[403], ZA[398], ZA[408]) + ZR30(ZA[408]);
- ZA[144] = ZA[134] + ZA[114];
- ZA[159] = ZA[155] + K[47];
-
- ZA[115] = ZR25(ZA[103]) + ZA[102];
- ZA[156] = ZR15(ZA[150]) + ZA[144];
- ZA[412] = ZA[393] + ZA[411];
- ZA[413] = ZA[411] + ZA[409];
- ZA[400] = ZA[397] + ZA[159];
-
- ZA[416] = (ZCh(ZA[412], ZA[407], ZA[402]) + ZA[400]) + ZR26(ZA[412]);
- ZA[414] = ZMa(ZA[408], ZA[403], ZA[413]) + ZR30(ZA[413]);
- ZA[145] = ZA[135] + ZA[115];
- ZA[160] = ZA[156] + K[48];
-
- ZA[122] = ZR25(ZA[110]) + ZA[103];
- ZA[161] = ZR15(ZA[155]) + ZA[145];
- ZA[417] = ZA[398] + ZA[416];
- ZA[418] = ZA[416] + ZA[414];
- ZA[405] = ZA[402] + ZA[160];
-
- ZA[421] = (ZCh(ZA[417], ZA[412], ZA[407]) + ZA[405]) + ZR26(ZA[417]);
- ZA[419] = ZMa(ZA[413], ZA[408], ZA[418]) + ZR30(ZA[418]);
- ZA[151] = ZA[142] + ZA[122];
- ZA[165] = ZA[161] + K[49];
-
- ZA[123] = ZR25(ZA[111]) + ZA[110];
- ZA[162] = ZR15(ZA[156]) + ZA[151];
- ZA[422] = ZA[403] + ZA[421];
- ZA[423] = ZA[421] + ZA[419];
- ZA[410] = ZA[407] + ZA[165];
-
- ZA[426] = (ZCh(ZA[422], ZA[417], ZA[412]) + ZA[410]) + ZR26(ZA[422]);
- ZA[424] = ZMa(ZA[418], ZA[413], ZA[423]) + ZR30(ZA[423]);
- ZA[152] = ZA[143] + ZA[123];
- ZA[166] = ZA[162] + K[50];
-
- ZA[130] = ZR25(ZA[118]) + ZA[111];
- ZA[167] = ZR15(ZA[161]) + ZA[152];
- ZA[427] = ZA[408] + ZA[426];
- ZA[428] = ZA[426] + ZA[424];
- ZA[415] = ZA[412] + ZA[166];
-
- ZA[431] = (ZCh(ZA[427], ZA[422], ZA[417]) + ZA[415]) + ZR26(ZA[427]);
- ZA[429] = ZMa(ZA[423], ZA[418], ZA[428]) + ZR30(ZA[428]);
- ZA[157] = ZA[149] + ZA[130];
- ZA[170] = ZA[167] + K[51];
-
- ZA[131] = ZR25(ZA[119]) + ZA[118];
- ZA[168] = ZR15(ZA[162]) + ZA[157];
- ZA[432] = ZA[413] + ZA[431];
- ZA[433] = ZA[431] + ZA[429];
- ZA[420] = ZA[417] + ZA[170];
-
- ZA[436] = (ZCh(ZA[432], ZA[427], ZA[422]) + ZA[420]) + ZR26(ZA[432]);
- ZA[434] = ZMa(ZA[428], ZA[423], ZA[433]) + ZR30(ZA[433]);
- ZA[158] = ZA[150] + ZA[131];
- ZA[171] = ZA[168] + K[52];
-
- ZA[138] = ZR25(ZA[126]) + ZA[119];
- ZA[172] = ZR15(ZA[167]) + ZA[158];
- ZA[437] = ZA[418] + ZA[436];
- ZA[438] = ZA[436] + ZA[434];
- ZA[425] = ZA[422] + ZA[171];
-
- ZA[441] = (ZCh(ZA[437], ZA[432], ZA[427]) + ZA[425]) + ZR26(ZA[437]);
- ZA[439] = ZMa(ZA[433], ZA[428], ZA[438]) + ZR30(ZA[438]);
- ZA[163] = ZA[155] + ZA[138];
- ZA[174] = ZA[172] + K[53];
-
- ZA[139] = ZR25(ZA[127]) + ZA[126];
- ZA[173] = ZR15(ZA[168]) + ZA[163];
- ZA[442] = ZA[423] + ZA[441];
- ZA[443] = ZA[441] + ZA[439];
- ZA[430] = ZA[427] + ZA[174];
-
- ZA[445] = (ZCh(ZA[442], ZA[437], ZA[432]) + ZA[430]) + ZR26(ZA[442]);
- ZA[444] = ZMa(ZA[438], ZA[433], ZA[443]) + ZR30(ZA[443]);
- ZA[164] = ZA[156] + ZA[139];
- ZA[175] = ZA[173] + K[54];
-
- ZA[146] = ZR25(ZA[134]) + ZA[127];
- ZA[176] = ZR15(ZA[172]) + ZA[164];
- ZA[446] = ZA[428] + ZA[445];
- ZA[447] = ZA[445] + ZA[444];
- ZA[435] = ZA[432] + ZA[175];
-
- ZA[449] = (ZCh(ZA[446], ZA[442], ZA[437]) + ZA[435]) + ZR26(ZA[446]);
- ZA[448] = ZMa(ZA[443], ZA[438], ZA[447]) + ZR30(ZA[447]);
- ZA[169] = ZA[161] + ZA[146];
- ZA[178] = ZA[176] + K[55];
-
- ZA[177] = ZR15(ZA[173]) + ZA[169];
- ZA[451] = ZA[449] + ZA[448];
- ZA[450] = ZA[433] + ZA[449];
- ZA[440] = ZA[437] + ZA[178];
-
- ZA[453] = (ZCh(ZA[450], ZA[446], ZA[442]) + ZA[440]) + ZR26(ZA[450]);
- ZA[452] = ZMa(ZA[447], ZA[443], ZA[451]) + ZR30(ZA[451]);
- ZA[179] = ZA[177] + K[56];
-
- ZA[454] = ZA[438] + ZA[453];
- ZA[494] = ZA[442] + ZA[179];
- ZA[455] = ZA[453] + ZA[452];
-
- ZA[457] = (ZCh(ZA[454], ZA[450], ZA[446]) + ZA[494]) + ZR26(ZA[454]);
- ZA[456] = ZMa(ZA[451], ZA[447], ZA[455]) + ZR30(ZA[455]);
-
- ZA[459] = ZA[457] + ZA[456];
-
- ZA[461] = ZA[455] + state1;
- ZA[460] = ZA[459] + state0;
-
- ZA[495] = ZA[460] + K[57];
- ZA[469] = ZA[461] + K[58];
-
- ZA[498] = (ZCh(ZA[495], K[59], K[60]) + ZA[469]) + ZR26(ZA[495]);
- ZA[462] = ZA[451] + state2;
-
- ZA[496] = ZA[460] + K[61];
- ZA[506] = ZA[498] + K[62];
- ZA[470] = ZA[462] + K[63];
-
- ZA[507] = (ZCh(ZA[506], ZA[495], K[59]) + ZA[470]) + ZR26(ZA[506]);
- ZA[500] = ZMa(K[64], K[65], ZA[496]) + ZR30(ZA[496]);
- ZA[463] = ZA[447] + state3;
-
- ZA[458] = ZA[443] + ZA[457];
- ZA[499] = ZA[498] + ZA[500];
- ZA[508] = ZA[507] + K[65];
- ZA[473] = ZA[463] + K[66];
-
- ZA[510] = (ZCh(ZA[508], ZA[506], ZA[495]) + ZA[473]) + ZR26(ZA[508]);
- ZA[928] = ZMa(ZA[496], K[64], ZA[499]) + ZR30(ZA[499]);
- ZA[464] = ZA[458] + state4;
-
- ZA[476] = ZA[464] + ZA[460] + K[67];
- ZA[511] = ZA[510] + K[64];
- ZA[509] = ZA[928] + ZA[507];
- ZA[465] = ZA[454] + state5;
-
- ZA[514] = (ZCh(ZA[511], ZA[508], ZA[506]) + ZA[476]) + ZR26(ZA[511]);
- ZA[512] = ZMa(ZA[499], ZA[496], ZA[509]) + ZR30(ZA[509]);
- ZA[478] = ZA[465] + K[68];
-
- ZA[519] = ZA[506] + ZA[478];
- ZA[516] = ZA[496] + ZA[514];
- ZA[513] = ZA[510] + ZA[512];
- ZA[466] = ZA[450] + state6;
-
- ZA[520] = (ZCh(ZA[516], ZA[511], ZA[508]) + ZA[519]) + ZR26(ZA[516]);
- ZA[515] = ZMa(ZA[509], ZA[499], ZA[513]) + ZR30(ZA[513]);
- ZA[480] = ZA[466] + K[69];
-
- ZA[524] = ZA[508] + ZA[480];
- ZA[521] = ZA[499] + ZA[520];
- ZA[517] = ZA[514] + ZA[515];
- ZA[467] = ZA[446] + state7;
-
- ZA[525] = (ZCh(ZA[521], ZA[516], ZA[511]) + ZA[524]) + ZR26(ZA[521]);
- ZA[522] = ZMa(ZA[513], ZA[509], ZA[517]) + ZR30(ZA[517]);
- ZA[484] = ZA[467] + K[70];
-
- ZA[529] = ZA[511] + ZA[484];
- ZA[526] = ZA[509] + ZA[525];
- ZA[523] = ZA[520] + ZA[522];
-
- ZA[530] = (ZCh(ZA[526], ZA[521], ZA[516]) + ZA[529]) + ZR26(ZA[526]);
- ZA[550] = ZMa(ZA[517], ZA[513], ZA[523]) + ZR30(ZA[523]);
-
- ZA[531] = ZA[513] + ZA[530];
- ZA[533] = ZA[516] + K[71];
- ZA[527] = ZA[550] + ZA[525];
-
- ZA[534] = (ZCh(ZA[531], ZA[526], ZA[521]) + ZA[533]) + ZR26(ZA[531]);
- ZA[551] = ZMa(ZA[523], ZA[517], ZA[527]) + ZR30(ZA[527]);
-
- ZA[535] = ZA[517] + ZA[534];
- ZA[538] = ZA[521] + K[1];
- ZA[532] = ZA[551] + ZA[530];
-
- ZA[539] = (ZCh(ZA[535], ZA[531], ZA[526]) + ZA[538]) + ZR26(ZA[535]);
- ZA[552] = ZMa(ZA[527], ZA[523], ZA[532]) + ZR30(ZA[532]);
-
- ZA[540] = ZA[523] + ZA[539];
- ZA[542] = ZA[526] + K[2];
- ZA[536] = ZA[552] + ZA[534];
-
- ZA[543] = (ZCh(ZA[540], ZA[535], ZA[531]) + ZA[542]) + ZR26(ZA[540]);
- ZA[553] = ZMa(ZA[532], ZA[527], ZA[536]) + ZR30(ZA[536]);
-
- ZA[544] = ZA[527] + ZA[543];
- ZA[555] = ZA[531] + K[3];
- ZA[541] = ZA[553] + ZA[539];
-
- ZA[558] = (ZCh(ZA[544], ZA[540], ZA[535]) + ZA[555]) + ZR26(ZA[544]);
- ZA[547] = ZMa(ZA[536], ZA[532], ZA[541]) + ZR30(ZA[541]);
-
- ZA[559] = ZA[532] + ZA[558];
- ZA[556] = ZA[535] + K[4];
- ZA[545] = ZA[547] + ZA[543];
-
- ZA[562] = (ZCh(ZA[559], ZA[544], ZA[540]) + ZA[556]) + ZR26(ZA[559]);
- ZA[561] = ZMa(ZA[541], ZA[536], ZA[545]) + ZR30(ZA[545]);
-
- ZA[563] = ZA[536] + ZA[562];
- ZA[560] = ZA[561] + ZA[558];
- ZA[557] = ZA[540] + K[5];
-
- ZA[568] = (ZCh(ZA[563], ZA[559], ZA[544]) + ZA[557]) + ZR26(ZA[563]);
- ZA[564] = ZMa(ZA[545], ZA[541], ZA[560]) + ZR30(ZA[560]);
-
- ZA[569] = ZA[541] + ZA[568];
- ZA[572] = ZA[544] + K[6];
- ZA[565] = ZA[562] + ZA[564];
-
- ZA[574] = (ZCh(ZA[569], ZA[563], ZA[559]) + ZA[572]) + ZR26(ZA[569]);
- ZA[570] = ZMa(ZA[560], ZA[545], ZA[565]) + ZR30(ZA[565]);
- ZA[468] = ZR25(ZA[461]);
-
- ZA[497] = ZA[468] + ZA[460];
- ZA[575] = ZA[545] + ZA[574];
- ZA[571] = ZA[568] + ZA[570];
- ZA[573] = ZA[559] + K[72];
-
- ZA[578] = (ZCh(ZA[575], ZA[569], ZA[563]) + ZA[573]) + ZR26(ZA[575]);
- ZA[576] = ZMa(ZA[565], ZA[560], ZA[571]) + ZR30(ZA[571]);
- ZA[929] = ZR25(ZA[462]);
- ZA[503] = ZA[497] + 0xe49b69c1U;
-
- ZA[471] = ZA[929] + ZA[461] + K[74];
- ZA[582] = ZA[563] + ZA[503];
- ZA[579] = ZA[560] + ZA[578];
- ZA[577] = ZA[574] + ZA[576];
-
- ZA[583] = (ZCh(ZA[579], ZA[575], ZA[569]) + ZA[582]) + ZR26(ZA[579]);
- ZA[580] = ZMa(ZA[571], ZA[565], ZA[577]) + ZR30(ZA[577]);
- ZA[488] = ZA[471] + K[75];
-
- ZA[472] = ZR25(ZA[463]) + ZA[462];
- ZA[587] = ZA[569] + ZA[488];
- ZA[584] = ZA[565] + ZA[583];
- ZA[581] = ZA[578] + ZA[580];
-
- ZA[588] = (ZCh(ZA[584], ZA[579], ZA[575]) + ZA[587]) + ZR26(ZA[584]);
- ZA[586] = ZMa(ZA[577], ZA[571], ZA[581]) + ZR30(ZA[581]);
- ZA[501] = ZR15(ZA[497]) + ZA[472];
- ZA[475] = ZR15(ZA[471]);
- ZA[926] = ZA[575] + K[8];
-
- ZA[474] = ZA[475] + ZA[463] + ZR25(ZA[464]);
- ZA[927] = ZA[926] + ZA[501];
- ZA[589] = ZA[571] + ZA[588];
- ZA[585] = ZA[583] + ZA[586];
-
- ZA[592] = (ZCh(ZA[589], ZA[584], ZA[579]) + ZA[927]) + ZR26(ZA[589]);
- ZA[590] = ZMa(ZA[581], ZA[577], ZA[585]) + ZR30(ZA[585]);
- ZA[477] = ZR25(ZA[465]) + ZA[464];
- ZA[489] = ZA[474] + K[9];
-
- ZA[518] = ZR15(ZA[501]) + ZA[477];
- ZA[479] = ZR25(ZA[466]);
- ZA[596] = ZA[579] + ZA[489];
- ZA[593] = ZA[577] + ZA[592];
- ZA[591] = ZA[588] + ZA[590];
-
- ZA[597] = (ZCh(ZA[593], ZA[589], ZA[584]) + ZA[596]) + ZR26(ZA[593]);
- ZA[594] = ZMa(ZA[585], ZA[581], ZA[591]) + ZR30(ZA[591]);
- ZA[481] = ZA[479] + ZA[465];
- ZA[601] = ZA[518] + K[11];
-
- ZA[482] = ZR15(ZA[474]) + ZA[481];
- ZA[602] = ZA[584] + ZA[601];
- ZA[598] = ZA[581] + ZA[597];
- ZA[595] = ZA[592] + ZA[594];
-
- ZA[632] = (ZCh(ZA[598], ZA[593], ZA[589]) + ZA[602]) + ZR26(ZA[598]);
- ZA[599] = ZMa(ZA[591], ZA[585], ZA[595]) + ZR30(ZA[595]);
- ZA[483] = ZA[466] + K[76] + ZR25(ZA[467]);
- ZA[490] = ZA[482] + K[12];
-
- ZA[528] = ZR15(ZA[518]) + ZA[483];
- ZA[736] = ZA[585] + ZA[632];
- ZA[605] = ZA[589] + ZA[490];
- ZA[600] = ZA[597] + ZA[599];
- ZA[485] = ZA[467] + K[77];
-
- ZA[738] = (ZCh(ZA[736], ZA[598], ZA[593]) + ZA[605]) + ZR26(ZA[736]);
- ZA[744] = ZMa(ZA[595], ZA[591], ZA[600]) + ZR30(ZA[600]);
- ZA[487] = ZR15(ZA[482]) + ZA[485];
- ZA[603] = ZA[528] + K[14];
-
- ZA[502] = ZA[497] + ZA[487];
- ZA[739] = ZA[591] + ZA[738];
- ZA[604] = ZA[593] + ZA[603];
- ZA[737] = ZA[744] + ZA[632];
-
- ZA[741] = (ZCh(ZA[739], ZA[736], ZA[598]) + ZA[604]) + ZR26(ZA[739]);
- ZA[745] = ZMa(ZA[600], ZA[595], ZA[737]) + ZR30(ZA[737]);
- ZA[486] = ZA[471] + K[10];
- ZA[606] = ZA[502] + K[15];
-
- ZA[537] = ZR15(ZA[528]) + ZA[486];
- ZA[742] = ZA[595] + ZA[741];
- ZA[613] = ZA[598] + ZA[606];
- ZA[740] = ZA[745] + ZA[738];
-
- ZA[747] = (ZCh(ZA[742], ZA[739], ZA[736]) + ZA[613]) + ZR26(ZA[742]);
- ZA[746] = ZMa(ZA[737], ZA[600], ZA[740]) + ZR30(ZA[740]);
- ZA[607] = ZA[537] + K[16];
-
- ZA[546] = ZR15(ZA[502]) + ZA[501];
- ZA[751] = ZA[736] + ZA[607];
- ZA[748] = ZA[600] + ZA[747];
- ZA[743] = ZA[746] + ZA[741];
-
- ZA[752] = (ZCh(ZA[748], ZA[742], ZA[739]) + ZA[751]) + ZR26(ZA[748]);
- ZA[749] = ZMa(ZA[740], ZA[737], ZA[743]) + ZR30(ZA[743]);
- ZA[608] = ZA[546] + K[17];
-
- ZA[554] = ZR15(ZA[537]) + ZA[474];
- ZA[756] = ZA[739] + ZA[608];
- ZA[753] = ZA[737] + ZA[752];
- ZA[750] = ZA[747] + ZA[749];
-
- ZA[757] = (ZCh(ZA[753], ZA[748], ZA[742]) + ZA[756]) + ZR26(ZA[753]);
- ZA[754] = ZMa(ZA[743], ZA[740], ZA[750]) + ZR30(ZA[750]);
- ZA[609] = ZA[554] + K[18];
-
- ZA[566] = ZR15(ZA[546]) + ZA[518];
- ZA[761] = ZA[742] + ZA[609];
- ZA[758] = ZA[740] + ZA[757];
- ZA[755] = ZA[752] + ZA[754];
-
- ZA[762] = (ZCh(ZA[758], ZA[753], ZA[748]) + ZA[761]) + ZR26(ZA[758]);
- ZA[759] = ZMa(ZA[750], ZA[743], ZA[755]) + ZR30(ZA[755]);
- ZA[610] = ZA[566] + K[19];
-
- ZA[567] = ZR15(ZA[554]) + ZA[482];
- ZA[766] = ZA[748] + ZA[610];
- ZA[763] = ZA[743] + ZA[762];
- ZA[760] = ZA[757] + ZA[759];
-
- ZA[767] = (ZCh(ZA[763], ZA[758], ZA[753]) + ZA[766]) + ZR26(ZA[763]);
- ZA[764] = ZMa(ZA[755], ZA[750], ZA[760]) + ZR30(ZA[760]);
- ZA[611] = ZA[567] + K[20];
-
- ZA[614] = ZR15(ZA[566]) + ZA[528];
- ZA[771] = ZA[753] + ZA[611];
- ZA[768] = ZA[750] + ZA[767];
- ZA[765] = ZA[762] + ZA[764];
-
- ZA[772] = (ZCh(ZA[768], ZA[763], ZA[758]) + ZA[771]) + ZR26(ZA[768]);
- ZA[769] = ZMa(ZA[760], ZA[755], ZA[765]) + ZR30(ZA[765]);
- ZA[612] = ZA[502] + K[78];
- ZA[615] = ZA[614] + K[22];
-
- ZA[616] = ZR15(ZA[567]) + ZA[612];
- ZA[504] = ZR25(ZA[497]) + K[76];
- ZA[776] = ZA[758] + ZA[615];
- ZA[773] = ZA[755] + ZA[772];
- ZA[770] = ZA[767] + ZA[769];
-
- ZA[777] = (ZCh(ZA[773], ZA[768], ZA[763]) + ZA[776]) + ZR26(ZA[773]);
- ZA[774] = ZMa(ZA[765], ZA[760], ZA[770]) + ZR30(ZA[770]);
- ZA[492] = ZR25(ZA[471]);
- ZA[618] = ZA[537] + ZA[504];
- ZA[617] = ZA[616] + K[23];
-
- ZA[619] = ZR15(ZA[614]) + ZA[618];
- ZA[781] = ZA[763] + ZA[617];
- ZA[778] = ZA[760] + ZA[777];
- ZA[775] = ZA[772] + ZA[774];
- ZA[505] = ZA[492] + ZA[497];
-
- ZA[782] = (ZCh(ZA[778], ZA[773], ZA[768]) + ZA[781]) + ZR26(ZA[778]);
- ZA[779] = ZMa(ZA[770], ZA[765], ZA[775]) + ZR30(ZA[775]);
- ZA[621] = ZA[505] + ZA[546];
- ZA[620] = ZA[619] + K[24];
-
- ZA[622] = ZR15(ZA[616]) + ZA[621];
- ZA[625] = ZR25(ZA[501]);
- ZA[786] = ZA[768] + ZA[620];
- ZA[783] = ZA[765] + ZA[782];
- ZA[624] = ZA[554] + ZA[471];
- ZA[780] = ZA[777] + ZA[779];
-
- ZA[787] = (ZCh(ZA[783], ZA[778], ZA[773]) + ZA[786]) + ZR26(ZA[783]);
- ZA[784] = ZMa(ZA[775], ZA[770], ZA[780]) + ZR30(ZA[780]);
- ZA[493] = ZR25(ZA[474]);
- ZA[626] = ZA[625] + ZA[624];
- ZA[623] = ZA[622] + K[25];
-
- ZA[627] = ZR15(ZA[619]) + ZA[626];
- ZA[791] = ZA[773] + ZA[623];
- ZA[788] = ZA[770] + ZA[787];
- ZA[785] = ZA[782] + ZA[784];
- ZA[629] = ZA[493] + ZA[501];
-
- ZA[792] = (ZCh(ZA[788], ZA[783], ZA[778]) + ZA[791]) + ZR26(ZA[788]);
- ZA[789] = ZMa(ZA[780], ZA[775], ZA[785]) + ZR30(ZA[785]);
- ZA[630] = ZA[566] + ZA[629];
- ZA[628] = ZA[627] + K[26];
-
- ZA[634] = ZR25(ZA[518]) + ZA[474];
- ZA[631] = ZR15(ZA[622]) + ZA[630];
- ZA[796] = ZA[778] + ZA[628];
- ZA[793] = ZA[775] + ZA[792];
- ZA[790] = ZA[787] + ZA[789];
-
- ZA[797] = (ZCh(ZA[793], ZA[788], ZA[783]) + ZA[796]) + ZR26(ZA[793]);
- ZA[794] = ZMa(ZA[785], ZA[780], ZA[790]) + ZR30(ZA[790]);
- ZA[491] = ZR25(ZA[482]);
- ZA[635] = ZA[567] + ZA[634];
- ZA[633] = ZA[631] + K[27];
-
- ZA[636] = ZR15(ZA[627]) + ZA[635];
- ZA[801] = ZA[783] + ZA[633];
- ZA[798] = ZA[780] + ZA[797];
- ZA[795] = ZA[792] + ZA[794];
- ZA[638] = ZA[491] + ZA[518];
-
- ZA[802] = (ZCh(ZA[798], ZA[793], ZA[788]) + ZA[801]) + ZR26(ZA[798]);
- ZA[799] = ZMa(ZA[790], ZA[785], ZA[795]) + ZR30(ZA[795]);
- ZA[639] = ZA[638] + ZA[614];
- ZA[637] = ZA[636] + K[28];
-
- ZA[642] = ZR25(ZA[528]) + ZA[482];
- ZA[640] = ZR15(ZA[631]) + ZA[639];
- ZA[806] = ZA[788] + ZA[637];
- ZA[803] = ZA[785] + ZA[802];
- ZA[800] = ZA[797] + ZA[799];
-
- ZA[807] = (ZCh(ZA[803], ZA[798], ZA[793]) + ZA[806]) + ZR26(ZA[803]);
- ZA[804] = ZMa(ZA[795], ZA[790], ZA[800]) + ZR30(ZA[800]);
- ZA[643] = ZA[616] + ZA[642];
- ZA[641] = ZA[640] + K[29];
-
- ZA[646] = ZR25(ZA[502]) + ZA[528];
- ZA[644] = ZR15(ZA[636]) + ZA[643];
- ZA[811] = ZA[793] + ZA[641];
- ZA[808] = ZA[790] + ZA[807];
- ZA[805] = ZA[802] + ZA[804];
-
- ZA[812] = (ZCh(ZA[808], ZA[803], ZA[798]) + ZA[811]) + ZR26(ZA[808]);
- ZA[809] = ZMa(ZA[800], ZA[795], ZA[805]) + ZR30(ZA[805]);
- ZA[647] = ZA[619] + ZA[646];
- ZA[645] = ZA[644] + K[30];
-
- ZA[650] = ZR25(ZA[537]) + ZA[502];
- ZA[648] = ZR15(ZA[640]) + ZA[647];
- ZA[816] = ZA[798] + ZA[645];
- ZA[813] = ZA[795] + ZA[812];
- ZA[810] = ZA[807] + ZA[809];
-
- ZA[817] = (ZCh(ZA[813], ZA[808], ZA[803]) + ZA[816]) + ZR26(ZA[813]);
- ZA[814] = ZMa(ZA[805], ZA[800], ZA[810]) + ZR30(ZA[810]);
- ZA[925] = ZA[622] + ZA[650];
- ZA[649] = ZA[648] + K[31];
-
- ZA[653] = ZR25(ZA[546]) + ZA[537];
- ZA[651] = ZR15(ZA[644]) + ZA[925];
- ZA[821] = ZA[803] + ZA[649];
- ZA[818] = ZA[800] + ZA[817];
- ZA[815] = ZA[812] + ZA[814];
-
- ZA[822] = (ZCh(ZA[818], ZA[813], ZA[808]) + ZA[821]) + ZR26(ZA[818]);
- ZA[819] = ZMa(ZA[810], ZA[805], ZA[815]) + ZR30(ZA[815]);
- ZA[654] = ZA[627] + ZA[653];
- ZA[652] = ZA[651] + K[32];
-
- ZA[657] = ZR25(ZA[554]) + ZA[546];
- ZA[655] = ZR15(ZA[648]) + ZA[654];
- ZA[826] = ZA[808] + ZA[652];
- ZA[823] = ZA[805] + ZA[822];
- ZA[820] = ZA[817] + ZA[819];
-
- ZA[827] = (ZCh(ZA[823], ZA[818], ZA[813]) + ZA[826]) + ZR26(ZA[823]);
- ZA[824] = ZMa(ZA[815], ZA[810], ZA[820]) + ZR30(ZA[820]);
- ZA[658] = ZA[631] + ZA[657];
- ZA[656] = ZA[655] + K[33];
-
- ZA[661] = ZR25(ZA[566]) + ZA[554];
- ZA[659] = ZR15(ZA[651]) + ZA[658];
- ZA[831] = ZA[813] + ZA[656];
- ZA[828] = ZA[810] + ZA[827];
- ZA[825] = ZA[822] + ZA[824];
-
- ZA[832] = (ZCh(ZA[828], ZA[823], ZA[818]) + ZA[831]) + ZR26(ZA[828]);
- ZA[829] = ZMa(ZA[820], ZA[815], ZA[825]) + ZR30(ZA[825]);
- ZA[662] = ZA[636] + ZA[661];
- ZA[660] = ZA[659] + K[34];
-
- ZA[665] = ZR25(ZA[567]) + ZA[566];
- ZA[663] = ZR15(ZA[655]) + ZA[662];
- ZA[836] = ZA[818] + ZA[660];
- ZA[833] = ZA[815] + ZA[832];
- ZA[830] = ZA[827] + ZA[829];
-
- ZA[837] = (ZCh(ZA[833], ZA[828], ZA[823]) + ZA[836]) + ZR26(ZA[833]);
- ZA[834] = ZMa(ZA[825], ZA[820], ZA[830]) + ZR30(ZA[830]);
- ZA[666] = ZA[640] + ZA[665];
- ZA[664] = ZA[663] + K[35];
-
- ZA[669] = ZR25(ZA[614]) + ZA[567];
- ZA[667] = ZR15(ZA[659]) + ZA[666];
- ZA[841] = ZA[823] + ZA[664];
- ZA[838] = ZA[820] + ZA[837];
- ZA[835] = ZA[832] + ZA[834];
-
- ZA[842] = (ZCh(ZA[838], ZA[833], ZA[828]) + ZA[841]) + ZR26(ZA[838]);
- ZA[839] = ZMa(ZA[830], ZA[825], ZA[835]) + ZR30(ZA[835]);
- ZA[670] = ZA[644] + ZA[669];
- ZA[668] = ZA[667] + K[36];
-
- ZA[677] = ZR25(ZA[616]) + ZA[614];
- ZA[671] = ZR15(ZA[663]) + ZA[670];
- ZA[846] = ZA[828] + ZA[668];
- ZA[843] = ZA[825] + ZA[842];
- ZA[840] = ZA[837] + ZA[839];
-
- ZA[847] = (ZCh(ZA[843], ZA[838], ZA[833]) + ZA[846]) + ZR26(ZA[843]);
- ZA[844] = ZMa(ZA[835], ZA[830], ZA[840]) + ZR30(ZA[840]);
- ZA[678] = ZA[648] + ZA[677];
- ZA[676] = ZA[671] + K[37];
-
- ZA[682] = ZR25(ZA[619]) + ZA[616];
- ZA[679] = ZR15(ZA[667]) + ZA[678];
- ZA[851] = ZA[833] + ZA[676];
- ZA[848] = ZA[830] + ZA[847];
- ZA[845] = ZA[842] + ZA[844];
-
- ZA[852] = (ZCh(ZA[848], ZA[843], ZA[838]) + ZA[851]) + ZR26(ZA[848]);
- ZA[849] = ZMa(ZA[840], ZA[835], ZA[845]) + ZR30(ZA[845]);
- ZA[683] = ZA[651] + ZA[682];
- ZA[680] = ZA[679] + K[38];
-
- ZA[686] = ZR25(ZA[622]) + ZA[619];
- ZA[684] = ZR15(ZA[671]) + ZA[683];
- ZA[856] = ZA[838] + ZA[680];
- ZA[853] = ZA[835] + ZA[852];
- ZA[850] = ZA[847] + ZA[849];
-
- ZA[857] = (ZCh(ZA[853], ZA[848], ZA[843]) + ZA[856]) + ZR26(ZA[853]);
- ZA[854] = ZMa(ZA[845], ZA[840], ZA[850]) + ZR30(ZA[850]);
- ZA[687] = ZA[655] + ZA[686];
- ZA[685] = ZA[684] + K[39];
-
- ZA[690] = ZR25(ZA[627]) + ZA[622];
- ZA[688] = ZR15(ZA[679]) + ZA[687];
- ZA[861] = ZA[843] + ZA[685];
- ZA[858] = ZA[840] + ZA[857];
- ZA[855] = ZA[852] + ZA[854];
-
- ZA[862] = (ZCh(ZA[858], ZA[853], ZA[848]) + ZA[861]) + ZR26(ZA[858]);
- ZA[859] = ZMa(ZA[850], ZA[845], ZA[855]) + ZR30(ZA[855]);
- ZA[691] = ZA[659] + ZA[690];
- ZA[689] = ZA[688] + K[40];
-
- ZA[694] = ZR25(ZA[631]) + ZA[627];
- ZA[692] = ZR15(ZA[684]) + ZA[691];
- ZA[866] = ZA[848] + ZA[689];
- ZA[863] = ZA[845] + ZA[862];
- ZA[860] = ZA[857] + ZA[859];
-
- ZA[867] = (ZCh(ZA[863], ZA[858], ZA[853]) + ZA[866]) + ZR26(ZA[863]);
- ZA[864] = ZMa(ZA[855], ZA[850], ZA[860]) + ZR30(ZA[860]);
- ZA[695] = ZA[663] + ZA[694];
- ZA[693] = ZA[692] + K[41];
-
- ZA[698] = ZR25(ZA[636]) + ZA[631];
- ZA[696] = ZR15(ZA[688]) + ZA[695];
- ZA[871] = ZA[853] + ZA[693];
- ZA[868] = ZA[850] + ZA[867];
- ZA[865] = ZA[862] + ZA[864];
-
- ZA[873] = (ZCh(ZA[868], ZA[863], ZA[858]) + ZA[871]) + ZR26(ZA[868]);
- ZA[869] = ZMa(ZA[860], ZA[855], ZA[865]) + ZR30(ZA[865]);
- ZA[699] = ZA[667] + ZA[698];
- ZA[697] = ZA[696] + K[42];
-
- ZA[702] = ZR25(ZA[640]) + ZA[636];
- ZA[700] = ZR15(ZA[692]) + ZA[699];
- ZA[877] = ZA[858] + ZA[697];
- ZA[874] = ZA[855] + ZA[873];
- ZA[870] = ZA[867] + ZA[869];
-
- ZA[878] = (ZCh(ZA[874], ZA[868], ZA[863]) + ZA[877]) + ZR26(ZA[874]);
- ZA[875] = ZMa(ZA[865], ZA[860], ZA[870]) + ZR30(ZA[870]);
- ZA[703] = ZA[671] + ZA[702];
- ZA[701] = ZA[700] + K[43];
-
- ZA[706] = ZR25(ZA[644]) + ZA[640];
- ZA[704] = ZR15(ZA[696]) + ZA[703];
- ZA[882] = ZA[863] + ZA[701];
- ZA[879] = ZA[860] + ZA[878];
- ZA[876] = ZA[873] + ZA[875];
-
- ZA[883] = (ZCh(ZA[879], ZA[874], ZA[868]) + ZA[882]) + ZR26(ZA[879]);
- ZA[880] = ZMa(ZA[870], ZA[865], ZA[876]) + ZR30(ZA[876]);
- ZA[707] = ZA[679] + ZA[706];
- ZA[705] = ZA[704] + K[44];
-
- ZA[710] = ZR25(ZA[648]) + ZA[644];
- ZA[708] = ZR15(ZA[700]) + ZA[707];
- ZA[887] = ZA[868] + ZA[705];
- ZA[884] = ZA[865] + ZA[883];
- ZA[881] = ZA[878] + ZA[880];
-
- ZA[888] = (ZCh(ZA[884], ZA[879], ZA[874]) + ZA[887]) + ZR26(ZA[884]);
- ZA[885] = ZMa(ZA[876], ZA[870], ZA[881]) + ZR30(ZA[881]);
- ZA[711] = ZA[684] + ZA[710];
- ZA[709] = ZA[708] + K[45];
-
- ZA[714] = ZR25(ZA[651]) + ZA[648];
- ZA[712] = ZR15(ZA[704]) + ZA[711];
- ZA[892] = ZA[874] + ZA[709];
- ZA[889] = ZA[870] + ZA[888];
- ZA[886] = ZA[883] + ZA[885];
-
- ZA[893] = (ZCh(ZA[889], ZA[884], ZA[879]) + ZA[892]) + ZR26(ZA[889]);
- ZA[890] = ZMa(ZA[881], ZA[876], ZA[886]) + ZR30(ZA[886]);
- ZA[715] = ZA[688] + ZA[714];
- ZA[713] = ZA[712] + K[46];
-
- ZA[718] = ZR25(ZA[655]) + ZA[651];
- ZA[716] = ZR15(ZA[708]) + ZA[715];
- ZA[897] = ZA[879] + ZA[713];
- ZA[894] = ZA[876] + ZA[893];
- ZA[891] = ZA[888] + ZA[890];
-
- ZA[898] = (ZCh(ZA[894], ZA[889], ZA[884]) + ZA[897]) + ZR26(ZA[894]);
- ZA[895] = ZMa(ZA[886], ZA[881], ZA[891]) + ZR30(ZA[891]);
- ZA[719] = ZA[692] + ZA[718];
- ZA[717] = ZA[716] + K[47];
-
- ZA[722] = ZR25(ZA[659]) + ZA[655];
- ZA[720] = ZR15(ZA[712]) + ZA[719];
- ZA[902] = ZA[884] + ZA[717];
- ZA[899] = ZA[881] + ZA[898];
- ZA[896] = ZA[893] + ZA[895];
-
- ZA[903] = (ZCh(ZA[899], ZA[894], ZA[889]) + ZA[902]) + ZR26(ZA[899]);
- ZA[900] = ZMa(ZA[891], ZA[886], ZA[896]) + ZR30(ZA[896]);
- ZA[723] = ZA[696] + ZA[722];
- ZA[721] = ZA[720] + K[48];
-
- ZA[672] = ZR25(ZA[663]) + ZA[659];
- ZA[724] = ZR15(ZA[716]) + ZA[723];
- ZA[907] = ZA[889] + ZA[721];
- ZA[904] = ZA[886] + ZA[903];
- ZA[901] = ZA[898] + ZA[900];
-
- ZA[908] = (ZCh(ZA[904], ZA[899], ZA[894]) + ZA[907]) + ZR26(ZA[904]);
- ZA[905] = ZMa(ZA[896], ZA[891], ZA[901]) + ZR30(ZA[901]);
- ZA[673] = ZR25(ZA[667]) + ZA[663];
- ZA[726] = ZA[700] + ZA[672];
- ZA[725] = ZA[724] + K[49];
-
- ZA[727] = ZR15(ZA[720]) + ZA[726];
- ZA[912] = ZA[894] + ZA[725];
- ZA[909] = ZA[891] + ZA[908];
- ZA[906] = ZA[903] + ZA[905];
- ZA[675] = ZA[667] + K[52];
- ZA[729] = ZA[704] + ZA[673];
-
- ZA[913] = (ZCh(ZA[909], ZA[904], ZA[899]) + ZA[912]) + ZR26(ZA[909]);
- ZA[910] = ZMa(ZA[901], ZA[896], ZA[906]) + ZR30(ZA[906]);
- ZA[674] = ZR25(ZA[671]) + ZA[675];
- ZA[730] = ZR15(ZA[724]) + ZA[729];
- ZA[728] = ZA[727] + K[50];
-
- ZA[681] = ZR25(ZA[679]) + ZA[671];
- ZA[917] = ZA[899] + ZA[901] + ZA[728];
- ZA[914] = ZA[896] + ZA[913];
- ZA[911] = ZA[908] + ZA[910];
- ZA[732] = ZA[708] + ZA[674];
- ZA[731] = ZA[730] + K[51];
-
- ZA[918] = (ZCh(ZA[914], ZA[909], ZA[904]) + ZA[917]) + ZR26(ZA[914]);
- ZA[915] = ZMa(ZA[906], ZA[901], ZA[911]) + ZR30(ZA[911]);
- ZA[733] = ZR15(ZA[727]) + ZA[732];
- ZA[919] = ZA[906] + ZA[904] + ZA[731];
- ZA[734] = ZA[712] + ZA[681];
-
- ZA[920] = (ZCh(ZA[918], ZA[914], ZA[909]) + ZA[919]) + ZR26(ZA[918]);
- ZA[735] = ZR15(ZA[730]) + ZA[734];
- ZA[921] = ZA[911] + ZA[909] + ZA[733];
- ZA[916] = ZA[913] + ZA[915];
-
- ZA[922] = (ZCh(ZA[920], ZA[918], ZA[914]) + ZA[921]) + ZR26(ZA[920]);
- ZA[923] = ZA[916] + ZA[914] + ZA[735];
-
- ZA[924] = (ZCh(ZA[922], ZA[920], ZA[918]) + ZA[923]) + ZR26(ZA[922]);
-
-#define FOUND (0x0F)
-#define SETFOUND(Xnonce) output[output[FOUND]++] = Xnonce
-
-#if defined(VECTORS4)
- bool result = any(ZA[924] == K[79]);
-
- if (result) {
- if (ZA[924].x == K[79])
- SETFOUND(Znonce.x);
- if (ZA[924].y == K[79])
- SETFOUND(Znonce.y);
- if (ZA[924].z == K[79])
- SETFOUND(Znonce.z);
- if (ZA[924].w == K[79])
- SETFOUND(Znonce.w);
- }
-#elif defined(VECTORS2)
- bool result = any(ZA[924] == K[79]);
-
- if (result) {
- if (ZA[924].x == K[79])
- SETFOUND(Znonce.x);
- if (ZA[924].y == K[79])
- SETFOUND(Znonce.y);
- }
-#else
- if (ZA[924] == K[79])
- SETFOUND(Znonce);
-#endif
-}
diff --git a/diakgcn121016.cl b/diakgcn121016.cl
deleted file mode 100644
index b87fbde..0000000
--- a/diakgcn121016.cl
+++ /dev/null
@@ -1,599 +0,0 @@
-// DiaKGCN 27-04-2012 - OpenCL kernel by Diapolo
-//
-// Parts and / or ideas for this kernel are based upon the public-domain poclbm project, the phatk kernel by Phateus and the DiabloMiner kernel by DiabloD3.
-// The kernel was rewritten by me (Diapolo) and is still public-domain!
-
-#ifdef VECTORS4
- typedef uint4 u;
-#elif defined VECTORS2
- typedef uint2 u;
-#else
- typedef uint u;
-#endif
-
-#ifdef BITALIGN
- #pragma OPENCL EXTENSION cl_amd_media_ops : enable
- #ifdef BFI_INT
- #define ch(x, y, z) amd_bytealign(x, y, z)
- #define ma(x, y, z) amd_bytealign(z ^ x, y, x)
- #else
- #define ch(x, y, z) bitselect(z, y, x)
- #define ma(z, x, y) bitselect(z, y, z ^ x)
- #endif
-#else
- #define ch(x, y, z) (z ^ (x & (y ^ z)))
- #define ma(x, y, z) ((x & z) | (y & (x | z)))
-#endif
-
-#define rotr15(n) (rotate(n, 15U) ^ rotate(n, 13U) ^ (n >> 10U))
-#define rotr25(n) (rotate(n, 25U) ^ rotate(n, 14U) ^ (n >> 3U))
-#define rotr26(n) (rotate(n, 26U) ^ rotate(n, 21U) ^ rotate(n, 7U))
-#define rotr30(n) (rotate(n, 30U) ^ rotate(n, 19U) ^ rotate(n, 10U))
-
-__kernel
- __attribute__((reqd_work_group_size(WORKSIZE, 1, 1)))
- void search(
-#ifndef GOFFSET
- const u base,
-#endif
- const uint PreVal0, const uint PreVal4,
- const uint H1, const uint D1A, const uint B1, const uint C1,
- const uint F1, const uint G1, const uint C1addK5, const uint B1addK6, const uint PreVal0addK7,
- const uint W16addK16, const uint W17addK17,
- const uint PreW18, const uint PreW19,
- const uint W16, const uint W17,
- const uint PreW31, const uint PreW32,
- const uint state0, const uint state1, const uint state2, const uint state3,
- const uint state4, const uint state5, const uint state6, const uint state7,
- const uint state0A, const uint state0B,
- const uint state1A, const uint state2A, const uint state3A, const uint state4A,
- const uint state5A, const uint state6A, const uint state7A,
- volatile __global uint * output)
-{
- u V[8];
- u W[16];
-
-#ifdef VECTORS4
- const u nonce = (uint)(get_local_id(0)) * 4U + (uint)(get_group_id(0)) * (uint)(WORKVEC) + base;
-#elif defined VECTORS2
- const u nonce = (uint)(get_local_id(0)) * 2U + (uint)(get_group_id(0)) * (uint)(WORKVEC) + base;
-#else
- #ifdef GOFFSET
- const u nonce = (uint)(get_global_id(0));
- #else
- const u nonce = (uint)(get_local_id(0)) + (uint)(get_group_id(0)) * (uint)(WORKSIZE) + base;
- #endif
-#endif
-
- V[0] = PreVal0 + nonce;
- V[1] = B1;
- V[2] = C1;
- V[3] = D1A;
- V[4] = PreVal4 + nonce;
- V[5] = F1;
- V[6] = G1;
- V[7] = H1;
-
- V[7] += V[3] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = V[3] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += C1addK5 + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = C1addK5 + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += B1addK6 + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = B1addK6 + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += PreVal0addK7 + nonce + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = PreVal0addK7 + nonce + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0xd807aa98U + V[7] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0xd807aa98U + V[7] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0x12835b01U + V[6] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0x12835b01U + V[6] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0x243185beU + V[5] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0x243185beU + V[5] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0x550c7dc3U + V[4] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0x550c7dc3U + V[4] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0x72be5d74U + V[3] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0x72be5d74U + V[3] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0x80deb1feU + V[2] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0x80deb1feU + V[2] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x9bdc06a7U + V[1] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x9bdc06a7U + V[1] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0xc19bf3f4U + V[0] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0xc19bf3f4U + V[0] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += W16addK16 + V[7] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = W16addK16 + V[7] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += W17addK17 + V[6] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = W17addK17 + V[6] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
-//----------------------------------------------------------------------------------
-
-#ifdef VECTORS4
- W[0] = PreW18 + (u)(rotr25(nonce.x), rotr25(nonce.x) ^ 0x2004000U, rotr25(nonce.x) ^ 0x4008000U, rotr25(nonce.x) ^ 0x600c000U);
-#elif defined VECTORS2
- W[0] = PreW18 + (u)(rotr25(nonce.x), rotr25(nonce.x) ^ 0x2004000U);
-#else
- W[0] = PreW18 + rotr25(nonce);
-#endif
- W[1] = PreW19 + nonce;
- W[2] = 0x80000000U + rotr15(W[0]);
- W[3] = rotr15(W[1]);
- W[4] = 0x00000280U + rotr15(W[2]);
- W[5] = W16 + rotr15(W[3]);
- W[6] = W17 + rotr15(W[4]);
- W[7] = W[0] + rotr15(W[5]);
- W[8] = W[1] + rotr15(W[6]);
- W[9] = W[2] + rotr15(W[7]);
- W[10] = W[3] + rotr15(W[8]);
- W[11] = W[4] + rotr15(W[9]);
- W[12] = W[5] + 0x00a00055U + rotr15(W[10]);
- W[13] = W[6] + PreW31 + rotr15(W[11]);
- W[14] = W[7] + PreW32 + rotr15(W[12]);
- W[15] = W[8] + W17 + rotr15(W[13]) + rotr25(W[0]);
-
- V[1] += 0x0fc19dc6U + V[5] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + W[0];
- V[5] = 0x0fc19dc6U + V[5] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + W[0] + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0x240ca1ccU + V[4] + W[1] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0x240ca1ccU + V[4] + W[1] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0x2de92c6fU + V[3] + W[2] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0x2de92c6fU + V[3] + W[2] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0x4a7484aaU + V[2] + W[3] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0x4a7484aaU + V[2] + W[3] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x5cb0a9dcU + V[1] + W[4] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x5cb0a9dcU + V[1] + W[4] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x76f988daU + V[0] + W[5] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x76f988daU + V[0] + W[5] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0x983e5152U + V[7] + W[6] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0x983e5152U + V[7] + W[6] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0xa831c66dU + V[6] + W[7] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0xa831c66dU + V[6] + W[7] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0xb00327c8U + V[5] + W[8] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0xb00327c8U + V[5] + W[8] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0xbf597fc7U + V[4] + W[9] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0xbf597fc7U + V[4] + W[9] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0xc6e00bf3U + V[3] + W[10] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0xc6e00bf3U + V[3] + W[10] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0xd5a79147U + V[2] + W[11] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0xd5a79147U + V[2] + W[11] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x06ca6351U + V[1] + W[12] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x06ca6351U + V[1] + W[12] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x14292967U + V[0] + W[13] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x14292967U + V[0] + W[13] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0x27b70a85U + V[7] + W[14] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0x27b70a85U + V[7] + W[14] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0x2e1b2138U + V[6] + W[15] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0x2e1b2138U + V[6] + W[15] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
-//----------------------------------------------------------------------------------
-
- W[0] = W[0] + W[9] + rotr15(W[14]) + rotr25( W[1]);
- W[1] = W[1] + W[10] + rotr15(W[15]) + rotr25( W[2]);
- W[2] = W[2] + W[11] + rotr15( W[0]) + rotr25( W[3]);
- W[3] = W[3] + W[12] + rotr15( W[1]) + rotr25( W[4]);
- W[4] = W[4] + W[13] + rotr15( W[2]) + rotr25( W[5]);
- W[5] = W[5] + W[14] + rotr15( W[3]) + rotr25( W[6]);
- W[6] = W[6] + W[15] + rotr15( W[4]) + rotr25( W[7]);
- W[7] = W[7] + W[0] + rotr15( W[5]) + rotr25( W[8]);
- W[8] = W[8] + W[1] + rotr15( W[6]) + rotr25( W[9]);
- W[9] = W[9] + W[2] + rotr15( W[7]) + rotr25(W[10]);
- W[10] = W[10] + W[3] + rotr15( W[8]) + rotr25(W[11]);
- W[11] = W[11] + W[4] + rotr15( W[9]) + rotr25(W[12]);
- W[12] = W[12] + W[5] + rotr15(W[10]) + rotr25(W[13]);
- W[13] = W[13] + W[6] + rotr15(W[11]) + rotr25(W[14]);
- W[14] = W[14] + W[7] + rotr15(W[12]) + rotr25(W[15]);
- W[15] = W[15] + W[8] + rotr15(W[13]) + rotr25( W[0]);
-
- V[1] += 0x4d2c6dfcU + V[5] + W[0] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0x4d2c6dfcU + V[5] + W[0] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0x53380d13U + V[4] + W[1] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0x53380d13U + V[4] + W[1] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0x650a7354U + V[3] + W[2] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0x650a7354U + V[3] + W[2] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0x766a0abbU + V[2] + W[3] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0x766a0abbU + V[2] + W[3] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x81c2c92eU + V[1] + W[4] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x81c2c92eU + V[1] + W[4] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x92722c85U + V[0] + W[5] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x92722c85U + V[0] + W[5] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0xa2bfe8a1U + V[7] + W[6] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0xa2bfe8a1U + V[7] + W[6] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0xa81a664bU + V[6] + W[7] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0xa81a664bU + V[6] + W[7] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0xc24b8b70U + V[5] + W[8] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0xc24b8b70U + V[5] + W[8] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0xc76c51a3U + V[4] + W[9] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0xc76c51a3U + V[4] + W[9] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0xd192e819U + V[3] + W[10] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0xd192e819U + V[3] + W[10] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0xd6990624U + V[2] + W[11] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0xd6990624U + V[2] + W[11] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0xf40e3585U + V[1] + W[12] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0xf40e3585U + V[1] + W[12] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x106aa070U + V[0] + W[13] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x106aa070U + V[0] + W[13] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0x19a4c116U + V[7] + W[14] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0x19a4c116U + V[7] + W[14] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0x1e376c08U + V[6] + W[15] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0x1e376c08U + V[6] + W[15] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
-//----------------------------------------------------------------------------------
-
- W[0] = W[0] + W[9] + rotr15(W[14]) + rotr25( W[1]);
- W[1] = W[1] + W[10] + rotr15(W[15]) + rotr25( W[2]);
- W[2] = W[2] + W[11] + rotr15( W[0]) + rotr25( W[3]);
- W[3] = W[3] + W[12] + rotr15( W[1]) + rotr25( W[4]);
- W[4] = W[4] + W[13] + rotr15( W[2]) + rotr25( W[5]);
- W[5] = W[5] + W[14] + rotr15( W[3]) + rotr25( W[6]);
- W[6] = W[6] + W[15] + rotr15( W[4]) + rotr25( W[7]);
- W[7] = W[7] + W[0] + rotr15( W[5]) + rotr25( W[8]);
- W[8] = W[8] + W[1] + rotr15( W[6]) + rotr25( W[9]);
- W[9] = W[9] + W[2] + rotr15( W[7]) + rotr25(W[10]);
- W[10] = W[10] + W[3] + rotr15( W[8]) + rotr25(W[11]);
- W[11] = W[11] + W[4] + rotr15( W[9]) + rotr25(W[12]);
- W[12] = W[12] + W[5] + rotr15(W[10]) + rotr25(W[13]);
- W[13] = W[13] + W[6] + rotr15(W[11]) + rotr25(W[14]);
-
- V[1] += 0x2748774cU + V[5] + W[0] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0x2748774cU + V[5] + W[0] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0x34b0bcb5U + V[4] + W[1] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0x34b0bcb5U + V[4] + W[1] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0x391c0cb3U + V[3] + W[2] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0x391c0cb3U + V[3] + W[2] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0x4ed8aa4aU + V[2] + W[3] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0x4ed8aa4aU + V[2] + W[3] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x5b9cca4fU + V[1] + W[4] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x5b9cca4fU + V[1] + W[4] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x682e6ff3U + V[0] + W[5] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x682e6ff3U + V[0] + W[5] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0x748f82eeU + V[7] + W[6] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0x748f82eeU + V[7] + W[6] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0x78a5636fU + V[6] + W[7] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0x78a5636fU + V[6] + W[7] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0x84c87814U + V[5] + W[8] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0x84c87814U + V[5] + W[8] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0x8cc70208U + V[4] + W[9] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0x8cc70208U + V[4] + W[9] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0x90befffaU + V[3] + W[10] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0x90befffaU + V[3] + W[10] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0xa4506cebU + V[2] + W[11] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0xa4506cebU + V[2] + W[11] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0xbef9a3f7U + V[1] + W[12] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0xbef9a3f7U + V[1] + W[12] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0xc67178f2U + V[0] + W[13] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0xc67178f2U + V[0] + W[13] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
-//----------------------------------------------------------------------------------
-
- W[0] = state0 + V[0] + rotr25(state1 + V[1]);
- W[1] = state1 + V[1] + 0x00a00000U + rotr25(state2 + V[2]);
- W[2] = state2 + V[2] + rotr15(W[0]) + rotr25(state3 + V[3]);
- W[3] = state3 + V[3] + rotr15(W[1]) + rotr25(state4 + V[4]);
- W[4] = state4 + V[4] + rotr15(W[2]) + rotr25(state5 + V[5]);
- W[5] = state5 + V[5] + rotr15(W[3]) + rotr25(state6 + V[6]);
- W[6] = state6 + V[6] + 0x00000100U + rotr15(W[4]) + rotr25(state7 + V[7]);
- W[7] = state7 + V[7] + W[0] + 0x11002000U + rotr15(W[5]);
- W[8] = W[1] + 0x80000000U + rotr15(W[6]);
- W[9] = W[2] + rotr15(W[7]);
- W[10] = W[3] + rotr15(W[8]);
- W[11] = W[4] + rotr15(W[9]);
- W[12] = W[5] + rotr15(W[10]);
- W[13] = W[6] + rotr15(W[11]);
- W[14] = W[7] + 0x00400022U + rotr15(W[12]);
- W[15] = W[8] + 0x00000100U + rotr15(W[13]) + rotr25(W[0]);
-
- // 0x71374491U + 0x1f83d9abU + state1
- const u state1AaddV1 = state1A + V[1];
- // 0xb5c0fbcfU + 0x9b05688cU + state2
- const u state2AaddV2 = state2A + V[2];
- // 0x510e527fU + 0xe9b5dba5U + state3
- const u state3AaddV3 = state3A + V[3];
- // 0x3956c25bU + state4
- const u state4AaddV4 = state4A + V[4];
- // 0x59f111f1U + state5
- const u state5AaddV5 = state5A + V[5];
- // 0x923f82a4U + state6
- const u state6AaddV6 = state6A + V[6];
- // 0xab1c5ed5U + state7
- const u state7AaddV7 = state7A + V[7];
-
- // 0x98c7e2a2U + state0
- V[3] = state0A + V[0];
- // 0xfc08884dU + state0
- V[7] = state0B + V[0];
- V[0] = 0x6a09e667U;
- V[1] = 0xbb67ae85U;
- V[2] = 0x3c6ef372U;
- V[4] = 0x510e527fU;
- V[5] = 0x9b05688cU;
- V[6] = 0x1f83d9abU;
-
- V[2] += state1AaddV1 + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = state1AaddV1 + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += state2AaddV2 + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = state2AaddV2 + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += state3AaddV3 + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = state3AaddV3 + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += state4AaddV4 + V[3] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = state4AaddV4 + V[3] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += state5AaddV5 + V[2] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = state5AaddV5 + V[2] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += state6AaddV6 + V[1] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = state6AaddV6 + V[1] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += state7AaddV7 + V[0] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = state7AaddV7 + V[0] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0x5807aa98U + V[7] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0x5807aa98U + V[7] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0x12835b01U + V[6] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0x12835b01U + V[6] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0x243185beU + V[5] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0x243185beU + V[5] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0x550c7dc3U + V[4] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0x550c7dc3U + V[4] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0x72be5d74U + V[3] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0x72be5d74U + V[3] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0x80deb1feU + V[2] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0x80deb1feU + V[2] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x9bdc06a7U + V[1] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x9bdc06a7U + V[1] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0xc19bf274U + V[0] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0xc19bf274U + V[0] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0xe49b69c1U + V[7] + W[0] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0xe49b69c1U + V[7] + W[0] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0xefbe4786U + V[6] + W[1] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0xefbe4786U + V[6] + W[1] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0x0fc19dc6U + V[5] + W[2] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0x0fc19dc6U + V[5] + W[2] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0x240ca1ccU + V[4] + W[3] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0x240ca1ccU + V[4] + W[3] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0x2de92c6fU + V[3] + W[4] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0x2de92c6fU + V[3] + W[4] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0x4a7484aaU + V[2] + W[5] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0x4a7484aaU + V[2] + W[5] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x5cb0a9dcU + V[1] + W[6] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x5cb0a9dcU + V[1] + W[6] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x76f988daU + V[0] + W[7] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x76f988daU + V[0] + W[7] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0x983e5152U + V[7] + W[8] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0x983e5152U + V[7] + W[8] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0xa831c66dU + V[6] + W[9] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0xa831c66dU + V[6] + W[9] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0xb00327c8U + V[5] + W[10] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0xb00327c8U + V[5] + W[10] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0xbf597fc7U + V[4] + W[11] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0xbf597fc7U + V[4] + W[11] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0xc6e00bf3U + V[3] + W[12] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0xc6e00bf3U + V[3] + W[12] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0xd5a79147U + V[2] + W[13] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0xd5a79147U + V[2] + W[13] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x06ca6351U + V[1] + W[14] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x06ca6351U + V[1] + W[14] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x14292967U + V[0] + W[15] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x14292967U + V[0] + W[15] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
-//----------------------------------------------------------------------------------
-
- W[0] = W[0] + W[9] + rotr15(W[14]) + rotr25( W[1]);
- W[1] = W[1] + W[10] + rotr15(W[15]) + rotr25( W[2]);
- W[2] = W[2] + W[11] + rotr15( W[0]) + rotr25( W[3]);
- W[3] = W[3] + W[12] + rotr15( W[1]) + rotr25( W[4]);
- W[4] = W[4] + W[13] + rotr15( W[2]) + rotr25( W[5]);
- W[5] = W[5] + W[14] + rotr15( W[3]) + rotr25( W[6]);
- W[6] = W[6] + W[15] + rotr15( W[4]) + rotr25( W[7]);
- W[7] = W[7] + W[0] + rotr15( W[5]) + rotr25( W[8]);
- W[8] = W[8] + W[1] + rotr15( W[6]) + rotr25( W[9]);
- W[9] = W[9] + W[2] + rotr15( W[7]) + rotr25(W[10]);
- W[10] = W[10] + W[3] + rotr15( W[8]) + rotr25(W[11]);
- W[11] = W[11] + W[4] + rotr15( W[9]) + rotr25(W[12]);
- W[12] = W[12] + W[5] + rotr15(W[10]) + rotr25(W[13]);
- W[13] = W[13] + W[6] + rotr15(W[11]) + rotr25(W[14]);
- W[14] = W[14] + W[7] + rotr15(W[12]) + rotr25(W[15]);
- W[15] = W[15] + W[8] + rotr15(W[13]) + rotr25( W[0]);
-
- V[3] += 0x27b70a85U + V[7] + W[0] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0x27b70a85U + V[7] + W[0] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0x2e1b2138U + V[6] + W[1] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0x2e1b2138U + V[6] + W[1] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0x4d2c6dfcU + V[5] + W[2] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0x4d2c6dfcU + V[5] + W[2] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0x53380d13U + V[4] + W[3] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0x53380d13U + V[4] + W[3] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0x650a7354U + V[3] + W[4] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0x650a7354U + V[3] + W[4] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0x766a0abbU + V[2] + W[5] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0x766a0abbU + V[2] + W[5] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x81c2c92eU + V[1] + W[6] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x81c2c92eU + V[1] + W[6] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x92722c85U + V[0] + W[7] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x92722c85U + V[0] + W[7] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0xa2bfe8a1U + V[7] + W[8] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0xa2bfe8a1U + V[7] + W[8] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0xa81a664bU + V[6] + W[9] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0xa81a664bU + V[6] + W[9] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0xc24b8b70U + V[5] + W[10] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0xc24b8b70U + V[5] + W[10] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0xc76c51a3U + V[4] + W[11] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0xc76c51a3U + V[4] + W[11] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0xd192e819U + V[3] + W[12] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0xd192e819U + V[3] + W[12] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0xd6990624U + V[2] + W[13] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0xd6990624U + V[2] + W[13] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0xf40e3585U + V[1] + W[14] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0xf40e3585U + V[1] + W[14] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x106aa070U + V[0] + W[15] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x106aa070U + V[0] + W[15] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
-//----------------------------------------------------------------------------------
-
- W[0] = W[0] + W[9] + rotr15(W[14]) + rotr25( W[1]);
- W[1] = W[1] + W[10] + rotr15(W[15]) + rotr25( W[2]);
- W[2] = W[2] + W[11] + rotr15( W[0]) + rotr25( W[3]);
- W[3] = W[3] + W[12] + rotr15( W[1]) + rotr25( W[4]);
- W[4] = W[4] + W[13] + rotr15( W[2]) + rotr25( W[5]);
- W[5] = W[5] + W[14] + rotr15( W[3]) + rotr25( W[6]);
- W[6] = W[6] + W[15] + rotr15( W[4]) + rotr25( W[7]);
- W[7] = W[7] + W[0] + rotr15( W[5]) + rotr25( W[8]);
- W[8] = W[8] + W[1] + rotr15( W[6]) + rotr25( W[9]);
- W[9] = W[9] + W[2] + rotr15( W[7]) + rotr25(W[10]);
- W[10] = W[10] + W[3] + rotr15( W[8]) + rotr25(W[11]);
- W[11] = W[11] + W[4] + rotr15( W[9]) + rotr25(W[12]);
- W[12] = W[12] + W[5] + rotr15(W[10]) + rotr25(W[13]);
-
- V[3] += 0x19a4c116U + V[7] + W[0] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0x19a4c116U + V[7] + W[0] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0x1e376c08U + V[6] + W[1] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
- V[6] = 0x1e376c08U + V[6] + W[1] + ch(V[3], V[4], V[5]) + rotr26(V[3]) + rotr30(V[7]) + ma(V[0], V[1], V[7]);
-
- V[1] += 0x2748774cU + V[5] + W[2] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
- V[5] = 0x2748774cU + V[5] + W[2] + ch(V[2], V[3], V[4]) + rotr26(V[2]) + rotr30(V[6]) + ma(V[7], V[0], V[6]);
-
- V[0] += 0x34b0bcb5U + V[4] + W[3] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
- V[4] = 0x34b0bcb5U + V[4] + W[3] + ch(V[1], V[2], V[3]) + rotr26(V[1]) + rotr30(V[5]) + ma(V[6], V[7], V[5]);
-
- V[7] += 0x391c0cb3U + V[3] + W[4] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
- V[3] = 0x391c0cb3U + V[3] + W[4] + ch(V[0], V[1], V[2]) + rotr26(V[0]) + rotr30(V[4]) + ma(V[5], V[6], V[4]);
-
- V[6] += 0x4ed8aa4aU + V[2] + W[5] + ch(V[7], V[0], V[1]) + rotr26(V[7]);
- V[2] = 0x4ed8aa4aU + V[2] + W[5] + ch(V[7], V[0], V[1]) + rotr26(V[7]) + rotr30(V[3]) + ma(V[4], V[5], V[3]);
-
- V[5] += 0x5b9cca4fU + V[1] + W[6] + ch(V[6], V[7], V[0]) + rotr26(V[6]);
- V[1] = 0x5b9cca4fU + V[1] + W[6] + ch(V[6], V[7], V[0]) + rotr26(V[6]) + rotr30(V[2]) + ma(V[3], V[4], V[2]);
-
- V[4] += 0x682e6ff3U + V[0] + W[7] + ch(V[5], V[6], V[7]) + rotr26(V[5]);
- V[0] = 0x682e6ff3U + V[0] + W[7] + ch(V[5], V[6], V[7]) + rotr26(V[5]) + rotr30(V[1]) + ma(V[2], V[3], V[1]);
-
- V[3] += 0x748f82eeU + V[7] + W[8] + ch(V[4], V[5], V[6]) + rotr26(V[4]);
- V[7] = 0x748f82eeU + V[7] + W[8] + ch(V[4], V[5], V[6]) + rotr26(V[4]) + rotr30(V[0]) + ma(V[1], V[2], V[0]);
-
- V[2] += 0x78a5636fU + V[6] + W[9] + ch(V[3], V[4], V[5]) + rotr26(V[3]);
-
- V[1] += 0x84c87814U + V[5] + W[10] + ch(V[2], V[3], V[4]) + rotr26(V[2]);
-
- V[0] += 0x8cc70208U + V[4] + W[11] + ch(V[1], V[2], V[3]) + rotr26(V[1]);
-
- V[7] += V[3] + W[12] + ch(V[0], V[1], V[2]) + rotr26(V[0]);
-
-#define FOUND (0x0F)
-#define SETFOUND(Xnonce) output[output[FOUND]++] = Xnonce
-
-#ifdef VECTORS4
- if ((V[7].x == 0x136032edU) ^ (V[7].y == 0x136032edU) ^ (V[7].z == 0x136032edU) ^ (V[7].w == 0x136032edU)) {
- if (V[7].x == 0x136032edU)
- SETFOUND(nonce.x);
- if (V[7].y == 0x136032edU)
- SETFOUND(nonce.y);
- if (V[7].z == 0x136032edU)
- SETFOUND(nonce.z);
- if (V[7].w == 0x136032edU)
- SETFOUND(nonce.w);
- }
-#elif defined VECTORS2
- if ((V[7].x == 0x136032edU) + (V[7].y == 0x136032edU)) {
- if (V[7].x == 0x136032edU)
- SETFOUND(nonce.x);
- if (V[7].y == 0x136032edU)
- SETFOUND(nonce.y);
- }
-#else
- if (V[7] == 0x136032edU)
- SETFOUND(nonce);
-#endif
-}
diff --git a/driver-avalon.c b/driver-avalon.c
index 8a892d8..db94436 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -291,14 +291,31 @@ static inline bool avalon_cts(char c)
static int avalon_read(struct cgpu_info *avalon, char *buf, size_t bufsize, int ep)
{
- int err, amount;
+ size_t total = 0, readsize = bufsize + 2;
+ char readbuf[AVALON_READBUF_SIZE];
+ int err, amount, ofs = 2, cp;
- err = usb_read_once(avalon, buf, bufsize, &amount, ep);
+ err = usb_read_once(avalon, readbuf, readsize, &amount, ep);
applog(LOG_DEBUG, "%s%i: Get avalon read got err %d",
avalon->drv->name, avalon->device_id, err);
- if (unlikely(err && err != LIBUSB_ERROR_TIMEOUT))
- amount = -1;
- return amount;
+ if (err && err != LIBUSB_ERROR_TIMEOUT)
+ return err;
+
+ if (amount < 2)
+ goto out;
+
+ /* The first 2 of every 64 bytes are status on FTDIRL */
+ while (amount > 2) {
+ cp = amount - 2;
+ if (cp > 62)
+ cp = 62;
+ memcpy(&buf[total], &readbuf[ofs], cp);
+ total += cp;
+ amount -= cp + 2;
+ ofs += 64;
+ }
+out:
+ return total;
}
static int avalon_reset(struct cgpu_info *avalon, bool initial)
@@ -561,7 +578,8 @@ static void avalon_idle(struct cgpu_info *avalon, struct avalon_info *info)
avalon_init_task(&at, 0, 0, info->fan_pwm, info->timeout,
info->asic_count, info->miner_count, 1, 1,
info->frequency);
- avalon_send_task(&at, avalon, info);
+ if (avalon_send_task(&at, avalon, info) == AVA_SEND_ERROR)
+ break;
}
applog(LOG_WARNING, "%s%i: Idling %d miners", avalon->drv->name, avalon->device_id, i);
wait_avalon_ready(avalon);
@@ -761,7 +779,9 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
&asic_count, &timeout, &frequency,
(usb_ident(avalon) == IDENT_BBF && opt_bitburner_fury_options != NULL) ? opt_bitburner_fury_options : opt_avalon_options);
- avalon->usbdev->usb_type = USB_TYPE_FTDI;
+ /* Even though this is an FTDI type chip, we want to do the parsing
+ * all ourselves so set it to std usb type */
+ avalon->usbdev->usb_type = USB_TYPE_STD;
/* We have a real Avalon! */
avalon_initialise(avalon);
diff --git a/driver-avalon.h b/driver-avalon.h
index 0a11161..9111291 100644
--- a/driver-avalon.h
+++ b/driver-avalon.h
@@ -65,7 +65,8 @@
#define AVALON_FTDI_READSIZE 510
#define AVALON_READBUF_SIZE 8192
-#define AVALON_LATENCY 16 /* This is basically the ftdi default anyway */
+/* Set latency to just less than full 64 byte packet size at 115200 baud */
+#define AVALON_LATENCY 4
struct avalon_task {
uint8_t reset :1;
diff --git a/driver-bab.c b/driver-bab.c
new file mode 100644
index 0000000..7db3df1
--- /dev/null
+++ b/driver-bab.c
@@ -0,0 +1,1871 @@
+/*
+ * Copyright 2013 Andrew Smith
+ * Copyright 2013 bitfury
+ *
+ * BitFury GPIO code based on chainminer code:
+ * https://github.com/bfsb/chainminer
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version. See COPYING for more details.
+ */
+
+#include "config.h"
+#include "compat.h"
+#include "miner.h"
+#include "sha2.h"
+
+/*
+ * Tested on RPi running both Raspbian and Arch
+ * with BlackArrow BitFury V1 16 chip GPIO board
+ */
+
+#ifndef LINUX
+static void bab_detect(__maybe_unused bool hotplug)
+{
+}
+#else
+
+#include <unistd.h>
+#include <linux/spi/spidev.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+
+#define BAB_SPI_BUS 0
+#define BAB_SPI_CHIP 0
+
+#define BAB_SPI_SPEED 96000
+#define BAB_SPI_BUFSIZ 1024
+
+#define BAB_ADDR(_n) (*((babinfo->gpio) + (_n)))
+
+#define BAB_INP_GPIO(_n) BAB_ADDR((_n) / 10) &= (~(7 << (((_n) % 10) * 3)))
+#define BAB_OUT_GPIO(_n) BAB_ADDR((_n) / 10) |= (1 << (((_n) % 10) * 3))
+#define BAB_OUT_GPIO_V(_n, _v) BAB_ADDR((_n) / 10) |= (((_v) <= 3 ? (_v) + 4 : \
+ ((_v) == 4 ? 3 : 2)) << (((_n) % 10) * 3))
+
+#define BAB_GPIO_SET BAB_ADDR(7)
+#define BAB_GPIO_CLR BAB_ADDR(10)
+#define BAB_GPIO_LEVEL BAB_ADDR(13)
+
+#define BAB_MAXCHIPS 256
+#define BAB_MAXBUF (BAB_MAXCHIPS * 512)
+#define BAB_MAXBANKS 4
+#define BAB_CORES 16
+#define BAB_X_COORD 21
+#define BAB_Y_COORD 36
+
+#define BAB_BREAK ((uint8_t *)"\04")
+#define BAB_ASYNC ((uint8_t *)"\05")
+#define BAB_SYNC ((uint8_t *)"\06")
+
+#define BAB_FFL " - from %s %s() line %d"
+#define BAB_FFL_HERE __FILE__, __func__, __LINE__
+#define BAB_FFL_PASS file, func, line
+
+#define bab_reset(_bank, _times) _bab_reset(babcgpu, babinfo, _bank, _times)
+#define bab_txrx(_buf, _siz, _det) _bab_txrx(babcgpu, babinfo, _buf, _siz, _det, BAB_FFL_HERE)
+#define bab_add_buf(_data) _bab_add_buf(babcgpu, babinfo, _data, sizeof(_data)-1, BAB_FFL_HERE)
+#define BAB_ADD_BREAK() _bab_add_buf(babcgpu, babinfo, BAB_BREAK, 1, BAB_FFL_HERE)
+#define BAB_ADD_ASYNC() _bab_add_buf(babcgpu, babinfo, BAB_ASYNC, 1, BAB_FFL_HERE)
+#define bab_config_reg(_reg, _ena) _bab_config_reg(babcgpu, babinfo, _reg, _ena, BAB_FFL_HERE)
+#define bab_add_data(_addr, _data, _siz) _bab_add_data(babcgpu, babinfo, _addr, (const uint8_t *)(_data), _siz, BAB_FFL_HERE)
+
+#define BAB_ADD_MIN 4
+#define BAB_ADD_MAX 128
+
+#define BAB_STATE_DONE 0
+#define BAB_STATE_READY 1
+#define BAB_STATE_SENDING 2
+#define BAB_STATE_SENT 3
+#define BAB_STATE_READING 4
+
+#define BAB_SPI_BUFFERS 2
+
+#define BAB_BASEA 4
+#define BAB_BASEB 61
+#define BAB_COUNTERS 16
+static const uint8_t bab_counters[BAB_COUNTERS] = {
+ 64, 64,
+ BAB_BASEA, BAB_BASEA+4,
+ BAB_BASEA+2, BAB_BASEA+2+16,
+ BAB_BASEA, BAB_BASEA+1,
+ (BAB_BASEB)%65, (BAB_BASEB+1)%65,
+ (BAB_BASEB+3)%65, (BAB_BASEB+3+16)%65,
+ (BAB_BASEB+4)%65, (BAB_BASEB+4+4)%65,
+ (BAB_BASEB+3+3)%65, (BAB_BASEB+3+1+3)%65
+};
+
+#define BAB_W1 16
+static const uint32_t bab_w1[BAB_W1] = {
+ 0, 0, 0, 0xffffffff,
+ 0x80000000, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0x00000280
+};
+
+#define BAB_W2 8
+static const uint32_t bab_w2[BAB_W2] = {
+ 0x80000000, 0, 0, 0,
+ 0, 0, 0, 0x00000100
+};
+
+#define BAB_TEST_DATA 19
+static const uint32_t bab_test_data[BAB_TEST_DATA] = {
+ 0xb0e72d8e, 0x1dc5b862, 0xe9e7c4a6, 0x3050f1f5,
+ 0x8a1a6b7e, 0x7ec384e8, 0x42c1c3fc, 0x8ed158a1,
+ 0x8a1a6b7e, 0x6f484872, 0x4ff0bb9b, 0x12c97f07,
+ 0xb0e72d8e, 0x55d979bc, 0x39403296, 0x40f09e84,
+ 0x8a0bb7b7, 0x33af304f, 0x0b290c1a //, 0xf0c4e61f
+};
+
+//maximum number of chips on alternative bank
+// #define BANKCHIPS 64
+
+/*
+ * maximum chip speed available for auto tuner
+ * speed/nrate/hrate/watt
+ * 53/ 97/ 100/ 84
+ * 54/ 98/ 107/ 88
+ * 55/ 99/ 115/ 93
+ * 56/ 101/ 125/ 99
+ */
+#define BAB_MAXSPEED 57
+#define BAB_DEFSPEED 54
+#define BAB_MINSPEED 52
+
+#define MIDSTATE_BYTES 32
+#define MERKLE_OFFSET 64
+#define MERKLE_BYTES 12
+#define BLOCK_HEADER_BYTES 80
+
+#define MIDSTATE_UINTS (MIDSTATE_BYTES / sizeof(uint32_t))
+#define DATA_UINTS ((BLOCK_HEADER_BYTES / sizeof(uint32_t)) - 1)
+
+// Auto adjust
+#define BAB_AUTO_REG 0
+#define BAB_AUTO_VAL 0x01
+// iclk
+#define BAB_ICLK_REG 1
+#define BAB_ICLK_VAL 0x02
+// No fast clock
+#define BAB_FAST_REG 2
+#define BAB_FAST_VAL 0x04
+// Divide by 2
+#define BAB_DIV2_REG 3
+#define BAB_DIV2_VAL 0x08
+// Slow Clock
+#define BAB_SLOW_REG 4
+#define BAB_SLOW_VAL 0x10
+// No oclk
+#define BAB_OCLK_REG 6
+#define BAB_OCLK_VAL 0x20
+// Has configured
+#define BAB_CFGD_VAL 0x40
+
+#define BAB_DEFCONF (BAB_AUTO_VAL | \
+ BAB_ICLK_VAL | \
+ BAB_DIV2_VAL | \
+ BAB_SLOW_VAL)
+
+#define BAB_REG_CLR_FROM 7
+#define BAB_REG_CLR_TO 11
+
+#define BAB_AUTO_SET(_c) ((_c) & BAB_AUTO_VAL)
+#define BAB_ICLK_SET(_c) ((_c) & BAB_ICLK_VAL)
+#define BAB_FAST_SET(_c) ((_c) & BAB_FAST_VAL)
+#define BAB_DIV2_SET(_c) ((_c) & BAB_DIV2_VAL)
+#define BAB_SLOW_SET(_c) ((_c) & BAB_SLOW_VAL)
+#define BAB_OCLK_SET(_c) ((_c) & BAB_OCLK_VAL)
+#define BAB_CFGD_SET(_c) ((_c) & BAB_CFGD_VAL)
+
+#define BAB_AUTO_BIT(_c) (BAB_AUTO_SET(_c) ? true : false)
+#define BAB_ICLK_BIT(_c) (BAB_ICLK_SET(_c) ? false : true)
+#define BAB_FAST_BIT(_c) (BAB_FAST_SET(_c) ? true : false)
+#define BAB_DIV2_BIT(_c) (BAB_DIV2_SET(_c) ? false : true)
+#define BAB_SLOW_BIT(_c) (BAB_SLOW_SET(_c) ? true : false)
+#define BAB_OCLK_BIT(_c) (BAB_OCLK_SET(_c) ? true : false)
+
+#define BAB_COUNT_ADDR 0x0100
+#define BAB_W1A_ADDR 0x1000
+#define BAB_W1B_ADDR 0x1400
+#define BAB_W2_ADDR 0x1900
+#define BAB_INP_ADDR 0x3000
+#define BAB_OSC_ADDR 0x6000
+#define BAB_REG_ADDR 0x7000
+
+/*
+ * valid: 0x01 0x03 0x07 0x0F 0x1F 0x3F 0x7F 0xFF
+ * max { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00 }
+ * max { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00 }
+ * avg { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00 }
+ * slo { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00 }
+ * min { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ * good: 0x1F (97) 0x3F (104) 0x7F (109) 0xFF (104)
+ */
+
+#define BAB_OSC 8
+static const uint8_t bab_osc_bits[BAB_OSC] =
+ { 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF };
+
+static const uint8_t bab_reg_ena[4] = { 0xc1, 0x6a, 0x59, 0xe3 };
+static const uint8_t bab_reg_dis[4] = { 0x00, 0x00, 0x00, 0x00 };
+
+#define BAB_NONCE_OFFSETS 3
+static const uint32_t bab_nonce_offsets[] = {-0x800000, 0, -0x400000};
+
+struct bab_work_send {
+ uint32_t midstate[MIDSTATE_UINTS];
+ uint32_t ms3steps[MIDSTATE_UINTS];
+ uint32_t merkle7;
+ uint32_t ntime;
+ uint32_t bits;
+};
+
+#define BAB_REPLY_NONCES 16
+struct bab_work_reply {
+ uint32_t nonce[BAB_REPLY_NONCES];
+ uint32_t jobsel;
+};
+
+#define MAX_BLISTS 4096
+
+typedef struct blist {
+ struct blist *prev;
+ struct blist *next;
+ struct work *work;
+ int nonces;
+} BLIST;
+
+#define MAX_RLISTS 256
+
+typedef struct rlist {
+ struct rlist *prev;
+ struct rlist *next;
+ int chip;
+ uint32_t nonce;
+ bool first_second;
+} RLIST;
+
+struct bab_info {
+ struct thr_info spi_thr;
+ struct thr_info res_thr;
+
+ pthread_mutex_t spi_lock;
+ pthread_mutex_t res_lock;
+ pthread_mutex_t did_lock;
+ cglock_t blist_lock;
+
+ // All GPIO goes through this
+ volatile unsigned *gpio;
+
+ int spifd;
+ int chips;
+ uint32_t chip_spis[BAB_MAXCHIPS+1];
+
+ int buffer;
+ int buf_status[BAB_SPI_BUFFERS];
+ uint8_t buf_write[BAB_SPI_BUFFERS][BAB_MAXBUF];
+ uint8_t buf_read[BAB_SPI_BUFFERS][BAB_MAXBUF];
+ uint32_t buf_used[BAB_SPI_BUFFERS];
+ uint32_t chip_off[BAB_SPI_BUFFERS][BAB_MAXCHIPS+1];
+ uint32_t bank_off[BAB_SPI_BUFFERS][BAB_MAXBANKS+2];
+
+ struct bab_work_send chip_input[BAB_MAXCHIPS];
+ struct bab_work_reply chip_results[BAB_MAXCHIPS];
+ struct bab_work_reply chip_prev[BAB_MAXCHIPS];
+
+ uint8_t chip_fast[BAB_MAXCHIPS];
+ uint8_t chip_conf[BAB_MAXCHIPS];
+ uint8_t old_fast[BAB_MAXCHIPS];
+ uint8_t old_conf[BAB_MAXCHIPS];
+ uint8_t chip_bank[BAB_MAXCHIPS+1];
+
+ uint8_t osc[BAB_OSC];
+
+ int fixchip;
+
+ /*
+ * Ignore errors in the first work reply since
+ * they may be from a previous run or random junk
+ * There can be >100 with just a 16 chip board
+ */
+ uint32_t initial_ignored;
+ bool nonce_before[BAB_MAXCHIPS];
+ bool not_first_reply[BAB_MAXCHIPS];
+
+ // Stats
+ struct timeval chip_start[BAB_MAXCHIPS];
+ int chip_busy[BAB_MAXCHIPS];
+ uint64_t core_good[BAB_MAXCHIPS][BAB_CORES];
+ uint64_t core_bad[BAB_MAXCHIPS][BAB_CORES];
+ uint64_t chip_spie[BAB_MAXCHIPS]; // spi errors
+ uint64_t chip_miso[BAB_MAXCHIPS]; // msio errors
+ uint64_t chip_nonces[BAB_MAXCHIPS];
+ uint64_t chip_good[BAB_MAXCHIPS];
+ uint64_t chip_bad[BAB_MAXCHIPS];
+ uint64_t chip_ncore[BAB_MAXCHIPS][BAB_X_COORD][BAB_Y_COORD];
+
+ uint64_t untested_nonces;
+ uint64_t tested_nonces;
+
+ uint64_t new_nonces;
+ uint64_t ok_nonces;
+
+ uint64_t nonce_offset_count[BAB_NONCE_OFFSETS];
+ uint64_t total_tests;
+ uint64_t max_tests_per_nonce;
+ uint64_t total_links;
+ uint64_t max_links;
+
+ int blist_count;
+ int bfree_count;
+ int work_count;
+ int chip_count;
+ BLIST *bfree_list;
+ BLIST *work_list;
+ BLIST *chip_list[BAB_MAXCHIPS];
+
+ int rlist_count;
+ int rfree_count;
+ int res_count;
+ RLIST *rfree_list;
+ RLIST *res_list_head;
+ RLIST *res_list_tail;
+
+ struct timeval last_did;
+
+ bool initialised;
+};
+
+static BLIST *new_blist_set(struct cgpu_info *babcgpu)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ BLIST *blist = NULL;
+ int i;
+
+ blist = calloc(MAX_BLISTS, sizeof(*blist));
+ if (!blist)
+ quithere(1, "Failed to calloc blist - when old count=%d", babinfo->blist_count);
+
+ babinfo->blist_count += MAX_BLISTS;
+ babinfo->bfree_count = MAX_BLISTS;
+
+ blist[0].prev = NULL;
+ blist[0].next = &(blist[1]);
+ for (i = 1; i < MAX_BLISTS-1; i++) {
+ blist[i].prev = &blist[i-1];
+ blist[i].next = &blist[i+1];
+ }
+ blist[MAX_BLISTS-1].prev = &(blist[MAX_BLISTS-2]);
+ blist[MAX_BLISTS-1].next = NULL;
+
+ return blist;
+}
+
+static BLIST *next_work(struct cgpu_info *babcgpu, int chip)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ BLIST *bitem;
+
+ cg_wlock(&babinfo->blist_lock);
+ bitem = babinfo->work_list;
+ if (bitem) {
+ // Unlink it from work
+ if (bitem->next)
+ bitem->next->prev = NULL;
+ babinfo->work_list = bitem->next;
+ babinfo->work_count--;
+
+ // Add it to the chip
+ bitem->next = babinfo->chip_list[chip];
+ bitem->prev = NULL;
+ if (bitem->next)
+ bitem->next->prev = bitem;
+ babinfo->chip_list[chip] = bitem;
+ babinfo->chip_count++;
+ }
+ cg_wunlock(&babinfo->blist_lock);
+
+ return bitem;
+}
+
+static void discard_last(struct cgpu_info *babcgpu, int chip)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ BLIST *bitem;
+
+ cg_wlock(&babinfo->blist_lock);
+ bitem = babinfo->chip_list[chip];
+ if (bitem) {
+ // Unlink it from the chip
+ if (bitem->next)
+ bitem->next->prev = NULL;
+ babinfo->chip_list[chip] = bitem->next;
+ babinfo->chip_count--;
+
+ // Put it in the free list
+ bitem->next = babinfo->bfree_list;
+ bitem->prev = NULL;
+ if (bitem->next)
+ bitem->next->prev = bitem;
+ babinfo->bfree_list = bitem;
+ babinfo->bfree_count++;
+ }
+ cg_wunlock(&babinfo->blist_lock);
+}
+
+static BLIST *store_work(struct cgpu_info *babcgpu, struct work *work)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ BLIST *bitem = NULL;
+ int ran_out = 0;
+
+ cg_wlock(&babinfo->blist_lock);
+
+ if (babinfo->bfree_list == NULL) {
+ ran_out = babinfo->blist_count;
+ babinfo->bfree_list = new_blist_set(babcgpu);
+ }
+
+ // unlink from free
+ bitem = babinfo->bfree_list;
+ babinfo->bfree_list = babinfo->bfree_list->next;
+ if (babinfo->bfree_list)
+ babinfo->bfree_list->prev = NULL;
+ babinfo->bfree_count--;
+
+ // add to work
+ bitem->next = babinfo->work_list;
+ bitem->prev = NULL;
+ if (bitem->next)
+ bitem->next->prev = bitem;
+ babinfo->work_list = bitem;
+ babinfo->work_count++;
+
+ bitem->work = work;
+ bitem->nonces = 0;
+
+ cg_wunlock(&babinfo->blist_lock);
+
+ if (ran_out > 0) {
+ applog(LOG_ERR, "%s%i: BLIST used count exceeded %d, now %d (work=%d chip=%d)",
+ babcgpu->drv->name, babcgpu->device_id,
+ ran_out, babinfo->blist_count,
+ babinfo->work_count,
+ babinfo->chip_count);
+ }
+
+ return bitem;
+}
+
+static void free_blist(struct cgpu_info *babcgpu, BLIST *bhead, int chip)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ struct work *work;
+ BLIST *bitem;
+
+ if (!bhead)
+ return;
+
+ // Unlink it from the chip
+ cg_wlock(&babinfo->blist_lock);
+ if (unlikely(bhead == babinfo->chip_list[chip])) {
+ // Removing the chip head is an error
+ bhead = bhead->next;
+ babinfo->chip_list[chip]->next = NULL;
+ } else
+ bhead->prev->next = NULL;
+ bitem = bhead;
+ while (bitem) {
+ babinfo->chip_count--;
+ bitem = bitem->next;
+ }
+ cg_wunlock(&babinfo->blist_lock);
+
+ while (bhead) {
+ bitem = bhead;
+ bhead = bitem->next;
+
+ // add to free
+ cg_wlock(&babinfo->blist_lock);
+ bitem->next = babinfo->bfree_list;
+ if (babinfo->bfree_list)
+ babinfo->bfree_list->prev = bitem;
+ bitem->prev = NULL;
+ babinfo->bfree_list = bitem;
+ babinfo->bfree_count++;
+ work = bitem->work;
+ cg_wunlock(&babinfo->blist_lock);
+
+ work_completed(babcgpu, work);
+ }
+
+}
+
+static RLIST *new_rlist_set(struct cgpu_info *babcgpu)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ RLIST *rlist = NULL;
+ int i;
+
+ rlist = calloc(MAX_RLISTS, sizeof(*rlist));
+ if (!rlist)
+ quithere(1, "Failed to calloc rlist - when old count=%d", babinfo->rlist_count);
+
+ babinfo->rlist_count += MAX_RLISTS;
+ babinfo->rfree_count = MAX_RLISTS;
+
+ rlist[0].prev = NULL;
+ rlist[0].next = &(rlist[1]);
+ for (i = 1; i < MAX_RLISTS-1; i++) {
+ rlist[i].prev = &rlist[i-1];
+ rlist[i].next = &rlist[i+1];
+ }
+ rlist[MAX_RLISTS-1].prev = &(rlist[MAX_RLISTS-2]);
+ rlist[MAX_RLISTS-1].next = NULL;
+
+ return rlist;
+}
+
+static RLIST *store_nonce(struct cgpu_info *babcgpu, int chip, uint32_t nonce, bool first_second)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ RLIST *ritem = NULL;
+ int ran_out = 0;
+
+ mutex_lock(&(babinfo->res_lock));
+
+ if (babinfo->rfree_list == NULL) {
+ ran_out = babinfo->rlist_count;
+ babinfo->rfree_list = new_rlist_set(babcgpu);
+ }
+
+ // unlink from rfree
+ ritem = babinfo->rfree_list;
+ babinfo->rfree_list = babinfo->rfree_list->next;
+ if (babinfo->rfree_list)
+ babinfo->rfree_list->prev = NULL;
+ babinfo->rfree_count--;
+
+ // add to head of results
+ ritem->next = babinfo->res_list_head;
+ ritem->prev = NULL;
+ babinfo->res_list_head = ritem;
+ if (ritem->next)
+ ritem->next->prev = ritem;
+ else
+ babinfo->res_list_tail = ritem;
+
+ babinfo->res_count++;
+
+ ritem->chip = chip;
+ ritem->nonce = nonce;
+ ritem->first_second = first_second;
+
+ mutex_unlock(&(babinfo->res_lock));
+
+ if (ran_out > 0) {
+ applog(LOG_ERR, "%s%i: RLIST used count exceeded %d, now %d (work=%d chip=%d)",
+ babcgpu->drv->name, babcgpu->device_id,
+ ran_out, babinfo->rlist_count,
+ babinfo->work_count,
+ babinfo->chip_count);
+ }
+
+ return ritem;
+}
+
+static bool oldest_nonce(struct cgpu_info *babcgpu, int *chip, uint32_t *nonce, bool *first_second)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ RLIST *ritem = NULL;
+ bool found = false;
+
+ mutex_lock(&(babinfo->res_lock));
+
+ if (babinfo->res_list_tail) {
+ // unlink from res
+ ritem = babinfo->res_list_tail;
+ if (ritem->prev) {
+ ritem->prev->next = NULL;
+ babinfo->res_list_tail = ritem->prev;
+ } else
+ babinfo->res_list_head = babinfo->res_list_tail = NULL;
+
+ babinfo->res_count--;
+
+ found = true;
+ *chip = ritem->chip;
+ *nonce = ritem->nonce;
+ *first_second = ritem->first_second;
+
+ // add to rfree
+ ritem->next = babinfo->rfree_list;
+ ritem->prev = NULL;
+ if (ritem->next)
+ ritem->next->prev = ritem;
+ babinfo->rfree_list = ritem;
+
+ babinfo->rfree_count++;
+ }
+
+ mutex_unlock(&(babinfo->res_lock));
+
+ return found;
+}
+
+static void _bab_reset(__maybe_unused struct cgpu_info *babcgpu, struct bab_info *babinfo, int bank, int times)
+{
+ const int banks[4] = { 18, 23, 24, 25 };
+ int i;
+
+ BAB_INP_GPIO(10);
+ BAB_OUT_GPIO(10);
+ BAB_INP_GPIO(11);
+ BAB_OUT_GPIO(11);
+
+ if (bank) {
+ for (i = 0; i < 4; i++) {
+ BAB_INP_GPIO(banks[i]);
+ BAB_OUT_GPIO(banks[i]);
+ if (bank == i+1)
+ BAB_GPIO_SET = 1 << banks[i];
+ else
+ BAB_GPIO_CLR = 1 << banks[i];
+ }
+ cgsleep_us(4096);
+ } else {
+ for (i = 0; i < 4; i++)
+ BAB_INP_GPIO(banks[i]);
+ }
+
+ BAB_GPIO_SET = 1 << 11;
+ for (i = 0; i < times; i++) { // 1us = 1MHz
+ BAB_GPIO_SET = 1 << 10;
+ cgsleep_us(1);
+ BAB_GPIO_CLR = 1 << 10;
+ cgsleep_us(1);
+ }
+ BAB_GPIO_CLR = 1 << 11;
+ BAB_INP_GPIO(11);
+ BAB_INP_GPIO(10);
+ BAB_INP_GPIO(9);
+ BAB_OUT_GPIO_V(11, 0);
+ BAB_OUT_GPIO_V(10, 0);
+ BAB_OUT_GPIO_V(9, 0);
+}
+
+// TODO: handle a false return where this is called?
+static bool _bab_txrx(struct cgpu_info *babcgpu, struct bab_info *babinfo, int buf, uint32_t siz, bool detect_ignore, const char *file, const char *func, const int line)
+{
+ int bank, i;
+ uint32_t pos;
+ struct spi_ioc_transfer tran;
+ uintptr_t rbuf, wbuf;
+
+ wbuf = (uintptr_t)(babinfo->buf_write[buf]);
+ rbuf = (uintptr_t)(babinfo->buf_read[buf]);
+
+ memset(&tran, 0, sizeof(tran));
+ tran.delay_usecs = 0;
+ tran.speed_hz = BAB_SPI_SPEED;
+
+ i = 0;
+ pos = 0;
+ for (bank = 0; bank <= BAB_MAXBANKS; bank++) {
+ if (babinfo->bank_off[buf][bank]) {
+ bab_reset(bank, 64);
+ break;
+ }
+ }
+
+ if (unlikely(bank > BAB_MAXBANKS)) {
+ applog(LOG_ERR, "%s%d: %s() failed to find a bank" BAB_FFL,
+ babcgpu->drv->name, babcgpu->device_id,
+ __func__, BAB_FFL_PASS);
+ return false;
+ }
+
+ while (siz > 0) {
+ tran.tx_buf = wbuf;
+ tran.rx_buf = rbuf;
+ tran.speed_hz = BAB_SPI_SPEED;
+ if (pos == babinfo->bank_off[buf][bank]) {
+ for (; ++bank <= BAB_MAXBANKS; ) {
+ if (babinfo->bank_off[buf][bank] > pos) {
+ bab_reset(bank, 64);
+ break;
+ }
+ }
+ }
+ if (siz < BAB_SPI_BUFSIZ)
+ tran.len = siz;
+ else
+ tran.len = BAB_SPI_BUFSIZ;
+
+ if (pos < babinfo->bank_off[buf][bank] &&
+ babinfo->bank_off[buf][bank] < (pos + tran.len))
+ tran.len = babinfo->bank_off[buf][bank] - pos;
+
+ for (; i < babinfo->chips; i++) {
+ if (!babinfo->chip_off[buf][i])
+ continue;
+ if (babinfo->chip_off[buf][i] >= pos + tran.len) {
+ tran.speed_hz = babinfo->chip_spis[i];
+ break;
+ }
+ }
+
+ if (unlikely(i > babinfo->chips)) {
+ applog(LOG_ERR, "%s%d: %s() failed to find chip" BAB_FFL,
+ babcgpu->drv->name, babcgpu->device_id,
+ __func__, BAB_FFL_PASS);
+ return false;
+ }
+
+ if (unlikely(babinfo->chip_spis[i] == BAB_SPI_SPEED)) {
+ applog(LOG_DEBUG, "%s%d: %s() chip[%d] speed %d shouldn't be %d" BAB_FFL,
+ babcgpu->drv->name, babcgpu->device_id,
+ __func__, i, (int)babinfo->chip_spis[i],
+ BAB_SPI_SPEED, BAB_FFL_PASS);
+ }
+
+ if (unlikely(tran.speed_hz == BAB_SPI_SPEED)) {
+ applog(LOG_DEBUG, "%s%d: %s() transfer speed %d shouldn't be %d" BAB_FFL,
+ babcgpu->drv->name, babcgpu->device_id,
+ __func__, (int)tran.speed_hz,
+ BAB_SPI_SPEED, BAB_FFL_PASS);
+ }
+
+ if (ioctl(babinfo->spifd, SPI_IOC_MESSAGE(1), (void *)&tran) < 0) {
+ if (!detect_ignore || errno != 110) {
+ applog(LOG_ERR, "%s%d: ioctl failed err=%d" BAB_FFL,
+ babcgpu->drv->name, babcgpu->device_id,
+ errno, BAB_FFL_PASS);
+ }
+ return false;
+ }
+
+ siz -= tran.len;
+ wbuf += tran.len;
+ rbuf += tran.len;
+ pos += tran.len;
+ }
+ mutex_lock(&(babinfo->did_lock));
+ cgtime(&(babinfo->last_did));
+ mutex_unlock(&(babinfo->did_lock));
+ return true;
+}
+
+static void _bab_add_buf_rev(__maybe_unused struct cgpu_info *babcgpu, struct bab_info *babinfo, const uint8_t *data, uint32_t siz, const char *file, const char *func, const int line)
+{
+ uint8_t tmp;
+ uint32_t now_used, i;
+ int buf;
+
+ buf = babinfo->buffer;
+ now_used = babinfo->buf_used[buf];
+ if (now_used + siz >= BAB_MAXBUF) {
+ quitfrom(1, file, func, line,
+ "%s() buffer %d limit of %d exceeded=%d siz=%d",
+ __func__, buf, BAB_MAXBUF, now_used + siz, siz);
+ }
+
+ for (i = 0; i < siz; i++) {
+ tmp = data[i];
+ tmp = ((tmp & 0xaa)>>1) | ((tmp & 0x55) << 1);
+ tmp = ((tmp & 0xcc)>>2) | ((tmp & 0x33) << 2);
+ tmp = ((tmp & 0xf0)>>4) | ((tmp & 0x0f) << 4);
+ babinfo->buf_write[buf][now_used + i] = tmp;
+ }
+
+ babinfo->buf_used[buf] += siz;
+}
+
+static void _bab_add_buf(__maybe_unused struct cgpu_info *babcgpu, struct bab_info *babinfo, const uint8_t *data, size_t siz, const char *file, const char *func, const int line)
+{
+ uint32_t now_used;
+ int buf;
+
+ buf = babinfo->buffer;
+ now_used = babinfo->buf_used[buf];
+ if (now_used + siz >= BAB_MAXBUF) {
+ quitfrom(1, file, func, line,
+ "%s() buffer %d limit of %d exceeded=%d siz=%d",
+ __func__, buf, BAB_MAXBUF, (int)(now_used + siz), (int)siz);
+ }
+
+ memcpy(&(babinfo->buf_write[buf][now_used]), data, siz);
+ babinfo->buf_used[buf] += siz;
+}
+
+static void _bab_add_data(struct cgpu_info *babcgpu, struct bab_info *babinfo, uint32_t addr, const uint8_t *data, size_t siz, const char *file, const char *func, const int line)
+{
+ uint8_t tmp[3];
+ int trf_siz;
+
+ if (siz < BAB_ADD_MIN || siz > BAB_ADD_MAX) {
+ quitfrom(1, file, func, line,
+ "%s() called with invalid siz=%d (min=%d max=%d)",
+ __func__, (int)siz, BAB_ADD_MIN, BAB_ADD_MAX);
+ }
+ trf_siz = siz / 4;
+ tmp[0] = (trf_siz - 1) | 0xE0;
+ tmp[1] = (addr >> 8) & 0xff;
+ tmp[2] = addr & 0xff;
+ _bab_add_buf(babcgpu, babinfo, tmp, sizeof(tmp), BAB_FFL_PASS);
+ _bab_add_buf_rev(babcgpu, babinfo, data, siz, BAB_FFL_PASS);
+}
+
+static void _bab_config_reg(struct cgpu_info *babcgpu, struct bab_info *babinfo, uint32_t reg, bool enable, const char *file, const char *func, const int line)
+{
+ if (enable) {
+ _bab_add_data(babcgpu, babinfo, BAB_REG_ADDR + reg*32,
+ bab_reg_ena, sizeof(bab_reg_ena), BAB_FFL_PASS);
+ } else {
+ _bab_add_data(babcgpu, babinfo, BAB_REG_ADDR + reg*32,
+ bab_reg_dis, sizeof(bab_reg_dis), BAB_FFL_PASS);
+ }
+
+}
+
+static void bab_set_osc(struct bab_info *babinfo, int chip)
+{
+ int fast, i;
+
+ fast = babinfo->chip_fast[chip];
+
+ for (i = 0; i < BAB_OSC && fast > BAB_OSC; i++, fast -= BAB_OSC) {
+ babinfo->osc[i] = 0xff;
+ }
+ if (i < BAB_OSC && fast > 0 && fast <= BAB_OSC)
+ babinfo->osc[i++] = bab_osc_bits[fast - 1];
+ for (; i < BAB_OSC; i++)
+ babinfo->osc[i] = 0x00;
+
+ applog(LOG_DEBUG, "@osc(chip=%d) fast=%d 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", chip, fast, babinfo->osc[0], babinfo->osc[1], babinfo->osc[2], babinfo->osc[3], babinfo->osc[4], babinfo->osc[5], babinfo->osc[6], babinfo->osc[7]);
+}
+
+static bool bab_put(struct cgpu_info *babcgpu, struct bab_info *babinfo)
+{
+ int buf, i, reg, bank = 0;
+
+ babinfo->buffer = -1;
+
+ mutex_lock(&(babinfo->spi_lock));
+ if (babinfo->buf_status[0] == BAB_STATE_DONE) {
+ babinfo->buffer = 0;
+ } else if (babinfo->buf_status[1] == BAB_STATE_DONE) {
+ babinfo->buffer = 1;
+ } else if (babinfo->buf_status[0] == BAB_STATE_READY) {
+ babinfo->buf_status[0] = BAB_STATE_DONE;
+ babinfo->buffer = 0;
+ } else if (babinfo->buf_status[1] == BAB_STATE_READY) {
+ babinfo->buf_status[1] = BAB_STATE_DONE;
+ babinfo->buffer = 1;
+ }
+ mutex_unlock(&(babinfo->spi_lock));
+
+ if (babinfo->buffer == -1)
+ return false;
+
+ buf = babinfo->buffer;
+ babinfo->buf_used[buf] = 0;
+ memset(babinfo->bank_off[buf], 0, sizeof(babinfo->bank_off) / BAB_SPI_BUFFERS);
+
+ BAB_ADD_BREAK();
+ for (i = 0; i < babinfo->chips; i++) {
+ if (babinfo->chip_bank[i] != bank) {
+ babinfo->bank_off[buf][bank] = babinfo->buf_used[buf];
+ bank = babinfo->chip_bank[i];
+ BAB_ADD_BREAK();
+ }
+ if (i == babinfo->fixchip &&
+ (BAB_CFGD_SET(babinfo->chip_conf[i]) ||
+ !babinfo->chip_conf[i])) {
+ bab_set_osc(babinfo, i);
+ bab_add_data(BAB_OSC_ADDR, babinfo->osc, sizeof(babinfo->osc));
+ bab_config_reg(BAB_ICLK_REG, BAB_ICLK_BIT(babinfo->chip_conf[i]));
+ bab_config_reg(BAB_FAST_REG, BAB_FAST_BIT(babinfo->chip_conf[i]));
+ bab_config_reg(BAB_DIV2_REG, BAB_DIV2_BIT(babinfo->chip_conf[i]));
+ bab_config_reg(BAB_SLOW_REG, BAB_SLOW_BIT(babinfo->chip_conf[i]));
+ bab_config_reg(BAB_OCLK_REG, BAB_OCLK_BIT(babinfo->chip_conf[i]));
+ for (reg = BAB_REG_CLR_FROM; reg <= BAB_REG_CLR_TO; reg++)
+ bab_config_reg(reg, false);
+ if (babinfo->chip_conf[i]) {
+ bab_add_data(BAB_COUNT_ADDR, bab_counters, sizeof(bab_counters));
+ bab_add_data(BAB_W1A_ADDR, bab_w1, sizeof(bab_w1));
+ bab_add_data(BAB_W1B_ADDR, bab_w1, sizeof(bab_w1)/2);
+ bab_add_data(BAB_W2_ADDR, bab_w2, sizeof(bab_w2));
+ babinfo->chip_conf[i] ^= BAB_CFGD_VAL;
+ }
+ babinfo->old_fast[i] = babinfo->chip_fast[i];
+ babinfo->old_conf[i] = babinfo->chip_conf[i];
+ } else {
+ if (babinfo->old_fast[i] != babinfo->chip_fast[i]) {
+ bab_set_osc(babinfo, i);
+ bab_add_data(BAB_OSC_ADDR, babinfo->osc, sizeof(babinfo->osc));
+ babinfo->old_fast[i] = babinfo->chip_fast[i];
+ }
+ if (babinfo->old_conf[i] != babinfo->chip_conf[i]) {
+ if (BAB_ICLK_SET(babinfo->old_conf[i]) !=
+ BAB_ICLK_SET(babinfo->chip_conf[i]))
+ bab_config_reg(BAB_ICLK_REG,
+ BAB_ICLK_BIT(babinfo->chip_conf[i]));
+ if (BAB_FAST_SET(babinfo->old_conf[i]) !=
+ BAB_FAST_SET(babinfo->chip_conf[i]))
+ bab_config_reg(BAB_FAST_REG,
+ BAB_FAST_BIT(babinfo->chip_conf[i]));
+ if (BAB_DIV2_SET(babinfo->old_conf[i]) !=
+ BAB_DIV2_SET(babinfo->chip_conf[i]))
+ bab_config_reg(BAB_DIV2_REG,
+ BAB_DIV2_BIT(babinfo->chip_conf[i]));
+ if (BAB_SLOW_SET(babinfo->old_conf[i]) !=
+ BAB_SLOW_SET(babinfo->chip_conf[i]))
+ bab_config_reg(BAB_SLOW_REG,
+ BAB_SLOW_BIT(babinfo->chip_conf[i]));
+ if (BAB_OCLK_SET(babinfo->old_conf[i]) !=
+ BAB_OCLK_SET(babinfo->chip_conf[i]))
+ bab_config_reg(BAB_OCLK_REG,
+ BAB_OCLK_BIT(babinfo->chip_conf[i]));
+ babinfo->old_conf[i] = babinfo->chip_conf[i];
+ }
+ }
+ babinfo->chip_off[buf][i] = babinfo->buf_used[buf] + 3;
+ if (babinfo->chip_conf[i])
+ bab_add_data(BAB_INP_ADDR, (uint8_t *)(&(babinfo->chip_input[i])),
+ sizeof(babinfo->chip_input[i]));
+
+ BAB_ADD_ASYNC();
+ }
+ babinfo->chip_off[buf][i] = babinfo->buf_used[buf];
+ babinfo->bank_off[buf][bank] = babinfo->buf_used[buf];
+
+ mutex_lock(&(babinfo->spi_lock));
+ babinfo->buf_status[buf] = BAB_STATE_READY;
+ mutex_unlock(&(babinfo->spi_lock));
+
+ babinfo->fixchip = (babinfo->fixchip + 1) % babinfo->chips;
+ return true;
+}
+
+static bool bab_get(__maybe_unused struct cgpu_info *babcgpu, struct bab_info *babinfo)
+{
+ int buf, i;
+
+ babinfo->buffer = -1;
+
+ mutex_lock(&(babinfo->spi_lock));
+ if (babinfo->buf_status[0] == BAB_STATE_SENT) {
+ babinfo->buf_status[0] = BAB_STATE_READING;
+ babinfo->buffer = 0;
+ } else if (babinfo->buf_status[1] == BAB_STATE_SENT) {
+ babinfo->buf_status[1] = BAB_STATE_READING;
+ babinfo->buffer = 1;
+ }
+ mutex_unlock(&(babinfo->spi_lock));
+
+ if (babinfo->buffer == -1)
+ return false;
+
+ buf = babinfo->buffer;
+ for (i = 0; i < babinfo->chips; i++) {
+ if (babinfo->chip_conf[i] & 0x7f) {
+ memcpy((void *)&(babinfo->chip_results[i]),
+ (void *)(babinfo->buf_read[buf] + babinfo->chip_off[buf][i]),
+ sizeof(babinfo->chip_results[0]));
+ }
+ }
+
+ mutex_lock(&(babinfo->spi_lock));
+ babinfo->buf_status[buf] = BAB_STATE_DONE;
+ mutex_unlock(&(babinfo->spi_lock));
+
+ return true;
+}
+
+void bab_detect_chips(struct cgpu_info *babcgpu, struct bab_info *babinfo, int bank, int first, int last)
+{
+ int buf, i, reg, j;
+
+ if (sizeof(struct bab_work_send) != sizeof(bab_test_data)) {
+ quithere(1, "struct bab_work_send (%d) and bab_test_data (%d)"
+ " must be the same size",
+ (int)sizeof(struct bab_work_send),
+ (int)sizeof(bab_test_data));
+ }
+
+ memset(babinfo->bank_off, 0, sizeof(babinfo->bank_off));
+
+ buf = babinfo->buffer = 0;
+ babinfo->buf_used[buf] = 0;
+ BAB_ADD_BREAK();
+ for (i = first; i < last && i < BAB_MAXCHIPS; i++) {
+ bab_set_osc(babinfo, i);
+ bab_add_data(BAB_OSC_ADDR, babinfo->osc, sizeof(babinfo->osc));
+ bab_config_reg(BAB_ICLK_REG, BAB_ICLK_BIT(babinfo->chip_conf[i]));
+ bab_config_reg(BAB_FAST_REG, BAB_FAST_BIT(babinfo->chip_conf[i]));
+ bab_config_reg(BAB_DIV2_REG, BAB_DIV2_BIT(babinfo->chip_conf[i]));
+ bab_config_reg(BAB_SLOW_REG, BAB_SLOW_BIT(babinfo->chip_conf[i]));
+ bab_config_reg(BAB_OCLK_REG, BAB_OCLK_BIT(babinfo->chip_conf[i]));
+ for (reg = BAB_REG_CLR_FROM; reg <= BAB_REG_CLR_TO; reg++)
+ bab_config_reg(reg, false);
+ bab_add_data(BAB_COUNT_ADDR, bab_counters, sizeof(bab_counters));
+ bab_add_data(BAB_W1A_ADDR, bab_w1, sizeof(bab_w1));
+ bab_add_data(BAB_W1B_ADDR, bab_w1, sizeof(bab_w1)/2);
+ bab_add_data(BAB_W2_ADDR, bab_w2, sizeof(bab_w2));
+ babinfo->chip_off[buf][i] = babinfo->buf_used[buf] + 3;
+ bab_add_data(BAB_INP_ADDR, bab_test_data, sizeof(bab_test_data));
+ babinfo->chip_off[buf][i+1] = babinfo->buf_used[buf];
+ babinfo->bank_off[buf][bank] = babinfo->buf_used[buf];
+ babinfo->chips = i + 1;
+ bab_txrx(buf, babinfo->buf_used[buf], false);
+ babinfo->buf_used[buf] = 0;
+ BAB_ADD_BREAK();
+ for (j = first; j <= i; j++) {
+ babinfo->chip_off[buf][j] = babinfo->buf_used[buf] + 3;
+ BAB_ADD_ASYNC();
+ }
+ }
+
+ buf = babinfo->buffer = 1;
+ babinfo->buf_used[buf] = 0;
+ BAB_ADD_BREAK();
+ for (i = first; i < last && i < BAB_MAXCHIPS; i++) {
+ babinfo->chip_off[buf][i] = babinfo->buf_used[buf] + 3;
+ bab_add_data(BAB_INP_ADDR, bab_test_data, sizeof(bab_test_data));
+ BAB_ADD_ASYNC();
+ }
+ babinfo->chip_off[buf][i] = babinfo->buf_used[buf];
+ babinfo->bank_off[buf][bank] = babinfo->buf_used[buf];
+ babinfo->chips = i;
+ bab_txrx(buf, babinfo->buf_used[buf], true);
+ babinfo->buf_used[buf] = 0;
+ babinfo->chips = first;
+ for (i = first; i < last && i < BAB_MAXCHIPS; i++) {
+ uint32_t tmp[DATA_UINTS-1];
+ memcpy(tmp, babinfo->buf_read[buf]+babinfo->chip_off[buf][i], sizeof(tmp));
+ for (j = 0; j < BAB_SPI_BUFFERS; j++)
+ babinfo->chip_off[j][i] = 0;
+ for (j = 0; j < BAB_REPLY_NONCES; j++) {
+ if (tmp[j] != 0xffffffff && tmp[j] != 0x00000000) {
+ babinfo->chip_bank[i] = bank;
+ babinfo->chips = i + 1;
+ break;
+ }
+ }
+ }
+ for (i = first ; i < babinfo->chips; i++)
+ babinfo->chip_bank[i] = bank;
+}
+
+static const char *bab_modules[] = {
+ "i2c-dev",
+ "i2c-bcm2708",
+ "spidev",
+ "spi-bcm2708",
+ NULL
+};
+
+static const char *bab_memory = "/dev/mem";
+
+static int bab_memory_addr = 0x20200000;
+
+static struct {
+ int request;
+ int value;
+} bab_ioc[] = {
+ { SPI_IOC_RD_MODE, 0 },
+ { SPI_IOC_WR_MODE, 0 },
+ { SPI_IOC_RD_BITS_PER_WORD, 8 },
+ { SPI_IOC_WR_BITS_PER_WORD, 8 },
+ { SPI_IOC_RD_MAX_SPEED_HZ, 1000000 },
+ { SPI_IOC_WR_MAX_SPEED_HZ, 1000000 },
+ { -1, -1 }
+};
+
+static bool bab_init_gpio(struct cgpu_info *babcgpu, struct bab_info *babinfo, int bus, int chip)
+{
+ int i, err, memfd, data;
+ char buf[64];
+
+ for (i = 0; bab_modules[i]; i++) {
+ snprintf(buf, sizeof(buf), "modprobe %s", bab_modules[i]);
+ err = system(buf);
+ if (err) {
+ applog(LOG_ERR, "%s failed to modprobe %s (%d) - you need to be root?",
+ babcgpu->drv->dname,
+ bab_modules[i], err);
+ goto bad_out;
+ }
+ }
+
+ memfd = open(bab_memory, O_RDWR | O_SYNC);
+ if (memfd < 0) {
+ applog(LOG_ERR, "%s failed open %s (%d)",
+ babcgpu->drv->dname,
+ bab_memory, errno);
+ goto bad_out;
+ }
+
+ babinfo->gpio = (volatile unsigned *)mmap(NULL, BAB_SPI_BUFSIZ,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, memfd,
+ bab_memory_addr);
+ if (babinfo->gpio == MAP_FAILED) {
+ close(memfd);
+ applog(LOG_ERR, "%s failed mmap gpio (%d)",
+ babcgpu->drv->dname,
+ errno);
+ goto bad_out;
+ }
+
+ close(memfd);
+
+ snprintf(buf, sizeof(buf), "/dev/spidev%d.%d", bus, chip);
+ babinfo->spifd = open(buf, O_RDWR);
+ if (babinfo->spifd < 0) {
+ applog(LOG_ERR, "%s failed to open spidev (%d)",
+ babcgpu->drv->dname,
+ errno);
+ goto map_out;
+ }
+
+ babcgpu->device_path = strdup(buf);
+
+ for (i = 0; bab_ioc[i].value != -1; i++) {
+ data = bab_ioc[i].value;
+ err = ioctl(babinfo->spifd, bab_ioc[i].request, (void *)&data);
+ if (err < 0) {
+ applog(LOG_ERR, "%s failed ioctl (%d) (%d)",
+ babcgpu->drv->dname,
+ i, errno);
+ goto close_out;
+ }
+ }
+
+ for (i = 0; i < BAB_MAXCHIPS; i++)
+ babinfo->chip_spis[i] = (int)((1000000.0 / (100.0 + 31.0 * (i + 1))) * 1000);
+
+ return true;
+
+close_out:
+ close(babinfo->spifd);
+ babinfo->spifd = 0;
+ free(babcgpu->device_path);
+ babcgpu->device_path = NULL;
+map_out:
+ munmap((void *)(babinfo->gpio), BAB_SPI_BUFSIZ);
+ babinfo->gpio = NULL;
+bad_out:
+ return false;
+}
+
+static void bab_init_chips(struct cgpu_info *babcgpu, struct bab_info *babinfo)
+{
+ bab_detect_chips(babcgpu, babinfo, 0, 0, BAB_MAXCHIPS);
+ memcpy(babinfo->old_conf, babinfo->chip_conf, sizeof(babinfo->old_conf));
+ memcpy(babinfo->old_fast, babinfo->chip_fast, sizeof(babinfo->old_fast));
+}
+
+static void bab_detect(bool hotplug)
+{
+ struct cgpu_info *babcgpu = NULL;
+ struct bab_info *babinfo = NULL;
+ int i;
+
+ if (hotplug)
+ return;
+
+ babcgpu = calloc(1, sizeof(*babcgpu));
+ if (unlikely(!babcgpu))
+ quithere(1, "Failed to calloc babcgpu");
+
+ babcgpu->drv = &bab_drv;
+ babcgpu->deven = DEV_ENABLED;
+ babcgpu->threads = 1;
+
+ babinfo = calloc(1, sizeof(*babinfo));
+ if (unlikely(!babinfo))
+ quithere(1, "Failed to calloc babinfo");
+ babcgpu->device_data = (void *)babinfo;
+
+ for (i = 0; i < BAB_MAXCHIPS; i++) {
+ babinfo->chip_conf[i] = BAB_DEFCONF;
+ babinfo->chip_fast[i] = BAB_DEFSPEED;
+ }
+
+ mutex_init(&babinfo->spi_lock);
+
+ if (!bab_init_gpio(babcgpu, babinfo, BAB_SPI_BUS, BAB_SPI_CHIP))
+ goto unalloc;
+
+ applog(LOG_WARNING, "%s V1 testing for %d chips ...", babcgpu->drv->dname, BAB_MAXCHIPS);
+
+ bab_init_chips(babcgpu, babinfo);
+
+ applog(LOG_WARNING, "%s found %d chips", babcgpu->drv->dname, babinfo->chips);
+
+ if (babinfo->chips == 0)
+ goto cleanup;
+
+ if (!add_cgpu(babcgpu))
+ goto cleanup;
+
+ mutex_init(&babinfo->res_lock);
+ mutex_init(&babinfo->did_lock);
+ cglock_init(&babinfo->blist_lock);
+
+ babinfo->initialised = true;
+
+ return;
+
+cleanup:
+ close(babinfo->spifd);
+ munmap((void *)(babinfo->gpio), BAB_SPI_BUFSIZ);
+unalloc:
+ mutex_destroy(&babinfo->spi_lock);
+ free(babinfo);
+ free(babcgpu);
+}
+
+static void bab_identify(__maybe_unused struct cgpu_info *babcgpu)
+{
+}
+
+#define BAB_LONG_WAIT_uS 1200000
+#define BAB_WAIT_MSG_EVERY 10
+#define BAB_LONG_WAIT_SLEEP_uS 100000
+#define BAB_STD_WAIT_uS 3000
+
+// thread to do spi txrx
+static void *bab_spi(void *userdata)
+{
+ struct cgpu_info *babcgpu = (struct cgpu_info *)userdata;
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ struct timeval start, stop;
+ double wait;
+ int i, buf, msgs;
+
+ applog(LOG_DEBUG, "%s%i: SPIing...",
+ babcgpu->drv->name, babcgpu->device_id);
+
+ // Wait until we're ready
+ while (babcgpu->shutdown == false) {
+ if (babinfo->initialised) {
+ break;
+ }
+ cgsleep_ms(3);
+ }
+
+ msgs = 0;
+ cgtime(&start);
+ while (babcgpu->shutdown == false) {
+ buf = -1;
+ mutex_lock(&(babinfo->spi_lock));
+ for (i = 0; i < BAB_SPI_BUFFERS; i++) {
+ if (babinfo->buf_status[i] == BAB_STATE_READY) {
+ babinfo->buf_status[i] = BAB_STATE_SENDING;
+ buf = i;
+ cgtime(&start);
+ break;
+ }
+ }
+ mutex_unlock(&(babinfo->spi_lock));
+
+ if (buf == -1) {
+ cgtime(&stop);
+ wait = us_tdiff(&stop, &start);
+ if (wait > BAB_LONG_WAIT_uS) {
+ if ((msgs++ % BAB_WAIT_MSG_EVERY) == 0) {
+ applog(LOG_WARNING, "%s%i: SPI waiting %.0fus ...",
+ babcgpu->drv->name,
+ babcgpu->device_id,
+ (float)wait);
+ }
+ }
+ cgsleep_us(BAB_LONG_WAIT_SLEEP_uS);
+ continue;
+ }
+
+ bab_txrx(buf, babinfo->buf_used[buf], false);
+ cgtime(&stop);
+ wait = us_tdiff(&stop, &start);
+ if (wait < BAB_STD_WAIT_uS)
+ cgsleep_us((uint64_t)(BAB_STD_WAIT_uS - wait));
+ else if (wait > BAB_LONG_WAIT_uS) {
+ applog(LOG_DEBUG, "%s%i: SPI waited %.0fus",
+ babcgpu->drv->name, babcgpu->device_id,
+ (float)wait);
+ }
+
+ mutex_lock(&(babinfo->spi_lock));
+ babinfo->buf_status[i] = BAB_STATE_SENT;
+ mutex_unlock(&(babinfo->spi_lock));
+ msgs = 0;
+ }
+
+ return NULL;
+}
+
+static void bab_flush_work(struct cgpu_info *babcgpu)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+
+ applog(LOG_DEBUG, "%s%i: flushing work",
+ babcgpu->drv->name, babcgpu->device_id);
+
+ mutex_lock(&(babinfo->did_lock));
+ memset(&(babinfo->last_did), 0, sizeof(babinfo->last_did));
+ mutex_unlock(&(babinfo->did_lock));
+}
+
+static void ms3steps(uint32_t *p)
+{
+ uint32_t a, b, c, d, e, f, g, h, new_e, new_a;
+ int i;
+
+ a = p[0];
+ b = p[1];
+ c = p[2];
+ d = p[3];
+ e = p[4];
+ f = p[5];
+ g = p[6];
+ h = p[7];
+ for (i = 0; i < 3; i++) {
+ new_e = p[i+16] + sha256_k[i] + h + CH(e,f,g) + SHA256_F2(e) + d;
+ new_a = p[i+16] + sha256_k[i] + h + CH(e,f,g) + SHA256_F2(e) +
+ SHA256_F1(a) + MAJ(a,b,c);
+ d = c;
+ c = b;
+ b = a;
+ a = new_a;
+ h = g;
+ g = f;
+ f = e;
+ e = new_e;
+ }
+ p[15] = a;
+ p[14] = b;
+ p[13] = c;
+ p[12] = d;
+ p[11] = e;
+ p[10] = f;
+ p[9] = g;
+ p[8] = h;
+}
+
+#define DATA_MERKLE7 16
+#define DATA_NTIME 17
+#define DATA_BITS 18
+#define DATA_NONCE 19
+
+#define WORK_MERKLE7 (16*4)
+#define WORK_NTIME (17*4)
+#define WORK_BITS (18*4)
+#define WORK_NONCE (19*4)
+
+static uint32_t decnonce(uint32_t in)
+{
+ uint32_t out;
+
+ /* First part load */
+ out = (in & 0xFF) << 24;
+ in >>= 8;
+
+ /* Byte reversal */
+ in = (((in & 0xaaaaaaaa) >> 1) | ((in & 0x55555555) << 1));
+ in = (((in & 0xcccccccc) >> 2) | ((in & 0x33333333) << 2));
+ in = (((in & 0xf0f0f0f0) >> 4) | ((in & 0x0f0f0f0f) << 4));
+
+ out |= (in >> 2) & 0x3FFFFF;
+
+ /* Extraction */
+ if (in & 1)
+ out |= (1 << 23);
+ if (in & 2)
+ out |= (1 << 22);
+
+ out -= 0x800004;
+ return out;
+}
+
+/*
+ * Find the matching work item by checking the nonce against each work
+ * item for the chip
+ * Discard any work items older than a match
+ */
+static bool oknonce(struct thr_info *thr, struct cgpu_info *babcgpu, int chip, uint32_t nonce)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ BLIST *bitem;
+ unsigned int links, tests;
+ int i;
+
+ babinfo->chip_nonces[chip]++;
+
+ nonce = decnonce(nonce);
+
+ /*
+ * We can grab the head of the chip work queue and then
+ * release the lock and follow it to the end
+ * since the other thread will only add items above the
+ * head - it wont touch the list->next pointers from the
+ * head to the end - only the head->prev pointer may get
+ * changed
+ */
+ cg_rlock(&babinfo->blist_lock);
+ bitem = babinfo->chip_list[chip];
+ cg_runlock(&babinfo->blist_lock);
+
+ if (!bitem) {
+ applog(LOG_ERR, "%s%i: chip %d has no work!",
+ babcgpu->drv->name, babcgpu->device_id, chip);
+ babinfo->untested_nonces++;
+ return false;
+ }
+
+ babinfo->tested_nonces++;
+
+ tests = 0;
+ links = 0;
+ while (bitem) {
+ if (!bitem->work) {
+ applog(LOG_ERR, "%s%i: chip %d bitem links %d has no work!",
+ babcgpu->drv->name,
+ babcgpu->device_id,
+ chip, links);
+ } else {
+ for (i = 0; i < BAB_NONCE_OFFSETS; i++) {
+ tests++;
+ if (test_nonce(bitem->work, nonce + bab_nonce_offsets[i])) {
+ submit_tested_work(thr, bitem->work);
+ babinfo->nonce_offset_count[i]++;
+ babinfo->chip_good[chip]++;
+ bitem->nonces++;
+ babinfo->new_nonces++;
+ babinfo->ok_nonces++;
+ free_blist(babcgpu, bitem->next, chip);
+ babinfo->total_tests += tests;
+ if (babinfo->max_tests_per_nonce < tests)
+ babinfo->max_tests_per_nonce = tests;
+ babinfo->total_links += links;
+ if (babinfo->max_links < links)
+ babinfo->max_links = links;
+ return true;
+ }
+ }
+ }
+ bitem = bitem->next;
+ links++;
+ }
+
+ if (babinfo->not_first_reply[chip]) {
+ babinfo->chip_bad[chip]++;
+ inc_hw_errors(thr);
+ } else
+ babinfo->initial_ignored++;
+
+ return false;
+}
+
+// Results checking thread
+static void *bab_res(void *userdata)
+{
+ struct cgpu_info *babcgpu = (struct cgpu_info *)userdata;
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ struct thr_info *thr = babcgpu->thr[0];
+ bool first_second;
+ uint32_t nonce;
+ int chip;
+
+ applog(LOG_DEBUG, "%s%i: Results...",
+ babcgpu->drv->name, babcgpu->device_id);
+
+ // Wait until we're ready
+ while (babcgpu->shutdown == false) {
+ if (babinfo->initialised) {
+ break;
+ }
+ cgsleep_ms(3);
+ }
+
+ while (babcgpu->shutdown == false) {
+ if (!oldest_nonce(babcgpu, &chip, &nonce, &first_second)) {
+ cgsleep_ms(3);
+ continue;
+ }
+
+ if (first_second)
+ babinfo->not_first_reply[chip] = true;
+
+ oknonce(thr, babcgpu, chip, nonce);
+ }
+
+ return NULL;
+}
+
+static bool bab_do_work(struct cgpu_info *babcgpu)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ int busy, newbusy, match, work_items = 0;
+ int spi, mis, miso;
+ int i, j;
+ BLIST *bitem;
+ bool res, got_a_nonce;
+
+ for (i = 0; i < babinfo->chips; i++) {
+ bitem = next_work(babcgpu, i);
+ if (!bitem) {
+ applog(LOG_ERR, "%s%i: short work list (%i) expected %d - discarded",
+ babcgpu->drv->name, babcgpu->device_id,
+ i, babinfo->chips);
+ for (j = 0; j < i; i++)
+ discard_last(babcgpu, j);
+
+ return false;
+ }
+ memcpy((void *)&(babinfo->chip_input[i].midstate[0]),
+ bitem->work->midstate, sizeof(bitem->work->midstate));
+ memcpy((void *)&(babinfo->chip_input[i].merkle7),
+ (void *)&(bitem->work->data[WORK_MERKLE7]), 12);
+
+ ms3steps((void *)&(babinfo->chip_input[i]));
+ work_items++;
+ }
+
+ // Send
+ res = bab_put(babcgpu, babinfo);
+ if (!res) {
+ applog(LOG_DEBUG, "%s%i: couldn't put work ...",
+ babcgpu->drv->name, babcgpu->device_id);
+ }
+
+ // Receive
+ res = bab_get(babcgpu, babinfo);
+ if (!res) {
+ applog(LOG_DEBUG, "%s%i: didn't get work reply ...",
+ babcgpu->drv->name, babcgpu->device_id);
+ return false;
+ }
+
+ applog(LOG_DEBUG, "%s%i: Did get work reply ...",
+ babcgpu->drv->name, babcgpu->device_id);
+
+ spi = mis = miso = 0;
+
+ for (i = 0; i < babinfo->chips; i++) {
+ match = 0;
+ newbusy = busy = babinfo->chip_busy[i];
+
+ if (!babinfo->chip_conf[i])
+ continue;
+
+ for (j = 1; j < BAB_REPLY_NONCES; j++) {
+ if (babinfo->chip_results[i].nonce[(busy+j) % BAB_REPLY_NONCES] !=
+ babinfo->chip_prev[i].nonce[(busy+j) % BAB_REPLY_NONCES])
+ newbusy = (busy+j) % BAB_REPLY_NONCES;
+ else
+ match++;
+ }
+
+ if (!match) {
+ if (!miso) {
+ mis++;
+// ignore for now ... babinfo->chip_miso[i]++;
+ }
+ miso = 1;
+ continue;
+ }
+
+ miso = 0;
+ if (babinfo->chip_results[i].jobsel != 0xffffffff &&
+ babinfo->chip_results[i].jobsel != 0x00000000) {
+ spi++;
+ babinfo->chip_spie[i]++;
+ applog(LOG_DEBUG, "%s%i: SPI ERROR on chip %d (0x%08x)",
+ babcgpu->drv->name, babcgpu->device_id,
+ i, babinfo->chip_results[i].jobsel);
+ }
+
+// Not used yet
+// if (babinfo->chip_results[i].jobsel != babinfo->chip_prev[i].jobsel) {
+
+ got_a_nonce = false;
+ for (; newbusy != busy; busy = (busy + 1) % BAB_REPLY_NONCES) {
+ if (babinfo->chip_results[i].nonce[busy] == 0xffffffff ||
+ babinfo->chip_results[i].nonce[busy] == 0x00000000) {
+ babinfo->chip_results[i].nonce[busy] = babinfo->chip_prev[i].nonce[busy];
+ spi = 1;
+ continue;
+ }
+
+ store_nonce(babcgpu, i,
+ babinfo->chip_results[i].nonce[busy],
+ babinfo->nonce_before[i]);
+
+ got_a_nonce = true;
+ }
+
+ /*
+ * We only care about this after the first reply we find a nonce
+ * After that, the value has no more effect
+ */
+ if (got_a_nonce)
+ babinfo->nonce_before[i] = true;
+
+ mis += miso;
+ babinfo->chip_miso[i] += miso;
+ babinfo->chip_busy[i] = busy;
+ }
+
+ memcpy((void *)(&(babinfo->chip_prev[0])),
+ (void *)(&(babinfo->chip_results[0])),
+ sizeof(babinfo->chip_prev));
+
+ applog(LOG_DEBUG, "Work: items:%d spi:%d miso:%d",
+ work_items, spi, mis);
+
+ return true;
+}
+
+static bool bab_thread_prepare(struct thr_info *thr)
+{
+ struct cgpu_info *babcgpu = thr->cgpu;
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+
+ if (thr_info_create(&(babinfo->spi_thr), NULL, bab_spi, (void *)babcgpu)) {
+ applog(LOG_ERR, "%s%i: SPI thread create failed",
+ babcgpu->drv->name, babcgpu->device_id);
+ return false;
+ }
+ pthread_detach(babinfo->spi_thr.pth);
+
+ /*
+ * We require a seperate results checking thread since there is a lot
+ * of work done checking the results multiple times - thus we don't
+ * want that delay affecting sending/receiving work to/from the device
+ */
+ if (thr_info_create(&(babinfo->res_thr), NULL, bab_res, (void *)babcgpu)) {
+ applog(LOG_ERR, "%s%i: Results thread create failed",
+ babcgpu->drv->name, babcgpu->device_id);
+ return false;
+ }
+ pthread_detach(babinfo->res_thr.pth);
+
+ return true;
+}
+
+static void bab_shutdown(struct thr_info *thr)
+{
+ struct cgpu_info *babcgpu = thr->cgpu;
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ int i;
+
+ applog(LOG_DEBUG, "%s%i: shutting down",
+ babcgpu->drv->name, babcgpu->device_id);
+
+ for (i = 0; i < babinfo->chips; i++)
+// TODO: bab_shutdown(babcgpu, babinfo, i);
+ ;
+
+ babcgpu->shutdown = true;
+}
+
+static bool bab_queue_full(struct cgpu_info *babcgpu)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ struct work *work;
+ bool ret;
+
+ if (babinfo->work_count >= babinfo->chips)
+ ret = true;
+ else {
+ work = get_queued(babcgpu);
+ if (work)
+ store_work(babcgpu, work);
+ else
+ // Avoid a hard loop when we can't get work fast enough
+ cgsleep_ms(10);
+
+ ret = false;
+ }
+
+ return ret;
+}
+
+/*
+ * 1.0s per nonce = 4.2GH/s
+ * So anything around 4GH/s or less per chip should be fine
+ */
+#define BAB_STD_WORK_uS 1000000
+
+#define BAB_STD_DELAY_uS 30000
+
+/*
+ * TODO: allow this to run through more than once - the second+
+ * time not sending any new work unless a flush occurs since:
+ * at the moment we have BAB_STD_WORK_uS latency added to earliest replies
+ */
+static int64_t bab_scanwork(__maybe_unused struct thr_info *thr)
+{
+ struct cgpu_info *babcgpu = thr->cgpu;
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ int64_t hashcount = 0;
+ struct timeval now;
+ double delay;
+
+ bab_do_work(babcgpu);
+
+ // Sleep now so we get the work "bab_queue_full()" just before we use it
+ while (80085) {
+ cgtime(&now);
+ mutex_lock(&(babinfo->did_lock));
+ delay = us_tdiff(&now, &(babinfo->last_did));
+ mutex_unlock(&(babinfo->did_lock));
+ if (delay < (BAB_STD_WORK_uS - BAB_STD_DELAY_uS))
+ cgsleep_us(BAB_STD_DELAY_uS);
+ else
+ break;
+ }
+
+ if (babinfo->new_nonces) {
+ hashcount += 0xffffffffull * babinfo->new_nonces;
+ babinfo->new_nonces = 0;
+ }
+
+ return hashcount;
+}
+
+#define CHIPS_PER_STAT 16
+
+static struct api_data *bab_api_stats(struct cgpu_info *babcgpu)
+{
+ struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+ struct api_data *root = NULL;
+ char data[2048];
+ char buf[32];
+ int i, to, j;
+
+ if (babinfo->initialised == false)
+ return NULL;
+
+ root = api_add_int(root, "Chips", &(babinfo->chips), true);
+
+ for (i = 0; i < babinfo->chips; i += CHIPS_PER_STAT) {
+ to = i + CHIPS_PER_STAT - 1;
+ if (to >= babinfo->chips)
+ to = babinfo->chips - 1;
+
+ data[0] = '\0';
+ for (j = i; j <= to; j++) {
+ snprintf(buf, sizeof(buf),
+ "%s%"PRIu64,
+ j == i ? "" : " ",
+ babinfo->chip_nonces[j]);
+ strcat(data, buf);
+ }
+ snprintf(buf, sizeof(buf), "Nonces %d - %d", i, to);
+ root = api_add_string(root, buf, data, true);
+
+ data[0] = '\0';
+ for (j = i; j <= to; j++) {
+ snprintf(buf, sizeof(buf),
+ "%s%"PRIu64,
+ j == i ? "" : " ",
+ babinfo->chip_good[j]);
+ strcat(data, buf);
+ }
+ snprintf(buf, sizeof(buf), "Good %d - %d", i, to);
+ root = api_add_string(root, buf, data, true);
+
+ data[0] = '\0';
+ for (j = i; j <= to; j++) {
+ snprintf(buf, sizeof(buf),
+ "%s%"PRIu64,
+ j == i ? "" : " ",
+ babinfo->chip_bad[j]);
+ strcat(data, buf);
+ }
+ snprintf(buf, sizeof(buf), "Bad %d - %d", i, to);
+ root = api_add_string(root, buf, data, true);
+
+ data[0] = '\0';
+ for (j = i; j <= to; j++) {
+ snprintf(buf, sizeof(buf),
+ "%s0x%02x",
+ j == i ? "" : " ",
+ (int)(babinfo->chip_conf[j]));
+ strcat(data, buf);
+ }
+ snprintf(buf, sizeof(buf), "Conf %d - %d", i, to);
+ root = api_add_string(root, buf, data, true);
+
+ data[0] = '\0';
+ for (j = i; j <= to; j++) {
+ snprintf(buf, sizeof(buf),
+ "%s0x%02x",
+ j == i ? "" : " ",
+ (int)(babinfo->chip_fast[j]));
+ strcat(data, buf);
+ }
+ snprintf(buf, sizeof(buf), "Fast %d - %d", i, to);
+ root = api_add_string(root, buf, data, true);
+ }
+
+ for (i = 0; i < BAB_NONCE_OFFSETS; i++) {
+ snprintf(buf, sizeof(buf), "Nonce Offset 0x%08x", bab_nonce_offsets[i]);
+ root = api_add_uint64(root, buf, &(babinfo->nonce_offset_count[i]), true);
+ }
+
+ root = api_add_uint64(root, "Tested", &(babinfo->tested_nonces), true);
+ root = api_add_uint64(root, "Total Tests", &(babinfo->total_tests), true);
+ root = api_add_uint64(root, "Max Tests", &(babinfo->max_tests_per_nonce), true);
+ float avg = babinfo->tested_nonces ? (float)(babinfo->total_tests) /
+ (float)(babinfo->tested_nonces) : 0;
+// TODO: add a API_AVG which is 3 places - double/float?
+ root = api_add_volts(root, "Avg Tests", &avg, true);
+ root = api_add_uint64(root, "Untested", &(babinfo->untested_nonces), true);
+
+ root = api_add_uint64(root, "Work Links", &(babinfo->total_links), true);
+ root = api_add_uint64(root, "Max Links", &(babinfo->max_links), true);
+ avg = babinfo->tested_nonces ? (float)(babinfo->total_links) /
+ (float)(babinfo->tested_nonces) : 0;
+ root = api_add_volts(root, "Avg Links", &avg, true);
+
+ root = api_add_uint32(root, "Initial Ignored", &(babinfo->initial_ignored), true);
+
+ root = api_add_int(root, "BList Count", &(babinfo->blist_count), true);
+ root = api_add_int(root, "BFree Count", &(babinfo->bfree_count), true);
+ root = api_add_int(root, "Work Count", &(babinfo->work_count), true);
+ root = api_add_int(root, "Chip Count", &(babinfo->chip_count), true);
+
+ root = api_add_int(root, "RList Count", &(babinfo->rlist_count), true);
+ root = api_add_int(root, "RFree Count", &(babinfo->rfree_count), true);
+ root = api_add_int(root, "Result Count", &(babinfo->res_count), true);
+
+ return root;
+}
+#endif
+
+struct device_drv bab_drv = {
+ .drv_id = DRIVER_bab,
+ .dname = "BlackArrowBitFuryGPIO",
+ .name = "BaB",
+ .drv_detect = bab_detect,
+#ifdef LINUX
+ .get_api_stats = bab_api_stats,
+//TODO: .get_statline_before = get_bab_statline_before,
+ .identify_device = bab_identify,
+ .thread_prepare = bab_thread_prepare,
+ .hash_work = hash_queued_work,
+ .scanwork = bab_scanwork,
+ .queue_full = bab_queue_full,
+ .flush_work = bab_flush_work,
+ .thread_shutdown = bab_shutdown
+#endif
+};
diff --git a/driver-bitforce.c b/driver-bitforce.c
index 6cd0d52..901ba08 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -483,18 +483,18 @@ re_send:
memcpy(ob + 8 + 32, work->data + 64, 12);
if (!bitforce->nonce_range) {
sprintf((char *)ob + 8 + 32 + 12, ">>>>>>>>");
- work->blk.nonce = bitforce->nonces = 0xffffffff;
+ work->nonce = bitforce->nonces = 0xffffffff;
len = 60;
} else {
uint32_t *nonce;
nonce = (uint32_t *)(ob + 8 + 32 + 12);
- *nonce = htobe32(work->blk.nonce);
+ *nonce = htobe32(work->nonce);
nonce = (uint32_t *)(ob + 8 + 32 + 12 + 4);
/* Split work up into 1/5th nonce ranges */
bitforce->nonces = 0x33333332;
- *nonce = htobe32(work->blk.nonce + bitforce->nonces);
- work->blk.nonce += bitforce->nonces + 1;
+ *nonce = htobe32(work->nonce + bitforce->nonces);
+ work->nonce += bitforce->nonces + 1;
sprintf((char *)ob + 8 + 32 + 12 + 8, ">>>>>>>>");
len = 68;
}
@@ -634,12 +634,12 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
#ifndef __BIG_ENDIAN__
nonce = swab32(nonce);
#endif
- if (unlikely(bitforce->nonce_range && (nonce >= work->blk.nonce ||
- (work->blk.nonce > 0 && nonce < work->blk.nonce - bitforce->nonces - 1)))) {
+ if (unlikely(bitforce->nonce_range && (nonce >= work->nonce ||
+ (work->nonce > 0 && nonce < work->nonce - bitforce->nonces - 1)))) {
applog(LOG_WARNING, "%s%i: Disabling broken nonce range support",
bitforce->drv->name, bitforce->device_id);
bitforce->nonce_range = false;
- work->blk.nonce = 0xffffffff;
+ work->nonce = 0xffffffff;
bitforce->sleep_ms *= 5;
bitforce->kname = KNAME_WORK;
}
diff --git a/driver-bitfury.c b/driver-bitfury.c
index b177626..3331d82 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -224,13 +224,12 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
{
struct cgpu_info *bitfury = thr->cgpu;
struct bitfury_info *info = bitfury->device_data;
+ int amount, i, aged = 0, total = 0, ms_diff;
struct work *work, *tmp;
- int amount, i, aged = 0;
struct timeval tv_now;
double nonce_rate;
int64_t ret = 0;
char buf[45];
- int ms_diff;
work = get_queue_work(thr, bitfury, thr->id);
if (unlikely(thr->work_restart)) {
@@ -248,27 +247,28 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
cgtime(&tv_now);
ms_diff = 600 - ms_tdiff(&tv_now, &info->tv_start);
if (ms_diff > 0) {
- usb_read_timeout_cancellable(bitfury, info->buf, 512, &amount, ms_diff, C_BF1_GETRES);
- info->tot += amount;
+ usb_read_timeout_cancellable(bitfury, info->buf, 512, &amount, ms_diff,
+ C_BF1_GETRES);
+ total += amount;
}
- if (unlikely(thr->work_restart))
- goto out;
-
/* Now look for the bulk of the previous work results, they will come
* in a batch following the first data. */
cgtime(&tv_now);
ms_diff = BF1WAIT - ms_tdiff(&tv_now, &info->tv_start);
- if (unlikely(ms_diff < 10))
+ /* If a work restart was sent, just empty the buffer. */
+ if (unlikely(ms_diff < 10 || thr->work_restart))
ms_diff = 10;
- usb_read_once_timeout_cancellable(bitfury, info->buf + info->tot, BF1MSGSIZE,
+ usb_read_once_timeout_cancellable(bitfury, info->buf + total, BF1MSGSIZE,
&amount, ms_diff, C_BF1_GETRES);
- info->tot += amount;
+ total += amount;
while (amount) {
- usb_read_once_timeout(bitfury, info->buf + info->tot, 512, &amount, 10, C_BF1_GETRES);
- info->tot += amount;
+ usb_read_once_timeout(bitfury, info->buf + total, 512, &amount, 10,
+ C_BF1_GETRES);
+ total += amount;
};
+ /* Don't send whatever work we've stored if we got a restart */
if (unlikely(thr->work_restart))
goto out;
@@ -280,9 +280,10 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
/* Get response acknowledging work */
usb_read(bitfury, buf, BF1MSGSIZE, &amount, C_BF1_GETWORK);
+out:
/* Search for what work the nonce matches in order of likelihood. Last
* entry is end of result marker. */
- for (i = 0; i < info->tot - BF1MSGSIZE; i += BF1MSGSIZE) {
+ for (i = 0; i < total - BF1MSGSIZE; i += BF1MSGSIZE) {
bool found = false;
uint32_t nonce;
@@ -304,8 +305,6 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
inc_hw_errors(thr);
}
- info->tot = 0;
-out:
cgtime(&tv_now);
/* This iterates over the hashlist finding work started more than 6
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 2f09de1..79921b8 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -19,7 +19,6 @@ struct bitfury_info {
char product[8];
uint32_t serial;
char buf[512];
- int tot;
int nonces;
int total_nonces;
double saved_nonces;
diff --git a/driver-drillbit.c b/driver-drillbit.c
index 0381aed..0364cf6 100644
--- a/driver-drillbit.c
+++ b/driver-drillbit.c
@@ -622,7 +622,6 @@ static int64_t drillbit_scanhash(struct thr_info *thr, struct work *work,
cascade:
drillbit_empty_buffer(drillbit);
- work->blk.nonce = 0xffffffff;
if (unlikely(drillbit->usbinfo.nodev)) {
applog(LOG_WARNING, "%s %d: Device disappeared, disabling thread",
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 7549a83..0b230fa 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -128,14 +128,17 @@ static bool hfa_send_frame(struct cgpu_info *hashfast, uint8_t opcode, uint16_t
return true;
}
-static bool hfa_send_header(struct cgpu_info *hashfast, struct hf_header *h, int cmd)
+/* Send an already assembled packet, consisting of an 8 byte header which may
+ * or may not be followed by a packet body. */
+
+static bool hfa_send_packet(struct cgpu_info *hashfast, struct hf_header *h, int cmd)
{
int amount, ret, len;
- len = sizeof(*h);
+ len = sizeof(*h) + h->data_length * 4;
ret = usb_write(hashfast, (char *)h, len, &amount, hfa_cmds[cmd].usb_cmd);
if (ret < 0 || amount != len) {
- applog(LOG_WARNING, "HFA%d: send_header: %s USB Send error, ret %d amount %d vs. length %d",
+ applog(LOG_WARNING, "HFA%d: send_packet: %s USB Send error, ret %d amount %d vs. length %d",
hashfast->device_id, hfa_cmds[cmd].cmd_name, ret, amount, len);
return false;
}
@@ -187,33 +190,57 @@ static bool hfa_get_data(struct cgpu_info *hashfast, char *buf, int len4)
return true;
}
+static const char *hf_usb_init_errors[] = {
+ "Success",
+ "Reset timeout",
+ "Address cycle timeout",
+ "Clockgate operation timeout",
+ "Configuration operation timeout",
+ "Excessive core failures",
+ "All cores failed diagnostics",
+ "Too many groups configured - increase ntime roll amount"
+};
+
static bool hfa_reset(struct cgpu_info *hashfast, struct hashfast_info *info)
{
struct hf_usb_init_header usb_init, *hu = &usb_init;
struct hf_usb_init_base *db;
+ struct hf_usb_init_options *ho;
+ int retries = 0, i;
char buf[1024];
struct hf_header *h = (struct hf_header *)buf;
uint8_t hcrc;
bool ret;
- int i;
- info->hash_clock_rate = 550; // Hash clock rate in Mhz
+ // XXX Following items need to be defaults with command-line overrides
+ info->hash_clock_rate = 550; // Hash clock rate in Mhz
+ info->group_ntime_roll = 1;
+ info->core_ntime_roll = 1;
+
// Assemble the USB_INIT request
memset(hu, 0, sizeof(*hu));
hu->preamble = HF_PREAMBLE;
hu->operation_code = OP_USB_INIT;
- hu->protocol = PROTOCOL_GLOBAL_WORK_QUEUE; // Protocol to use
- hu->hash_clock = info->hash_clock_rate; // Hash clock rate in Mhz
+ hu->protocol = PROTOCOL_GLOBAL_WORK_QUEUE; // Protocol to use
+ hu->hash_clock = info->hash_clock_rate; // Hash clock rate in Mhz
+ if (info->group_ntime_roll > 1 && info->core_ntime_roll) {
+ ho = (struct hf_usb_init_options *)(hu + 1);
+ memset(ho, 0, sizeof(*ho));
+ ho->group_ntime_roll = info->group_ntime_roll;
+ ho->core_ntime_roll = info->core_ntime_roll;
+ hu->data_length = sizeof(*ho) / 4;
+ }
hu->crc8 = hfa_crc8((uint8_t *)hu);
applog(LOG_INFO, "HFA%d: Sending OP_USB_INIT with GWQ protocol specified",
hashfast->device_id);
- if (!hfa_send_header(hashfast, (struct hf_header *)hu, HF_USB_CMD(OP_USB_INIT)))
+ if (!hfa_send_packet(hashfast, (struct hf_header *)hu, HF_USB_CMD(OP_USB_INIT)))
return false;
// Check for the correct response.
// We extend the normal timeout - a complete device initialization, including
// bringing power supplies up from standby, etc., can take over a second.
+tryagain:
for (i = 0; i < 30; i++) {
ret = hfa_get_header(hashfast, h, &hcrc);
if (ret)
@@ -228,8 +255,13 @@ static bool hfa_reset(struct cgpu_info *hashfast, struct hashfast_info *info)
return false;
}
if (h->operation_code != OP_USB_INIT) {
- applog(LOG_WARNING, "HFA %d: OP_USB_INIT: Tossing packet, valid but unexpected type", hashfast->device_id);
+ // This can happen if valid packet(s) were in transit *before* the OP_USB_INIT arrived
+ // at the device, so we just toss the packets and keep looking for the response.
+ applog(LOG_WARNING, "HFA %d: OP_USB_INIT: Tossing packet, valid but unexpected type %d",
+ hashfast->device_id, h->operation_code);
hfa_get_data(hashfast, buf, h->data_length);
+ if (retries++ < 3)
+ goto tryagain;
return false;
}
@@ -241,7 +273,7 @@ static bool hfa_reset(struct cgpu_info *hashfast, struct hashfast_info *info)
info->asic_count = h->chip_address;
info->core_count = h->core_address;
info->device_type = (uint8_t)h->hdata;
- info->ref_frequency = (uint8_t)(h->hdata>>8);
+ info->ref_frequency = (uint8_t)(h->hdata >> 8);
info->hash_sequence_head = 0;
info->hash_sequence_tail = 0;
info->device_sequence_tail = 0;
@@ -286,6 +318,15 @@ static bool hfa_reset(struct cgpu_info *hashfast, struct hashfast_info *info)
return false;
}
+ // See if the initialization suceeded
+ if (db->operation_status) {
+ applog(LOG_WARNING, "HFA %d: OP_USB_INIT failed! Operation status %d (%s)",
+ hashfast->device_id, db->operation_status,
+ (db->operation_status < sizeof(hf_usb_init_errors)/sizeof(hf_usb_init_errors[0])) ?
+ hf_usb_init_errors[db->operation_status] : "Unknown error code");
+ return false;
+ }
+
return true;
}
@@ -390,9 +431,15 @@ static bool hfa_detect_one_usb(libusb_device *dev, struct usb_find_devices *foun
return false;
}
- add_cgpu(hashfast);
+ if (!hfa_detect_common(hashfast)) {
+ usb_uninit(hashfast);
+ hashfast = usb_free_cgpu(hashfast);
+ return false;
+ }
+ if (!add_cgpu(hashfast))
+ return false;
- return hfa_detect_common(hashfast);
+ return true;
}
static void hfa_detect(bool hotplug)
diff --git a/driver-hashfast.h b/driver-hashfast.h
index 6c8efb2..cf6b7ad 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -79,6 +79,8 @@ struct hashfast_info {
struct hf_config_data config_data; // Configuration data used from USB_INIT
int core_bitmap_size; // in bytes
uint32_t *core_bitmap; // Core OK bitmap test results, run with PLL Bypassed
+ int group_ntime_roll; // Total ntime roll amount per group
+ int core_ntime_roll; // Total core ntime roll amount
pthread_mutex_t lock;
struct work **works;
diff --git a/driver-icarus.c b/driver-icarus.c
index 2e26836..7da4a99 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -1143,8 +1143,6 @@ static int64_t icarus_scanwork(struct thr_info *thr)
if (ret == ICA_NONCE_ERROR)
goto out;
- work->blk.nonce = 0xffffffff;
-
// aborted before becoming idle, get new work
if (ret == ICA_NONCE_TIMEOUT || ret == ICA_NONCE_RESTART) {
timersub(&tv_finish, &tv_start, &elapsed);
diff --git a/driver-klondike.c b/driver-klondike.c
index a445bf4..3a740ec 100644
--- a/driver-klondike.c
+++ b/driver-klondike.c
@@ -1129,26 +1129,28 @@ static void klondike_flush_work(struct cgpu_info *klncgpu)
KLINE kline;
int slaves, dev;
- wr_lock(&(klninfo->stat_lock));
- klninfo->block_seq++;
- slaves = klninfo->status[0].kline.ws.slavecount;
- wr_unlock(&(klninfo->stat_lock));
+ if (klninfo->initialised) {
+ wr_lock(&(klninfo->stat_lock));
+ klninfo->block_seq++;
+ slaves = klninfo->status[0].kline.ws.slavecount;
+ wr_unlock(&(klninfo->stat_lock));
- applog(LOG_DEBUG, "%s%i: flushing work",
- klncgpu->drv->name, klncgpu->device_id);
- zero_kline(&kline);
- kline.hd.cmd = KLN_CMD_ABORT;
- for (dev = 0; dev <= slaves; dev++) {
- kline.hd.dev = dev;
- kitem = SendCmdGetReply(klncgpu, &kline, KSENDHD(0));
- if (kitem != NULL) {
- wr_lock(&(klninfo->stat_lock));
- memcpy((void *)&(klninfo->status[dev]),
- kitem,
- sizeof(klninfo->status[dev]));
- klninfo->jobque[dev].flushed = true;
- wr_unlock(&(klninfo->stat_lock));
- kitem = release_kitem(klncgpu, kitem);
+ applog(LOG_DEBUG, "%s%i: flushing work",
+ klncgpu->drv->name, klncgpu->device_id);
+ zero_kline(&kline);
+ kline.hd.cmd = KLN_CMD_ABORT;
+ for (dev = 0; dev <= slaves; dev++) {
+ kline.hd.dev = dev;
+ kitem = SendCmdGetReply(klncgpu, &kline, KSENDHD(0));
+ if (kitem != NULL) {
+ wr_lock(&(klninfo->stat_lock));
+ memcpy((void *)&(klninfo->status[dev]),
+ kitem,
+ sizeof(klninfo->status[dev]));
+ klninfo->jobque[dev].flushed = true;
+ wr_unlock(&(klninfo->stat_lock));
+ kitem = release_kitem(klncgpu, kitem);
+ }
}
}
}
@@ -1432,7 +1434,8 @@ static void get_klondike_statline_before(char *buf, size_t siz, struct cgpu_info
}
rd_unlock(&(klninfo->stat_lock));
fan /= slaves + 1;
- fan *= 100/255;
+ //fan *= 100/255; // <-- You can't do this because int 100 / int 255 == 0
+ fan = 100 * fan / 255;
if (fan > 99) // short on screen space
fan = 99;
clock /= slaves + 1;
diff --git a/driver-modminer.c b/driver-modminer.c
index 44ee90c..e10cbba 100644
--- a/driver-modminer.c
+++ b/driver-modminer.c
@@ -1029,7 +1029,7 @@ tryagain:
if (hashes > 0xffffffff)
hashes = 0xffffffff;
- work->blk.nonce = 0xffffffff;
+ work->nonce = 0xffffffff;
return hashes;
}
diff --git a/driver-opencl.c b/driver-opencl.c
deleted file mode 100644
index d7b663a..0000000
--- a/driver-opencl.c
+++ /dev/null
@@ -1,1591 +0,0 @@
-/*
- * Copyright 2011-2012 Con Kolivas
- * Copyright 2011-2012 Luke Dashjr
- * Copyright 2010 Jeff Garzik
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version. See COPYING for more details.
- */
-
-#include "config.h"
-
-#ifdef HAVE_CURSES
-#include <curses.h>
-#endif
-
-#include <string.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-#include <sys/types.h>
-
-#ifndef WIN32
-#include <sys/resource.h>
-#endif
-#include <ccan/opt/opt.h>
-
-#include "compat.h"
-#include "miner.h"
-#include "driver-opencl.h"
-#include "findnonce.h"
-#include "ocl.h"
-#include "adl.h"
-#include "util.h"
-
-/* TODO: cleanup externals ********************/
-
-#ifdef HAVE_CURSES
-extern WINDOW *mainwin, *statuswin, *logwin;
-extern void enable_curses(void);
-#endif
-
-extern int mining_threads;
-extern double total_secs;
-extern int opt_g_threads;
-extern bool opt_loginput;
-extern char *opt_kernel_path;
-extern int gpur_thr_id;
-extern bool opt_noadl;
-extern bool have_opencl;
-
-extern void *miner_thread(void *userdata);
-extern int dev_from_id(int thr_id);
-extern void decay_time(double *f, double fadd);
-
-/**********************************************/
-
-#ifdef HAVE_ADL
-extern float gpu_temp(int gpu);
-extern int gpu_fanspeed(int gpu);
-extern int gpu_fanpercent(int gpu);
-#endif
-
-#ifdef HAVE_OPENCL
-char *set_vector(char *arg)
-{
- int i, val = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set vector";
- val = atoi(nextptr);
- if (val != 1 && val != 2 && val != 4)
- return "Invalid value passed to set_vector";
-
- gpus[device++].vwidth = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
- if (val != 1 && val != 2 && val != 4)
- return "Invalid value passed to set_vector";
-
- gpus[device++].vwidth = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].vwidth = gpus[0].vwidth;
- }
-
- return NULL;
-}
-
-char *set_worksize(char *arg)
-{
- int i, val = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set work size";
- val = atoi(nextptr);
- if (val < 1 || val > 9999)
- return "Invalid value passed to set_worksize";
-
- gpus[device++].work_size = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
- if (val < 1 || val > 9999)
- return "Invalid value passed to set_worksize";
-
- gpus[device++].work_size = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].work_size = gpus[0].work_size;
- }
-
- return NULL;
-}
-
-#ifdef USE_SCRYPT
-char *set_shaders(char *arg)
-{
- int i, val = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set lookup gap";
- val = atoi(nextptr);
-
- gpus[device++].shaders = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
-
- gpus[device++].shaders = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].shaders = gpus[0].shaders;
- }
-
- return NULL;
-}
-
-char *set_lookup_gap(char *arg)
-{
- int i, val = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set lookup gap";
- val = atoi(nextptr);
-
- gpus[device++].opt_lg = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
-
- gpus[device++].opt_lg = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].opt_lg = gpus[0].opt_lg;
- }
-
- return NULL;
-}
-
-char *set_thread_concurrency(char *arg)
-{
- int i, val = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set thread concurrency";
- val = atoi(nextptr);
-
- gpus[device++].opt_tc = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
-
- gpus[device++].opt_tc = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].opt_tc = gpus[0].opt_tc;
- }
-
- return NULL;
-}
-#endif
-
-static enum cl_kernels select_kernel(char *arg)
-{
- if (!strcmp(arg, "diablo"))
- return KL_DIABLO;
- if (!strcmp(arg, "diakgcn"))
- return KL_DIAKGCN;
- if (!strcmp(arg, "poclbm"))
- return KL_POCLBM;
- if (!strcmp(arg, "phatk"))
- return KL_PHATK;
-#ifdef USE_SCRYPT
- if (!strcmp(arg, "scrypt"))
- return KL_SCRYPT;
-#endif
- return KL_NONE;
-}
-
-char *set_kernel(char *arg)
-{
- enum cl_kernels kern;
- int i, device = 0;
- char *nextptr;
-
- if (opt_scrypt)
- return "Cannot specify a kernel with scrypt";
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set kernel";
- kern = select_kernel(nextptr);
- if (kern == KL_NONE)
- return "Invalid parameter to set_kernel";
- gpus[device++].kernel = kern;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- kern = select_kernel(nextptr);
- if (kern == KL_NONE)
- return "Invalid parameter to set_kernel";
-
- gpus[device++].kernel = kern;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].kernel = gpus[0].kernel;
- }
-
- return NULL;
-}
-#endif
-
-#ifdef HAVE_ADL
-/* This function allows us to map an adl device to an opencl device for when
- * simple enumeration has failed to match them. */
-char *set_gpu_map(char *arg)
-{
- int val1 = 0, val2 = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set gpu map";
- if (sscanf(arg, "%d:%d", &val1, &val2) != 2)
- return "Invalid description for map pair";
- if (val1 < 0 || val1 > MAX_GPUDEVICES || val2 < 0 || val2 > MAX_GPUDEVICES)
- return "Invalid value passed to set_gpu_map";
-
- gpus[val1].virtual_adl = val2;
- gpus[val1].mapped = true;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- if (sscanf(nextptr, "%d:%d", &val1, &val2) != 2)
- return "Invalid description for map pair";
- if (val1 < 0 || val1 > MAX_GPUDEVICES || val2 < 0 || val2 > MAX_GPUDEVICES)
- return "Invalid value passed to set_gpu_map";
- gpus[val1].virtual_adl = val2;
- gpus[val1].mapped = true;
- }
-
- return NULL;
-}
-
-char *set_gpu_engine(char *arg)
-{
- int i, val1 = 0, val2 = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set gpu engine";
- get_intrange(nextptr, &val1, &val2);
- if (val1 < 0 || val1 > 9999 || val2 < 0 || val2 > 9999)
- return "Invalid value passed to set_gpu_engine";
-
- gpus[device].min_engine = val1;
- gpus[device].gpu_engine = val2;
- device++;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- get_intrange(nextptr, &val1, &val2);
- if (val1 < 0 || val1 > 9999 || val2 < 0 || val2 > 9999)
- return "Invalid value passed to set_gpu_engine";
- gpus[device].min_engine = val1;
- gpus[device].gpu_engine = val2;
- device++;
- }
-
- if (device == 1) {
- for (i = 1; i < MAX_GPUDEVICES; i++) {
- gpus[i].min_engine = gpus[0].min_engine;
- gpus[i].gpu_engine = gpus[0].gpu_engine;
- }
- }
-
- return NULL;
-}
-
-char *set_gpu_fan(char *arg)
-{
- int i, val1 = 0, val2 = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set gpu fan";
- get_intrange(nextptr, &val1, &val2);
- if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100)
- return "Invalid value passed to set_gpu_fan";
-
- gpus[device].min_fan = val1;
- gpus[device].gpu_fan = val2;
- device++;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- get_intrange(nextptr, &val1, &val2);
- if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100)
- return "Invalid value passed to set_gpu_fan";
-
- gpus[device].min_fan = val1;
- gpus[device].gpu_fan = val2;
- device++;
- }
-
- if (device == 1) {
- for (i = 1; i < MAX_GPUDEVICES; i++) {
- gpus[i].min_fan = gpus[0].min_fan;
- gpus[i].gpu_fan = gpus[0].gpu_fan;
- }
- }
-
- return NULL;
-}
-
-char *set_gpu_memclock(char *arg)
-{
- int i, val = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set gpu memclock";
- val = atoi(nextptr);
- if (val < 0 || val >= 9999)
- return "Invalid value passed to set_gpu_memclock";
-
- gpus[device++].gpu_memclock = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
- if (val < 0 || val >= 9999)
- return "Invalid value passed to set_gpu_memclock";
-
- gpus[device++].gpu_memclock = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].gpu_memclock = gpus[0].gpu_memclock;
- }
-
- return NULL;
-}
-
-char *set_gpu_memdiff(char *arg)
-{
- int i, val = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set gpu memdiff";
- val = atoi(nextptr);
- if (val < -9999 || val > 9999)
- return "Invalid value passed to set_gpu_memdiff";
-
- gpus[device++].gpu_memdiff = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
- if (val < -9999 || val > 9999)
- return "Invalid value passed to set_gpu_memdiff";
-
- gpus[device++].gpu_memdiff = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].gpu_memdiff = gpus[0].gpu_memdiff;
- }
-
- return NULL;
-}
-
-char *set_gpu_powertune(char *arg)
-{
- int i, val = 0, device = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set gpu powertune";
- val = atoi(nextptr);
- if (val < -99 || val > 99)
- return "Invalid value passed to set_gpu_powertune";
-
- gpus[device++].gpu_powertune = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
- if (val < -99 || val > 99)
- return "Invalid value passed to set_gpu_powertune";
-
- gpus[device++].gpu_powertune = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].gpu_powertune = gpus[0].gpu_powertune;
- }
-
- return NULL;
-}
-
-char *set_gpu_vddc(char *arg)
-{
- int i, device = 0;
- float val = 0;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set gpu vddc";
- val = atof(nextptr);
- if (val < 0 || val >= 9999)
- return "Invalid value passed to set_gpu_vddc";
-
- gpus[device++].gpu_vddc = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atof(nextptr);
- if (val < 0 || val >= 9999)
- return "Invalid value passed to set_gpu_vddc";
-
- gpus[device++].gpu_vddc = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++)
- gpus[i].gpu_vddc = gpus[0].gpu_vddc;
- }
-
- return NULL;
-}
-
-char *set_temp_overheat(char *arg)
-{
- int i, val = 0, device = 0, *to;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set temp overheat";
- val = atoi(nextptr);
- if (val < 0 || val > 200)
- return "Invalid value passed to set temp overheat";
-
- to = &gpus[device++].adl.overtemp;
- *to = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
- if (val < 0 || val > 200)
- return "Invalid value passed to set temp overheat";
-
- to = &gpus[device++].adl.overtemp;
- *to = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++) {
- to = &gpus[i].adl.overtemp;
- *to = val;
- }
- }
-
- return NULL;
-}
-
-char *set_temp_target(char *arg)
-{
- int i, val = 0, device = 0, *tt;
- char *nextptr;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set temp target";
- val = atoi(nextptr);
- if (val < 0 || val > 200)
- return "Invalid value passed to set temp target";
-
- tt = &gpus[device++].adl.targettemp;
- *tt = val;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- val = atoi(nextptr);
- if (val < 0 || val > 200)
- return "Invalid value passed to set temp target";
-
- tt = &gpus[device++].adl.targettemp;
- *tt = val;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++) {
- tt = &gpus[i].adl.targettemp;
- *tt = val;
- }
- }
-
- return NULL;
-}
-#endif
-#ifdef HAVE_OPENCL
-char *set_intensity(char *arg)
-{
- int i, device = 0, *tt;
- char *nextptr, val = 0;
-
- nextptr = strtok(arg, ",");
- if (nextptr == NULL)
- return "Invalid parameters for set intensity";
- if (!strncasecmp(nextptr, "d", 1))
- gpus[device].dynamic = true;
- else {
- gpus[device].dynamic = false;
- val = atoi(nextptr);
- if (val < MIN_INTENSITY || val > MAX_GPU_INTENSITY)
- return "Invalid value passed to set intensity";
- tt = &gpus[device].intensity;
- *tt = val;
- }
-
- device++;
-
- while ((nextptr = strtok(NULL, ",")) != NULL) {
- if (!strncasecmp(nextptr, "d", 1))
- gpus[device].dynamic = true;
- else {
- gpus[device].dynamic = false;
- val = atoi(nextptr);
- if (val < MIN_INTENSITY || val > MAX_GPU_INTENSITY)
- return "Invalid value passed to set intensity";
-
- tt = &gpus[device].intensity;
- *tt = val;
- }
- device++;
- }
- if (device == 1) {
- for (i = device; i < MAX_GPUDEVICES; i++) {
- gpus[i].dynamic = gpus[0].dynamic;
- gpus[i].intensity = gpus[0].intensity;
- }
- }
-
- return NULL;
-}
-
-void print_ndevs(int *ndevs)
-{
- opt_log_output = true;
- opencl_drv.drv_detect(false);
- clear_adl(*ndevs);
- applog(LOG_INFO, "%i GPU devices max detected", *ndevs);
-}
-#endif
-
-struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
-struct cgpu_info *cpus;
-
-#ifdef HAVE_OPENCL
-
-/* In dynamic mode, only the first thread of each device will be in use.
- * This potentially could start a thread that was stopped with the start-stop
- * options if one were to disable dynamic from the menu on a paused GPU */
-void pause_dynamic_threads(int gpu)
-{
- struct cgpu_info *cgpu = &gpus[gpu];
- int i;
-
- for (i = 1; i < cgpu->threads; i++) {
- struct thr_info *thr;
-
- thr = get_thread(i);
- if (!thr->pause && cgpu->dynamic) {
- applog(LOG_WARNING, "Disabling extra threads due to dynamic mode.");
- applog(LOG_WARNING, "Tune dynamic intensity with --gpu-dyninterval");
- }
-
- thr->pause = cgpu->dynamic;
- if (!cgpu->dynamic && cgpu->deven != DEV_DISABLED)
- cgsem_post(&thr->sem);
- }
-}
-
-#endif /* HAVE_OPENCL */
-
-#if defined(HAVE_OPENCL) && defined(HAVE_CURSES)
-void manage_gpu(void)
-{
- struct thr_info *thr;
- int selected, gpu, i;
- char checkin[40];
- char input;
-
- if (!opt_g_threads)
- return;
-
- opt_loginput = true;
- immedok(logwin, true);
- clear_logwin();
-retry:
-
- for (gpu = 0; gpu < nDevs; gpu++) {
- struct cgpu_info *cgpu = &gpus[gpu];
- double displayed_rolling, displayed_total;
- bool mhash_base = true;
-
- displayed_rolling = cgpu->rolling;
- displayed_total = cgpu->total_mhashes / total_secs;
- if (displayed_rolling < 1) {
- displayed_rolling *= 1000;
- displayed_total *= 1000;
- mhash_base = false;
- }
-
- wlog("GPU %d: %.1f / %.1f %sh/s | A:%d R:%d HW:%d U:%.2f/m I:%d\n",
- gpu, displayed_rolling, displayed_total, mhash_base ? "M" : "K",
- cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
- cgpu->utility, cgpu->intensity);
-#ifdef HAVE_ADL
- if (gpus[gpu].has_adl) {
- int engineclock = 0, memclock = 0, activity = 0, fanspeed = 0, fanpercent = 0, powertune = 0;
- float temp = 0, vddc = 0;
-
- if (gpu_stats(gpu, &temp, &engineclock, &memclock, &vddc, &activity, &fanspeed, &fanpercent, &powertune)) {
- char logline[255];
-
- strcpy(logline, ""); // In case it has no data
- if (temp != -1)
- sprintf(logline, "%.1f C ", temp);
- if (fanspeed != -1 || fanpercent != -1) {
- tailsprintf(logline, sizeof(logline), "F: ");
- if (fanpercent != -1)
- tailsprintf(logline, sizeof(logline), "%d%% ", fanpercent);
- if (fanspeed != -1)
- tailsprintf(logline, sizeof(logline), "(%d RPM) ", fanspeed);
- tailsprintf(logline, sizeof(logline), " ");
- }
- if (engineclock != -1)
- tailsprintf(logline, sizeof(logline), "E: %d MHz ", engineclock);
- if (memclock != -1)
- tailsprintf(logline, sizeof(logline), "M: %d Mhz ", memclock);
- if (vddc != -1)
- tailsprintf(logline, sizeof(logline), "V: %.3fV ", vddc);
- if (activity != -1)
- tailsprintf(logline, sizeof(logline), "A: %d%% ", activity);
- if (powertune != -1)
- tailsprintf(logline, sizeof(logline), "P: %d%%", powertune);
- tailsprintf(logline, sizeof(logline), "\n");
- _wlog(logline);
- }
- }
-#endif
- wlog("Last initialised: %s\n", cgpu->init);
- wlog("Intensity: ");
- if (gpus[gpu].dynamic)
- wlog("Dynamic (only one thread in use)\n");
- else
- wlog("%d\n", gpus[gpu].intensity);
- for (i = 0; i < mining_threads; i++) {
- thr = get_thread(i);
- if (thr->cgpu != cgpu)
- continue;
- get_datestamp(checkin, sizeof(checkin), &thr->last);
- displayed_rolling = thr->rolling;
- if (!mhash_base)
- displayed_rolling *= 1000;
- wlog("Thread %d: %.1f %sh/s %s ", i, displayed_rolling, mhash_base ? "M" : "K" , cgpu->deven != DEV_DISABLED ? "Enabled" : "Disabled");
- switch (cgpu->status) {
- default:
- case LIFE_WELL:
- wlog("ALIVE");
- break;
- case LIFE_SICK:
- wlog("SICK reported in %s", checkin);
- break;
- case LIFE_DEAD:
- wlog("DEAD reported in %s", checkin);
- break;
- case LIFE_INIT:
- case LIFE_NOSTART:
- wlog("Never started");
- break;
- }
- if (thr->pause)
- wlog(" paused");
- wlog("\n");
- }
- wlog("\n");
- }
-
- wlogprint("[E]nable [D]isable [I]ntensity [R]estart GPU %s\n",adl_active ? "[C]hange settings" : "");
-
- wlogprint("Or press any other key to continue\n");
- logwin_update();
- input = getch();
-
- if (nDevs == 1)
- selected = 0;
- else
- selected = -1;
- if (!strncasecmp(&input, "e", 1)) {
- struct cgpu_info *cgpu;
-
- if (selected)
- selected = curses_int("Select GPU to enable");
- if (selected < 0 || selected >= nDevs) {
- wlogprint("Invalid selection\n");
- goto retry;
- }
- if (gpus[selected].deven != DEV_DISABLED) {
- wlogprint("Device already enabled\n");
- goto retry;
- }
- gpus[selected].deven = DEV_ENABLED;
- for (i = 0; i < mining_threads; ++i) {
- thr = get_thread(i);
- cgpu = thr->cgpu;
- if (cgpu->drv->drv_id != DRIVER_opencl)
- continue;
- if (dev_from_id(i) != selected)
- continue;
- if (cgpu->status != LIFE_WELL) {
- wlogprint("Must restart device before enabling it");
- goto retry;
- }
- applog(LOG_DEBUG, "Pushing sem post to thread %d", thr->id);
-
- cgsem_post(&thr->sem);
- }
- goto retry;
- } if (!strncasecmp(&input, "d", 1)) {
- if (selected)
- selected = curses_int("Select GPU to disable");
- if (selected < 0 || selected >= nDevs) {
- wlogprint("Invalid selection\n");
- goto retry;
- }
- if (gpus[selected].deven == DEV_DISABLED) {
- wlogprint("Device already disabled\n");
- goto retry;
- }
- gpus[selected].deven = DEV_DISABLED;
- goto retry;
- } else if (!strncasecmp(&input, "i", 1)) {
- int intensity;
- char *intvar;
-
- if (selected)
- selected = curses_int("Select GPU to change intensity on");
- if (selected < 0 || selected >= nDevs) {
- wlogprint("Invalid selection\n");
- goto retry;
- }
- if (opt_scrypt) {
- intvar = curses_input("Set GPU scan intensity (d or "
- MIN_SCRYPT_INTENSITY_STR " -> "
- MAX_SCRYPT_INTENSITY_STR ")");
- } else {
- intvar = curses_input("Set GPU scan intensity (d or "
- MIN_SHA_INTENSITY_STR " -> "
- MAX_SHA_INTENSITY_STR ")");
- }
- if (!intvar) {
- wlogprint("Invalid input\n");
- goto retry;
- }
- if (!strncasecmp(intvar, "d", 1)) {
- wlogprint("Dynamic mode enabled on gpu %d\n", selected);
- gpus[selected].dynamic = true;
- pause_dynamic_threads(selected);
- free(intvar);
- goto retry;
- }
- intensity = atoi(intvar);
- free(intvar);
- if (intensity < MIN_INTENSITY || intensity > MAX_INTENSITY) {
- wlogprint("Invalid selection\n");
- goto retry;
- }
- gpus[selected].dynamic = false;
- gpus[selected].intensity = intensity;
- wlogprint("Intensity on gpu %d set to %d\n", selected, intensity);
- pause_dynamic_threads(selected);
- goto retry;
- } else if (!strncasecmp(&input, "r", 1)) {
- if (selected)
- selected = curses_int("Select GPU to attempt to restart");
- if (selected < 0 || selected >= nDevs) {
- wlogprint("Invalid selection\n");
- goto retry;
- }
- wlogprint("Attempting to restart threads of GPU %d\n", selected);
- reinit_device(&gpus[selected]);
- goto retry;
- } else if (adl_active && (!strncasecmp(&input, "c", 1))) {
- if (selected)
- selected = curses_int("Select GPU to change settings on");
- if (selected < 0 || selected >= nDevs) {
- wlogprint("Invalid selection\n");
- goto retry;
- }
- change_gpusettings(selected);
- goto retry;
- } else
- clear_logwin();
-
- immedok(logwin, false);
- opt_loginput = false;
-}
-#else
-void manage_gpu(void)
-{
-}
-#endif
-
-
-#ifdef HAVE_OPENCL
-static _clState *clStates[MAX_GPUDEVICES];
-
-#define CL_SET_BLKARG(blkvar) status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->blkvar)
-#define CL_SET_ARG(var) status |= clSetKernelArg(*kernel, num++, sizeof(var), (void *)&var)
-#define CL_SET_VARG(args, var) status |= clSetKernelArg(*kernel, num++, args * sizeof(uint), (void *)var)
-
-static cl_int queue_poclbm_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint threads)
-{
- cl_kernel *kernel = &clState->kernel;
- unsigned int num = 0;
- cl_int status = 0;
-
- CL_SET_BLKARG(ctx_a);
- CL_SET_BLKARG(ctx_b);
- CL_SET_BLKARG(ctx_c);
- CL_SET_BLKARG(ctx_d);
- CL_SET_BLKARG(ctx_e);
- CL_SET_BLKARG(ctx_f);
- CL_SET_BLKARG(ctx_g);
- CL_SET_BLKARG(ctx_h);
-
- CL_SET_BLKARG(cty_b);
- CL_SET_BLKARG(cty_c);
-
-
- CL_SET_BLKARG(cty_f);
- CL_SET_BLKARG(cty_g);
- CL_SET_BLKARG(cty_h);
-
- if (!clState->goffset) {
- cl_uint vwidth = clState->vwidth;
- uint *nonces = alloca(sizeof(uint) * vwidth);
- unsigned int i;
-
- for (i = 0; i < vwidth; i++)
- nonces[i] = blk->nonce + (i * threads);
- CL_SET_VARG(vwidth, nonces);
- }
-
- CL_SET_BLKARG(fW0);
- CL_SET_BLKARG(fW1);
- CL_SET_BLKARG(fW2);
- CL_SET_BLKARG(fW3);
- CL_SET_BLKARG(fW15);
- CL_SET_BLKARG(fW01r);
-
- CL_SET_BLKARG(D1A);
- CL_SET_BLKARG(C1addK5);
- CL_SET_BLKARG(B1addK6);
- CL_SET_BLKARG(W16addK16);
- CL_SET_BLKARG(W17addK17);
- CL_SET_BLKARG(PreVal4addT1);
- CL_SET_BLKARG(PreVal0);
-
- CL_SET_ARG(clState->outputBuffer);
-
- return status;
-}
-
-static cl_int queue_phatk_kernel(_clState *clState, dev_blk_ctx *blk,
- __maybe_unused cl_uint threads)
-{
- cl_kernel *kernel = &clState->kernel;
- cl_uint vwidth = clState->vwidth;
- unsigned int i, num = 0;
- cl_int status = 0;
- uint *nonces;
-
- CL_SET_BLKARG(ctx_a);
- CL_SET_BLKARG(ctx_b);
- CL_SET_BLKARG(ctx_c);
- CL_SET_BLKARG(ctx_d);
- CL_SET_BLKARG(ctx_e);
- CL_SET_BLKARG(ctx_f);
- CL_SET_BLKARG(ctx_g);
- CL_SET_BLKARG(ctx_h);
-
- CL_SET_BLKARG(cty_b);
- CL_SET_BLKARG(cty_c);
- CL_SET_BLKARG(cty_d);
- CL_SET_BLKARG(cty_f);
- CL_SET_BLKARG(cty_g);
- CL_SET_BLKARG(cty_h);
-
- nonces = alloca(sizeof(uint) * vwidth);
- for (i = 0; i < vwidth; i++)
- nonces[i] = blk->nonce + i;
- CL_SET_VARG(vwidth, nonces);
-
- CL_SET_BLKARG(W16);
- CL_SET_BLKARG(W17);
- CL_SET_BLKARG(PreVal4_2);
- CL_SET_BLKARG(PreVal0);
- CL_SET_BLKARG(PreW18);
- CL_SET_BLKARG(PreW19);
- CL_SET_BLKARG(PreW31);
- CL_SET_BLKARG(PreW32);
-
- CL_SET_ARG(clState->outputBuffer);
-
- return status;
-}
-
-static cl_int queue_diakgcn_kernel(_clState *clState, dev_blk_ctx *blk,
- __maybe_unused cl_uint threads)
-{
- cl_kernel *kernel = &clState->kernel;
- unsigned int num = 0;
- cl_int status = 0;
-
- if (!clState->goffset) {
- cl_uint vwidth = clState->vwidth;
- uint *nonces = alloca(sizeof(uint) * vwidth);
- unsigned int i;
- for (i = 0; i < vwidth; i++)
- nonces[i] = blk->nonce + i;
- CL_SET_VARG(vwidth, nonces);
- }
-
- CL_SET_BLKARG(PreVal0);
- CL_SET_BLKARG(PreVal4_2);
- CL_SET_BLKARG(cty_h);
- CL_SET_BLKARG(D1A);
- CL_SET_BLKARG(cty_b);
- CL_SET_BLKARG(cty_c);
- CL_SET_BLKARG(cty_f);
- CL_SET_BLKARG(cty_g);
- CL_SET_BLKARG(C1addK5);
- CL_SET_BLKARG(B1addK6);
- CL_SET_BLKARG(PreVal0addK7);
- CL_SET_BLKARG(W16addK16);
- CL_SET_BLKARG(W17addK17);
- CL_SET_BLKARG(PreW18);
- CL_SET_BLKARG(PreW19);
- CL_SET_BLKARG(W16);
- CL_SET_BLKARG(W17);
- CL_SET_BLKARG(PreW31);
- CL_SET_BLKARG(PreW32);
-
- CL_SET_BLKARG(ctx_a);
- CL_SET_BLKARG(ctx_b);
- CL_SET_BLKARG(ctx_c);
- CL_SET_BLKARG(ctx_d);
- CL_SET_BLKARG(ctx_e);
- CL_SET_BLKARG(ctx_f);
- CL_SET_BLKARG(ctx_g);
- CL_SET_BLKARG(ctx_h);
-
- CL_SET_BLKARG(zeroA);
- CL_SET_BLKARG(zeroB);
-
- CL_SET_BLKARG(oneA);
- CL_SET_BLKARG(twoA);
- CL_SET_BLKARG(threeA);
- CL_SET_BLKARG(fourA);
- CL_SET_BLKARG(fiveA);
- CL_SET_BLKARG(sixA);
- CL_SET_BLKARG(sevenA);
-
- CL_SET_ARG(clState->outputBuffer);
-
- return status;
-}
-
-static cl_int queue_diablo_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint threads)
-{
- cl_kernel *kernel = &clState->kernel;
- unsigned int num = 0;
- cl_int status = 0;
-
- if (!clState->goffset) {
- cl_uint vwidth = clState->vwidth;
- uint *nonces = alloca(sizeof(uint) * vwidth);
- unsigned int i;
-
- for (i = 0; i < vwidth; i++)
- nonces[i] = blk->nonce + (i * threads);
- CL_SET_VARG(vwidth, nonces);
- }
-
-
- CL_SET_BLKARG(PreVal0);
- CL_SET_BLKARG(PreVal0addK7);
- CL_SET_BLKARG(PreVal4addT1);
- CL_SET_BLKARG(PreW18);
- CL_SET_BLKARG(PreW19);
- CL_SET_BLKARG(W16);
- CL_SET_BLKARG(W17);
- CL_SET_BLKARG(W16addK16);
- CL_SET_BLKARG(W17addK17);
- CL_SET_BLKARG(PreW31);
- CL_SET_BLKARG(PreW32);
-
- CL_SET_BLKARG(D1A);
- CL_SET_BLKARG(cty_b);
- CL_SET_BLKARG(cty_c);
- CL_SET_BLKARG(cty_h);
- CL_SET_BLKARG(cty_f);
- CL_SET_BLKARG(cty_g);
-
- CL_SET_BLKARG(C1addK5);
- CL_SET_BLKARG(B1addK6);
-
- CL_SET_BLKARG(ctx_a);
- CL_SET_BLKARG(ctx_b);
- CL_SET_BLKARG(ctx_c);
- CL_SET_BLKARG(ctx_d);
- CL_SET_BLKARG(ctx_e);
- CL_SET_BLKARG(ctx_f);
- CL_SET_BLKARG(ctx_g);
- CL_SET_BLKARG(ctx_h);
-
- CL_SET_ARG(clState->outputBuffer);
-
- return status;
-}
-
-#ifdef USE_SCRYPT
-static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_unused cl_uint threads)
-{
- unsigned char *midstate = blk->work->midstate;
- cl_kernel *kernel = &clState->kernel;
- unsigned int num = 0;
- cl_uint le_target;
- cl_int status = 0;
-
- le_target = *(cl_uint *)(blk->work->device_target + 28);
- clState->cldata = blk->work->data;
- status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL,NULL);
-
- CL_SET_ARG(clState->CLbuffer0);
- CL_SET_ARG(clState->outputBuffer);
- CL_SET_ARG(clState->padbuffer8);
- CL_SET_VARG(4, &midstate[0]);
- CL_SET_VARG(4, &midstate[16]);
- CL_SET_ARG(le_target);
-
- return status;
-}
-#endif
-
-static void set_threads_hashes(unsigned int vectors,int64_t *hashes, size_t *globalThreads,
- unsigned int minthreads, __maybe_unused int *intensity)
-{
- unsigned int threads = 0;
-
- while (threads < minthreads) {
- threads = 1 << ((opt_scrypt ? 0 : 15) + *intensity);
- if (threads < minthreads) {
- if (likely(*intensity < MAX_INTENSITY))
- (*intensity)++;
- else
- threads = minthreads;
- }
- }
-
- *globalThreads = threads;
- *hashes = threads * vectors;
-}
-#endif /* HAVE_OPENCL */
-
-
-#ifdef HAVE_OPENCL
-/* We have only one thread that ever re-initialises GPUs, thus if any GPU
- * init command fails due to a completely wedged GPU, the thread will never
- * return, unable to harm other GPUs. If it does return, it means we only had
- * a soft failure and then the reinit_gpu thread is ready to tackle another
- * GPU */
-void *reinit_gpu(void *userdata)
-{
- struct thr_info *mythr = userdata;
- struct cgpu_info *cgpu;
- struct thr_info *thr;
- struct timeval now;
- char name[256];
- int thr_id;
- int gpu;
-
- pthread_detach(pthread_self());
-
-select_cgpu:
- cgpu = tq_pop(mythr->q, NULL);
- if (!cgpu)
- goto out;
-
- if (clDevicesNum() != nDevs) {
- applog(LOG_WARNING, "Hardware not reporting same number of active devices, will not attempt to restart GPU");
- goto out;
- }
-
- gpu = cgpu->device_id;
-
- for (thr_id = 0; thr_id < mining_threads; ++thr_id) {
- thr = get_thread(thr_id);
- cgpu = thr->cgpu;
- if (cgpu->drv->drv_id != DRIVER_opencl)
- continue;
- if (dev_from_id(thr_id) != gpu)
- continue;
-
- thr = get_thread(thr_id);
- if (!thr) {
- applog(LOG_WARNING, "No reference to thread %d exists", thr_id);
- continue;
- }
-
- thr->rolling = thr->cgpu->rolling = 0;
- /* Reports the last time we tried to revive a sick GPU */
- cgtime(&thr->sick);
- if (!pthread_cancel(thr->pth)) {
- applog(LOG_WARNING, "Thread %d still exists, killing it off", thr_id);
- } else
- applog(LOG_WARNING, "Thread %d no longer exists", thr_id);
- }
-
- for (thr_id = 0; thr_id < mining_threads; ++thr_id) {
- int virtual_gpu;
-
- thr = get_thread(thr_id);
- cgpu = thr->cgpu;
- if (cgpu->drv->drv_id != DRIVER_opencl)
- continue;
- if (dev_from_id(thr_id) != gpu)
- continue;
-
- virtual_gpu = cgpu->virtual_gpu;
- /* Lose this ram cause we may get stuck here! */
- //tq_freeze(thr->q);
-
- thr->q = tq_new();
- if (!thr->q)
- quit(1, "Failed to tq_new in reinit_gpu");
-
- /* Lose this ram cause we may dereference in the dying thread! */
- //free(clState);
-
- applog(LOG_INFO, "Reinit GPU thread %d", thr_id);
- clStates[thr_id] = initCl(virtual_gpu, name, sizeof(name));
- if (!clStates[thr_id]) {
- applog(LOG_ERR, "Failed to reinit GPU thread %d", thr_id);
- goto select_cgpu;
- }
- applog(LOG_INFO, "initCl() finished. Found %s", name);
-
- if (unlikely(thr_info_create(thr, NULL, miner_thread, thr))) {
- applog(LOG_ERR, "thread %d create failed", thr_id);
- return NULL;
- }
- applog(LOG_WARNING, "Thread %d restarted", thr_id);
- }
-
- cgtime(&now);
- get_datestamp(cgpu->init, sizeof(cgpu->init), &now);
-
- for (thr_id = 0; thr_id < mining_threads; ++thr_id) {
- thr = get_thread(thr_id);
- cgpu = thr->cgpu;
- if (cgpu->drv->drv_id != DRIVER_opencl)
- continue;
- if (dev_from_id(thr_id) != gpu)
- continue;
-
- cgsem_post(&thr->sem);
- }
-
- goto select_cgpu;
-out:
- return NULL;
-}
-#else
-void *reinit_gpu(__maybe_unused void *userdata)
-{
- return NULL;
-}
-#endif
-
-
-#ifdef HAVE_OPENCL
-static void opencl_detect(bool hotplug)
-{
- int i;
-
- if (opt_nogpu || hotplug)
- return;
- nDevs = clDevicesNum();
- if (nDevs < 0) {
- applog(LOG_ERR, "clDevicesNum returned error, no GPUs usable");
- nDevs = 0;
- }
-
- if (!nDevs)
- return;
-
- /* If opt_g_threads is not set, use default 1 thread on scrypt and
- * 2 for regular mining */
- if (opt_g_threads == -1) {
- if (opt_scrypt)
- opt_g_threads = 1;
- else
- opt_g_threads = 2;
- }
-
- if (opt_scrypt)
- opencl_drv.max_diff = 65536;
-
- for (i = 0; i < nDevs; ++i) {
- struct cgpu_info *cgpu;
-
- cgpu = &gpus[i];
- cgpu->deven = DEV_ENABLED;
- cgpu->drv = &opencl_drv;
- cgpu->device_id = i;
- cgpu->threads = opt_g_threads;
- cgpu->virtual_gpu = i;
- add_cgpu(cgpu);
- }
-
- if (!opt_noadl)
- init_adl(nDevs);
-}
-
-static void reinit_opencl_device(struct cgpu_info *gpu)
-{
- tq_push(control_thr[gpur_thr_id].q, gpu);
-}
-
-#ifdef HAVE_ADL
-static void get_opencl_statline_before(char *buf, size_t bufsiz, struct cgpu_info *gpu)
-{
- if (gpu->has_adl) {
- int gpuid = gpu->device_id;
- float gt = gpu_temp(gpuid);
- int gf = gpu_fanspeed(gpuid);
- int gp;
-
- if (gt != -1)
- tailsprintf(buf, bufsiz, "%5.1fC ", gt);
- else
- tailsprintf(buf, bufsiz, " ");
- if (gf != -1)
- // show invalid as 9999
- tailsprintf(buf, bufsiz, "%4dRPM ", gf > 9999 ? 9999 : gf);
- else if ((gp = gpu_fanpercent(gpuid)) != -1)
- tailsprintf(buf, bufsiz, "%3d%% ", gp);
- else
- tailsprintf(buf, bufsiz, " ");
- tailsprintf(buf, bufsiz, "| ");
- } else
- gpu->drv->get_statline_before = &blank_get_statline_before;
-}
-#endif
-
-static void get_opencl_statline(char *buf, size_t bufsiz, struct cgpu_info *gpu)
-{
- tailsprintf(buf, bufsiz, " I:%2d", gpu->intensity);
-}
-
-struct opencl_thread_data {
- cl_int (*queue_kernel_parameters)(_clState *, dev_blk_ctx *, cl_uint);
- uint32_t *res;
-};
-
-static uint32_t *blank_res;
-
-static bool opencl_thread_prepare(struct thr_info *thr)
-{
- char name[256];
- struct timeval now;
- struct cgpu_info *cgpu = thr->cgpu;
- int gpu = cgpu->device_id;
- int virtual_gpu = cgpu->virtual_gpu;
- int i = thr->id;
- static bool failmessage = false;
- int buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE;
-
- if (!blank_res)
- blank_res = calloc(buffersize, 1);
- if (!blank_res) {
- applog(LOG_ERR, "Failed to calloc in opencl_thread_init");
- return false;
- }
-
- strcpy(name, "");
- applog(LOG_INFO, "Init GPU thread %i GPU %i virtual GPU %i", i, gpu, virtual_gpu);
- clStates[i] = initCl(virtual_gpu, name, sizeof(name));
- if (!clStates[i]) {
-#ifdef HAVE_CURSES
- if (use_curses)
- enable_curses();
-#endif
- applog(LOG_ERR, "Failed to init GPU thread %d, disabling device %d", i, gpu);
- if (!failmessage) {
- applog(LOG_ERR, "Restarting the GPU from the menu will not fix this.");
- applog(LOG_ERR, "Try restarting cgminer.");
- failmessage = true;
-#ifdef HAVE_CURSES
- char *buf;
- if (use_curses) {
- buf = curses_input("Press enter to continue");
- if (buf)
- free(buf);
- }
-#endif
- }
- cgpu->deven = DEV_DISABLED;
- cgpu->status = LIFE_NOSTART;
-
- dev_error(cgpu, REASON_DEV_NOSTART);
-
- return false;
- }
- if (!cgpu->name)
- cgpu->name = strdup(name);
- if (!cgpu->kname)
- {
- switch (clStates[i]->chosen_kernel) {
- case KL_DIABLO:
- cgpu->kname = "diablo";
- break;
- case KL_DIAKGCN:
- cgpu->kname = "diakgcn";
- break;
- case KL_PHATK:
- cgpu->kname = "phatk";
- break;
-#ifdef USE_SCRYPT
- case KL_SCRYPT:
- cgpu->kname = "scrypt";
- break;
-#endif
- case KL_POCLBM:
- cgpu->kname = "poclbm";
- break;
- default:
- break;
- }
- }
- applog(LOG_INFO, "initCl() finished. Found %s", name);
- cgtime(&now);
- get_datestamp(cgpu->init, sizeof(cgpu->init), &now);
-
- have_opencl = true;
-
- return true;
-}
-
-static bool opencl_thread_init(struct thr_info *thr)
-{
- const int thr_id = thr->id;
- struct cgpu_info *gpu = thr->cgpu;
- struct opencl_thread_data *thrdata;
- _clState *clState = clStates[thr_id];
- cl_int status = 0;
- thrdata = calloc(1, sizeof(*thrdata));
- thr->cgpu_data = thrdata;
- int buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE;
-
- if (!thrdata) {
- applog(LOG_ERR, "Failed to calloc in opencl_thread_init");
- return false;
- }
-
- switch (clState->chosen_kernel) {
- case KL_POCLBM:
- thrdata->queue_kernel_parameters = &queue_poclbm_kernel;
- break;
- case KL_PHATK:
- thrdata->queue_kernel_parameters = &queue_phatk_kernel;
- break;
- case KL_DIAKGCN:
- thrdata->queue_kernel_parameters = &queue_diakgcn_kernel;
- break;
-#ifdef USE_SCRYPT
- case KL_SCRYPT:
- thrdata->queue_kernel_parameters = &queue_scrypt_kernel;
- break;
-#endif
- default:
- case KL_DIABLO:
- thrdata->queue_kernel_parameters = &queue_diablo_kernel;
- break;
- }
-
- thrdata->res = calloc(buffersize, 1);
-
- if (!thrdata->res) {
- free(thrdata);
- applog(LOG_ERR, "Failed to calloc in opencl_thread_init");
- return false;
- }
-
- status |= clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0,
- buffersize, blank_res, 0, NULL, NULL);
- if (unlikely(status != CL_SUCCESS)) {
- applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed.");
- return false;
- }
-
- gpu->status = LIFE_WELL;
-
- gpu->device_last_well = time(NULL);
-
- return true;
-}
-
-
-static bool opencl_prepare_work(struct thr_info __maybe_unused *thr, struct work *work)
-{
-#ifdef USE_SCRYPT
- if (opt_scrypt)
- work->blk.work = work;
- else
-#endif
- precalc_hash(&work->blk, (uint32_t *)(work->midstate), (uint32_t *)(work->data + 64));
- return true;
-}
-
-extern int opt_dynamic_interval;
-
-static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
- int64_t __maybe_unused max_nonce)
-{
- const int thr_id = thr->id;
- struct opencl_thread_data *thrdata = thr->cgpu_data;
- struct cgpu_info *gpu = thr->cgpu;
- _clState *clState = clStates[thr_id];
- const cl_kernel *kernel = &clState->kernel;
- const int dynamic_us = opt_dynamic_interval * 1000;
-
- cl_int status;
- size_t globalThreads[1];
- size_t localThreads[1] = { clState->wsize };
- int64_t hashes;
- int found = opt_scrypt ? SCRYPT_FOUND : FOUND;
- int buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE;
-
- /* Windows' timer resolution is only 15ms so oversample 5x */
- if (gpu->dynamic && (++gpu->intervals * dynamic_us) > 70000) {
- struct timeval tv_gpuend;
- double gpu_us;
-
- cgtime(&tv_gpuend);
- gpu_us = us_tdiff(&tv_gpuend, &gpu->tv_gpustart) / gpu->intervals;
- if (gpu_us > dynamic_us) {
- if (gpu->intensity > MIN_INTENSITY)
- --gpu->intensity;
- } else if (gpu_us < dynamic_us / 2) {
- if (gpu->intensity < MAX_INTENSITY)
- ++gpu->intensity;
- }
- memcpy(&(gpu->tv_gpustart), &tv_gpuend, sizeof(struct timeval));
- gpu->intervals = 0;
- }
-
- set_threads_hashes(clState->vwidth, &hashes, globalThreads, localThreads[0], &gpu->intensity);
- if (hashes > gpu->max_hashes)
- gpu->max_hashes = hashes;
-
- status = thrdata->queue_kernel_parameters(clState, &work->blk, globalThreads[0]);
- if (unlikely(status != CL_SUCCESS)) {
- applog(LOG_ERR, "Error: clSetKernelArg of all params failed.");
- return -1;
- }
-
- if (clState->goffset) {
- size_t global_work_offset[1];
-
- global_work_offset[0] = work->blk.nonce;
- status = clEnqueueNDRangeKernel(clState->commandQueue, *kernel, 1, global_work_offset,
- globalThreads, localThreads, 0, NULL, NULL);
- } else
- status = clEnqueueNDRangeKernel(clState->commandQueue, *kernel, 1, NULL,
- globalThreads, localThreads, 0, NULL, NULL);
- if (unlikely(status != CL_SUCCESS)) {
- applog(LOG_ERR, "Error %d: Enqueueing kernel onto command queue. (clEnqueueNDRangeKernel)", status);
- return -1;
- }
-
- status = clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
- buffersize, thrdata->res, 0, NULL, NULL);
- if (unlikely(status != CL_SUCCESS)) {
- applog(LOG_ERR, "Error: clEnqueueReadBuffer failed error %d. (clEnqueueReadBuffer)", status);
- return -1;
- }
-
- /* The amount of work scanned can fluctuate when intensity changes
- * and since we do this one cycle behind, we increment the work more
- * than enough to prevent repeating work */
- work->blk.nonce += gpu->max_hashes;
-
- /* This finish flushes the readbuffer set with CL_FALSE in clEnqueueReadBuffer */
- clFinish(clState->commandQueue);
-
- /* FOUND entry is used as a counter to say how many nonces exist */
- if (thrdata->res[found]) {
- /* Clear the buffer again */
- status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_FALSE, 0,
- buffersize, blank_res, 0, NULL, NULL);
- if (unlikely(status != CL_SUCCESS)) {
- applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed.");
- return -1;
- }
- applog(LOG_DEBUG, "GPU %d found something?", gpu->device_id);
- postcalc_hash_async(thr, work, thrdata->res);
- memset(thrdata->res, 0, buffersize);
- /* This finish flushes the writebuffer set with CL_FALSE in clEnqueueWriteBuffer */
- clFinish(clState->commandQueue);
- }
-
- return hashes;
-}
-
-static void opencl_thread_shutdown(struct thr_info *thr)
-{
- const int thr_id = thr->id;
- _clState *clState = clStates[thr_id];
-
- clReleaseKernel(clState->kernel);
- clReleaseProgram(clState->program);
- clReleaseCommandQueue(clState->commandQueue);
- clReleaseContext(clState->context);
-}
-
-struct device_drv opencl_drv = {
- .drv_id = DRIVER_opencl,
- .dname = "opencl",
- .name = "GPU",
- .drv_detect = opencl_detect,
- .reinit_device = reinit_opencl_device,
-#ifdef HAVE_ADL
- .get_statline_before = get_opencl_statline_before,
-#endif
- .get_statline = get_opencl_statline,
- .thread_prepare = opencl_thread_prepare,
- .thread_init = opencl_thread_init,
- .prepare_work = opencl_prepare_work,
- .scanhash = opencl_scanhash,
- .thread_shutdown = opencl_thread_shutdown,
-};
-#endif
diff --git a/driver-opencl.h b/driver-opencl.h
deleted file mode 100644
index 1cb8807..0000000
--- a/driver-opencl.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __DEVICE_GPU_H__
-#define __DEVICE_GPU_H__
-
-#include "miner.h"
-
-
-extern void print_ndevs(int *ndevs);
-extern void *reinit_gpu(void *userdata);
-extern char *set_gpu_map(char *arg);
-extern char *set_gpu_engine(char *arg);
-extern char *set_gpu_fan(char *arg);
-extern char *set_gpu_memclock(char *arg);
-extern char *set_gpu_memdiff(char *arg);
-extern char *set_gpu_powertune(char *arg);
-extern char *set_gpu_vddc(char *arg);
-extern char *set_temp_overheat(char *arg);
-extern char *set_temp_target(char *arg);
-extern char *set_intensity(char *arg);
-extern char *set_vector(char *arg);
-extern char *set_worksize(char *arg);
-#ifdef USE_SCRYPT
-extern char *set_shaders(char *arg);
-extern char *set_lookup_gap(char *arg);
-extern char *set_thread_concurrency(char *arg);
-#endif
-extern char *set_kernel(char *arg);
-void manage_gpu(void);
-extern void pause_dynamic_threads(int gpu);
-
-extern bool have_opencl;
-extern int opt_platform_id;
-
-extern struct device_drv opencl_drv;
-
-#endif /* __DEVICE_GPU_H__ */
diff --git a/example.conf b/example.conf
index ae3366e..2448ed5 100644
--- a/example.conf
+++ b/example.conf
@@ -17,24 +17,9 @@
}
],
-"intensity" : "d,9,9,9",
-"gpu-engine" : "0-985,0-950,0-960,0-1000",
-"gpu-fan" : "0-85,0-85,0-85,0-85",
-"gpu-memclock" : "860,825,835,875",
-"gpu-powertune" : "20,20,20,20",
-"temp-cutoff" : "95,95,95,95",
-"temp-overheat" : "85,85,85,85",
-"temp-target" : "75,75,75,75",
-
-"auto-fan" : true,
-"auto-gpu" : true,
-"expiry" : "120",
"failover-only" : true,
-"gpu-threads" : "2",
-"log" : "5",
-"queue" : "1",
-"scan-time" : "60",
-"temp-hysteresis" : "3",
-
-"kernel-path" : "/usr/local/bin"
+"no-submit-stale" : true,
+"api-listen" : true,
+"api-port" : "4028",
+"api-allow" : "W:192.168.1.0/24,W:127.0.0.1"
}
diff --git a/findnonce.c b/findnonce.c
deleted file mode 100644
index baa652f..0000000
--- a/findnonce.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright 2011-2013 Con Kolivas
- * Copyright 2011 Nils Schneider
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version. See COPYING for more details.
- */
-
-#include "config.h"
-#ifdef HAVE_OPENCL
-
-#include <stdio.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "findnonce.h"
-#include "scrypt.h"
-
-const uint32_t SHA256_K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
-};
-
-#define rotate(x,y) ((x<<y) | (x>>(sizeof(x)*8-y)))
-#define rotr(x,y) ((x>>y) | (x<<(sizeof(x)*8-y)))
-
-#define R(a, b, c, d, e, f, g, h, w, k) \
- h = h + (rotate(e, 26) ^ rotate(e, 21) ^ rotate(e, 7)) + (g ^ (e & (f ^ g))) + k + w; \
- d = d + h; \
- h = h + (rotate(a, 30) ^ rotate(a, 19) ^ rotate(a, 10)) + ((a & b) | (c & (a | b)))
-
-void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data)
-{
- cl_uint A, B, C, D, E, F, G, H;
-
- A = state[0];
- B = state[1];
- C = state[2];
- D = state[3];
- E = state[4];
- F = state[5];
- G = state[6];
- H = state[7];
-
- R(A, B, C, D, E, F, G, H, data[0], SHA256_K[0]);
- R(H, A, B, C, D, E, F, G, data[1], SHA256_K[1]);
- R(G, H, A, B, C, D, E, F, data[2], SHA256_K[2]);
-
- blk->cty_a = A;
- blk->cty_b = B;
- blk->cty_c = C;
- blk->cty_d = D;
-
- blk->D1A = D + 0xb956c25b;
-
- blk->cty_e = E;
- blk->cty_f = F;
- blk->cty_g = G;
- blk->cty_h = H;
-
- blk->ctx_a = state[0];
- blk->ctx_b = state[1];
- blk->ctx_c = state[2];
- blk->ctx_d = state[3];
- blk->ctx_e = state[4];
- blk->ctx_f = state[5];
- blk->ctx_g = state[6];
- blk->ctx_h = state[7];
-
- blk->merkle = data[0];
- blk->ntime = data[1];
- blk->nbits = data[2];
-
- blk->W16 = blk->fW0 = data[0] + (rotr(data[1], 7) ^ rotr(data[1], 18) ^ (data[1] >> 3));
- blk->W17 = blk->fW1 = data[1] + (rotr(data[2], 7) ^ rotr(data[2], 18) ^ (data[2] >> 3)) + 0x01100000;
- blk->PreVal4 = blk->fcty_e = blk->ctx_e + (rotr(B, 6) ^ rotr(B, 11) ^ rotr(B, 25)) + (D ^ (B & (C ^ D))) + 0xe9b5dba5;
- blk->T1 = blk->fcty_e2 = (rotr(F, 2) ^ rotr(F, 13) ^ rotr(F, 22)) + ((F & G) | (H & (F | G)));
- blk->PreVal4_2 = blk->PreVal4 + blk->T1;
- blk->PreVal0 = blk->PreVal4 + blk->ctx_a;
- blk->PreW31 = 0x00000280 + (rotr(blk->W16, 7) ^ rotr(blk->W16, 18) ^ (blk->W16 >> 3));
- blk->PreW32 = blk->W16 + (rotr(blk->W17, 7) ^ rotr(blk->W17, 18) ^ (blk->W17 >> 3));
- blk->PreW18 = data[2] + (rotr(blk->W16, 17) ^ rotr(blk->W16, 19) ^ (blk->W16 >> 10));
- blk->PreW19 = 0x11002000 + (rotr(blk->W17, 17) ^ rotr(blk->W17, 19) ^ (blk->W17 >> 10));
-
-
- blk->W2 = data[2];
-
- blk->W2A = blk->W2 + (rotr(blk->W16, 19) ^ rotr(blk->W16, 17) ^ (blk->W16 >> 10));
- blk->W17_2 = 0x11002000 + (rotr(blk->W17, 19) ^ rotr(blk->W17, 17) ^ (blk->W17 >> 10));
-
- blk->fW2 = data[2] + (rotr(blk->fW0, 17) ^ rotr(blk->fW0, 19) ^ (blk->fW0 >> 10));
- blk->fW3 = 0x11002000 + (rotr(blk->fW1, 17) ^ rotr(blk->fW1, 19) ^ (blk->fW1 >> 10));
- blk->fW15 = 0x00000280 + (rotr(blk->fW0, 7) ^ rotr(blk->fW0, 18) ^ (blk->fW0 >> 3));
- blk->fW01r = blk->fW0 + (rotr(blk->fW1, 7) ^ rotr(blk->fW1, 18) ^ (blk->fW1 >> 3));
-
-
- blk->PreVal4addT1 = blk->PreVal4 + blk->T1;
- blk->T1substate0 = blk->ctx_a - blk->T1;
-
- blk->C1addK5 = blk->cty_c + SHA256_K[5];
- blk->B1addK6 = blk->cty_b + SHA256_K[6];
- blk->PreVal0addK7 = blk->PreVal0 + SHA256_K[7];
- blk->W16addK16 = blk->W16 + SHA256_K[16];
- blk->W17addK17 = blk->W17 + SHA256_K[17];
-
- blk->zeroA = blk->ctx_a + 0x98c7e2a2;
- blk->zeroB = blk->ctx_a + 0xfc08884d;
- blk->oneA = blk->ctx_b + 0x90bb1e3c;
- blk->twoA = blk->ctx_c + 0x50c6645b;
- blk->threeA = blk->ctx_d + 0x3ac42e24;
- blk->fourA = blk->ctx_e + SHA256_K[4];
- blk->fiveA = blk->ctx_f + SHA256_K[5];
- blk->sixA = blk->ctx_g + SHA256_K[6];
- blk->sevenA = blk->ctx_h + SHA256_K[7];
-}
-
-#if 0 // not used any more
-
-#define P(t) (W[(t)&0xF] = W[(t-16)&0xF] + (rotate(W[(t-15)&0xF], 25) ^ rotate(W[(t-15)&0xF], 14) ^ (W[(t-15)&0xF] >> 3)) + W[(t-7)&0xF] + (rotate(W[(t-2)&0xF], 15) ^ rotate(W[(t-2)&0xF], 13) ^ (W[(t-2)&0xF] >> 10)))
-
-#define IR(u) \
- R(A, B, C, D, E, F, G, H, W[u+0], SHA256_K[u+0]); \
- R(H, A, B, C, D, E, F, G, W[u+1], SHA256_K[u+1]); \
- R(G, H, A, B, C, D, E, F, W[u+2], SHA256_K[u+2]); \
- R(F, G, H, A, B, C, D, E, W[u+3], SHA256_K[u+3]); \
- R(E, F, G, H, A, B, C, D, W[u+4], SHA256_K[u+4]); \
- R(D, E, F, G, H, A, B, C, W[u+5], SHA256_K[u+5]); \
- R(C, D, E, F, G, H, A, B, W[u+6], SHA256_K[u+6]); \
- R(B, C, D, E, F, G, H, A, W[u+7], SHA256_K[u+7])
-#define FR(u) \
- R(A, B, C, D, E, F, G, H, P(u+0), SHA256_K[u+0]); \
- R(H, A, B, C, D, E, F, G, P(u+1), SHA256_K[u+1]); \
- R(G, H, A, B, C, D, E, F, P(u+2), SHA256_K[u+2]); \
- R(F, G, H, A, B, C, D, E, P(u+3), SHA256_K[u+3]); \
- R(E, F, G, H, A, B, C, D, P(u+4), SHA256_K[u+4]); \
- R(D, E, F, G, H, A, B, C, P(u+5), SHA256_K[u+5]); \
- R(C, D, E, F, G, H, A, B, P(u+6), SHA256_K[u+6]); \
- R(B, C, D, E, F, G, H, A, P(u+7), SHA256_K[u+7])
-
-#define PIR(u) \
- R(F, G, H, A, B, C, D, E, W[u+3], SHA256_K[u+3]); \
- R(E, F, G, H, A, B, C, D, W[u+4], SHA256_K[u+4]); \
- R(D, E, F, G, H, A, B, C, W[u+5], SHA256_K[u+5]); \
- R(C, D, E, F, G, H, A, B, W[u+6], SHA256_K[u+6]); \
- R(B, C, D, E, F, G, H, A, W[u+7], SHA256_K[u+7])
-
-#define PFR(u) \
- R(A, B, C, D, E, F, G, H, P(u+0), SHA256_K[u+0]); \
- R(H, A, B, C, D, E, F, G, P(u+1), SHA256_K[u+1]); \
- R(G, H, A, B, C, D, E, F, P(u+2), SHA256_K[u+2]); \
- R(F, G, H, A, B, C, D, E, P(u+3), SHA256_K[u+3]); \
- R(E, F, G, H, A, B, C, D, P(u+4), SHA256_K[u+4]); \
- R(D, E, F, G, H, A, B, C, P(u+5), SHA256_K[u+5])
-
-#endif
-
-struct pc_data {
- struct thr_info *thr;
- struct work *work;
- uint32_t res[SCRYPT_MAXBUFFERS];
- pthread_t pth;
- int found;
-};
-
-static void *postcalc_hash(void *userdata)
-{
- struct pc_data *pcd = (struct pc_data *)userdata;
- struct thr_info *thr = pcd->thr;
- unsigned int entry = 0;
- int found = opt_scrypt ? SCRYPT_FOUND : FOUND;
-
- pthread_detach(pthread_self());
-
- /* To prevent corrupt values in FOUND from trying to read beyond the
- * end of the res[] array */
- if (unlikely(pcd->res[found] & ~found)) {
- applog(LOG_WARNING, "%s%d: invalid nonce count - HW error",
- thr->cgpu->drv->name, thr->cgpu->device_id);
- hw_errors++;
- thr->cgpu->hw_errors++;
- pcd->res[found] &= found;
- }
-
- for (entry = 0; entry < pcd->res[found]; entry++) {
- uint32_t nonce = pcd->res[entry];
-
- applog(LOG_DEBUG, "OCL NONCE %u found in slot %d", nonce, entry);
- submit_nonce(thr, pcd->work, nonce);
- }
-
- discard_work(pcd->work);
- free(pcd);
-
- return NULL;
-}
-
-void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res)
-{
- struct pc_data *pcd = malloc(sizeof(struct pc_data));
- int buffersize;
-
- if (unlikely(!pcd)) {
- applog(LOG_ERR, "Failed to malloc pc_data in postcalc_hash_async");
- return;
- }
-
- pcd->thr = thr;
- pcd->work = copy_work(work);
- buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE;
- memcpy(&pcd->res, res, buffersize);
-
- if (pthread_create(&pcd->pth, NULL, postcalc_hash, (void *)pcd)) {
- applog(LOG_ERR, "Failed to create postcalc_hash thread");
- return;
- }
-}
-#endif /* HAVE_OPENCL */
diff --git a/findnonce.h b/findnonce.h
deleted file mode 100644
index fc5a157..0000000
--- a/findnonce.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __FINDNONCE_H__
-#define __FINDNONCE_H__
-#include "miner.h"
-#include "config.h"
-
-#define MAXTHREADS (0xFFFFFFFEULL)
-#define MAXBUFFERS (0x10)
-#define BUFFERSIZE (sizeof(uint32_t) * MAXBUFFERS)
-#define FOUND (0x0F)
-
-#define SCRYPT_MAXBUFFERS (0x100)
-#define SCRYPT_BUFFERSIZE (sizeof(uint32_t) * SCRYPT_MAXBUFFERS)
-#define SCRYPT_FOUND (0xFF)
-
-#ifdef HAVE_OPENCL
-extern void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data);
-extern void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res);
-#endif /* HAVE_OPENCL */
-#endif /*__FINDNONCE_H__*/
diff --git a/miner.h b/miner.h
index 250adec..261527f 100644
--- a/miner.h
+++ b/miner.h
@@ -35,14 +35,6 @@ extern char *curly;
#include <semaphore.h>
#endif
-#ifdef HAVE_OPENCL
-#ifdef __APPLE_CC__
-#include <OpenCL/opencl.h>
-#else
-#include <CL/cl.h>
-#endif
-#endif /* HAVE_OPENCL */
-
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
@@ -250,10 +242,10 @@ static inline int fsync (int fd)
DRIVER_ADD_COMMAND(klondike) \
DRIVER_ADD_COMMAND(knc) \
DRIVER_ADD_COMMAND(drillbit) \
+ DRIVER_ADD_COMMAND(bab) \
DRIVER_ADD_COMMAND(avalon)
#define DRIVER_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \
- DRIVER_ADD_COMMAND(opencl) \
FPGA_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \
ASIC_PARSE_COMMANDS(DRIVER_ADD_COMMAND)
@@ -523,45 +515,12 @@ struct cgpu_info {
int64_t max_hashes;
const char *kname;
-#ifdef HAVE_OPENCL
- bool mapped;
- int virtual_gpu;
- int virtual_adl;
- int intensity;
- bool dynamic;
-
- cl_uint vwidth;
- size_t work_size;
- enum cl_kernels kernel;
- cl_ulong max_alloc;
-
-#ifdef USE_SCRYPT
- int opt_lg, lookup_gap;
- size_t opt_tc, thread_concurrency;
- size_t shaders;
-#endif
- struct timeval tv_gpustart;
- int intervals;
-#endif
bool new_work;
float temp;
int cutofftemp;
-#ifdef HAVE_ADL
- bool has_adl;
- struct gpu_adl adl;
-
- int gpu_engine;
- int min_engine;
- int gpu_fan;
- int min_fan;
- int gpu_memclock;
- int gpu_memdiff;
- int gpu_powertune;
- float gpu_vddc;
-#endif
int diff1;
double diff_accepted;
double diff_rejected;
@@ -1206,40 +1165,6 @@ extern uint64_t best_diff;
extern struct timeval block_timeval;
extern char *workpadding;
-#ifdef HAVE_OPENCL
-typedef struct {
- cl_uint ctx_a; cl_uint ctx_b; cl_uint ctx_c; cl_uint ctx_d;
- cl_uint ctx_e; cl_uint ctx_f; cl_uint ctx_g; cl_uint ctx_h;
- cl_uint cty_a; cl_uint cty_b; cl_uint cty_c; cl_uint cty_d;
- cl_uint cty_e; cl_uint cty_f; cl_uint cty_g; cl_uint cty_h;
- cl_uint merkle; cl_uint ntime; cl_uint nbits; cl_uint nonce;
- cl_uint fW0; cl_uint fW1; cl_uint fW2; cl_uint fW3; cl_uint fW15;
- cl_uint fW01r; cl_uint fcty_e; cl_uint fcty_e2;
- cl_uint W16; cl_uint W17; cl_uint W2;
- cl_uint PreVal4; cl_uint T1;
- cl_uint C1addK5; cl_uint D1A; cl_uint W2A; cl_uint W17_2;
- cl_uint PreVal4addT1; cl_uint T1substate0;
- cl_uint PreVal4_2;
- cl_uint PreVal0;
- cl_uint PreW18;
- cl_uint PreW19;
- cl_uint PreW31;
- cl_uint PreW32;
-
- /* For diakgcn */
- cl_uint B1addK6, PreVal0addK7, W16addK16, W17addK17;
- cl_uint zeroA, zeroB;
- cl_uint oneA, twoA, threeA, fourA, fiveA, sixA, sevenA;
-#ifdef USE_SCRYPT
- struct work *work;
-#endif
-} dev_blk_ctx;
-#else
-typedef struct {
- uint32_t nonce;
-} dev_blk_ctx;
-#endif
-
struct curl_ent {
CURL *curl;
struct list_head node;
@@ -1417,8 +1342,7 @@ struct work {
int rolls;
int drv_rolllimit; /* How much the driver can roll ntime */
-
- dev_blk_ctx blk;
+ uint32_t nonce; /* For devices that hash sole work */
struct thr_info *thr;
int thr_id;
diff --git a/ocl.c b/ocl.c
deleted file mode 100644
index 977eee8..0000000
--- a/ocl.c
+++ /dev/null
@@ -1,848 +0,0 @@
-/*
- * Copyright 2011-2012 Con Kolivas
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version. See COPYING for more details.
- */
-
-#include "config.h"
-#ifdef HAVE_OPENCL
-
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <limits.h>
-#include <sys/types.h>
-
-#ifdef WIN32
- #include <winsock2.h>
-#else
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <netdb.h>
-#endif
-
-#include <time.h>
-#include <sys/time.h>
-#include <pthread.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "findnonce.h"
-#include "ocl.h"
-
-int opt_platform_id = -1;
-
-char *file_contents(const char *filename, int *length)
-{
- char *fullpath = alloca(PATH_MAX);
- void *buffer;
- FILE *f;
-
- strcpy(fullpath, opt_kernel_path);
- strcat(fullpath, filename);
-
- /* Try in the optional kernel path or installed prefix first */
- f = fopen(fullpath, "rb");
- if (!f) {
- /* Then try from the path cgminer was called */
- strcpy(fullpath, cgminer_path);
- strcat(fullpath, filename);
- f = fopen(fullpath, "rb");
- }
- /* Finally try opening it directly */
- if (!f)
- f = fopen(filename, "rb");
-
- if (!f) {
- applog(LOG_ERR, "Unable to open %s or %s for reading", filename, fullpath);
- return NULL;
- }
-
- fseek(f, 0, SEEK_END);
- *length = ftell(f);
- fseek(f, 0, SEEK_SET);
-
- buffer = malloc(*length+1);
- *length = fread(buffer, 1, *length, f);
- fclose(f);
- ((char*)buffer)[*length] = '\0';
-
- return (char*)buffer;
-}
-
-int clDevicesNum(void) {
- cl_int status;
- char pbuff[256];
- cl_uint numDevices;
- cl_uint numPlatforms;
- int most_devices = -1;
- cl_platform_id *platforms;
- cl_platform_id platform = NULL;
- unsigned int i, mdplatform = 0;
-
- status = clGetPlatformIDs(0, NULL, &numPlatforms);
- /* If this fails, assume no GPUs. */
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: clGetPlatformsIDs failed (no OpenCL SDK installed?)", status);
- return -1;
- }
-
- if (numPlatforms == 0) {
- applog(LOG_ERR, "clGetPlatformsIDs returned no platforms (no OpenCL SDK installed?)");
- return -1;
- }
-
- platforms = (cl_platform_id *)alloca(numPlatforms*sizeof(cl_platform_id));
- status = clGetPlatformIDs(numPlatforms, platforms, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Getting Platform Ids. (clGetPlatformsIDs)", status);
- return -1;
- }
-
- for (i = 0; i < numPlatforms; i++) {
- if (opt_platform_id >= 0 && (int)i != opt_platform_id)
- continue;
-
- status = clGetPlatformInfo( platforms[i], CL_PLATFORM_VENDOR, sizeof(pbuff), pbuff, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Getting Platform Info. (clGetPlatformInfo)", status);
- return -1;
- }
- platform = platforms[i];
- applog(LOG_INFO, "CL Platform %d vendor: %s", i, pbuff);
- status = clGetPlatformInfo(platform, CL_PLATFORM_NAME, sizeof(pbuff), pbuff, NULL);
- if (status == CL_SUCCESS)
- applog(LOG_INFO, "CL Platform %d name: %s", i, pbuff);
- status = clGetPlatformInfo(platform, CL_PLATFORM_VERSION, sizeof(pbuff), pbuff, NULL);
- if (status == CL_SUCCESS)
- applog(LOG_INFO, "CL Platform %d version: %s", i, pbuff);
- status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
- if (status != CL_SUCCESS) {
- applog(LOG_INFO, "Error %d: Getting Device IDs (num)", status);
- continue;
- }
- applog(LOG_INFO, "Platform %d devices: %d", i, numDevices);
- if ((int)numDevices > most_devices) {
- most_devices = numDevices;
- mdplatform = i;
- }
- if (numDevices) {
- unsigned int j;
- cl_device_id *devices = (cl_device_id *)malloc(numDevices*sizeof(cl_device_id));
-
- clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numDevices, devices, NULL);
- for (j = 0; j < numDevices; j++) {
- clGetDeviceInfo(devices[j], CL_DEVICE_NAME, sizeof(pbuff), pbuff, NULL);
- applog(LOG_INFO, "\t%i\t%s", j, pbuff);
- }
- free(devices);
- }
- }
-
- if (opt_platform_id < 0)
- opt_platform_id = mdplatform;;
-
- return most_devices;
-}
-
-static int advance(char **area, unsigned *remaining, const char *marker)
-{
- char *find = memmem(*area, *remaining, marker, strlen(marker));
-
- if (!find) {
- applog(LOG_DEBUG, "Marker \"%s\" not found", marker);
- return 0;
- }
- *remaining -= find - *area;
- *area = find;
- return 1;
-}
-
-#define OP3_INST_BFE_UINT 4ULL
-#define OP3_INST_BFE_INT 5ULL
-#define OP3_INST_BFI_INT 6ULL
-#define OP3_INST_BIT_ALIGN_INT 12ULL
-#define OP3_INST_BYTE_ALIGN_INT 13ULL
-
-void patch_opcodes(char *w, unsigned remaining)
-{
- uint64_t *opcode = (uint64_t *)w;
- int patched = 0;
- int count_bfe_int = 0;
- int count_bfe_uint = 0;
- int count_byte_align = 0;
- while (42) {
- int clamp = (*opcode >> (32 + 31)) & 0x1;
- int dest_rel = (*opcode >> (32 + 28)) & 0x1;
- int alu_inst = (*opcode >> (32 + 13)) & 0x1f;
- int s2_neg = (*opcode >> (32 + 12)) & 0x1;
- int s2_rel = (*opcode >> (32 + 9)) & 0x1;
- int pred_sel = (*opcode >> 29) & 0x3;
- if (!clamp && !dest_rel && !s2_neg && !s2_rel && !pred_sel) {
- if (alu_inst == OP3_INST_BFE_INT) {
- count_bfe_int++;
- } else if (alu_inst == OP3_INST_BFE_UINT) {
- count_bfe_uint++;
- } else if (alu_inst == OP3_INST_BYTE_ALIGN_INT) {
- count_byte_align++;
- // patch this instruction to BFI_INT
- *opcode &= 0xfffc1fffffffffffULL;
- *opcode |= OP3_INST_BFI_INT << (32 + 13);
- patched++;
- }
- }
- if (remaining <= 8)
- break;
- opcode++;
- remaining -= 8;
- }
- applog(LOG_DEBUG, "Potential OP3 instructions identified: "
- "%i BFE_INT, %i BFE_UINT, %i BYTE_ALIGN",
- count_bfe_int, count_bfe_uint, count_byte_align);
- applog(LOG_DEBUG, "Patched a total of %i BFI_INT instructions", patched);
-}
-
-_clState *initCl(unsigned int gpu, char *name, size_t nameSize)
-{
- _clState *clState = calloc(1, sizeof(_clState));
- bool patchbfi = false, prog_built = false;
- struct cgpu_info *cgpu = &gpus[gpu];
- cl_platform_id platform = NULL;
- char pbuff[256], vbuff[255];
- cl_platform_id* platforms;
- cl_uint preferred_vwidth;
- cl_device_id *devices;
- cl_uint numPlatforms;
- cl_uint numDevices;
- cl_int status;
-
- status = clGetPlatformIDs(0, NULL, &numPlatforms);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Getting Platforms. (clGetPlatformsIDs)", status);
- return NULL;
- }
-
- platforms = (cl_platform_id *)alloca(numPlatforms*sizeof(cl_platform_id));
- status = clGetPlatformIDs(numPlatforms, platforms, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Getting Platform Ids. (clGetPlatformsIDs)", status);
- return NULL;
- }
-
- if (opt_platform_id >= (int)numPlatforms) {
- applog(LOG_ERR, "Specified platform that does not exist");
- return NULL;
- }
-
- status = clGetPlatformInfo(platforms[opt_platform_id], CL_PLATFORM_VENDOR, sizeof(pbuff), pbuff, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Getting Platform Info. (clGetPlatformInfo)", status);
- return NULL;
- }
- platform = platforms[opt_platform_id];
-
- if (platform == NULL) {
- perror("NULL platform found!\n");
- return NULL;
- }
-
- applog(LOG_INFO, "CL Platform vendor: %s", pbuff);
- status = clGetPlatformInfo(platform, CL_PLATFORM_NAME, sizeof(pbuff), pbuff, NULL);
- if (status == CL_SUCCESS)
- applog(LOG_INFO, "CL Platform name: %s", pbuff);
- status = clGetPlatformInfo(platform, CL_PLATFORM_VERSION, sizeof(vbuff), vbuff, NULL);
- if (status == CL_SUCCESS)
- applog(LOG_INFO, "CL Platform version: %s", vbuff);
-
- status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Getting Device IDs (num)", status);
- return NULL;
- }
-
- if (numDevices > 0 ) {
- devices = (cl_device_id *)malloc(numDevices*sizeof(cl_device_id));
-
- /* Now, get the device list data */
-
- status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numDevices, devices, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Getting Device IDs (list)", status);
- return NULL;
- }
-
- applog(LOG_INFO, "List of devices:");
-
- unsigned int i;
- for (i = 0; i < numDevices; i++) {
- status = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sizeof(pbuff), pbuff, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Getting Device Info", status);
- return NULL;
- }
-
- applog(LOG_INFO, "\t%i\t%s", i, pbuff);
- }
-
- if (gpu < numDevices) {
- status = clGetDeviceInfo(devices[gpu], CL_DEVICE_NAME, sizeof(pbuff), pbuff, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Getting Device Info", status);
- return NULL;
- }
-
- applog(LOG_INFO, "Selected %i: %s", gpu, pbuff);
- strncpy(name, pbuff, nameSize);
- } else {
- applog(LOG_ERR, "Invalid GPU %i", gpu);
- return NULL;
- }
-
- } else return NULL;
-
- cl_context_properties cps[3] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platform, 0 };
-
- clState->context = clCreateContextFromType(cps, CL_DEVICE_TYPE_GPU, NULL, NULL, &status);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Creating Context. (clCreateContextFromType)", status);
- return NULL;
- }
-
- /////////////////////////////////////////////////////////////////
- // Create an OpenCL command queue
- /////////////////////////////////////////////////////////////////
- clState->commandQueue = clCreateCommandQueue(clState->context, devices[gpu],
- CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &status);
- if (status != CL_SUCCESS) /* Try again without OOE enable */
- clState->commandQueue = clCreateCommandQueue(clState->context, devices[gpu], 0 , &status);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Creating Command Queue. (clCreateCommandQueue)", status);
- return NULL;
- }
-
- /* Check for BFI INT support. Hopefully people don't mix devices with
- * and without it! */
- char * extensions = malloc(1024);
- const char * camo = "cl_amd_media_ops";
- char *find;
-
- status = clGetDeviceInfo(devices[gpu], CL_DEVICE_EXTENSIONS, 1024, (void *)extensions, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_EXTENSIONS", status);
- return NULL;
- }
- find = strstr(extensions, camo);
- if (find)
- clState->hasBitAlign = true;
-
- /* Check for OpenCL >= 1.0 support, needed for global offset parameter usage. */
- char * devoclver = malloc(1024);
- const char * ocl10 = "OpenCL 1.0";
- const char * ocl11 = "OpenCL 1.1";
-
- status = clGetDeviceInfo(devices[gpu], CL_DEVICE_VERSION, 1024, (void *)devoclver, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_VERSION", status);
- return NULL;
- }
- find = strstr(devoclver, ocl10);
- if (!find) {
- clState->hasOpenCL11plus = true;
- find = strstr(devoclver, ocl11);
- if (!find)
- clState->hasOpenCL12plus = true;
- }
-
- status = clGetDeviceInfo(devices[gpu], CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, sizeof(cl_uint), (void *)&preferred_vwidth, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT", status);
- return NULL;
- }
- applog(LOG_DEBUG, "Preferred vector width reported %d", preferred_vwidth);
-
- status = clGetDeviceInfo(devices[gpu], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), (void *)&clState->max_work_size, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_MAX_WORK_GROUP_SIZE", status);
- return NULL;
- }
- applog(LOG_DEBUG, "Max work group size reported %d", (int)(clState->max_work_size));
-
- status = clGetDeviceInfo(devices[gpu], CL_DEVICE_MAX_MEM_ALLOC_SIZE , sizeof(cl_ulong), (void *)&cgpu->max_alloc, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_MAX_MEM_ALLOC_SIZE", status);
- return NULL;
- }
- applog(LOG_DEBUG, "Max mem alloc size is %lu", (long unsigned int)(cgpu->max_alloc));
-
- /* Create binary filename based on parameters passed to opencl
- * compiler to ensure we only load a binary that matches what would
- * have otherwise created. The filename is:
- * name + kernelname +/- g(offset) + v + vectors + w + work_size + l + sizeof(long) + .bin
- * For scrypt the filename is:
- * name + kernelname + g + lg + lookup_gap + tc + thread_concurrency + w + work_size + l + sizeof(long) + .bin
- */
- char binaryfilename[255];
- char filename[255];
- char numbuf[16];
-
- if (cgpu->kernel == KL_NONE) {
- if (opt_scrypt) {
- applog(LOG_INFO, "Selecting scrypt kernel");
- clState->chosen_kernel = KL_SCRYPT;
- } else if (!strstr(name, "Tahiti") &&
- /* Detect all 2.6 SDKs not with Tahiti and use diablo kernel */
- (strstr(vbuff, "844.4") || // Linux 64 bit ATI 2.6 SDK
- strstr(vbuff, "851.4") || // Windows 64 bit ""
- strstr(vbuff, "831.4") ||
- strstr(vbuff, "898.1") || // 12.2 driver SDK
- strstr(vbuff, "923.1") || // 12.4
- strstr(vbuff, "938.2") || // SDK 2.7
- strstr(vbuff, "1113.2"))) {// SDK 2.8
- applog(LOG_INFO, "Selecting diablo kernel");
- clState->chosen_kernel = KL_DIABLO;
- /* Detect all 7970s, older ATI and NVIDIA and use poclbm */
- } else if (strstr(name, "Tahiti") || !clState->hasBitAlign) {
- applog(LOG_INFO, "Selecting poclbm kernel");
- clState->chosen_kernel = KL_POCLBM;
- /* Use phatk for the rest R5xxx R6xxx */
- } else {
- applog(LOG_INFO, "Selecting phatk kernel");
- clState->chosen_kernel = KL_PHATK;
- }
- cgpu->kernel = clState->chosen_kernel;
- } else {
- clState->chosen_kernel = cgpu->kernel;
- if (clState->chosen_kernel == KL_PHATK &&
- (strstr(vbuff, "844.4") || strstr(vbuff, "851.4") ||
- strstr(vbuff, "831.4") || strstr(vbuff, "898.1") ||
- strstr(vbuff, "923.1") || strstr(vbuff, "938.2") ||
- strstr(vbuff, "1113.2"))) {
- applog(LOG_WARNING, "WARNING: You have selected the phatk kernel.");
- applog(LOG_WARNING, "You are running SDK 2.6+ which performs poorly with this kernel.");
- applog(LOG_WARNING, "Downgrade your SDK and delete any .bin files before starting again.");
- applog(LOG_WARNING, "Or allow cgminer to automatically choose a more suitable kernel.");
- }
- }
-
- /* For some reason 2 vectors is still better even if the card says
- * otherwise, and many cards lie about their max so use 256 as max
- * unless explicitly set on the command line. Tahiti prefers 1 */
- if (strstr(name, "Tahiti"))
- preferred_vwidth = 1;
- else if (preferred_vwidth > 2)
- preferred_vwidth = 2;
-
- switch (clState->chosen_kernel) {
- case KL_POCLBM:
- strcpy(filename, POCLBM_KERNNAME".cl");
- strcpy(binaryfilename, POCLBM_KERNNAME);
- break;
- case KL_PHATK:
- strcpy(filename, PHATK_KERNNAME".cl");
- strcpy(binaryfilename, PHATK_KERNNAME);
- break;
- case KL_DIAKGCN:
- strcpy(filename, DIAKGCN_KERNNAME".cl");
- strcpy(binaryfilename, DIAKGCN_KERNNAME);
- break;
- case KL_SCRYPT:
- strcpy(filename, SCRYPT_KERNNAME".cl");
- strcpy(binaryfilename, SCRYPT_KERNNAME);
- /* Scrypt only supports vector 1 */
- cgpu->vwidth = 1;
- break;
- case KL_NONE: /* Shouldn't happen */
- case KL_DIABLO:
- strcpy(filename, DIABLO_KERNNAME".cl");
- strcpy(binaryfilename, DIABLO_KERNNAME);
- break;
- }
-
- if (cgpu->vwidth)
- clState->vwidth = cgpu->vwidth;
- else {
- clState->vwidth = preferred_vwidth;
- cgpu->vwidth = preferred_vwidth;
- }
-
- if (((clState->chosen_kernel == KL_POCLBM || clState->chosen_kernel == KL_DIABLO || clState->chosen_kernel == KL_DIAKGCN) &&
- clState->vwidth == 1 && clState->hasOpenCL11plus) || opt_scrypt)
- clState->goffset = true;
-
- if (cgpu->work_size && cgpu->work_size <= clState->max_work_size)
- clState->wsize = cgpu->work_size;
- else if (opt_scrypt)
- clState->wsize = 256;
- else if (strstr(name, "Tahiti"))
- clState->wsize = 64;
- else
- clState->wsize = (clState->max_work_size <= 256 ? clState->max_work_size : 256) / clState->vwidth;
- cgpu->work_size = clState->wsize;
-
-#ifdef USE_SCRYPT
- if (opt_scrypt) {
- if (!cgpu->opt_lg) {
- applog(LOG_DEBUG, "GPU %d: selecting lookup gap of 2", gpu);
- cgpu->lookup_gap = 2;
- } else
- cgpu->lookup_gap = cgpu->opt_lg;
-
- if (!cgpu->opt_tc) {
- unsigned int sixtyfours;
-
- sixtyfours = cgpu->max_alloc / 131072 / 64 - 1;
- cgpu->thread_concurrency = sixtyfours * 64;
- if (cgpu->shaders && cgpu->thread_concurrency > cgpu->shaders) {
- cgpu->thread_concurrency -= cgpu->thread_concurrency % cgpu->shaders;
- if (cgpu->thread_concurrency > cgpu->shaders * 5)
- cgpu->thread_concurrency = cgpu->shaders * 5;
- }
- applog(LOG_DEBUG, "GPU %d: selecting thread concurrency of %d", gpu, (int)(cgpu->thread_concurrency));
- } else
- cgpu->thread_concurrency = cgpu->opt_tc;
- }
-#endif
-
- FILE *binaryfile;
- size_t *binary_sizes;
- char **binaries;
- int pl;
- char *source = file_contents(filename, &pl);
- size_t sourceSize[] = {(size_t)pl};
- cl_uint slot, cpnd;
-
- slot = cpnd = 0;
-
- if (!source)
- return NULL;
-
- binary_sizes = calloc(sizeof(size_t) * MAX_GPUDEVICES * 4, 1);
- if (unlikely(!binary_sizes)) {
- applog(LOG_ERR, "Unable to calloc binary_sizes");
- return NULL;
- }
- binaries = calloc(sizeof(char *) * MAX_GPUDEVICES * 4, 1);
- if (unlikely(!binaries)) {
- applog(LOG_ERR, "Unable to calloc binaries");
- return NULL;
- }
-
- strcat(binaryfilename, name);
- if (clState->goffset)
- strcat(binaryfilename, "g");
- if (opt_scrypt) {
-#ifdef USE_SCRYPT
- sprintf(numbuf, "lg%utc%u", cgpu->lookup_gap, (unsigned int)cgpu->thread_concurrency);
- strcat(binaryfilename, numbuf);
-#endif
- } else {
- sprintf(numbuf, "v%d", clState->vwidth);
- strcat(binaryfilename, numbuf);
- }
- sprintf(numbuf, "w%d", (int)clState->wsize);
- strcat(binaryfilename, numbuf);
- sprintf(numbuf, "l%d", (int)sizeof(long));
- strcat(binaryfilename, numbuf);
- strcat(binaryfilename, ".bin");
-
- binaryfile = fopen(binaryfilename, "rb");
- if (!binaryfile) {
- applog(LOG_DEBUG, "No binary found, generating from source");
- } else {
- struct stat binary_stat;
-
- if (unlikely(stat(binaryfilename, &binary_stat))) {
- applog(LOG_DEBUG, "Unable to stat binary, generating from source");
- fclose(binaryfile);
- goto build;
- }
- if (!binary_stat.st_size)
- goto build;
-
- binary_sizes[slot] = binary_stat.st_size;
- binaries[slot] = (char *)calloc(binary_sizes[slot], 1);
- if (unlikely(!binaries[slot])) {
- applog(LOG_ERR, "Unable to calloc binaries");
- fclose(binaryfile);
- return NULL;
- }
-
- if (fread(binaries[slot], 1, binary_sizes[slot], binaryfile) != binary_sizes[slot]) {
- applog(LOG_ERR, "Unable to fread binaries");
- fclose(binaryfile);
- free(binaries[slot]);
- goto build;
- }
-
- clState->program = clCreateProgramWithBinary(clState->context, 1, &devices[gpu], &binary_sizes[slot], (const unsigned char **)binaries, &status, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Loading Binary into cl_program (clCreateProgramWithBinary)", status);
- fclose(binaryfile);
- free(binaries[slot]);
- goto build;
- }
-
- fclose(binaryfile);
- applog(LOG_DEBUG, "Loaded binary image %s", binaryfilename);
-
- goto built;
- }
-
- /////////////////////////////////////////////////////////////////
- // Load CL file, build CL program object, create CL kernel object
- /////////////////////////////////////////////////////////////////
-
-build:
- clState->program = clCreateProgramWithSource(clState->context, 1, (const char **)&source, sourceSize, &status);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Loading Binary into cl_program (clCreateProgramWithSource)", status);
- return NULL;
- }
-
- /* create a cl program executable for all the devices specified */
- char *CompilerOptions = calloc(1, 256);
-
-#ifdef USE_SCRYPT
- if (opt_scrypt)
- sprintf(CompilerOptions, "-D LOOKUP_GAP=%d -D CONCURRENT_THREADS=%d -D WORKSIZE=%d",
- cgpu->lookup_gap, (unsigned int)cgpu->thread_concurrency, (int)clState->wsize);
- else
-#endif
- {
- sprintf(CompilerOptions, "-D WORKSIZE=%d -D VECTORS%d -D WORKVEC=%d",
- (int)clState->wsize, clState->vwidth, (int)clState->wsize * clState->vwidth);
- }
- applog(LOG_DEBUG, "Setting worksize to %d", (int)(clState->wsize));
- if (clState->vwidth > 1)
- applog(LOG_DEBUG, "Patched source to suit %d vectors", clState->vwidth);
-
- if (clState->hasBitAlign) {
- strcat(CompilerOptions, " -D BITALIGN");
- applog(LOG_DEBUG, "cl_amd_media_ops found, setting BITALIGN");
- if (!clState->hasOpenCL12plus &&
- (strstr(name, "Cedar") ||
- strstr(name, "Redwood") ||
- strstr(name, "Juniper") ||
- strstr(name, "Cypress" ) ||
- strstr(name, "Hemlock" ) ||
- strstr(name, "Caicos" ) ||
- strstr(name, "Turks" ) ||
- strstr(name, "Barts" ) ||
- strstr(name, "Cayman" ) ||
- strstr(name, "Antilles" ) ||
- strstr(name, "Wrestler" ) ||
- strstr(name, "Zacate" ) ||
- strstr(name, "WinterPark" )))
- patchbfi = true;
- } else
- applog(LOG_DEBUG, "cl_amd_media_ops not found, will not set BITALIGN");
-
- if (patchbfi) {
- strcat(CompilerOptions, " -D BFI_INT");
- applog(LOG_DEBUG, "BFI_INT patch requiring device found, patched source with BFI_INT");
- } else
- applog(LOG_DEBUG, "BFI_INT patch requiring device not found, will not BFI_INT patch");
-
- if (clState->goffset)
- strcat(CompilerOptions, " -D GOFFSET");
-
- if (!clState->hasOpenCL11plus)
- strcat(CompilerOptions, " -D OCL1");
-
- applog(LOG_DEBUG, "CompilerOptions: %s", CompilerOptions);
- status = clBuildProgram(clState->program, 1, &devices[gpu], CompilerOptions , NULL, NULL);
- free(CompilerOptions);
-
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status);
- size_t logSize;
- status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &logSize);
-
- char *log = malloc(logSize);
- status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
- applog(LOG_ERR, "%s", log);
- return NULL;
- }
-
- prog_built = true;
-
-#ifdef __APPLE__
- /* OSX OpenCL breaks reading off binaries with >1 GPU so always build
- * from source. */
- goto built;
-#endif
-
- status = clGetProgramInfo(clState->program, CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), &cpnd, NULL);
- if (unlikely(status != CL_SUCCESS)) {
- applog(LOG_ERR, "Error %d: Getting program info CL_PROGRAM_NUM_DEVICES. (clGetProgramInfo)", status);
- return NULL;
- }
-
- status = clGetProgramInfo(clState->program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t)*cpnd, binary_sizes, NULL);
- if (unlikely(status != CL_SUCCESS)) {
- applog(LOG_ERR, "Error %d: Getting program info CL_PROGRAM_BINARY_SIZES. (clGetProgramInfo)", status);
- return NULL;
- }
-
- /* The actual compiled binary ends up in a RANDOM slot! Grr, so we have
- * to iterate over all the binary slots and find where the real program
- * is. What the heck is this!? */
- for (slot = 0; slot < cpnd; slot++)
- if (binary_sizes[slot])
- break;
-
- /* copy over all of the generated binaries. */
- applog(LOG_DEBUG, "Binary size for gpu %d found in binary slot %d: %d", gpu, slot, (int)(binary_sizes[slot]));
- if (!binary_sizes[slot]) {
- applog(LOG_ERR, "OpenCL compiler generated a zero sized binary, FAIL!");
- return NULL;
- }
- binaries[slot] = calloc(sizeof(char) * binary_sizes[slot], 1);
- status = clGetProgramInfo(clState->program, CL_PROGRAM_BINARIES, sizeof(char *) * cpnd, binaries, NULL );
- if (unlikely(status != CL_SUCCESS)) {
- applog(LOG_ERR, "Error %d: Getting program info. CL_PROGRAM_BINARIES (clGetProgramInfo)", status);
- return NULL;
- }
-
- /* Patch the kernel if the hardware supports BFI_INT but it needs to
- * be hacked in */
- if (patchbfi) {
- unsigned remaining = binary_sizes[slot];
- char *w = binaries[slot];
- unsigned int start, length;
-
- /* Find 2nd incidence of .text, and copy the program's
- * position and length at a fixed offset from that. Then go
- * back and find the 2nd incidence of \x7ELF (rewind by one
- * from ELF) and then patch the opcocdes */
- if (!advance(&w, &remaining, ".text"))
- goto build;
- w++; remaining--;
- if (!advance(&w, &remaining, ".text")) {
- /* 32 bit builds only one ELF */
- w--; remaining++;
- }
- memcpy(&start, w + 285, 4);
- memcpy(&length, w + 289, 4);
- w = binaries[slot]; remaining = binary_sizes[slot];
- if (!advance(&w, &remaining, "ELF"))
- goto build;
- w++; remaining--;
- if (!advance(&w, &remaining, "ELF")) {
- /* 32 bit builds only one ELF */
- w--; remaining++;
- }
- w--; remaining++;
- w += start; remaining -= start;
- applog(LOG_DEBUG, "At %p (%u rem. bytes), to begin patching",
- w, remaining);
- patch_opcodes(w, length);
-
- status = clReleaseProgram(clState->program);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Releasing program. (clReleaseProgram)", status);
- return NULL;
- }
-
- clState->program = clCreateProgramWithBinary(clState->context, 1, &devices[gpu], &binary_sizes[slot], (const unsigned char **)&binaries[slot], &status, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Loading Binary into cl_program (clCreateProgramWithBinary)", status);
- return NULL;
- }
-
- /* Program needs to be rebuilt */
- prog_built = false;
- }
-
- free(source);
-
- /* Save the binary to be loaded next time */
- binaryfile = fopen(binaryfilename, "wb");
- if (!binaryfile) {
- /* Not a fatal problem, just means we build it again next time */
- applog(LOG_DEBUG, "Unable to create file %s", binaryfilename);
- } else {
- if (unlikely(fwrite(binaries[slot], 1, binary_sizes[slot], binaryfile) != binary_sizes[slot])) {
- applog(LOG_ERR, "Unable to fwrite to binaryfile");
- return NULL;
- }
- fclose(binaryfile);
- }
-built:
- if (binaries[slot])
- free(binaries[slot]);
- free(binaries);
- free(binary_sizes);
-
- applog(LOG_INFO, "Initialising kernel %s with%s bitalign, %d vectors and worksize %d",
- filename, clState->hasBitAlign ? "" : "out", clState->vwidth, (int)(clState->wsize));
-
- if (!prog_built) {
- /* create a cl program executable for all the devices specified */
- status = clBuildProgram(clState->program, 1, &devices[gpu], NULL, NULL, NULL);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status);
- size_t logSize;
- status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &logSize);
-
- char *log = malloc(logSize);
- status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
- applog(LOG_ERR, "%s", log);
- return NULL;
- }
- }
-
- /* get a kernel object handle for a kernel with the given name */
- clState->kernel = clCreateKernel(clState->program, "search", &status);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: Creating Kernel from program. (clCreateKernel)", status);
- return NULL;
- }
-
-#ifdef USE_SCRYPT
- if (opt_scrypt) {
- size_t ipt = (1024 / cgpu->lookup_gap + (1024 % cgpu->lookup_gap > 0));
- size_t bufsize = 128 * ipt * cgpu->thread_concurrency;
-
- /* Use the max alloc value which has been rounded to a power of
- * 2 greater >= required amount earlier */
- if (bufsize > cgpu->max_alloc) {
- applog(LOG_WARNING, "Maximum buffer memory device %d supports says %lu",
- gpu, (long unsigned int)(cgpu->max_alloc));
- applog(LOG_WARNING, "Your scrypt settings come to %d", (int)bufsize);
- }
- applog(LOG_DEBUG, "Creating scrypt buffer sized %d", (int)bufsize);
- clState->padbufsize = bufsize;
-
- /* This buffer is weird and might work to some degree even if
- * the create buffer call has apparently failed, so check if we
- * get anything back before we call it a failure. */
- clState->padbuffer8 = NULL;
- clState->padbuffer8 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, bufsize, NULL, &status);
- if (status != CL_SUCCESS && !clState->padbuffer8) {
- applog(LOG_ERR, "Error %d: clCreateBuffer (padbuffer8), decrease TC or increase LG", status);
- return NULL;
- }
-
- clState->CLbuffer0 = clCreateBuffer(clState->context, CL_MEM_READ_ONLY, 128, NULL, &status);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: clCreateBuffer (CLbuffer0)", status);
- return NULL;
- }
- clState->outputBuffer = clCreateBuffer(clState->context, CL_MEM_WRITE_ONLY, SCRYPT_BUFFERSIZE, NULL, &status);
- } else
-#endif
- clState->outputBuffer = clCreateBuffer(clState->context, CL_MEM_WRITE_ONLY, BUFFERSIZE, NULL, &status);
- if (status != CL_SUCCESS) {
- applog(LOG_ERR, "Error %d: clCreateBuffer (outputBuffer)", status);
- return NULL;
- }
-
- return clState;
-}
-#endif /* HAVE_OPENCL */
-
diff --git a/ocl.h b/ocl.h
deleted file mode 100644
index ed8bfde..0000000
--- a/ocl.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __OCL_H__
-#define __OCL_H__
-
-#include "config.h"
-
-#include <stdbool.h>
-#ifdef HAVE_OPENCL
-#ifdef __APPLE_CC__
-#include <OpenCL/opencl.h>
-#else
-#include <CL/cl.h>
-#endif
-
-#include "miner.h"
-
-typedef struct {
- cl_context context;
- cl_kernel kernel;
- cl_command_queue commandQueue;
- cl_program program;
- cl_mem outputBuffer;
-#ifdef USE_SCRYPT
- cl_mem CLbuffer0;
- cl_mem padbuffer8;
- size_t padbufsize;
- void * cldata;
-#endif
- bool hasBitAlign;
- bool hasOpenCL11plus;
- bool hasOpenCL12plus;
- bool goffset;
- cl_uint vwidth;
- size_t max_work_size;
- size_t wsize;
- enum cl_kernels chosen_kernel;
-} _clState;
-
-extern char *file_contents(const char *filename, int *length);
-extern int clDevicesNum(void);
-extern _clState *initCl(unsigned int gpu, char *name, size_t nameSize);
-#endif /* HAVE_OPENCL */
-#endif /* __OCL_H__ */
diff --git a/phatk121016.cl b/phatk121016.cl
deleted file mode 100644
index 60f2870..0000000
--- a/phatk121016.cl
+++ /dev/null
@@ -1,417 +0,0 @@
-// This file is taken and modified from the public-domain poclbm project, and
-// I have therefore decided to keep it public-domain.
-// Modified version copyright 2011-2012 Con Kolivas
-
-#ifdef VECTORS4
- typedef uint4 u;
-#elif defined VECTORS2
- typedef uint2 u;
-#else
- typedef uint u;
-#endif
-
-__constant uint K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
-};
-
-__constant uint ConstW[128] = {
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000U, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000280U,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x80000000U, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000100U,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
-};
-
-__constant uint H[8] = {
- 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
-};
-
-
-#ifdef BITALIGN
- #pragma OPENCL EXTENSION cl_amd_media_ops : enable
- #define rot(x, y) amd_bitalign(x, x, (uint)(32 - y))
-
-// This part is not from the stock poclbm kernel. It's part of an optimization
-// added in the Phoenix Miner.
-
-// Some AMD devices have Vals[0] BFI_INT opcode, which behaves exactly like the
-// SHA-256 Ch function, but provides it in exactly one instruction. If
-// detected, use it for Ch. Otherwise, construct Ch out of simpler logical
-// primitives.
-
- #ifdef BFI_INT
- // Well, slight problem... It turns out BFI_INT isn't actually exposed to
- // OpenCL (or CAL IL for that matter) in any way. However, there is
- // a similar instruction, BYTE_ALIGN_INT, which is exposed to OpenCL via
- // amd_bytealign, takes the same inputs, and provides the same output.
- // We can use that as a placeholder for BFI_INT and have the application
- // patch it after compilation.
-
- // This is the BFI_INT function
- #define Ch(x, y, z) amd_bytealign(x,y,z)
- // Ma can also be implemented in terms of BFI_INT...
- #define Ma(z, x, y) amd_bytealign(z^x,y,x)
- #else // BFI_INT
- // Later SDKs optimise this to BFI INT without patching and GCN
- // actually fails if manually patched with BFI_INT
-
- #define Ch(x, y, z) bitselect((u)z, (u)y, (u)x)
- #define Ma(x, y, z) bitselect((u)x, (u)y, (u)z ^ (u)x)
- #define rotr(x, y) amd_bitalign((u)x, (u)x, (u)y)
- #endif
-#else // BITALIGN
- #define Ch(x, y, z) (z ^ (x & (y ^ z)))
- #define Ma(x, y, z) ((x & z) | (y & (x | z)))
- #define rot(x, y) rotate((u)x, (u)y)
- #define rotr(x, y) rotate((u)x, (u)(32-y))
-#endif
-
-
-
-//Various intermediate calculations for each SHA round
-#define s0(n) (S0(Vals[(0 + 128 - (n)) % 8]))
-#define S0(n) (rot(n, 30u)^rot(n, 19u)^rot(n,10u))
-
-#define s1(n) (S1(Vals[(4 + 128 - (n)) % 8]))
-#define S1(n) (rot(n, 26u)^rot(n, 21u)^rot(n, 7u))
-
-#define ch(n) Ch(Vals[(4 + 128 - (n)) % 8],Vals[(5 + 128 - (n)) % 8],Vals[(6 + 128 - (n)) % 8])
-#define maj(n) Ma(Vals[(1 + 128 - (n)) % 8],Vals[(2 + 128 - (n)) % 8],Vals[(0 + 128 - (n)) % 8])
-
-//t1 calc when W is already calculated
-#define t1(n) K[(n) % 64] + Vals[(7 + 128 - (n)) % 8] + W[(n)] + s1(n) + ch(n)
-
-//t1 calc which calculates W
-#define t1W(n) K[(n) % 64] + Vals[(7 + 128 - (n)) % 8] + W(n) + s1(n) + ch(n)
-
-//Used for constant W Values (the compiler optimizes out zeros)
-#define t1C(n) (K[(n) % 64]+ ConstW[(n)]) + Vals[(7 + 128 - (n)) % 8] + s1(n) + ch(n)
-
-//t2 Calc
-#define t2(n) maj(n) + s0(n)
-
-#define rotC(x,n) (x<<n | x >> (32-n))
-
-//W calculation used for SHA round
-#define W(n) (W[n] = P4(n) + P3(n) + P2(n) + P1(n))
-
-
-
-//Partial W calculations (used for the begining where only some values are nonzero)
-#define P1(n) ((rot(W[(n)-2],15u)^rot(W[(n)-2],13u)^((W[(n)-2])>>10U)))
-#define P2(n) ((rot(W[(n)-15],25u)^rot(W[(n)-15],14u)^((W[(n)-15])>>3U)))
-
-
-#define p1(x) ((rot(x,15u)^rot(x,13u)^((x)>>10U)))
-#define p2(x) ((rot(x,25u)^rot(x,14u)^((x)>>3U)))
-
-
-#define P3(n) W[n-7]
-#define P4(n) W[n-16]
-
-
-//Partial Calcs for constant W values
-#define P1C(n) ((rotC(ConstW[(n)-2],15)^rotC(ConstW[(n)-2],13)^((ConstW[(n)-2])>>10U)))
-#define P2C(n) ((rotC(ConstW[(n)-15],25)^rotC(ConstW[(n)-15],14)^((ConstW[(n)-15])>>3U)))
-#define P3C(x) ConstW[x-7]
-#define P4C(x) ConstW[x-16]
-
-//SHA round with built in W calc
-#define sharoundW(n) Barrier1(n); Vals[(3 + 128 - (n)) % 8] += t1W(n); Vals[(7 + 128 - (n)) % 8] = t1W(n) + t2(n);
-
-//SHA round without W calc
-#define sharound(n) Barrier2(n); Vals[(3 + 128 - (n)) % 8] += t1(n); Vals[(7 + 128 - (n)) % 8] = t1(n) + t2(n);
-
-//SHA round for constant W values
-#define sharoundC(n) Barrier3(n); Vals[(3 + 128 - (n)) % 8] += t1C(n); Vals[(7 + 128 - (n)) % 8] = t1C(n) + t2(n);
-
-//The compiler is stupid... I put this in there only to stop the compiler from (de)optimizing the order
-#define Barrier1(n) t1 = t1C((n+1))
-#define Barrier2(n) t1 = t1C((n))
-#define Barrier3(n) t1 = t1C((n))
-
-//#define WORKSIZE 256
-#define MAXBUFFERS (4095)
-
-__kernel
- __attribute__((reqd_work_group_size(WORKSIZE, 1, 1)))
-void search( const uint state0, const uint state1, const uint state2, const uint state3,
- const uint state4, const uint state5, const uint state6, const uint state7,
- const uint B1, const uint C1, const uint D1,
- const uint F1, const uint G1, const uint H1,
- const u base,
- const uint W16, const uint W17,
- const uint PreVal4, const uint PreVal0,
- const uint PreW18, const uint PreW19,
- const uint PreW31, const uint PreW32,
-
- volatile __global uint * output)
-{
-
-
- u W[124];
- u Vals[8];
-
-//Dummy Variable to prevent compiler from reordering between rounds
- u t1;
-
- //Vals[0]=state0;
- Vals[1]=B1;
- Vals[2]=C1;
- Vals[3]=D1;
- //Vals[4]=PreVal4;
- Vals[5]=F1;
- Vals[6]=G1;
- Vals[7]=H1;
-
- W[16] = W16;
- W[17] = W17;
-
-#ifdef VECTORS4
- //Less dependencies to get both the local id and group id and then add them
- W[3] = base + (uint)(get_local_id(0)) * 4u + (uint)(get_group_id(0)) * (WORKSIZE * 4u);
- uint r = rot(W[3].x,25u)^rot(W[3].x,14u)^((W[3].x)>>3U);
- //Since only the 2 LSB is opposite between the nonces, we can save an instruction by flipping the 4 bits in W18 rather than the 1 bit in W3
- W[18] = PreW18 + (u){r, r ^ 0x2004000U, r ^ 0x4008000U, r ^ 0x600C000U};
-#elif defined VECTORS2
- W[3] = base + (uint)(get_local_id(0)) * 2u + (uint)(get_group_id(0)) * (WORKSIZE * 2u);
- uint r = rot(W[3].x,25u)^rot(W[3].x,14u)^((W[3].x)>>3U);
- W[18] = PreW18 + (u){r, r ^ 0x2004000U};
-#else
- W[3] = base + get_local_id(0) + get_group_id(0) * (WORKSIZE);
- u r = rot(W[3],25u)^rot(W[3],14u)^((W[3])>>3U);
- W[18] = PreW18 + r;
-#endif
- //the order of the W calcs and Rounds is like this because the compiler needs help finding how to order the instructions
-
-
-
- Vals[4] = PreVal4 + W[3];
- Vals[0] = PreVal0 + W[3];
-
- sharoundC(4);
- W[19] = PreW19 + W[3];
- sharoundC(5);
- W[20] = P4C(20) + P1(20);
- sharoundC(6);
- W[21] = P1(21);
- sharoundC(7);
- W[22] = P3C(22) + P1(22);
- sharoundC(8);
- W[23] = W[16] + P1(23);
- sharoundC(9);
- W[24] = W[17] + P1(24);
- sharoundC(10);
- W[25] = P1(25) + P3(25);
- W[26] = P1(26) + P3(26);
- sharoundC(11);
- W[27] = P1(27) + P3(27);
- W[28] = P1(28) + P3(28);
- sharoundC(12);
- W[29] = P1(29) + P3(29);
- sharoundC(13);
- W[30] = P1(30) + P2C(30) + P3(30);
- W[31] = PreW31 + (P1(31) + P3(31));
- sharoundC(14);
- W[32] = PreW32 + (P1(32) + P3(32));
- sharoundC(15);
- sharound(16);
- sharound(17);
- sharound(18);
- sharound(19);
- sharound(20);
- sharound(21);
- sharound(22);
- sharound(23);
- sharound(24);
- sharound(25);
- sharound(26);
- sharound(27);
- sharound(28);
- sharound(29);
- sharound(30);
- sharound(31);
- sharound(32);
- sharoundW(33);
- sharoundW(34);
- sharoundW(35);
- sharoundW(36);
- sharoundW(37);
- sharoundW(38);
- sharoundW(39);
- sharoundW(40);
- sharoundW(41);
- sharoundW(42);
- sharoundW(43);
- sharoundW(44);
- sharoundW(45);
- sharoundW(46);
- sharoundW(47);
- sharoundW(48);
- sharoundW(49);
- sharoundW(50);
- sharoundW(51);
- sharoundW(52);
- sharoundW(53);
- sharoundW(54);
- sharoundW(55);
- sharoundW(56);
- sharoundW(57);
- sharoundW(58);
- sharoundW(59);
- sharoundW(60);
- sharoundW(61);
- sharoundW(62);
- sharoundW(63);
-
- W[64]=state0+Vals[0];
- W[65]=state1+Vals[1];
- W[66]=state2+Vals[2];
- W[67]=state3+Vals[3];
- W[68]=state4+Vals[4];
- W[69]=state5+Vals[5];
- W[70]=state6+Vals[6];
- W[71]=state7+Vals[7];
-
- Vals[0]=H[0];
- Vals[1]=H[1];
- Vals[2]=H[2];
- Vals[3]=H[3];
- Vals[4]=H[4];
- Vals[5]=H[5];
- Vals[6]=H[6];
- Vals[7]=H[7];
-
- //sharound(64 + 0);
- const u Temp = (0xb0edbdd0U + K[0]) + W[64];
- Vals[7] = Temp + 0x08909ae5U;
- Vals[3] = 0xa54ff53aU + Temp;
-
-#define P124(n) P2(n) + P1(n) + P4(n)
-
-
- W[64 + 16] = + P2(64 + 16) + P4(64 + 16);
- sharound(64 + 1);
- W[64 + 17] = P1C(64 + 17) + P2(64 + 17) + P4(64 + 17);
- sharound(64 + 2);
- W[64 + 18] = P124(64 + 18);
- sharound(64 + 3);
- W[64 + 19] = P124(64 + 19);
- sharound(64 + 4);
- W[64 + 20] = P124(64 + 20);
- sharound(64 + 5);
- W[64 + 21] = P124(64 + 21);
- sharound(64 + 6);
- W[64 + 22] = P4(64 + 22) + P3C(64 + 22) + P2(64 + 22) + P1(64 + 22);
- sharound(64 + 7);
- W[64 + 23] = P4(64 + 23) + P3(64 + 23) + P2C(64 + 23) + P1(64 + 23);
- sharoundC(64 + 8);
- W[64 + 24] = P1(64 + 24) + P4C(64 + 24) + P3(64 + 24);
- sharoundC(64 + 9);
- W[64 + 25] = P3(64 + 25) + P1(64 + 25);
- sharoundC(64 + 10);
- W[64 + 26] = P3(64 + 26) + P1(64 + 26);
- sharoundC(64 + 11);
- W[64 + 27] = P3(64 + 27) + P1(64 + 27);
- sharoundC(64 + 12);
- W[64 + 28] = P3(64 + 28) + P1(64 + 28);
- sharoundC(64 + 13);
- W[64 + 29] = P1(64 + 29) + P3(64 + 29);
- W[64 + 30] = P3(64 + 30) + P2C(64 + 30) + P1(64 + 30);
- sharoundC(64 + 14);
- W[64 + 31] = P4C(64 + 31) + P3(64 + 31) + P2(64 + 31) + P1(64 + 31);
- sharoundC(64 + 15);
- sharound(64 + 16);
- sharound(64 + 17);
- sharound(64 + 18);
- sharound(64 + 19);
- sharound(64 + 20);
- sharound(64 + 21);
- sharound(64 + 22);
- sharound(64 + 23);
- sharound(64 + 24);
- sharound(64 + 25);
- sharound(64 + 26);
- sharound(64 + 27);
- sharound(64 + 28);
- sharound(64 + 29);
- sharound(64 + 30);
- sharound(64 + 31);
- sharoundW(64 + 32);
- sharoundW(64 + 33);
- sharoundW(64 + 34);
- sharoundW(64 + 35);
- sharoundW(64 + 36);
- sharoundW(64 + 37);
- sharoundW(64 + 38);
- sharoundW(64 + 39);
- sharoundW(64 + 40);
- sharoundW(64 + 41);
- sharoundW(64 + 42);
- sharoundW(64 + 43);
- sharoundW(64 + 44);
- sharoundW(64 + 45);
- sharoundW(64 + 46);
- sharoundW(64 + 47);
- sharoundW(64 + 48);
- sharoundW(64 + 49);
- sharoundW(64 + 50);
- sharoundW(64 + 51);
- sharoundW(64 + 52);
- sharoundW(64 + 53);
- sharoundW(64 + 54);
- sharoundW(64 + 55);
- sharoundW(64 + 56);
- sharoundW(64 + 57);
- sharoundW(64 + 58);
-
- W[117] += W[108] + Vals[3] + Vals[7] + P2(124) + P1(124) + Ch((Vals[0] + Vals[4]) + (K[59] + W(59+64)) + s1(64+59)+ ch(59+64),Vals[1],Vals[2]) -
- (-(K[60] + H[7]) - S1((Vals[0] + Vals[4]) + (K[59] + W(59+64)) + s1(64+59)+ ch(59+64)));
-
-#define FOUND (0x0F)
-#define SETFOUND(Xnonce) output[output[FOUND]++] = Xnonce
-
-#ifdef VECTORS4
- bool result = W[117].x & W[117].y & W[117].z & W[117].w;
- if (!result) {
- if (!W[117].x)
- SETFOUND(W[3].x);
- if (!W[117].y)
- SETFOUND(W[3].y);
- if (!W[117].z)
- SETFOUND(W[3].z);
- if (!W[117].w)
- SETFOUND(W[3].w);
- }
-#elif defined VECTORS2
- bool result = W[117].x & W[117].y;
- if (!result) {
- if (!W[117].x)
- SETFOUND(W[3].x);
- if (!W[117].y)
- SETFOUND(W[3].y);
- }
-#else
- if (!W[117])
- SETFOUND(W[3]);
-#endif
-}
diff --git a/poclbm130302.cl b/poclbm130302.cl
deleted file mode 100644
index 6f5fd01..0000000
--- a/poclbm130302.cl
+++ /dev/null
@@ -1,1388 +0,0 @@
-// -ck modified kernel taken from Phoenix taken from poclbm, with aspects of
-// phatk and others.
-// Modified version copyright 2011-2012 Con Kolivas
-
-// This file is taken and modified from the public-domain poclbm project, and
-// we have therefore decided to keep it public-domain in Phoenix.
-
-#ifdef VECTORS4
- typedef uint4 u;
-#elif defined VECTORS2
- typedef uint2 u;
-#else
- typedef uint u;
-#endif
-
-__constant uint K[87] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
-
- 0xc19bf3f4U,
- 0x80000000U,
- 0x00000280U,
- 0x00a00055U,
- 0xf377ed68U,
- 0xa54ff53aU,
- 0x08909ae5U,
- 0x90bb1e3cU,
- 0x9b05688cU,
- 0xca0b3af3U,
- 0x3c6ef372U,
- 0xbb67ae85U,
- 0x6a09e667U,
- 0x50c6645bU,
- 0x510e527fU,
- 0x3ac42e24U,
- 0x5807aa98U,
- 0xc19bf274U,
- 0x00a00000U,
- 0x00000100U,
- 0x11002000U,
- 0x00400022U,
- 0x136032edU
-};
-
-#define xc19bf3f4U K[64]
-#define x80000000U K[65]
-#define x00000280U K[66]
-#define x00a00055U K[67]
-#define xf377ed68U K[68]
-#define xa54ff53aU K[69]
-#define x08909ae5U K[70]
-#define x90bb1e3cU K[71]
-#define x9b05688cU K[72]
-#define xca0b3af3U K[73]
-#define x3c6ef372U K[74]
-#define xbb67ae85U K[75]
-#define x6a09e667U K[76]
-#define x50c6645bU K[77]
-#define x510e527fU K[78]
-#define x3ac42e24U K[79]
-#define x5807aa98U K[80]
-#define xc19bf274U K[81]
-#define x00a00000U K[82]
-#define x00000100U K[83]
-#define x11002000U K[84]
-#define x00400022U K[85]
-#define x136032edU K[86]
-
-// This part is not from the stock poclbm kernel. It's part of an optimization
-// added in the Phoenix Miner.
-
-// Some AMD devices have a BFI_INT opcode, which behaves exactly like the
-// SHA-256 ch function, but provides it in exactly one instruction. If
-// detected, use it for ch. Otherwise, construct ch out of simpler logical
-// primitives.
-
-#ifdef BITALIGN
- #pragma OPENCL EXTENSION cl_amd_media_ops : enable
- #define rotr(x, y) amd_bitalign((u)x, (u)x, (u)y)
-#else
- #define rotr(x, y) rotate((u)x, (u)(32 - y))
-#endif
-#ifdef BFI_INT
- // Well, slight problem... It turns out BFI_INT isn't actually exposed to
- // OpenCL (or CAL IL for that matter) in any way. However, there is
- // a similar instruction, BYTE_ALIGN_INT, which is exposed to OpenCL via
- // amd_bytealign, takes the same inputs, and provides the same output.
- // We can use that as a placeholder for BFI_INT and have the application
- // patch it after compilation.
-
- // This is the BFI_INT function
- #define ch(x, y, z) amd_bytealign(x, y, z)
-
- // Ma can also be implemented in terms of BFI_INT...
- #define Ma(x, y, z) amd_bytealign( (z^x), (y), (x) )
-
- // AMD's KernelAnalyzer throws errors compiling the kernel if we use
- // amd_bytealign on constants with vectors enabled, so we use this to avoid
- // problems. (this is used 4 times, and likely optimized out by the compiler.)
- #define Ma2(x, y, z) bitselect((u)x, (u)y, (u)z ^ (u)x)
-#else // BFI_INT
- //GCN actually fails if manually patched with BFI_INT
-
- #define ch(x, y, z) bitselect((u)z, (u)y, (u)x)
- #define Ma(x, y, z) bitselect((u)x, (u)y, (u)z ^ (u)x)
- #define Ma2(x, y, z) Ma(x, y, z)
-#endif
-
-
-__kernel
-__attribute__((vec_type_hint(u)))
-__attribute__((reqd_work_group_size(WORKSIZE, 1, 1)))
-void search(const uint state0, const uint state1, const uint state2, const uint state3,
- const uint state4, const uint state5, const uint state6, const uint state7,
- const uint b1, const uint c1,
- const uint f1, const uint g1, const uint h1,
-#ifndef GOFFSET
- const u base,
-#endif
- const uint fw0, const uint fw1, const uint fw2, const uint fw3, const uint fw15, const uint fw01r,
- const uint D1A, const uint C1addK5, const uint B1addK6,
- const uint W16addK16, const uint W17addK17,
- const uint PreVal4addT1, const uint Preval0,
- volatile __global uint * output)
-{
- u Vals[24];
- u *W = &Vals[8];
-
-#ifdef GOFFSET
- const u nonce = (uint)(get_global_id(0));
-#else
- const u nonce = base + (uint)(get_global_id(0));
-#endif
-
-Vals[5]=Preval0;
-Vals[5]+=nonce;
-
-Vals[0]=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],b1,c1);
-Vals[0]+=D1A;
-
-Vals[2]=Vals[0];
-Vals[2]+=h1;
-
-Vals[1]=PreVal4addT1;
-Vals[1]+=nonce;
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-
-Vals[6]=C1addK5;
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],b1);
-
-Vals[3]=Vals[6];
-Vals[3]+=g1;
-Vals[0]+=Ma2(g1,Vals[1],f1);
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma2(f1,Vals[0],Vals[1]);
-
-Vals[7]=B1addK6;
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-
-Vals[4]=Vals[7];
-Vals[4]+=f1;
-
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[7];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[8];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[9];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[10];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[11];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[12];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[13];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[14];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=xc19bf3f4U;
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=W16addK16;
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=W17addK17;
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[2]=(rotr(nonce,7)^rotr(nonce,18)^(nonce>>3U));
-W[2]+=fw2;
-Vals[4]+=W[2];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[18];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[3]=nonce;
-W[3]+=fw3;
-Vals[1]+=W[3];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[19];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[4]=(rotr(W[2],17)^rotr(W[2],19)^(W[2]>>10U));
-W[4]+=x80000000U;
-Vals[0]+=W[4];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[20];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[5]=(rotr(W[3],17)^rotr(W[3],19)^(W[3]>>10U));
-Vals[6]+=W[5];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[21];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[6]=(rotr(W[4],17)^rotr(W[4],19)^(W[4]>>10U));
-W[6]+=x00000280U;
-Vals[7]+=W[6];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[22];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[7]=(rotr(W[5],17)^rotr(W[5],19)^(W[5]>>10U));
-W[7]+=fw0;
-Vals[5]+=W[7];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[23];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[8]=(rotr(W[6],17)^rotr(W[6],19)^(W[6]>>10U));
-W[8]+=fw1;
-Vals[2]+=W[8];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[24];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[9]=W[2];
-W[9]+=(rotr(W[7],17)^rotr(W[7],19)^(W[7]>>10U));
-Vals[3]+=W[9];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[25];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[10]=W[3];
-W[10]+=(rotr(W[8],17)^rotr(W[8],19)^(W[8]>>10U));
-Vals[4]+=W[10];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[26];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[11]=W[4];
-W[11]+=(rotr(W[9],17)^rotr(W[9],19)^(W[9]>>10U));
-Vals[1]+=W[11];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[27];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[12]=W[5];
-W[12]+=(rotr(W[10],17)^rotr(W[10],19)^(W[10]>>10U));
-Vals[0]+=W[12];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[28];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[13]=W[6];
-W[13]+=(rotr(W[11],17)^rotr(W[11],19)^(W[11]>>10U));
-Vals[6]+=W[13];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[29];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[14]=x00a00055U;
-W[14]+=W[7];
-W[14]+=(rotr(W[12],17)^rotr(W[12],19)^(W[12]>>10U));
-Vals[7]+=W[14];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[30];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[15]=fw15;
-W[15]+=W[8];
-W[15]+=(rotr(W[13],17)^rotr(W[13],19)^(W[13]>>10U));
-Vals[5]+=W[15];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[31];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[0]=fw01r;
-W[0]+=W[9];
-W[0]+=(rotr(W[14],17)^rotr(W[14],19)^(W[14]>>10U));
-Vals[2]+=W[0];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[32];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[1]=fw1;
-W[1]+=(rotr(W[2],7)^rotr(W[2],18)^(W[2]>>3U));
-W[1]+=W[10];
-W[1]+=(rotr(W[15],17)^rotr(W[15],19)^(W[15]>>10U));
-Vals[3]+=W[1];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[33];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[2]+=(rotr(W[3],7)^rotr(W[3],18)^(W[3]>>3U));
-W[2]+=W[11];
-W[2]+=(rotr(W[0],17)^rotr(W[0],19)^(W[0]>>10U));
-Vals[4]+=W[2];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[34];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[3]+=(rotr(W[4],7)^rotr(W[4],18)^(W[4]>>3U));
-W[3]+=W[12];
-W[3]+=(rotr(W[1],17)^rotr(W[1],19)^(W[1]>>10U));
-Vals[1]+=W[3];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[35];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[4]+=(rotr(W[5],7)^rotr(W[5],18)^(W[5]>>3U));
-W[4]+=W[13];
-W[4]+=(rotr(W[2],17)^rotr(W[2],19)^(W[2]>>10U));
-Vals[0]+=W[4];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[36];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[5]+=(rotr(W[6],7)^rotr(W[6],18)^(W[6]>>3U));
-W[5]+=W[14];
-W[5]+=(rotr(W[3],17)^rotr(W[3],19)^(W[3]>>10U));
-Vals[6]+=W[5];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[37];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[6]+=(rotr(W[7],7)^rotr(W[7],18)^(W[7]>>3U));
-W[6]+=W[15];
-W[6]+=(rotr(W[4],17)^rotr(W[4],19)^(W[4]>>10U));
-Vals[7]+=W[6];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[38];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[7]+=(rotr(W[8],7)^rotr(W[8],18)^(W[8]>>3U));
-W[7]+=W[0];
-W[7]+=(rotr(W[5],17)^rotr(W[5],19)^(W[5]>>10U));
-Vals[5]+=W[7];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[39];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[8]+=(rotr(W[9],7)^rotr(W[9],18)^(W[9]>>3U));
-W[8]+=W[1];
-W[8]+=(rotr(W[6],17)^rotr(W[6],19)^(W[6]>>10U));
-Vals[2]+=W[8];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[40];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[9]+=(rotr(W[10],7)^rotr(W[10],18)^(W[10]>>3U));
-W[9]+=W[2];
-W[9]+=(rotr(W[7],17)^rotr(W[7],19)^(W[7]>>10U));
-Vals[3]+=W[9];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[41];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[10]+=(rotr(W[11],7)^rotr(W[11],18)^(W[11]>>3U));
-W[10]+=W[3];
-W[10]+=(rotr(W[8],17)^rotr(W[8],19)^(W[8]>>10U));
-Vals[4]+=W[10];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[42];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[11]+=(rotr(W[12],7)^rotr(W[12],18)^(W[12]>>3U));
-W[11]+=W[4];
-W[11]+=(rotr(W[9],17)^rotr(W[9],19)^(W[9]>>10U));
-Vals[1]+=W[11];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[43];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[12]+=(rotr(W[13],7)^rotr(W[13],18)^(W[13]>>3U));
-W[12]+=W[5];
-W[12]+=(rotr(W[10],17)^rotr(W[10],19)^(W[10]>>10U));
-Vals[0]+=W[12];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[44];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[13]+=(rotr(W[14],7)^rotr(W[14],18)^(W[14]>>3U));
-W[13]+=W[6];
-W[13]+=(rotr(W[11],17)^rotr(W[11],19)^(W[11]>>10U));
-Vals[6]+=W[13];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[45];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[14]+=(rotr(W[15],7)^rotr(W[15],18)^(W[15]>>3U));
-W[14]+=W[7];
-W[14]+=(rotr(W[12],17)^rotr(W[12],19)^(W[12]>>10U));
-Vals[7]+=W[14];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[46];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[15]+=(rotr(W[0],7)^rotr(W[0],18)^(W[0]>>3U));
-W[15]+=W[8];
-W[15]+=(rotr(W[13],17)^rotr(W[13],19)^(W[13]>>10U));
-Vals[5]+=W[15];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[47];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[0]+=(rotr(W[1],7)^rotr(W[1],18)^(W[1]>>3U));
-W[0]+=W[9];
-W[0]+=(rotr(W[14],17)^rotr(W[14],19)^(W[14]>>10U));
-Vals[2]+=W[0];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[48];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[1]+=(rotr(W[2],7)^rotr(W[2],18)^(W[2]>>3U));
-W[1]+=W[10];
-W[1]+=(rotr(W[15],17)^rotr(W[15],19)^(W[15]>>10U));
-Vals[3]+=W[1];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[49];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[2]+=(rotr(W[3],7)^rotr(W[3],18)^(W[3]>>3U));
-W[2]+=W[11];
-W[2]+=(rotr(W[0],17)^rotr(W[0],19)^(W[0]>>10U));
-Vals[4]+=W[2];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[50];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[3]+=(rotr(W[4],7)^rotr(W[4],18)^(W[4]>>3U));
-W[3]+=W[12];
-W[3]+=(rotr(W[1],17)^rotr(W[1],19)^(W[1]>>10U));
-Vals[1]+=W[3];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[51];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[4]+=(rotr(W[5],7)^rotr(W[5],18)^(W[5]>>3U));
-W[4]+=W[13];
-W[4]+=(rotr(W[2],17)^rotr(W[2],19)^(W[2]>>10U));
-Vals[0]+=W[4];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[52];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[5]+=(rotr(W[6],7)^rotr(W[6],18)^(W[6]>>3U));
-W[5]+=W[14];
-W[5]+=(rotr(W[3],17)^rotr(W[3],19)^(W[3]>>10U));
-Vals[6]+=W[5];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[53];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[6]+=(rotr(W[7],7)^rotr(W[7],18)^(W[7]>>3U));
-W[6]+=W[15];
-W[6]+=(rotr(W[4],17)^rotr(W[4],19)^(W[4]>>10U));
-Vals[7]+=W[6];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[54];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[7]+=(rotr(W[8],7)^rotr(W[8],18)^(W[8]>>3U));
-W[7]+=W[0];
-W[7]+=(rotr(W[5],17)^rotr(W[5],19)^(W[5]>>10U));
-Vals[5]+=W[7];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[55];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[8]+=(rotr(W[9],7)^rotr(W[9],18)^(W[9]>>3U));
-W[8]+=W[1];
-W[8]+=(rotr(W[6],17)^rotr(W[6],19)^(W[6]>>10U));
-Vals[2]+=W[8];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[56];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[9]+=(rotr(W[10],7)^rotr(W[10],18)^(W[10]>>3U));
-W[9]+=W[2];
-W[9]+=(rotr(W[7],17)^rotr(W[7],19)^(W[7]>>10U));
-Vals[3]+=W[9];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[57];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[10]+=(rotr(W[11],7)^rotr(W[11],18)^(W[11]>>3U));
-W[10]+=W[3];
-W[10]+=(rotr(W[8],17)^rotr(W[8],19)^(W[8]>>10U));
-Vals[4]+=W[10];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[58];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[11]+=(rotr(W[12],7)^rotr(W[12],18)^(W[12]>>3U));
-W[11]+=W[4];
-W[11]+=(rotr(W[9],17)^rotr(W[9],19)^(W[9]>>10U));
-Vals[1]+=W[11];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[59];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[12]+=(rotr(W[13],7)^rotr(W[13],18)^(W[13]>>3U));
-W[12]+=W[5];
-W[12]+=(rotr(W[10],17)^rotr(W[10],19)^(W[10]>>10U));
-Vals[0]+=W[12];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[60];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[13]+=(rotr(W[14],7)^rotr(W[14],18)^(W[14]>>3U));
-W[13]+=W[6];
-W[13]+=(rotr(W[11],17)^rotr(W[11],19)^(W[11]>>10U));
-Vals[6]+=W[13];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[61];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-Vals[7]+=W[14];
-Vals[7]+=(rotr(W[15],7)^rotr(W[15],18)^(W[15]>>3U));
-Vals[7]+=W[7];
-Vals[7]+=(rotr(W[12],17)^rotr(W[12],19)^(W[12]>>10U));
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[62];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-Vals[5]+=W[15];
-Vals[5]+=(rotr(W[0],7)^rotr(W[0],18)^(W[0]>>3U));
-Vals[5]+=W[8];
-Vals[5]+=(rotr(W[13],17)^rotr(W[13],19)^(W[13]>>10U));
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[63];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-Vals[5]+=state0;
-
-W[7]=state7;
-W[7]+=Vals[2];
-
-Vals[2]=xf377ed68U;
-Vals[2]+=Vals[5];
-W[0]=Vals[5];
-Vals[5]=x6a09e667U;
-
-W[3]=state3;
-W[3]+=Vals[0];
-
-Vals[0]=xa54ff53aU;
-Vals[0]+=Vals[2];
-Vals[2]+=x08909ae5U;
-
-W[6]=state6;
-W[6]+=Vals[3];
-
-Vals[3]=x90bb1e3cU;
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=(x9b05688cU^(Vals[0]&xca0b3af3U));
-
-Vals[7]+=state1;
-Vals[3]+=Vals[7];
-W[1]=Vals[7];
-Vals[7]=xbb67ae85U;
-
-W[2]=state2;
-W[2]+=Vals[6];
-
-Vals[6]=x3c6ef372U;
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma2(Vals[7],Vals[2],Vals[5]);
-
-W[5]=state5;
-W[5]+=Vals[4];
-
-Vals[4]=x50c6645bU;
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],x510e527fU);
-Vals[4]+=W[2];
-
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma2(Vals[5],Vals[3],Vals[2]);
-
-W[4]=state4;
-W[4]+=Vals[1];
-
-Vals[1]=x3ac42e24U;
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=W[3];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[4];
-Vals[0]+=W[4];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[5];
-Vals[6]+=W[5];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[6];
-Vals[7]+=W[6];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[7];
-Vals[5]+=W[7];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=x5807aa98U;
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[9];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[10];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[11];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[12];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[13];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[14];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=xc19bf274U;
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[0]+=(rotr(W[1],7)^rotr(W[1],18)^(W[1]>>3U));
-Vals[2]+=W[0];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[16];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[1]+=(rotr(W[2],7)^rotr(W[2],18)^(W[2]>>3U));
-W[1]+=x00a00000U;
-Vals[3]+=W[1];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[17];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[2]+=(rotr(W[3],7)^rotr(W[3],18)^(W[3]>>3U));
-W[2]+=(rotr(W[0],17)^rotr(W[0],19)^(W[0]>>10U));
-Vals[4]+=W[2];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[18];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[3]+=(rotr(W[4],7)^rotr(W[4],18)^(W[4]>>3U));
-W[3]+=(rotr(W[1],17)^rotr(W[1],19)^(W[1]>>10U));
-Vals[1]+=W[3];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[19];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[4]+=(rotr(W[5],7)^rotr(W[5],18)^(W[5]>>3U));
-W[4]+=(rotr(W[2],17)^rotr(W[2],19)^(W[2]>>10U));
-Vals[0]+=W[4];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[20];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[5]+=(rotr(W[6],7)^rotr(W[6],18)^(W[6]>>3U));
-W[5]+=(rotr(W[3],17)^rotr(W[3],19)^(W[3]>>10U));
-Vals[6]+=W[5];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[21];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[6]+=(rotr(W[7],7)^rotr(W[7],18)^(W[7]>>3U));
-W[6]+=x00000100U;
-W[6]+=(rotr(W[4],17)^rotr(W[4],19)^(W[4]>>10U));
-Vals[7]+=W[6];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[22];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[7]+=x11002000U;
-W[7]+=W[0];
-W[7]+=(rotr(W[5],17)^rotr(W[5],19)^(W[5]>>10U));
-Vals[5]+=W[7];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[23];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[8]=x80000000U;
-W[8]+=W[1];
-W[8]+=(rotr(W[6],17)^rotr(W[6],19)^(W[6]>>10U));
-Vals[2]+=W[8];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[24];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[9]=W[2];
-W[9]+=(rotr(W[7],17)^rotr(W[7],19)^(W[7]>>10U));
-Vals[3]+=W[9];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[25];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[10]=W[3];
-W[10]+=(rotr(W[8],17)^rotr(W[8],19)^(W[8]>>10U));
-Vals[4]+=W[10];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[26];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[11]=W[4];
-W[11]+=(rotr(W[9],17)^rotr(W[9],19)^(W[9]>>10U));
-Vals[1]+=W[11];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[27];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[12]=W[5];
-W[12]+=(rotr(W[10],17)^rotr(W[10],19)^(W[10]>>10U));
-Vals[0]+=W[12];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[28];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[13]=W[6];
-W[13]+=(rotr(W[11],17)^rotr(W[11],19)^(W[11]>>10U));
-Vals[6]+=W[13];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[29];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[14]=x00400022U;
-W[14]+=W[7];
-W[14]+=(rotr(W[12],17)^rotr(W[12],19)^(W[12]>>10U));
-Vals[7]+=W[14];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[30];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[15]=x00000100U;
-W[15]+=(rotr(W[0],7)^rotr(W[0],18)^(W[0]>>3U));
-W[15]+=W[8];
-W[15]+=(rotr(W[13],17)^rotr(W[13],19)^(W[13]>>10U));
-Vals[5]+=W[15];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[31];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[0]+=(rotr(W[1],7)^rotr(W[1],18)^(W[1]>>3U));
-W[0]+=W[9];
-W[0]+=(rotr(W[14],17)^rotr(W[14],19)^(W[14]>>10U));
-Vals[2]+=W[0];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[32];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[1]+=(rotr(W[2],7)^rotr(W[2],18)^(W[2]>>3U));
-W[1]+=W[10];
-W[1]+=(rotr(W[15],17)^rotr(W[15],19)^(W[15]>>10U));
-Vals[3]+=W[1];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[33];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[2]+=(rotr(W[3],7)^rotr(W[3],18)^(W[3]>>3U));
-W[2]+=W[11];
-W[2]+=(rotr(W[0],17)^rotr(W[0],19)^(W[0]>>10U));
-Vals[4]+=W[2];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[34];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[3]+=(rotr(W[4],7)^rotr(W[4],18)^(W[4]>>3U));
-W[3]+=W[12];
-W[3]+=(rotr(W[1],17)^rotr(W[1],19)^(W[1]>>10U));
-Vals[1]+=W[3];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[35];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[4]+=(rotr(W[5],7)^rotr(W[5],18)^(W[5]>>3U));
-W[4]+=W[13];
-W[4]+=(rotr(W[2],17)^rotr(W[2],19)^(W[2]>>10U));
-Vals[0]+=W[4];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[36];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[5]+=(rotr(W[6],7)^rotr(W[6],18)^(W[6]>>3U));
-W[5]+=W[14];
-W[5]+=(rotr(W[3],17)^rotr(W[3],19)^(W[3]>>10U));
-Vals[6]+=W[5];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[37];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[6]+=(rotr(W[7],7)^rotr(W[7],18)^(W[7]>>3U));
-W[6]+=W[15];
-W[6]+=(rotr(W[4],17)^rotr(W[4],19)^(W[4]>>10U));
-Vals[7]+=W[6];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[38];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[7]+=(rotr(W[8],7)^rotr(W[8],18)^(W[8]>>3U));
-W[7]+=W[0];
-W[7]+=(rotr(W[5],17)^rotr(W[5],19)^(W[5]>>10U));
-Vals[5]+=W[7];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[39];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[8]+=(rotr(W[9],7)^rotr(W[9],18)^(W[9]>>3U));
-W[8]+=W[1];
-W[8]+=(rotr(W[6],17)^rotr(W[6],19)^(W[6]>>10U));
-Vals[2]+=W[8];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[40];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[9]+=(rotr(W[10],7)^rotr(W[10],18)^(W[10]>>3U));
-W[9]+=W[2];
-W[9]+=(rotr(W[7],17)^rotr(W[7],19)^(W[7]>>10U));
-Vals[3]+=W[9];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[41];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[10]+=(rotr(W[11],7)^rotr(W[11],18)^(W[11]>>3U));
-W[10]+=W[3];
-W[10]+=(rotr(W[8],17)^rotr(W[8],19)^(W[8]>>10U));
-Vals[4]+=W[10];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[42];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[11]+=(rotr(W[12],7)^rotr(W[12],18)^(W[12]>>3U));
-W[11]+=W[4];
-W[11]+=(rotr(W[9],17)^rotr(W[9],19)^(W[9]>>10U));
-Vals[1]+=W[11];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[43];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[12]+=(rotr(W[13],7)^rotr(W[13],18)^(W[13]>>3U));
-W[12]+=W[5];
-W[12]+=(rotr(W[10],17)^rotr(W[10],19)^(W[10]>>10U));
-Vals[0]+=W[12];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[44];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[13]+=(rotr(W[14],7)^rotr(W[14],18)^(W[14]>>3U));
-W[13]+=W[6];
-W[13]+=(rotr(W[11],17)^rotr(W[11],19)^(W[11]>>10U));
-Vals[6]+=W[13];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[45];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[14]+=(rotr(W[15],7)^rotr(W[15],18)^(W[15]>>3U));
-W[14]+=W[7];
-W[14]+=(rotr(W[12],17)^rotr(W[12],19)^(W[12]>>10U));
-Vals[7]+=W[14];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[46];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[15]+=(rotr(W[0],7)^rotr(W[0],18)^(W[0]>>3U));
-W[15]+=W[8];
-W[15]+=(rotr(W[13],17)^rotr(W[13],19)^(W[13]>>10U));
-Vals[5]+=W[15];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[47];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[0]+=(rotr(W[1],7)^rotr(W[1],18)^(W[1]>>3U));
-W[0]+=W[9];
-W[0]+=(rotr(W[14],17)^rotr(W[14],19)^(W[14]>>10U));
-Vals[2]+=W[0];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[48];
-Vals[0]+=Vals[2];
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-
-W[1]+=(rotr(W[2],7)^rotr(W[2],18)^(W[2]>>3U));
-W[1]+=W[10];
-W[1]+=(rotr(W[15],17)^rotr(W[15],19)^(W[15]>>10U));
-Vals[3]+=W[1];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[49];
-Vals[6]+=Vals[3];
-Vals[3]+=(rotr(Vals[2],2)^rotr(Vals[2],13)^rotr(Vals[2],22));
-Vals[3]+=Ma(Vals[7],Vals[2],Vals[5]);
-
-W[2]+=(rotr(W[3],7)^rotr(W[3],18)^(W[3]>>3U));
-W[2]+=W[11];
-W[2]+=(rotr(W[0],17)^rotr(W[0],19)^(W[0]>>10U));
-Vals[4]+=W[2];
-Vals[4]+=(rotr(Vals[6],6)^rotr(Vals[6],11)^rotr(Vals[6],25));
-Vals[4]+=ch(Vals[6],Vals[0],Vals[1]);
-Vals[4]+=K[50];
-Vals[7]+=Vals[4];
-Vals[4]+=(rotr(Vals[3],2)^rotr(Vals[3],13)^rotr(Vals[3],22));
-Vals[4]+=Ma(Vals[5],Vals[3],Vals[2]);
-
-W[3]+=(rotr(W[4],7)^rotr(W[4],18)^(W[4]>>3U));
-W[3]+=W[12];
-W[3]+=(rotr(W[1],17)^rotr(W[1],19)^(W[1]>>10U));
-Vals[1]+=W[3];
-Vals[1]+=(rotr(Vals[7],6)^rotr(Vals[7],11)^rotr(Vals[7],25));
-Vals[1]+=ch(Vals[7],Vals[6],Vals[0]);
-Vals[1]+=K[51];
-Vals[5]+=Vals[1];
-Vals[1]+=(rotr(Vals[4],2)^rotr(Vals[4],13)^rotr(Vals[4],22));
-Vals[1]+=Ma(Vals[2],Vals[4],Vals[3]);
-
-W[4]+=(rotr(W[5],7)^rotr(W[5],18)^(W[5]>>3U));
-W[4]+=W[13];
-W[4]+=(rotr(W[2],17)^rotr(W[2],19)^(W[2]>>10U));
-Vals[0]+=W[4];
-Vals[0]+=(rotr(Vals[5],6)^rotr(Vals[5],11)^rotr(Vals[5],25));
-Vals[0]+=ch(Vals[5],Vals[7],Vals[6]);
-Vals[0]+=K[52];
-Vals[2]+=Vals[0];
-Vals[0]+=(rotr(Vals[1],2)^rotr(Vals[1],13)^rotr(Vals[1],22));
-Vals[0]+=Ma(Vals[3],Vals[1],Vals[4]);
-
-W[5]+=(rotr(W[6],7)^rotr(W[6],18)^(W[6]>>3U));
-W[5]+=W[14];
-W[5]+=(rotr(W[3],17)^rotr(W[3],19)^(W[3]>>10U));
-Vals[6]+=W[5];
-Vals[6]+=(rotr(Vals[2],6)^rotr(Vals[2],11)^rotr(Vals[2],25));
-Vals[6]+=ch(Vals[2],Vals[5],Vals[7]);
-Vals[6]+=K[53];
-Vals[3]+=Vals[6];
-Vals[6]+=(rotr(Vals[0],2)^rotr(Vals[0],13)^rotr(Vals[0],22));
-Vals[6]+=Ma(Vals[4],Vals[0],Vals[1]);
-
-W[6]+=(rotr(W[7],7)^rotr(W[7],18)^(W[7]>>3U));
-W[6]+=W[15];
-W[6]+=(rotr(W[4],17)^rotr(W[4],19)^(W[4]>>10U));
-Vals[7]+=W[6];
-Vals[7]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[7]+=ch(Vals[3],Vals[2],Vals[5]);
-Vals[7]+=K[54];
-Vals[4]+=Vals[7];
-Vals[7]+=(rotr(Vals[6],2)^rotr(Vals[6],13)^rotr(Vals[6],22));
-Vals[7]+=Ma(Vals[1],Vals[6],Vals[0]);
-
-W[7]+=(rotr(W[8],7)^rotr(W[8],18)^(W[8]>>3U));
-W[7]+=W[0];
-W[7]+=(rotr(W[5],17)^rotr(W[5],19)^(W[5]>>10U));
-Vals[5]+=W[7];
-Vals[5]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[5]+=ch(Vals[4],Vals[3],Vals[2]);
-Vals[5]+=K[55];
-Vals[1]+=Vals[5];
-Vals[5]+=(rotr(Vals[7],2)^rotr(Vals[7],13)^rotr(Vals[7],22));
-Vals[5]+=Ma(Vals[0],Vals[7],Vals[6]);
-
-W[8]+=(rotr(W[9],7)^rotr(W[9],18)^(W[9]>>3U));
-W[8]+=W[1];
-W[8]+=(rotr(W[6],17)^rotr(W[6],19)^(W[6]>>10U));
-Vals[2]+=W[8];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-Vals[2]+=K[56];
-Vals[0]+=Vals[2];
-
-W[9]+=(rotr(W[10],7)^rotr(W[10],18)^(W[10]>>3U));
-W[9]+=W[2];
-W[9]+=(rotr(W[7],17)^rotr(W[7],19)^(W[7]>>10U));
-Vals[3]+=W[9];
-Vals[3]+=(rotr(Vals[0],6)^rotr(Vals[0],11)^rotr(Vals[0],25));
-Vals[3]+=ch(Vals[0],Vals[1],Vals[4]);
-Vals[3]+=K[57];
-Vals[3]+=Vals[6];
-
-W[10]+=(rotr(W[11],7)^rotr(W[11],18)^(W[11]>>3U));
-W[10]+=W[3];
-W[10]+=(rotr(W[8],17)^rotr(W[8],19)^(W[8]>>10U));
-Vals[4]+=W[10];
-Vals[4]+=(rotr(Vals[3],6)^rotr(Vals[3],11)^rotr(Vals[3],25));
-Vals[4]+=ch(Vals[3],Vals[0],Vals[1]);
-Vals[4]+=K[58];
-Vals[4]+=Vals[7];
-Vals[1]+=(rotr(Vals[4],6)^rotr(Vals[4],11)^rotr(Vals[4],25));
-Vals[1]+=ch(Vals[4],Vals[3],Vals[0]);
-Vals[1]+=W[11];
-Vals[1]+=(rotr(W[12],7)^rotr(W[12],18)^(W[12]>>3U));
-Vals[1]+=W[4];
-Vals[1]+=(rotr(W[9],17)^rotr(W[9],19)^(W[9]>>10U));
-Vals[1]+=K[59];
-Vals[1]+=Vals[5];
-
-Vals[2]+=Ma(Vals[6],Vals[5],Vals[7]);
-Vals[2]+=(rotr(Vals[5],2)^rotr(Vals[5],13)^rotr(Vals[5],22));
-Vals[2]+=W[12];
-Vals[2]+=(rotr(W[13],7)^rotr(W[13],18)^(W[13]>>3U));
-Vals[2]+=W[5];
-Vals[2]+=(rotr(W[10],17)^rotr(W[10],19)^(W[10]>>10U));
-Vals[2]+=Vals[0];
-Vals[2]+=(rotr(Vals[1],6)^rotr(Vals[1],11)^rotr(Vals[1],25));
-Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
-
-#define FOUND (0x0F)
-#define SETFOUND(Xnonce) output[output[FOUND]++] = Xnonce
-
-#if defined(VECTORS2) || defined(VECTORS4)
- if (any(Vals[2] == x136032edU)) {
- if (Vals[2].x == x136032edU)
- SETFOUND(nonce.x);
- if (Vals[2].y == x136032edU)
- SETFOUND(nonce.y);
-#if defined(VECTORS4)
- if (Vals[2].z == x136032edU)
- SETFOUND(nonce.z);
- if (Vals[2].w == x136032edU)
- SETFOUND(nonce.w);
-#endif
- }
-#else
- if (Vals[2] == x136032edU)
- SETFOUND(nonce);
-#endif
-}
diff --git a/scrypt.c b/scrypt.c
deleted file mode 100644
index e0c75f4..0000000
--- a/scrypt.c
+++ /dev/null
@@ -1,491 +0,0 @@
-/*-
- * Copyright 2009 Colin Percival, 2011 ArtForz
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file was originally written by Colin Percival as part of the Tarsnap
- * online backup system.
- */
-
-#include "config.h"
-#include "miner.h"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-typedef struct SHA256Context {
- uint32_t state[8];
- uint32_t buf[16];
-} SHA256_CTX;
-
-/*
- * Encode a length len/4 vector of (uint32_t) into a length len vector of
- * (unsigned char) in big-endian form. Assumes len is a multiple of 4.
- */
-static inline void
-be32enc_vect(uint32_t *dst, const uint32_t *src, uint32_t len)
-{
- uint32_t i;
-
- for (i = 0; i < len; i++)
- dst[i] = htobe32(src[i]);
-}
-
-/* Elementary functions used by SHA256 */
-#define Ch(x, y, z) ((x & (y ^ z)) ^ z)
-#define Maj(x, y, z) ((x & (y | z)) | (y & z))
-#define SHR(x, n) (x >> n)
-#define ROTR(x, n) ((x >> n) | (x << (32 - n)))
-#define S0(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
-#define S1(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
-#define s0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
-#define s1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
-
-/* SHA256 round function */
-#define RND(a, b, c, d, e, f, g, h, k) \
- t0 = h + S1(e) + Ch(e, f, g) + k; \
- t1 = S0(a) + Maj(a, b, c); \
- d += t0; \
- h = t0 + t1;
-
-/* Adjusted round function for rotating state */
-#define RNDr(S, W, i, k) \
- RND(S[(64 - i) % 8], S[(65 - i) % 8], \
- S[(66 - i) % 8], S[(67 - i) % 8], \
- S[(68 - i) % 8], S[(69 - i) % 8], \
- S[(70 - i) % 8], S[(71 - i) % 8], \
- W[i] + k)
-
-/*
- * SHA256 block compression function. The 256-bit state is transformed via
- * the 512-bit input block to produce a new state.
- */
-static void
-SHA256_Transform(uint32_t * state, const uint32_t block[16], int swap)
-{
- uint32_t W[64];
- uint32_t S[8];
- uint32_t t0, t1;
- int i;
-
- /* 1. Prepare message schedule W. */
- if(swap)
- for (i = 0; i < 16; i++)
- W[i] = htobe32(block[i]);
- else
- memcpy(W, block, 64);
- for (i = 16; i < 64; i += 2) {
- W[i] = s1(W[i - 2]) + W[i - 7] + s0(W[i - 15]) + W[i - 16];
- W[i+1] = s1(W[i - 1]) + W[i - 6] + s0(W[i - 14]) + W[i - 15];
- }
-
- /* 2. Initialize working variables. */
- memcpy(S, state, 32);
-
- /* 3. Mix. */
- RNDr(S, W, 0, 0x428a2f98);
- RNDr(S, W, 1, 0x71374491);
- RNDr(S, W, 2, 0xb5c0fbcf);
- RNDr(S, W, 3, 0xe9b5dba5);
- RNDr(S, W, 4, 0x3956c25b);
- RNDr(S, W, 5, 0x59f111f1);
- RNDr(S, W, 6, 0x923f82a4);
- RNDr(S, W, 7, 0xab1c5ed5);
- RNDr(S, W, 8, 0xd807aa98);
- RNDr(S, W, 9, 0x12835b01);
- RNDr(S, W, 10, 0x243185be);
- RNDr(S, W, 11, 0x550c7dc3);
- RNDr(S, W, 12, 0x72be5d74);
- RNDr(S, W, 13, 0x80deb1fe);
- RNDr(S, W, 14, 0x9bdc06a7);
- RNDr(S, W, 15, 0xc19bf174);
- RNDr(S, W, 16, 0xe49b69c1);
- RNDr(S, W, 17, 0xefbe4786);
- RNDr(S, W, 18, 0x0fc19dc6);
- RNDr(S, W, 19, 0x240ca1cc);
- RNDr(S, W, 20, 0x2de92c6f);
- RNDr(S, W, 21, 0x4a7484aa);
- RNDr(S, W, 22, 0x5cb0a9dc);
- RNDr(S, W, 23, 0x76f988da);
- RNDr(S, W, 24, 0x983e5152);
- RNDr(S, W, 25, 0xa831c66d);
- RNDr(S, W, 26, 0xb00327c8);
- RNDr(S, W, 27, 0xbf597fc7);
- RNDr(S, W, 28, 0xc6e00bf3);
- RNDr(S, W, 29, 0xd5a79147);
- RNDr(S, W, 30, 0x06ca6351);
- RNDr(S, W, 31, 0x14292967);
- RNDr(S, W, 32, 0x27b70a85);
- RNDr(S, W, 33, 0x2e1b2138);
- RNDr(S, W, 34, 0x4d2c6dfc);
- RNDr(S, W, 35, 0x53380d13);
- RNDr(S, W, 36, 0x650a7354);
- RNDr(S, W, 37, 0x766a0abb);
- RNDr(S, W, 38, 0x81c2c92e);
- RNDr(S, W, 39, 0x92722c85);
- RNDr(S, W, 40, 0xa2bfe8a1);
- RNDr(S, W, 41, 0xa81a664b);
- RNDr(S, W, 42, 0xc24b8b70);
- RNDr(S, W, 43, 0xc76c51a3);
- RNDr(S, W, 44, 0xd192e819);
- RNDr(S, W, 45, 0xd6990624);
- RNDr(S, W, 46, 0xf40e3585);
- RNDr(S, W, 47, 0x106aa070);
- RNDr(S, W, 48, 0x19a4c116);
- RNDr(S, W, 49, 0x1e376c08);
- RNDr(S, W, 50, 0x2748774c);
- RNDr(S, W, 51, 0x34b0bcb5);
- RNDr(S, W, 52, 0x391c0cb3);
- RNDr(S, W, 53, 0x4ed8aa4a);
- RNDr(S, W, 54, 0x5b9cca4f);
- RNDr(S, W, 55, 0x682e6ff3);
- RNDr(S, W, 56, 0x748f82ee);
- RNDr(S, W, 57, 0x78a5636f);
- RNDr(S, W, 58, 0x84c87814);
- RNDr(S, W, 59, 0x8cc70208);
- RNDr(S, W, 60, 0x90befffa);
- RNDr(S, W, 61, 0xa4506ceb);
- RNDr(S, W, 62, 0xbef9a3f7);
- RNDr(S, W, 63, 0xc67178f2);
-
- /* 4. Mix local working variables into global state */
- for (i = 0; i < 8; i++)
- state[i] += S[i];
-}
-
-static inline void
-SHA256_InitState(uint32_t * state)
-{
- /* Magic initialization constants */
- state[0] = 0x6A09E667;
- state[1] = 0xBB67AE85;
- state[2] = 0x3C6EF372;
- state[3] = 0xA54FF53A;
- state[4] = 0x510E527F;
- state[5] = 0x9B05688C;
- state[6] = 0x1F83D9AB;
- state[7] = 0x5BE0CD19;
-}
-
-static const uint32_t passwdpad[12] = {0x00000080, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80020000};
-static const uint32_t outerpad[8] = {0x80000000, 0, 0, 0, 0, 0, 0, 0x00000300};
-
-/**
- * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
- * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
- * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1).
- */
-static inline void
-PBKDF2_SHA256_80_128(const uint32_t * passwd, uint32_t * buf)
-{
- SHA256_CTX PShictx, PShoctx;
- uint32_t tstate[8];
- uint32_t ihash[8];
- uint32_t i;
- uint32_t pad[16];
-
- static const uint32_t innerpad[11] = {0x00000080, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xa0040000};
-
- /* If Klen > 64, the key is really SHA256(K). */
- SHA256_InitState(tstate);
- SHA256_Transform(tstate, passwd, 1);
- memcpy(pad, passwd+16, 16);
- memcpy(pad+4, passwdpad, 48);
- SHA256_Transform(tstate, pad, 1);
- memcpy(ihash, tstate, 32);
-
- SHA256_InitState(PShictx.state);
- for (i = 0; i < 8; i++)
- pad[i] = ihash[i] ^ 0x36363636;
- for (; i < 16; i++)
- pad[i] = 0x36363636;
- SHA256_Transform(PShictx.state, pad, 0);
- SHA256_Transform(PShictx.state, passwd, 1);
- be32enc_vect(PShictx.buf, passwd+16, 4);
- be32enc_vect(PShictx.buf+5, innerpad, 11);
-
- SHA256_InitState(PShoctx.state);
- for (i = 0; i < 8; i++)
- pad[i] = ihash[i] ^ 0x5c5c5c5c;
- for (; i < 16; i++)
- pad[i] = 0x5c5c5c5c;
- SHA256_Transform(PShoctx.state, pad, 0);
- memcpy(PShoctx.buf+8, outerpad, 32);
-
- /* Iterate through the blocks. */
- for (i = 0; i < 4; i++) {
- uint32_t istate[8];
- uint32_t ostate[8];
-
- memcpy(istate, PShictx.state, 32);
- PShictx.buf[4] = i + 1;
- SHA256_Transform(istate, PShictx.buf, 0);
- memcpy(PShoctx.buf, istate, 32);
-
- memcpy(ostate, PShoctx.state, 32);
- SHA256_Transform(ostate, PShoctx.buf, 0);
- be32enc_vect(buf+i*8, ostate, 8);
- }
-}
-
-
-static inline void
-PBKDF2_SHA256_80_128_32(const uint32_t * passwd, const uint32_t * salt, uint32_t *ostate)
-{
- uint32_t tstate[8];
- uint32_t ihash[8];
- uint32_t i;
-
- /* Compute HMAC state after processing P and S. */
- uint32_t pad[16];
-
- static const uint32_t ihash_finalblk[16] = {0x00000001,0x80000000,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0x00000620};
-
- /* If Klen > 64, the key is really SHA256(K). */
- SHA256_InitState(tstate);
- SHA256_Transform(tstate, passwd, 1);
- memcpy(pad, passwd+16, 16);
- memcpy(pad+4, passwdpad, 48);
- SHA256_Transform(tstate, pad, 1);
- memcpy(ihash, tstate, 32);
-
- SHA256_InitState(ostate);
- for (i = 0; i < 8; i++)
- pad[i] = ihash[i] ^ 0x5c5c5c5c;
- for (; i < 16; i++)
- pad[i] = 0x5c5c5c5c;
- SHA256_Transform(ostate, pad, 0);
-
- SHA256_InitState(tstate);
- for (i = 0; i < 8; i++)
- pad[i] = ihash[i] ^ 0x36363636;
- for (; i < 16; i++)
- pad[i] = 0x36363636;
- SHA256_Transform(tstate, pad, 0);
- SHA256_Transform(tstate, salt, 1);
- SHA256_Transform(tstate, salt+16, 1);
- SHA256_Transform(tstate, ihash_finalblk, 0);
- memcpy(pad, tstate, 32);
- memcpy(pad+8, outerpad, 32);
-
- /* Feed the inner hash to the outer SHA256 operation. */
- SHA256_Transform(ostate, pad, 0);
-}
-
-
-/**
- * salsa20_8(B):
- * Apply the salsa20/8 core to the provided block.
- */
-static inline void
-salsa20_8(uint32_t B[16], const uint32_t Bx[16])
-{
- uint32_t x00,x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12,x13,x14,x15;
- size_t i;
-
- x00 = (B[ 0] ^= Bx[ 0]);
- x01 = (B[ 1] ^= Bx[ 1]);
- x02 = (B[ 2] ^= Bx[ 2]);
- x03 = (B[ 3] ^= Bx[ 3]);
- x04 = (B[ 4] ^= Bx[ 4]);
- x05 = (B[ 5] ^= Bx[ 5]);
- x06 = (B[ 6] ^= Bx[ 6]);
- x07 = (B[ 7] ^= Bx[ 7]);
- x08 = (B[ 8] ^= Bx[ 8]);
- x09 = (B[ 9] ^= Bx[ 9]);
- x10 = (B[10] ^= Bx[10]);
- x11 = (B[11] ^= Bx[11]);
- x12 = (B[12] ^= Bx[12]);
- x13 = (B[13] ^= Bx[13]);
- x14 = (B[14] ^= Bx[14]);
- x15 = (B[15] ^= Bx[15]);
- for (i = 0; i < 8; i += 2) {
-#define R(a,b) (((a) << (b)) | ((a) >> (32 - (b))))
- /* Operate on columns. */
- x04 ^= R(x00+x12, 7); x09 ^= R(x05+x01, 7); x14 ^= R(x10+x06, 7); x03 ^= R(x15+x11, 7);
- x08 ^= R(x04+x00, 9); x13 ^= R(x09+x05, 9); x02 ^= R(x14+x10, 9); x07 ^= R(x03+x15, 9);
- x12 ^= R(x08+x04,13); x01 ^= R(x13+x09,13); x06 ^= R(x02+x14,13); x11 ^= R(x07+x03,13);
- x00 ^= R(x12+x08,18); x05 ^= R(x01+x13,18); x10 ^= R(x06+x02,18); x15 ^= R(x11+x07,18);
-
- /* Operate on rows. */
- x01 ^= R(x00+x03, 7); x06 ^= R(x05+x04, 7); x11 ^= R(x10+x09, 7); x12 ^= R(x15+x14, 7);
- x02 ^= R(x01+x00, 9); x07 ^= R(x06+x05, 9); x08 ^= R(x11+x10, 9); x13 ^= R(x12+x15, 9);
- x03 ^= R(x02+x01,13); x04 ^= R(x07+x06,13); x09 ^= R(x08+x11,13); x14 ^= R(x13+x12,13);
- x00 ^= R(x03+x02,18); x05 ^= R(x04+x07,18); x10 ^= R(x09+x08,18); x15 ^= R(x14+x13,18);
-#undef R
- }
- B[ 0] += x00;
- B[ 1] += x01;
- B[ 2] += x02;
- B[ 3] += x03;
- B[ 4] += x04;
- B[ 5] += x05;
- B[ 6] += x06;
- B[ 7] += x07;
- B[ 8] += x08;
- B[ 9] += x09;
- B[10] += x10;
- B[11] += x11;
- B[12] += x12;
- B[13] += x13;
- B[14] += x14;
- B[15] += x15;
-}
-
-/* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output
- scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes
- */
-static void scrypt_1024_1_1_256_sp(const uint32_t* input, char* scratchpad, uint32_t *ostate)
-{
- uint32_t * V;
- uint32_t X[32];
- uint32_t i;
- uint32_t j;
- uint32_t k;
- uint64_t *p1, *p2;
-
- p1 = (uint64_t *)X;
- V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));
-
- PBKDF2_SHA256_80_128(input, X);
-
- for (i = 0; i < 1024; i += 2) {
- memcpy(&V[i * 32], X, 128);
-
- salsa20_8(&X[0], &X[16]);
- salsa20_8(&X[16], &X[0]);
-
- memcpy(&V[(i + 1) * 32], X, 128);
-
- salsa20_8(&X[0], &X[16]);
- salsa20_8(&X[16], &X[0]);
- }
- for (i = 0; i < 1024; i += 2) {
- j = X[16] & 1023;
- p2 = (uint64_t *)(&V[j * 32]);
- for(k = 0; k < 16; k++)
- p1[k] ^= p2[k];
-
- salsa20_8(&X[0], &X[16]);
- salsa20_8(&X[16], &X[0]);
-
- j = X[16] & 1023;
- p2 = (uint64_t *)(&V[j * 32]);
- for(k = 0; k < 16; k++)
- p1[k] ^= p2[k];
-
- salsa20_8(&X[0], &X[16]);
- salsa20_8(&X[16], &X[0]);
- }
-
- PBKDF2_SHA256_80_128_32(input, X, ostate);
-}
-
-/* 131583 rounded up to 4 byte alignment */
-#define SCRATCHBUF_SIZE (131584)
-
-void scrypt_regenhash(struct work *work)
-{
- uint32_t data[20];
- char *scratchbuf;
- uint32_t *nonce = (uint32_t *)(work->data + 76);
- uint32_t *ohash = (uint32_t *)(work->hash);
-
- be32enc_vect(data, (const uint32_t *)work->data, 19);
- data[19] = htobe32(*nonce);
- scratchbuf = alloca(SCRATCHBUF_SIZE);
- scrypt_1024_1_1_256_sp(data, scratchbuf, ohash);
- flip32(ohash, ohash);
-}
-
-static const uint32_t diff1targ = 0x0000ffff;
-
-/* Used externally as confirmation of correct OCL code */
-int scrypt_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce)
-{
- uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]);
- uint32_t data[20], ohash[8];
- char *scratchbuf;
-
- be32enc_vect(data, (const uint32_t *)pdata, 19);
- data[19] = htobe32(nonce);
- scratchbuf = alloca(SCRATCHBUF_SIZE);
- scrypt_1024_1_1_256_sp(data, scratchbuf, ohash);
- tmp_hash7 = be32toh(ohash[7]);
-
- applog(LOG_DEBUG, "htarget %08lx diff1 %08lx hash %08lx",
- (long unsigned int)Htarg,
- (long unsigned int)diff1targ,
- (long unsigned int)tmp_hash7);
- if (tmp_hash7 > diff1targ)
- return -1;
- if (tmp_hash7 > Htarg)
- return 0;
- return 1;
-}
-
-bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *pmidstate,
- unsigned char *pdata, unsigned char __maybe_unused *phash1,
- unsigned char __maybe_unused *phash, const unsigned char *ptarget,
- uint32_t max_nonce, uint32_t *last_nonce, uint32_t n)
-{
- uint32_t *nonce = (uint32_t *)(pdata + 76);
- char *scratchbuf;
- uint32_t data[20];
- uint32_t tmp_hash7;
- uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]);
- bool ret = false;
-
- be32enc_vect(data, (const uint32_t *)pdata, 19);
-
- scratchbuf = malloc(SCRATCHBUF_SIZE);
- if (unlikely(!scratchbuf)) {
- applog(LOG_ERR, "Failed to malloc scratchbuf in scanhash_scrypt");
- return ret;
- }
-
- while(1) {
- uint32_t ostate[8];
-
- *nonce = ++n;
- data[19] = htobe32(n);
- scrypt_1024_1_1_256_sp(data, scratchbuf, ostate);
- tmp_hash7 = be32toh(ostate[7]);
-
- if (unlikely(tmp_hash7 <= Htarg)) {
- ((uint32_t *)pdata)[19] = htobe32(n);
- *last_nonce = n;
- ret = true;
- break;
- }
-
- if (unlikely((n >= max_nonce) || thr->work_restart)) {
- *last_nonce = n;
- break;
- }
- }
-
- free(scratchbuf);;
- return ret;
-}
diff --git a/scrypt.h b/scrypt.h
deleted file mode 100644
index 8f3d219..0000000
--- a/scrypt.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef SCRYPT_H
-#define SCRYPT_H
-
-#include "miner.h"
-
-#ifdef USE_SCRYPT
-extern int scrypt_test(unsigned char *pdata, const unsigned char *ptarget,
- uint32_t nonce);
-extern void scrypt_regenhash(struct work *work);
-
-#else /* USE_SCRYPT */
-static inline int scrypt_test(__maybe_unused unsigned char *pdata,
- __maybe_unused const unsigned char *ptarget,
- __maybe_unused uint32_t nonce)
-{
- return 0;
-}
-
-static inline void scrypt_regenhash(__maybe_unused struct work *work)
-{
-}
-#endif /* USE_SCRYPT */
-
-#endif /* SCRYPT_H */
diff --git a/scrypt130511.cl b/scrypt130511.cl
deleted file mode 100644
index 5ae0304..0000000
--- a/scrypt130511.cl
+++ /dev/null
@@ -1,853 +0,0 @@
-/*-
- * Copyright 2009 Colin Percival, 2011 ArtForz, 2011 pooler, 2012 mtrlt,
- * 2012-2013 Con Kolivas.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file was originally written by Colin Percival as part of the Tarsnap
- * online backup system.
- */
-
-__constant uint ES[2] = { 0x00FF00FF, 0xFF00FF00 };
-__constant uint K[] = {
- 0x428a2f98U,
- 0x71374491U,
- 0xb5c0fbcfU,
- 0xe9b5dba5U,
- 0x3956c25bU,
- 0x59f111f1U,
- 0x923f82a4U,
- 0xab1c5ed5U,
- 0xd807aa98U,
- 0x12835b01U,
- 0x243185beU, // 10
- 0x550c7dc3U,
- 0x72be5d74U,
- 0x80deb1feU,
- 0x9bdc06a7U,
- 0xe49b69c1U,
- 0xefbe4786U,
- 0x0fc19dc6U,
- 0x240ca1ccU,
- 0x2de92c6fU,
- 0x4a7484aaU, // 20
- 0x5cb0a9dcU,
- 0x76f988daU,
- 0x983e5152U,
- 0xa831c66dU,
- 0xb00327c8U,
- 0xbf597fc7U,
- 0xc6e00bf3U,
- 0xd5a79147U,
- 0x06ca6351U,
- 0x14292967U, // 30
- 0x27b70a85U,
- 0x2e1b2138U,
- 0x4d2c6dfcU,
- 0x53380d13U,
- 0x650a7354U,
- 0x766a0abbU,
- 0x81c2c92eU,
- 0x92722c85U,
- 0xa2bfe8a1U,
- 0xa81a664bU, // 40
- 0xc24b8b70U,
- 0xc76c51a3U,
- 0xd192e819U,
- 0xd6990624U,
- 0xf40e3585U,
- 0x106aa070U,
- 0x19a4c116U,
- 0x1e376c08U,
- 0x2748774cU,
- 0x34b0bcb5U, // 50
- 0x391c0cb3U,
- 0x4ed8aa4aU,
- 0x5b9cca4fU,
- 0x682e6ff3U,
- 0x748f82eeU,
- 0x78a5636fU,
- 0x84c87814U,
- 0x8cc70208U,
- 0x90befffaU,
- 0xa4506cebU, // 60
- 0xbef9a3f7U,
- 0xc67178f2U,
- 0x98c7e2a2U,
- 0xfc08884dU,
- 0xcd2a11aeU,
- 0x510e527fU,
- 0x9b05688cU,
- 0xC3910C8EU,
- 0xfb6feee7U,
- 0x2a01a605U, // 70
- 0x0c2e12e0U,
- 0x4498517BU,
- 0x6a09e667U,
- 0xa4ce148bU,
- 0x95F61999U,
- 0xc19bf174U,
- 0xBB67AE85U,
- 0x3C6EF372U,
- 0xA54FF53AU,
- 0x1F83D9ABU, // 80
- 0x5BE0CD19U,
- 0x5C5C5C5CU,
- 0x36363636U,
- 0x80000000U,
- 0x000003FFU,
- 0x00000280U,
- 0x000004a0U,
- 0x00000300U
-};
-
-#define rotl(x,y) rotate(x,y)
-#define Ch(x,y,z) bitselect(z,y,x)
-#define Maj(x,y,z) Ch((x^z),y,z)
-
-#define EndianSwap(n) (rotl(n & ES[0], 24U)|rotl(n & ES[1], 8U))
-
-#define Tr2(x) (rotl(x, 30U) ^ rotl(x, 19U) ^ rotl(x, 10U))
-#define Tr1(x) (rotl(x, 26U) ^ rotl(x, 21U) ^ rotl(x, 7U))
-#define Wr2(x) (rotl(x, 25U) ^ rotl(x, 14U) ^ (x>>3U))
-#define Wr1(x) (rotl(x, 15U) ^ rotl(x, 13U) ^ (x>>10U))
-
-#define RND(a, b, c, d, e, f, g, h, k) \
- h += Tr1(e); \
- h += Ch(e, f, g); \
- h += k; \
- d += h; \
- h += Tr2(a); \
- h += Maj(a, b, c);
-
-void SHA256(uint4*restrict state0,uint4*restrict state1, const uint4 block0, const uint4 block1, const uint4 block2, const uint4 block3)
-{
- uint4 S0 = *state0;
- uint4 S1 = *state1;
-
-#define A S0.x
-#define B S0.y
-#define C S0.z
-#define D S0.w
-#define E S1.x
-#define F S1.y
-#define G S1.z
-#define H S1.w
-
- uint4 W[4];
-
- W[ 0].x = block0.x;
- RND(A,B,C,D,E,F,G,H, W[0].x+ K[0]);
- W[ 0].y = block0.y;
- RND(H,A,B,C,D,E,F,G, W[0].y+ K[1]);
- W[ 0].z = block0.z;
- RND(G,H,A,B,C,D,E,F, W[0].z+ K[2]);
- W[ 0].w = block0.w;
- RND(F,G,H,A,B,C,D,E, W[0].w+ K[3]);
-
- W[ 1].x = block1.x;
- RND(E,F,G,H,A,B,C,D, W[1].x+ K[4]);
- W[ 1].y = block1.y;
- RND(D,E,F,G,H,A,B,C, W[1].y+ K[5]);
- W[ 1].z = block1.z;
- RND(C,D,E,F,G,H,A,B, W[1].z+ K[6]);
- W[ 1].w = block1.w;
- RND(B,C,D,E,F,G,H,A, W[1].w+ K[7]);
-
- W[ 2].x = block2.x;
- RND(A,B,C,D,E,F,G,H, W[2].x+ K[8]);
- W[ 2].y = block2.y;
- RND(H,A,B,C,D,E,F,G, W[2].y+ K[9]);
- W[ 2].z = block2.z;
- RND(G,H,A,B,C,D,E,F, W[2].z+ K[10]);
- W[ 2].w = block2.w;
- RND(F,G,H,A,B,C,D,E, W[2].w+ K[11]);
-
- W[ 3].x = block3.x;
- RND(E,F,G,H,A,B,C,D, W[3].x+ K[12]);
- W[ 3].y = block3.y;
- RND(D,E,F,G,H,A,B,C, W[3].y+ K[13]);
- W[ 3].z = block3.z;
- RND(C,D,E,F,G,H,A,B, W[3].z+ K[14]);
- W[ 3].w = block3.w;
- RND(B,C,D,E,F,G,H,A, W[3].w+ K[76]);
-
- W[ 0].x += Wr1(W[ 3].z) + W[ 2].y + Wr2(W[ 0].y);
- RND(A,B,C,D,E,F,G,H, W[0].x+ K[15]);
-
- W[ 0].y += Wr1(W[ 3].w) + W[ 2].z + Wr2(W[ 0].z);
- RND(H,A,B,C,D,E,F,G, W[0].y+ K[16]);
-
- W[ 0].z += Wr1(W[ 0].x) + W[ 2].w + Wr2(W[ 0].w);
- RND(G,H,A,B,C,D,E,F, W[0].z+ K[17]);
-
- W[ 0].w += Wr1(W[ 0].y) + W[ 3].x + Wr2(W[ 1].x);
- RND(F,G,H,A,B,C,D,E, W[0].w+ K[18]);
-
- W[ 1].x += Wr1(W[ 0].z) + W[ 3].y + Wr2(W[ 1].y);
- RND(E,F,G,H,A,B,C,D, W[1].x+ K[19]);
-
- W[ 1].y += Wr1(W[ 0].w) + W[ 3].z + Wr2(W[ 1].z);
- RND(D,E,F,G,H,A,B,C, W[1].y+ K[20]);
-
- W[ 1].z += Wr1(W[ 1].x) + W[ 3].w + Wr2(W[ 1].w);
- RND(C,D,E,F,G,H,A,B, W[1].z+ K[21]);
-
- W[ 1].w += Wr1(W[ 1].y) + W[ 0].x + Wr2(W[ 2].x);
- RND(B,C,D,E,F,G,H,A, W[1].w+ K[22]);
-
- W[ 2].x += Wr1(W[ 1].z) + W[ 0].y + Wr2(W[ 2].y);
- RND(A,B,C,D,E,F,G,H, W[2].x+ K[23]);
-
- W[ 2].y += Wr1(W[ 1].w) + W[ 0].z + Wr2(W[ 2].z);
- RND(H,A,B,C,D,E,F,G, W[2].y+ K[24]);
-
- W[ 2].z += Wr1(W[ 2].x) + W[ 0].w + Wr2(W[ 2].w);
- RND(G,H,A,B,C,D,E,F, W[2].z+ K[25]);
-
- W[ 2].w += Wr1(W[ 2].y) + W[ 1].x + Wr2(W[ 3].x);
- RND(F,G,H,A,B,C,D,E, W[2].w+ K[26]);
-
- W[ 3].x += Wr1(W[ 2].z) + W[ 1].y + Wr2(W[ 3].y);
- RND(E,F,G,H,A,B,C,D, W[3].x+ K[27]);
-
- W[ 3].y += Wr1(W[ 2].w) + W[ 1].z + Wr2(W[ 3].z);
- RND(D,E,F,G,H,A,B,C, W[3].y+ K[28]);
-
- W[ 3].z += Wr1(W[ 3].x) + W[ 1].w + Wr2(W[ 3].w);
- RND(C,D,E,F,G,H,A,B, W[3].z+ K[29]);
-
- W[ 3].w += Wr1(W[ 3].y) + W[ 2].x + Wr2(W[ 0].x);
- RND(B,C,D,E,F,G,H,A, W[3].w+ K[30]);
-
- W[ 0].x += Wr1(W[ 3].z) + W[ 2].y + Wr2(W[ 0].y);
- RND(A,B,C,D,E,F,G,H, W[0].x+ K[31]);
-
- W[ 0].y += Wr1(W[ 3].w) + W[ 2].z + Wr2(W[ 0].z);
- RND(H,A,B,C,D,E,F,G, W[0].y+ K[32]);
-
- W[ 0].z += Wr1(W[ 0].x) + W[ 2].w + Wr2(W[ 0].w);
- RND(G,H,A,B,C,D,E,F, W[0].z+ K[33]);
-
- W[ 0].w += Wr1(W[ 0].y) + W[ 3].x + Wr2(W[ 1].x);
- RND(F,G,H,A,B,C,D,E, W[0].w+ K[34]);
-
- W[ 1].x += Wr1(W[ 0].z) + W[ 3].y + Wr2(W[ 1].y);
- RND(E,F,G,H,A,B,C,D, W[1].x+ K[35]);
-
- W[ 1].y += Wr1(W[ 0].w) + W[ 3].z + Wr2(W[ 1].z);
- RND(D,E,F,G,H,A,B,C, W[1].y+ K[36]);
-
- W[ 1].z += Wr1(W[ 1].x) + W[ 3].w + Wr2(W[ 1].w);
- RND(C,D,E,F,G,H,A,B, W[1].z+ K[37]);
-
- W[ 1].w += Wr1(W[ 1].y) + W[ 0].x + Wr2(W[ 2].x);
- RND(B,C,D,E,F,G,H,A, W[1].w+ K[38]);
-
- W[ 2].x += Wr1(W[ 1].z) + W[ 0].y + Wr2(W[ 2].y);
- RND(A,B,C,D,E,F,G,H, W[2].x+ K[39]);
-
- W[ 2].y += Wr1(W[ 1].w) + W[ 0].z + Wr2(W[ 2].z);
- RND(H,A,B,C,D,E,F,G, W[2].y+ K[40]);
-
- W[ 2].z += Wr1(W[ 2].x) + W[ 0].w + Wr2(W[ 2].w);
- RND(G,H,A,B,C,D,E,F, W[2].z+ K[41]);
-
- W[ 2].w += Wr1(W[ 2].y) + W[ 1].x + Wr2(W[ 3].x);
- RND(F,G,H,A,B,C,D,E, W[2].w+ K[42]);
-
- W[ 3].x += Wr1(W[ 2].z) + W[ 1].y + Wr2(W[ 3].y);
- RND(E,F,G,H,A,B,C,D, W[3].x+ K[43]);
-
- W[ 3].y += Wr1(W[ 2].w) + W[ 1].z + Wr2(W[ 3].z);
- RND(D,E,F,G,H,A,B,C, W[3].y+ K[44]);
-
- W[ 3].z += Wr1(W[ 3].x) + W[ 1].w + Wr2(W[ 3].w);
- RND(C,D,E,F,G,H,A,B, W[3].z+ K[45]);
-
- W[ 3].w += Wr1(W[ 3].y) + W[ 2].x + Wr2(W[ 0].x);
- RND(B,C,D,E,F,G,H,A, W[3].w+ K[46]);
-
- W[ 0].x += Wr1(W[ 3].z) + W[ 2].y + Wr2(W[ 0].y);
- RND(A,B,C,D,E,F,G,H, W[0].x+ K[47]);
-
- W[ 0].y += Wr1(W[ 3].w) + W[ 2].z + Wr2(W[ 0].z);
- RND(H,A,B,C,D,E,F,G, W[0].y+ K[48]);
-
- W[ 0].z += Wr1(W[ 0].x) + W[ 2].w + Wr2(W[ 0].w);
- RND(G,H,A,B,C,D,E,F, W[0].z+ K[49]);
-
- W[ 0].w += Wr1(W[ 0].y) + W[ 3].x + Wr2(W[ 1].x);
- RND(F,G,H,A,B,C,D,E, W[0].w+ K[50]);
-
- W[ 1].x += Wr1(W[ 0].z) + W[ 3].y + Wr2(W[ 1].y);
- RND(E,F,G,H,A,B,C,D, W[1].x+ K[51]);
-
- W[ 1].y += Wr1(W[ 0].w) + W[ 3].z + Wr2(W[ 1].z);
- RND(D,E,F,G,H,A,B,C, W[1].y+ K[52]);
-
- W[ 1].z += Wr1(W[ 1].x) + W[ 3].w + Wr2(W[ 1].w);
- RND(C,D,E,F,G,H,A,B, W[1].z+ K[53]);
-
- W[ 1].w += Wr1(W[ 1].y) + W[ 0].x + Wr2(W[ 2].x);
- RND(B,C,D,E,F,G,H,A, W[1].w+ K[54]);
-
- W[ 2].x += Wr1(W[ 1].z) + W[ 0].y + Wr2(W[ 2].y);
- RND(A,B,C,D,E,F,G,H, W[2].x+ K[55]);
-
- W[ 2].y += Wr1(W[ 1].w) + W[ 0].z + Wr2(W[ 2].z);
- RND(H,A,B,C,D,E,F,G, W[2].y+ K[56]);
-
- W[ 2].z += Wr1(W[ 2].x) + W[ 0].w + Wr2(W[ 2].w);
- RND(G,H,A,B,C,D,E,F, W[2].z+ K[57]);
-
- W[ 2].w += Wr1(W[ 2].y) + W[ 1].x + Wr2(W[ 3].x);
- RND(F,G,H,A,B,C,D,E, W[2].w+ K[58]);
-
- W[ 3].x += Wr1(W[ 2].z) + W[ 1].y + Wr2(W[ 3].y);
- RND(E,F,G,H,A,B,C,D, W[3].x+ K[59]);
-
- W[ 3].y += Wr1(W[ 2].w) + W[ 1].z + Wr2(W[ 3].z);
- RND(D,E,F,G,H,A,B,C, W[3].y+ K[60]);
-
- W[ 3].z += Wr1(W[ 3].x) + W[ 1].w + Wr2(W[ 3].w);
- RND(C,D,E,F,G,H,A,B, W[3].z+ K[61]);
-
- W[ 3].w += Wr1(W[ 3].y) + W[ 2].x + Wr2(W[ 0].x);
- RND(B,C,D,E,F,G,H,A, W[3].w+ K[62]);
-
-#undef A
-#undef B
-#undef C
-#undef D
-#undef E
-#undef F
-#undef G
-#undef H
-
- *state0 += S0;
- *state1 += S1;
-}
-
-void SHA256_fresh(uint4*restrict state0,uint4*restrict state1, const uint4 block0, const uint4 block1, const uint4 block2, const uint4 block3)
-{
-#define A (*state0).x
-#define B (*state0).y
-#define C (*state0).z
-#define D (*state0).w
-#define E (*state1).x
-#define F (*state1).y
-#define G (*state1).z
-#define H (*state1).w
-
- uint4 W[4];
-
- W[0].x = block0.x;
- D= K[63] +W[0].x;
- H= K[64] +W[0].x;
-
- W[0].y = block0.y;
- C= K[65] +Tr1(D)+Ch(D, K[66], K[67])+W[0].y;
- G= K[68] +C+Tr2(H)+Ch(H, K[69] ,K[70]);
-
- W[0].z = block0.z;
- B= K[71] +Tr1(C)+Ch(C,D,K[66])+W[0].z;
- F= K[72] +B+Tr2(G)+Maj(G,H, K[73]);
-
- W[0].w = block0.w;
- A= K[74] +Tr1(B)+Ch(B,C,D)+W[0].w;
- E= K[75] +A+Tr2(F)+Maj(F,G,H);
-
- W[1].x = block1.x;
- RND(E,F,G,H,A,B,C,D, W[1].x+ K[4]);
- W[1].y = block1.y;
- RND(D,E,F,G,H,A,B,C, W[1].y+ K[5]);
- W[1].z = block1.z;
- RND(C,D,E,F,G,H,A,B, W[1].z+ K[6]);
- W[1].w = block1.w;
- RND(B,C,D,E,F,G,H,A, W[1].w+ K[7]);
-
- W[2].x = block2.x;
- RND(A,B,C,D,E,F,G,H, W[2].x+ K[8]);
- W[2].y = block2.y;
- RND(H,A,B,C,D,E,F,G, W[2].y+ K[9]);
- W[2].z = block2.z;
- RND(G,H,A,B,C,D,E,F, W[2].z+ K[10]);
- W[2].w = block2.w;
- RND(F,G,H,A,B,C,D,E, W[2].w+ K[11]);
-
- W[3].x = block3.x;
- RND(E,F,G,H,A,B,C,D, W[3].x+ K[12]);
- W[3].y = block3.y;
- RND(D,E,F,G,H,A,B,C, W[3].y+ K[13]);
- W[3].z = block3.z;
- RND(C,D,E,F,G,H,A,B, W[3].z+ K[14]);
- W[3].w = block3.w;
- RND(B,C,D,E,F,G,H,A, W[3].w+ K[76]);
-
- W[0].x += Wr1(W[3].z) + W[2].y + Wr2(W[0].y);
- RND(A,B,C,D,E,F,G,H, W[0].x+ K[15]);
-
- W[0].y += Wr1(W[3].w) + W[2].z + Wr2(W[0].z);
- RND(H,A,B,C,D,E,F,G, W[0].y+ K[16]);
-
- W[0].z += Wr1(W[0].x) + W[2].w + Wr2(W[0].w);
- RND(G,H,A,B,C,D,E,F, W[0].z+ K[17]);
-
- W[0].w += Wr1(W[0].y) + W[3].x + Wr2(W[1].x);
- RND(F,G,H,A,B,C,D,E, W[0].w+ K[18]);
-
- W[1].x += Wr1(W[0].z) + W[3].y + Wr2(W[1].y);
- RND(E,F,G,H,A,B,C,D, W[1].x+ K[19]);
-
- W[1].y += Wr1(W[0].w) + W[3].z + Wr2(W[1].z);
- RND(D,E,F,G,H,A,B,C, W[1].y+ K[20]);
-
- W[1].z += Wr1(W[1].x) + W[3].w + Wr2(W[1].w);
- RND(C,D,E,F,G,H,A,B, W[1].z+ K[21]);
-
- W[1].w += Wr1(W[1].y) + W[0].x + Wr2(W[2].x);
- RND(B,C,D,E,F,G,H,A, W[1].w+ K[22]);
-
- W[2].x += Wr1(W[1].z) + W[0].y + Wr2(W[2].y);
- RND(A,B,C,D,E,F,G,H, W[2].x+ K[23]);
-
- W[2].y += Wr1(W[1].w) + W[0].z + Wr2(W[2].z);
- RND(H,A,B,C,D,E,F,G, W[2].y+ K[24]);
-
- W[2].z += Wr1(W[2].x) + W[0].w + Wr2(W[2].w);
- RND(G,H,A,B,C,D,E,F, W[2].z+ K[25]);
-
- W[2].w += Wr1(W[2].y) + W[1].x + Wr2(W[3].x);
- RND(F,G,H,A,B,C,D,E, W[2].w+ K[26]);
-
- W[3].x += Wr1(W[2].z) + W[1].y + Wr2(W[3].y);
- RND(E,F,G,H,A,B,C,D, W[3].x+ K[27]);
-
- W[3].y += Wr1(W[2].w) + W[1].z + Wr2(W[3].z);
- RND(D,E,F,G,H,A,B,C, W[3].y+ K[28]);
-
- W[3].z += Wr1(W[3].x) + W[1].w + Wr2(W[3].w);
- RND(C,D,E,F,G,H,A,B, W[3].z+ K[29]);
-
- W[3].w += Wr1(W[3].y) + W[2].x + Wr2(W[0].x);
- RND(B,C,D,E,F,G,H,A, W[3].w+ K[30]);
-
- W[0].x += Wr1(W[3].z) + W[2].y + Wr2(W[0].y);
- RND(A,B,C,D,E,F,G,H, W[0].x+ K[31]);
-
- W[0].y += Wr1(W[3].w) + W[2].z + Wr2(W[0].z);
- RND(H,A,B,C,D,E,F,G, W[0].y+ K[32]);
-
- W[0].z += Wr1(W[0].x) + W[2].w + Wr2(W[0].w);
- RND(G,H,A,B,C,D,E,F, W[0].z+ K[33]);
-
- W[0].w += Wr1(W[0].y) + W[3].x + Wr2(W[1].x);
- RND(F,G,H,A,B,C,D,E, W[0].w+ K[34]);
-
- W[1].x += Wr1(W[0].z) + W[3].y + Wr2(W[1].y);
- RND(E,F,G,H,A,B,C,D, W[1].x+ K[35]);
-
- W[1].y += Wr1(W[0].w) + W[3].z + Wr2(W[1].z);
- RND(D,E,F,G,H,A,B,C, W[1].y+ K[36]);
-
- W[1].z += Wr1(W[1].x) + W[3].w + Wr2(W[1].w);
- RND(C,D,E,F,G,H,A,B, W[1].z+ K[37]);
-
- W[1].w += Wr1(W[1].y) + W[0].x + Wr2(W[2].x);
- RND(B,C,D,E,F,G,H,A, W[1].w+ K[38]);
-
- W[2].x += Wr1(W[1].z) + W[0].y + Wr2(W[2].y);
- RND(A,B,C,D,E,F,G,H, W[2].x+ K[39]);
-
- W[2].y += Wr1(W[1].w) + W[0].z + Wr2(W[2].z);
- RND(H,A,B,C,D,E,F,G, W[2].y+ K[40]);
-
- W[2].z += Wr1(W[2].x) + W[0].w + Wr2(W[2].w);
- RND(G,H,A,B,C,D,E,F, W[2].z+ K[41]);
-
- W[2].w += Wr1(W[2].y) + W[1].x + Wr2(W[3].x);
- RND(F,G,H,A,B,C,D,E, W[2].w+ K[42]);
-
- W[3].x += Wr1(W[2].z) + W[1].y + Wr2(W[3].y);
- RND(E,F,G,H,A,B,C,D, W[3].x+ K[43]);
-
- W[3].y += Wr1(W[2].w) + W[1].z + Wr2(W[3].z);
- RND(D,E,F,G,H,A,B,C, W[3].y+ K[44]);
-
- W[3].z += Wr1(W[3].x) + W[1].w + Wr2(W[3].w);
- RND(C,D,E,F,G,H,A,B, W[3].z+ K[45]);
-
- W[3].w += Wr1(W[3].y) + W[2].x + Wr2(W[0].x);
- RND(B,C,D,E,F,G,H,A, W[3].w+ K[46]);
-
- W[0].x += Wr1(W[3].z) + W[2].y + Wr2(W[0].y);
- RND(A,B,C,D,E,F,G,H, W[0].x+ K[47]);
-
- W[0].y += Wr1(W[3].w) + W[2].z + Wr2(W[0].z);
- RND(H,A,B,C,D,E,F,G, W[0].y+ K[48]);
-
- W[0].z += Wr1(W[0].x) + W[2].w + Wr2(W[0].w);
- RND(G,H,A,B,C,D,E,F, W[0].z+ K[49]);
-
- W[0].w += Wr1(W[0].y) + W[3].x + Wr2(W[1].x);
- RND(F,G,H,A,B,C,D,E, W[0].w+ K[50]);
-
- W[1].x += Wr1(W[0].z) + W[3].y + Wr2(W[1].y);
- RND(E,F,G,H,A,B,C,D, W[1].x+ K[51]);
-
- W[1].y += Wr1(W[0].w) + W[3].z + Wr2(W[1].z);
- RND(D,E,F,G,H,A,B,C, W[1].y+ K[52]);
-
- W[1].z += Wr1(W[1].x) + W[3].w + Wr2(W[1].w);
- RND(C,D,E,F,G,H,A,B, W[1].z+ K[53]);
-
- W[1].w += Wr1(W[1].y) + W[0].x + Wr2(W[2].x);
- RND(B,C,D,E,F,G,H,A, W[1].w+ K[54]);
-
- W[2].x += Wr1(W[1].z) + W[0].y + Wr2(W[2].y);
- RND(A,B,C,D,E,F,G,H, W[2].x+ K[55]);
-
- W[2].y += Wr1(W[1].w) + W[0].z + Wr2(W[2].z);
- RND(H,A,B,C,D,E,F,G, W[2].y+ K[56]);
-
- W[2].z += Wr1(W[2].x) + W[0].w + Wr2(W[2].w);
- RND(G,H,A,B,C,D,E,F, W[2].z+ K[57]);
-
- W[2].w += Wr1(W[2].y) + W[1].x + Wr2(W[3].x);
- RND(F,G,H,A,B,C,D,E, W[2].w+ K[58]);
-
- W[3].x += Wr1(W[2].z) + W[1].y + Wr2(W[3].y);
- RND(E,F,G,H,A,B,C,D, W[3].x+ K[59]);
-
- W[3].y += Wr1(W[2].w) + W[1].z + Wr2(W[3].z);
- RND(D,E,F,G,H,A,B,C, W[3].y+ K[60]);
-
- W[3].z += Wr1(W[3].x) + W[1].w + Wr2(W[3].w);
- RND(C,D,E,F,G,H,A,B, W[3].z+ K[61]);
-
- W[3].w += Wr1(W[3].y) + W[2].x + Wr2(W[0].x);
- RND(B,C,D,E,F,G,H,A, W[3].w+ K[62]);
-
-#undef A
-#undef B
-#undef C
-#undef D
-#undef E
-#undef F
-#undef G
-#undef H
-
- *state0 += (uint4)(K[73], K[77], K[78], K[79]);
- *state1 += (uint4)(K[66], K[67], K[80], K[81]);
-}
-
-__constant uint fixedW[64] =
-{
- 0x428a2f99,0xf1374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
- 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf794,
- 0xf59b89c2,0x73924787,0x23c6886e,0xa42ca65c,0x15ed3627,0x4d6edcbf,0xe28217fc,0xef02488f,
- 0xb707775c,0x0468c23f,0xe7e72b4c,0x49e1f1a2,0x4b99c816,0x926d1570,0xaa0fc072,0xadb36e2c,
- 0xad87a3ea,0xbcb1d3a3,0x7b993186,0x562b9420,0xbff3ca0c,0xda4b0c23,0x6cd8711a,0x8f337caa,
- 0xc91b1417,0xc359dce1,0xa83253a7,0x3b13c12d,0x9d3d725d,0xd9031a84,0xb1a03340,0x16f58012,
- 0xe64fb6a2,0xe84d923a,0xe93a5730,0x09837686,0x078ff753,0x29833341,0xd5de0b7e,0x6948ccf4,
- 0xe0a1adbe,0x7c728e11,0x511c78e4,0x315b45bd,0xfca71413,0xea28f96a,0x79703128,0x4e1ef848,
-};
-
-void SHA256_fixed(uint4*restrict state0,uint4*restrict state1)
-{
- uint4 S0 = *state0;
- uint4 S1 = *state1;
-
-#define A S0.x
-#define B S0.y
-#define C S0.z
-#define D S0.w
-#define E S1.x
-#define F S1.y
-#define G S1.z
-#define H S1.w
-
- RND(A,B,C,D,E,F,G,H, fixedW[0]);
- RND(H,A,B,C,D,E,F,G, fixedW[1]);
- RND(G,H,A,B,C,D,E,F, fixedW[2]);
- RND(F,G,H,A,B,C,D,E, fixedW[3]);
- RND(E,F,G,H,A,B,C,D, fixedW[4]);
- RND(D,E,F,G,H,A,B,C, fixedW[5]);
- RND(C,D,E,F,G,H,A,B, fixedW[6]);
- RND(B,C,D,E,F,G,H,A, fixedW[7]);
- RND(A,B,C,D,E,F,G,H, fixedW[8]);
- RND(H,A,B,C,D,E,F,G, fixedW[9]);
- RND(G,H,A,B,C,D,E,F, fixedW[10]);
- RND(F,G,H,A,B,C,D,E, fixedW[11]);
- RND(E,F,G,H,A,B,C,D, fixedW[12]);
- RND(D,E,F,G,H,A,B,C, fixedW[13]);
- RND(C,D,E,F,G,H,A,B, fixedW[14]);
- RND(B,C,D,E,F,G,H,A, fixedW[15]);
- RND(A,B,C,D,E,F,G,H, fixedW[16]);
- RND(H,A,B,C,D,E,F,G, fixedW[17]);
- RND(G,H,A,B,C,D,E,F, fixedW[18]);
- RND(F,G,H,A,B,C,D,E, fixedW[19]);
- RND(E,F,G,H,A,B,C,D, fixedW[20]);
- RND(D,E,F,G,H,A,B,C, fixedW[21]);
- RND(C,D,E,F,G,H,A,B, fixedW[22]);
- RND(B,C,D,E,F,G,H,A, fixedW[23]);
- RND(A,B,C,D,E,F,G,H, fixedW[24]);
- RND(H,A,B,C,D,E,F,G, fixedW[25]);
- RND(G,H,A,B,C,D,E,F, fixedW[26]);
- RND(F,G,H,A,B,C,D,E, fixedW[27]);
- RND(E,F,G,H,A,B,C,D, fixedW[28]);
- RND(D,E,F,G,H,A,B,C, fixedW[29]);
- RND(C,D,E,F,G,H,A,B, fixedW[30]);
- RND(B,C,D,E,F,G,H,A, fixedW[31]);
- RND(A,B,C,D,E,F,G,H, fixedW[32]);
- RND(H,A,B,C,D,E,F,G, fixedW[33]);
- RND(G,H,A,B,C,D,E,F, fixedW[34]);
- RND(F,G,H,A,B,C,D,E, fixedW[35]);
- RND(E,F,G,H,A,B,C,D, fixedW[36]);
- RND(D,E,F,G,H,A,B,C, fixedW[37]);
- RND(C,D,E,F,G,H,A,B, fixedW[38]);
- RND(B,C,D,E,F,G,H,A, fixedW[39]);
- RND(A,B,C,D,E,F,G,H, fixedW[40]);
- RND(H,A,B,C,D,E,F,G, fixedW[41]);
- RND(G,H,A,B,C,D,E,F, fixedW[42]);
- RND(F,G,H,A,B,C,D,E, fixedW[43]);
- RND(E,F,G,H,A,B,C,D, fixedW[44]);
- RND(D,E,F,G,H,A,B,C, fixedW[45]);
- RND(C,D,E,F,G,H,A,B, fixedW[46]);
- RND(B,C,D,E,F,G,H,A, fixedW[47]);
- RND(A,B,C,D,E,F,G,H, fixedW[48]);
- RND(H,A,B,C,D,E,F,G, fixedW[49]);
- RND(G,H,A,B,C,D,E,F, fixedW[50]);
- RND(F,G,H,A,B,C,D,E, fixedW[51]);
- RND(E,F,G,H,A,B,C,D, fixedW[52]);
- RND(D,E,F,G,H,A,B,C, fixedW[53]);
- RND(C,D,E,F,G,H,A,B, fixedW[54]);
- RND(B,C,D,E,F,G,H,A, fixedW[55]);
- RND(A,B,C,D,E,F,G,H, fixedW[56]);
- RND(H,A,B,C,D,E,F,G, fixedW[57]);
- RND(G,H,A,B,C,D,E,F, fixedW[58]);
- RND(F,G,H,A,B,C,D,E, fixedW[59]);
- RND(E,F,G,H,A,B,C,D, fixedW[60]);
- RND(D,E,F,G,H,A,B,C, fixedW[61]);
- RND(C,D,E,F,G,H,A,B, fixedW[62]);
- RND(B,C,D,E,F,G,H,A, fixedW[63]);
-
-#undef A
-#undef B
-#undef C
-#undef D
-#undef E
-#undef F
-#undef G
-#undef H
- *state0 += S0;
- *state1 += S1;
-}
-
-void shittify(uint4 B[8])
-{
- uint4 tmp[4];
- tmp[0] = (uint4)(B[1].x,B[2].y,B[3].z,B[0].w);
- tmp[1] = (uint4)(B[2].x,B[3].y,B[0].z,B[1].w);
- tmp[2] = (uint4)(B[3].x,B[0].y,B[1].z,B[2].w);
- tmp[3] = (uint4)(B[0].x,B[1].y,B[2].z,B[3].w);
-
-#pragma unroll
- for(uint i=0; i<4; ++i)
- B[i] = EndianSwap(tmp[i]);
-
- tmp[0] = (uint4)(B[5].x,B[6].y,B[7].z,B[4].w);
- tmp[1] = (uint4)(B[6].x,B[7].y,B[4].z,B[5].w);
- tmp[2] = (uint4)(B[7].x,B[4].y,B[5].z,B[6].w);
- tmp[3] = (uint4)(B[4].x,B[5].y,B[6].z,B[7].w);
-
-#pragma unroll
- for(uint i=0; i<4; ++i)
- B[i+4] = EndianSwap(tmp[i]);
-}
-
-void unshittify(uint4 B[8])
-{
- uint4 tmp[4];
- tmp[0] = (uint4)(B[3].x,B[2].y,B[1].z,B[0].w);
- tmp[1] = (uint4)(B[0].x,B[3].y,B[2].z,B[1].w);
- tmp[2] = (uint4)(B[1].x,B[0].y,B[3].z,B[2].w);
- tmp[3] = (uint4)(B[2].x,B[1].y,B[0].z,B[3].w);
-
-#pragma unroll
- for(uint i=0; i<4; ++i)
- B[i] = EndianSwap(tmp[i]);
-
- tmp[0] = (uint4)(B[7].x,B[6].y,B[5].z,B[4].w);
- tmp[1] = (uint4)(B[4].x,B[7].y,B[6].z,B[5].w);
- tmp[2] = (uint4)(B[5].x,B[4].y,B[7].z,B[6].w);
- tmp[3] = (uint4)(B[6].x,B[5].y,B[4].z,B[7].w);
-
-#pragma unroll
- for(uint i=0; i<4; ++i)
- B[i+4] = EndianSwap(tmp[i]);
-}
-
-void salsa(uint4 B[8])
-{
- uint4 w[4];
-
-#pragma unroll
- for(uint i=0; i<4; ++i)
- w[i] = (B[i]^=B[i+4]);
-
-#pragma unroll
- for(uint i=0; i<4; ++i)
- {
- w[0] ^= rotl(w[3] +w[2] , 7U);
- w[1] ^= rotl(w[0] +w[3] , 9U);
- w[2] ^= rotl(w[1] +w[0] ,13U);
- w[3] ^= rotl(w[2] +w[1] ,18U);
- w[2] ^= rotl(w[3].wxyz+w[0].zwxy, 7U);
- w[1] ^= rotl(w[2].wxyz+w[3].zwxy, 9U);
- w[0] ^= rotl(w[1].wxyz+w[2].zwxy,13U);
- w[3] ^= rotl(w[0].wxyz+w[1].zwxy,18U);
- }
-
-#pragma unroll
- for(uint i=0; i<4; ++i)
- w[i] = (B[i+4]^=(B[i]+=w[i]));
-
-#pragma unroll
- for(uint i=0; i<4; ++i)
- {
- w[0] ^= rotl(w[3] +w[2] , 7U);
- w[1] ^= rotl(w[0] +w[3] , 9U);
- w[2] ^= rotl(w[1] +w[0] ,13U);
- w[3] ^= rotl(w[2] +w[1] ,18U);
- w[2] ^= rotl(w[3].wxyz+w[0].zwxy, 7U);
- w[1] ^= rotl(w[2].wxyz+w[3].zwxy, 9U);
- w[0] ^= rotl(w[1].wxyz+w[2].zwxy,13U);
- w[3] ^= rotl(w[0].wxyz+w[1].zwxy,18U);
- }
-
-#pragma unroll
- for(uint i=0; i<4; ++i)
- B[i+4] += w[i];
-}
-
-#define Coord(x,y,z) x+y*(x ## SIZE)+z*(y ## SIZE)*(x ## SIZE)
-#define CO Coord(z,x,y)
-
-void scrypt_core(uint4 X[8], __global uint4*restrict lookup)
-{
- shittify(X);
- const uint zSIZE = 8;
- const uint ySIZE = (1024/LOOKUP_GAP+(1024%LOOKUP_GAP>0));
- const uint xSIZE = CONCURRENT_THREADS;
- uint x = get_global_id(0)%xSIZE;
-
- for(uint y=0; y<1024/LOOKUP_GAP; ++y)
- {
-#pragma unroll
- for(uint z=0; z<zSIZE; ++z)
- lookup[CO] = X[z];
- for(uint i=0; i<LOOKUP_GAP; ++i)
- salsa(X);
- }
-#if (LOOKUP_GAP != 1) && (LOOKUP_GAP != 2) && (LOOKUP_GAP != 4) && (LOOKUP_GAP != 8)
- {
- uint y = (1024/LOOKUP_GAP);
-#pragma unroll
- for(uint z=0; z<zSIZE; ++z)
- lookup[CO] = X[z];
- for(uint i=0; i<1024%LOOKUP_GAP; ++i)
- salsa(X);
- }
-#endif
- for (uint i=0; i<1024; ++i)
- {
- uint4 V[8];
- uint j = X[7].x & K[85];
- uint y = (j/LOOKUP_GAP);
-#pragma unroll
- for(uint z=0; z<zSIZE; ++z)
- V[z] = lookup[CO];
-
-#if (LOOKUP_GAP == 1)
-#elif (LOOKUP_GAP == 2)
- if (j&1)
- salsa(V);
-#else
- uint val = j%LOOKUP_GAP;
- for (uint z=0; z<val; ++z)
- salsa(V);
-#endif
-
-#pragma unroll
- for(uint z=0; z<zSIZE; ++z)
- X[z] ^= V[z];
- salsa(X);
- }
- unshittify(X);
-}
-
-#define SCRYPT_FOUND (0xFF)
-#define SETFOUND(Xnonce) output[output[SCRYPT_FOUND]++] = Xnonce
-
-__attribute__((reqd_work_group_size(WORKSIZE, 1, 1)))
-__kernel void search(__global const uint4 * restrict input,
-volatile __global uint*restrict output, __global uint4*restrict padcache,
-const uint4 midstate0, const uint4 midstate16, const uint target)
-{
- uint gid = get_global_id(0);
- uint4 X[8];
- uint4 tstate0, tstate1, ostate0, ostate1, tmp0, tmp1;
- uint4 data = (uint4)(input[4].x,input[4].y,input[4].z,gid);
- uint4 pad0 = midstate0, pad1 = midstate16;
-
- SHA256(&pad0,&pad1, data, (uint4)(K[84],0,0,0), (uint4)(0,0,0,0), (uint4)(0,0,0, K[86]));
- SHA256_fresh(&ostate0,&ostate1, pad0^ K[82], pad1^ K[82], K[82], K[82]);
- SHA256_fresh(&tstate0,&tstate1, pad0^ K[83], pad1^ K[83], K[83], K[83]);
-
- tmp0 = tstate0;
- tmp1 = tstate1;
- SHA256(&tstate0, &tstate1, input[0],input[1],input[2],input[3]);
-
-#pragma unroll
- for (uint i=0; i<4; i++)
- {
- pad0 = tstate0;
- pad1 = tstate1;
- X[i*2 ] = ostate0;
- X[i*2+1] = ostate1;
-
- SHA256(&pad0,&pad1, data, (uint4)(i+1,K[84],0,0), (uint4)(0,0,0,0), (uint4)(0,0,0, K[87]));
- SHA256(X+i*2,X+i*2+1, pad0, pad1, (uint4)(K[84], 0U, 0U, 0U), (uint4)(0U, 0U, 0U, K[88]));
- }
- scrypt_core(X,padcache);
- SHA256(&tmp0,&tmp1, X[0], X[1], X[2], X[3]);
- SHA256(&tmp0,&tmp1, X[4], X[5], X[6], X[7]);
- SHA256_fixed(&tmp0,&tmp1);
- SHA256(&ostate0,&ostate1, tmp0, tmp1, (uint4)(K[84], 0U, 0U, 0U), (uint4)(0U, 0U, 0U, K[88]));
-
- bool result = (EndianSwap(ostate1.w) <= target);
- if (result)
- SETFOUND(gid);
-}
diff --git a/sha2.c b/sha2.c
index f1970e1..6777b28 100644
--- a/sha2.c
+++ b/sha2.c
@@ -36,16 +36,6 @@
#include "sha2.h"
-#define SHFR(x, n) (x >> n)
-#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
-#define CH(x, y, z) ((x & y) ^ (~x & z))
-#define MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
-
-#define SHA256_F1(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
-#define SHA256_F2(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
-#define SHA256_F3(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3))
-#define SHA256_F4(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10))
-
#define UNPACK32(x, str) \
{ \
*((str) + 3) = (uint8_t) ((x) ); \
diff --git a/sha2.h b/sha2.h
index faa4f61..71d4404 100644
--- a/sha2.h
+++ b/sha2.h
@@ -41,6 +41,16 @@
#define SHA256_DIGEST_SIZE ( 256 / 8)
#define SHA256_BLOCK_SIZE ( 512 / 8)
+#define SHFR(x, n) (x >> n)
+#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
+#define CH(x, y, z) ((x & y) ^ (~x & z))
+#define MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
+
+#define SHA256_F1(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
+#define SHA256_F2(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
+#define SHA256_F3(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3))
+#define SHA256_F4(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10))
+
typedef struct {
unsigned int tot_len;
unsigned int len;
@@ -48,6 +58,8 @@ typedef struct {
uint32_t h[8];
} sha256_ctx;
+extern uint32_t sha256_k[64];
+
void sha256_init(sha256_ctx * ctx);
void sha256_update(sha256_ctx *ctx, const unsigned char *message,
unsigned int len);
diff --git a/usbutils.c b/usbutils.c
index 56bb7b7..212dfa8 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -211,6 +211,20 @@ static struct usb_epinfo kln_epinfos[] = {
static struct usb_intinfo kln_ints[] = {
USB_EPS(0, kln_epinfos)
};
+
+static struct usb_epinfo kli0_epinfos[] = {
+ { LIBUSB_TRANSFER_TYPE_INTERRUPT, 8, EPI(1), 0, 0 }
+};
+
+static struct usb_epinfo kli1_epinfos[] = {
+ { LIBUSB_TRANSFER_TYPE_BULK, 64, EPI(2), 0, 0 },
+ { LIBUSB_TRANSFER_TYPE_BULK, 64, EPO(2), 0, 0 }
+};
+
+static struct usb_intinfo kli_ints[] = {
+ USB_EPS(1, kli1_epinfos),
+ USB_EPS(0, kli0_epinfos)
+};
#endif
#ifdef USE_ICARUS
@@ -418,6 +432,16 @@ static struct usb_find_devices find_dev[] = {
.timeout = KLONDIKE_TIMEOUT_MS,
.latency = 10,
INTINFO(kln_ints) },
+ {
+ .drv = DRIVER_klondike,
+ .name = "KLI",
+ .ident = IDENT_KLN,
+ .idVendor = 0x04D8,
+ .idProduct = 0xF60A,
+ .config = 1,
+ .timeout = KLONDIKE_TIMEOUT_MS,
+ .latency = 10,
+ INTINFO(kli_ints) },
#endif
#ifdef USE_ICARUS
{
@@ -2454,15 +2478,11 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
struct usb_transfer ut;
unsigned char endpoint;
int err, errn;
- /* End of transfer and zero length packet required */
- bool eot = false, zlp = false;
#if DO_USB_STATS
struct timeval tv_start, tv_finish;
#endif
unsigned char buf[512];
#ifdef WIN32
- int dummy;
-
/* On windows the callback_timeout is a safety mechanism only. */
bulk_timeout = timeout;
callback_timeout += WIN_CALLBACK_EXTRA;
@@ -2475,11 +2495,6 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
usb_epinfo = &(cgpu->usbdev->found->intinfos[intinfo].epinfos[epinfo]);
endpoint = usb_epinfo->ep;
- if (length > usb_epinfo->wMaxPacketSize)
- length = usb_epinfo->wMaxPacketSize;
- else if (length == usb_epinfo->wMaxPacketSize)
- eot = true;
-
/* Avoid any async transfers during shutdown to allow the polling
* thread to be shut down after all existing transfers are complete */
if (unlikely(cgpu->shutdown))
@@ -2489,15 +2504,9 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
if ((endpoint & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT) {
memcpy(buf, data, length);
- /* If this is the last packet in a transfer and is the length
- * of the wMaxPacketSize then we need to send a zero length
- * packet to let the device know it's the end of the message.*/
- if (eot)
- zlp = true;
-#ifndef WIN32
- /* Windows doesn't support this flag so we emulate it below */
+ if (length > usb_epinfo->wMaxPacketSize)
+ length = usb_epinfo->wMaxPacketSize;
ut.transfer->flags |= LIBUSB_TRANSFER_ADD_ZERO_PACKET;
-#endif
}
USBDEBUG("USB debug: @usb_bulk_transfer(%s (nodev=%s),intinfo=%d,epinfo=%d,data=%p,length=%d,timeout=%u,mode=%d,cmd=%s,seq=%d) endpoint=%d", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), intinfo, epinfo, data, length, timeout, mode, usb_cmdname(cmd), seq, (int)endpoint);
@@ -2540,12 +2549,6 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
}
if ((endpoint & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN)
memcpy(data, buf, *transferred);
- else if (zlp) {
-#ifdef WIN32
- /* Send a zero length packet */
- libusb_bulk_transfer(dev_handle, endpoint, NULL, 0, &dummy, 100);
-#endif
- }
return err;
}