runtime icon indicating copy to clipboard operation
runtime copied to clipboard

SIMD at System.Numerics.Vectors: Could not load type 'System.Numerics.Vector`1'

Open cheers00 opened this issue 11 years ago • 5 comments

Hi, I wanted to try SIMD after reading the article at http://blogs.microsoft.co.il/sasha/2014/04/22/c-vectorization-microsoft-bcl-simd/ and I am getting the following error.

{"Could not load type 'System.Numerics.Vector`1' from assembly 'System.Numerics.Vectors, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.":"System.Numerics.Vector`1"}

I am using VS 15 CTP6 and the project is set to x64.

I've added the package using Nuget manager.

<package id="System.Numerics.Vectors" version="1.1.6-beta" targetFramework="net45" />

I can build without any problem but at execution I get the above exception. I can not also step-into MinMax vector function.

Wondering if I am missing any settings.

    class Program
    {
        static void MinMaxStandard(int[] a, out int minimum, out int maximum)
        {
            int min = int.MaxValue, max = int.MinValue;
            for (int i = 0; i < a.Length; ++i)
            {
                min = Math.Min(min, a[i]);
                max = Math.Max(max, a[i]);
            }
            minimum = min;
            maximum = max;
        }

        static void MinMax(int[] a, out int minimum, out int maximum)
        {
            int simdLength = Vector<int>.Count;
            Vector<int> vmin = new Vector<int>(int.MaxValue);
            Vector<int> vmax = new Vector<int>(int.MinValue);
            for (int i = 0; i < a.Length; i += simdLength)
            {
                Vector<int> va = new Vector<int>(a, i);
                Vector<int> vLessThan = Vector.LessThan(va, vmin);
                vmin = Vector.ConditionalSelect(vLessThan, va, vmin);
                Vector<int> vGreaterThan = Vector.GreaterThan(va, vmax);
                vmax = Vector.ConditionalSelect(vGreaterThan, va, vmax);
            }
            int min = int.MaxValue, max = int.MinValue;
            for (int i = 0; i < simdLength; ++i)
            {
                min = Math.Min(min, vmin[i]);
                max = Math.Max(max, vmax[i]);
            }
            minimum = min;
            maximum = max;
        }

        static void Main(string[] args)
        {
            int[] n2 = new int[] { 102, 106, 109, 111, 112, 113, 115, 118, 122, 123, 124, 125, 129, 130, 131, 132, 135, 136, 138, 139, 144, 147, 148, 149, 152, 155, 158, 159, 160, 161, 162, 163, 166, 167, 174, 176, 177, 178, 179, 180, 181, 183, 184, 185, 190, 193, 195, 197, 198, 201, 203, 204, 207, 208, 211, 212, 213, 217, 219, 220, 221, 228, 230, 232, 233, 236, 240, 245, 246, 249, 251, 252, 257, 258, 259, 262, 264, 266, 270, 272, 274, 276, 278, 280, 281, 282, 283, 288, 290, 293, 297, 298, 302, 304, 307, 308, 309, 310, 315, 319, 322, 323, 324, 325, 327, 331, 339, 340, 341, 342, 343, 345, 346, 347, 352, 353, 355, 356, 357, 359, 360, 362, 363, 365, 366, 367, 368, 372, 373, 377, 379, 383, 385, 386, 388, 389, 391, 392, 395, 396, 397, 398, 399, 400, 403, 408, 409, 410, 413, 414, 416, 417, 420, 423, 427, 437, 439, 444, 446, 447, 448, 451, 452, 453, 459, 460, 461, 462, 466, 469, 471, 472, 473, 476, 479, 480, 482, 485, 488, 495, 497, 498, 499, 501, 502, 503, 504, 511, 518, 520, 524, 526, 528, 531, 533, 535, 539, 541, 544, 545, 546, 549, 550, 551, 552, 553, 554, 557, 564, 566, 572, 574, 576, 577, 580, 581, 583, 584, 586, 587, 589, 591, 605, 606, 607, 609, 610, 622, 624, 631, 634, 635, 636, 638, 639, 641, 645, 647, 651, 653, 655, 657, 659, 662, 664, 665, 666, 669, 670, 671, 674, 676, 678, 679, 686, 688, 691, 693, 694, 700, 701, 702, 703, 705, 709, 710, 711, 712, 716, 718, 724, 733, 734, 735, 736, 739, 741, 743, 744, 746, 747, 749, 752, 753, 755, 756, 758, 759, 763, 764, 766, 770, 776, 778, 780, 782, 783, 787, 789, 791, 793, 795, 796, 797, 801, 804, 805, 806, 809, 814, 821, 823, 827, 830, 833, 839, 842, 850, 854, 860, 861, 863, 868, 870, 874, 880, 881, 888, 890, 893, 894, 897, 902, 903, 904, 906, 907, 913, 914, 915, 916, 920, 922, 928, 929, 930, 933, 948, 950, 952, 954, 956, 958, 961, 964, 965, 966, 970, 974, 975, 977, 979, 980, 988, 989, 992, 993, 997, 1000, 1005, 1007, 1008, 1011, 1012, 1014, 1015, 1016, 1019, 1020, 1021, 1024, 1027, 1029, 1030, 1031, 1039, 1040, 1043, 1044, 1047, 1048, 1049, 1053, 1056, 1057, 1058, 1059, 1064, 1065, 1069, 1075, 1077, 1078, 1079, 1080, 1081, 1084, 1086, 1087, 1089, 1092, 1093, 1094, 1097, 1099, 1100, 1102, 1106, 1107, 1110, 1115, 1116, 1121, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1139, 1142, 1143, 1144, 1146, 1147, 1150, 1152, 1154, 1156, 1157, 1160, 1165, 1166, 1172, 1176, 1177, 1181, 1182, 1183, 1184, 1187, 1190, 1192, 1195, 1197, 1201, 1203, 1208, 1209, 1210, 1211, 1214, 1215, 1219, 1221, 1222, 1223, 1224, 1226, 1229, 1232, 1234, 1238, 1241, 1250, 1251, 1252, 1257, 1261, 1273, 1275, 1277, 1279, 1282, 1287, 1288, 1292, 1295, 1296, 1300, 1304, 1305, 1311, 1316, 1317, 1318, 1319, 1324, 1325, 1327, 1330, 1333, 1335, 1336, 1337, 1341, 1342, 1344, 1348, 1351, 1354, 1357, 1358, 1363, 1366, 1368, 1369, 1373, 1374, 1376, 1377, 1379, 1381, 1389, 1390, 1392, 1399, 1401, 1405, 1409, 1412, 1414, 1416, 1418, 1420, 1421, 1422, 1426, 1427, 1429, 1437, 1443, 1444, 1445, 1446, 1450, 1451, 1453, 1454, 1455, 1461, 1465, 1466, 1467, 1468, 1470, 1473, 1474, 1479, 1480, 1483, 1484, 1486, 1487, 1489, 1493, 1497, 1498, 1499, 1501, 1504, 1505, 1508, 1511, 1514, 1515, 1518, 1520, 1522, 1523, 1524, 1526, 1528, 1531, 1536, 1537, 1542, 1543, 1544, 1546, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1558, 1561, 1564, 1567, 1571, 1572, 1574, 1575, 1578, 1585, 1587, 1588, 1597, 1600, 1602, 1604, 1606, 1608, 1612, 1615, 1616, 1618, 1620, 1624, 1631, 1639, 1640, 1642, 1645, 1646, 1647, 1650, 1654, 1656, 1659, 1662, 1663, 1665, 1666, 1667, 1669, 1671, 1672, 1673, 1676, 1678, 1683, 1689, 1690, 1693, 1697, 1698, 1701, 1703, 1704, 1705, 1711, 1712, 1713, 1720, 1721, 1727, 1729, 1731, 1732, 1734, 1739, 1741, 1743, 1745, 1746, 1748, 1750, 1752, 1753, 1756, 1757, 1760, 1762, 1764, 1765, 1767, 1771, 1772, 1773, 1775, 1776, 1777, 1778, 1779, 1780, 1782, 1790, 1799, 1804, 1810, 1814, 1819, 1821, 1822, 1823, 1824, 1825, 1828, 1830, 1832, 1833, 1834, 1835, 1836, 1840, 1841, 1843, 1845, 1847, 1848, 1849, 1850, 1851, 1852, 1856, 1858, 1860, 1861, 1863, 1864, 1871, 1877, 1879, 1881, 1884, 1886, 1887, 1889, 1890, 1891, 1893, 1896, 1897, 1902, 1905, 1907, 1908, 1916, 1919, 1921, 1929, 1930, 1934, 1936, 1937, 1943, 1944, 1947, 1950, 1952, 1954, 1956, 1957, 1958, 1961, 1962, 1965, 1966, 1968, 1971, 1976, 1980, 1983, 1987, 1990, 1991, 1992, 1993, 1995, 2001, 2003, 2004, 2005, 2006, 2008, 2010, 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021, 2024, 2025, 2027, 2029, 2031, 2032, 2035, 2038, 2047, 2048, 2050, 2053, 2059, 2060, 2071, 2073, 2079, 2083, 2084, 2085, 2086, 2088, 2093, 2096, 2098, 2099, 2100, 2102, 2105, 2106, 2107, 2108, 2113, 2114, 2118, 2119, 2120, 2126, 2127, 2130, 2131, 2132, 2135, 2136, 2137, 2138, 2143, 2145, 2152, 2153, 2154, 2156, 2157, 2159, 2160, 2162, 2164, 2165, 2169, 2171, 2172, 2174, 2176, 2177, 2181, 2182, 2183, 2185, 2186, 2187, 2193, 2194, 2198, 2200, 2202, 2205, 2208, 2209, 2210, 2213, 2214, 2217, 2218, 2219, 2220, 2221, 2227, 2232, 2235, 2236, 2238, 2239, 2242, 2243, 2246, 2253, 2254, 2255, 2258, 2259, 2260, 2261, 2264, 2266, 2267, 2272, 2273, 2274, 2275, 2276, 2281, 2283, 2285, 2286, 2287, 2288, 2291, 2295, 2298, 2300, 2302, 2308, 2309, 2312, 2313, 2315, 2317, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2327, 2328, 2331, 2335, 2339, 2340, 2341, 2344, 2347, 2351, 2353, 2355, 2358, 2361, 2362, 2366, 2367, 2368, 2370, 2372, 2373, 2375, 2378, 2380, 2382, 2383, 2386, 2387, 2388, 2391, 2392, 2394, 2395, 2396, 2397, 2399, 2400, 2401, 2404, 2409, 2410, 2411, 2412, 2414, 2416, 2419, 2426, 2427, 2428, 2434, 2435, 2440, 2443, 2446, 2449, 2456, 2458, 2459, 2460, 2462, 2465, 2471, 2472, 2473, 2475, 2477, 2481, 2490, 2491, 2493, 2496, 2498, 2499, 2500, 2503, 2506, 2511, 2512, 2513, 2514, 2517, 2520, 2524, 2527, 2528, 2532, 2533, 2534, 2535, 2536, 2539, 2540, 2542, 2543, 2544, 2545, 2547, 2548, 2549, 2554, 2555, 2558, 2560, 2562, 2566, 2567, 2571, 2572, 2577, 2584, 2590, 2591, 2593, 2594, 2597, 2598, 2602, 2604, 2606, 2612, 2616, 2618, 2621, 2624, 2628, 2630, 2633, 2634, 2638, 2639, 2641, 2645, 2646, 2647, 2648, 2652, 2653, 2654, 2656, 2661, 2662, 2664, 2671, 2675, 2676, 2677, 2681, 2682, 2685, 2686, 2689, 2694, 2695, 2696, 2700, 2701, 2703, 2705, 2708, 2711, 2715, 2716, 2721, 2722, 2725, 2726, 2728, 2730, 2731, 2735, 2737, 2740, 2741, 2744, 2746, 2747, 2752, 2756, 2759, 2760, 2761, 2763, 2768, 2772, 2774, 2776, 2779, 2780, 2784, 2785, 2786, 2791, 2792, 2794, 2795, 2796, 2798, 2807, 2809, 2810, 2814, 2826, 2832, 2833, 2834, 2837, 2839, 2841, 2843, 2846, 2847, 2849, 2854, 2855, 2856, 2857, 2861, 2863, 2864, 2865, 2867, 2868, 2871, 2873, 2875, 2876, 2879, 2880, 2881, 2886, 2887, 2888, 2892, 2893, 2895, 2899, 2900, 2901, 2902, 2903, 2905, 2906, 2907, 2908, 2911, 2912, 2915, 2921, 2922, 2924, 2928, 2929, 2930, 2931, 2932, 2934, 2941, 2944, 2945, 2948, 2955, 2956, 2959, 2960, 2961, 2963, 2968, 2970, 2972, 2976, 2978, 2983, 2985, 2986, 2987, 2989, 2990, 2994, 2998, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3009, 3014, 3016, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3027, 3029, 3030, 3031, 3036, 3039, 3040, 3044, 3046, 3048, 3050, 3058, 3059, 3062, 3063, 3064, 3065, 3067, 3068, 3069, 3070, 3074, 3075, 3079, 3080, 3081, 3082, 3084, 3085, 3086, 3091, 3093, 3094, 3096, 3099, 3100, 3101, 3102, 3104, 3106, 3107, 3114, 3116, 3117, 3120, 3121, 3126, 3128, 3130, 3131, 3135, 3138, 3141, 3144, 3145, 3147, 3151, 3152, 3154, 3157, 3162, 3166, 3168, 3178, 3179, 3181, 3182, 3183, 3185, 3187, 3189, 3190, 3192, 3194, 3196, 3199, 3201, 3206, 3208, 3210, 3211, 3213, 3220, 3221, 3227, 3232, 3233, 3234, 3236, 3237, 3238, 3240, 3241, 3243, 3247, 3248, 3250, 3253, 3258, 3259, 3267, 3270, 3271, 3273, 3275, 3277, 3278, 3284, 3286, 3287, 3288, 3293, 3296, 3301, 3302, 3306, 3310, 3314, 3317, 3321, 3325, 3327, 3329, 3331, 3333, 3334, 3335, 3337, 3338, 3339, 3340, 3341, 3342, 3343, 3347, 3350, 3351, 3354, 3355, 3356, 3357, 3364, 3366, 3367, 3368, 3370, 3371, 3372, 3376, 3382, 3383, 3384, 3387, 3390, 3395, 3397, 3400, 3404, 3405, 3410, 3412, 3416, 3418, 3420, 3422, 3423, 3424, 3425, 3426, 3428, 3429, 3430, 3432, 3433, 3434, 3436, 3442, 3451, 3455, 3456, 3463, 3464, 3465, 3469, 3470, 3471, 3472, 3473, 3476, 3482, 3484, 3487, 3490, 3491, 3494, 3495, 3499, 3501, 3504, 3508, 3511, 3513, 3514, 3516, 3517, 3519, 3521, 3522, 3527, 3528, 3529, 3535, 3537, 3538, 3540, 3543, 3544, 3546, 3551, 3552, 3553, 3558, 3561, 3563, 3564, 3565, 3569, 3571, 3574, 3575, 3576, 3578, 3579, 3585, 3593, 3594, 3596, 3599, 3600, 3607, 3610, 3612, 3617, 3622, 3626, 3630, 3632, 3635, 3636, 3637, 3638, 3639, 3641, 3643, 3647, 3648, 3651, 3653, 3654, 3658, 3661, 3666, 3668, 3675, 3676, 3682, 3683, 3684, 3685, 3687, 3689, 3691, 3693, 3696, 3699, 3702, 3703, 3704, 3707, 3708, 3709, 3712, 3713, 3714, 3717, 3719, 3723, 3724, 3726, 3727, 3728, 3731, 3737, 3740, 3743, 3747, 3751, 3752, 3754, 3757, 3759, 3771, 3772, 3773, 3775, 3779, 3788, 3791, 3794, 3796, 3799, 3802, 3804, 3810, 3814, 3817, 3819, 3821, 3822, 3824, 3827, 3830, 3832, 3833, 3834, 3836, 3838, 3839, 3840, 3843, 3844, 3847, 3851, 3854, 3858, 3859, 3860, 3862, 3863, 3865, 3868, 3869, 3872, 3873, 3874, 3877, 3879, 3880, 3886, 3887, 3889, 3892, 3893, 3895, 3900, 3902, 3904, 3905, 3906, 3908, 3914, 3915, 3920, 3921, 3922, 3924, 3926, 3929, 3931, 3933, 3934, 3937, 3938, 3940, 3945, 3949, 3951, 3958, 3960, 3966, 3967, 3970, 3971, 3977, 3992, 3995, 3996, 3999, 4000, 4007, 4012, 4014, 4017, 4018, 4023, 4024, 4025, 4026, 4028, 4030, 4031, 4033, 4037, 4039, 4040, 4043, 4046, 4049, 4050, 4052, 4060, 4061, 4067, 4071, 4073, 4075, 4076, 4080, 4081, 4082, 4084, 4088, 4090, 4091, 4092, 4095, 4099, 4100, 4102, 4103, 4104, 4106, 4107, 4108, 4111, 4113, 4117, 4118, 4119, 4122, 4123, 4127, 4130, 4131, 4134, 4135, 4137, 4140, 4143, 4148, 4149, 4150, 4153, 4155, 4156, 4160, 4161, 4166, 4168, 4171, 4172, 4174, 4175, 4177, 4178, 4182, 4183, 4184, 4185, 4188, 4189, 4192, 4193, 4194, 4196, 4204, 4205, 4208, 4212, 4223, 4225, 4226, 4229, 4233, 4239, 4241, 4242, 4243, 4244, 4245, 4246, 4247, 4251, 4252, 4256, 4263, 4264, 4266, 4270, 4273, 4274, 4278, 4281, 4289, 4290, 4291, 4292, 4295, 4296, 4298, 4302, 4303, 4305, 4316, 4318, 4319, 4328, 4329, 4331, 4333, 4335, 4338, 4340, 4345, 4346, 4348, 4350, 4354, 4355, 4357, 4362, 4363, 4366, 4367, 4369, 4371, 4374, 4375, 4376, 4377, 4381, 4389, 4390, 4392, 4395, 4396, 4397, 4399, 4400, 4402, 4406, 4407, 4408, 4410, 4411, 4412, 4420, 4422, 4427, 4428, 4430, 4432, 4434, 4438, 4439, 4444, 4447, 4450, 4455, 4457, 4461, 4462, 4466, 4467, 4474, 4476, 4479, 4482, 4485, 4486, 4487, 4489, 4494, 4499, 4500, 4501, 4506, 4515, 4519, 4521, 4523, 4527, 4529, 4531, 4538, 4542, 4545, 4546, 4551, 4553, 4554, 4556, 4557, 4560, 4561, 4562, 4563, 4565, 4567, 4568, 4572, 4573, 4577, 4578, 4582, 4584, 4586, 4587, 4588, 4589, 4590, 4593, 4596, 4598, 4600, 4603, 4604, 4608, 4609, 4611, 4613, 4614, 4619, 4620, 4621, 4625, 4627, 4629, 4634, 4635, 4636, 4638, 4641, 4642, 4643, 4647, 4652, 4655, 4656, 4658, 4662, 4668, 4672, 4676, 4678, 4682, 4683, 4686, 4689, 4692, 4695, 4701, 4702, 4703, 4706, 4710, 4711, 4712, 4713, 4715, 4716, 4721, 4728, 4729, 4733, 4734, 4736, 4738, 4744, 4745, 4746, 4749, 4750, 4751, 4753, 4755, 4757, 4758, 4762, 4764, 4765, 4766, 4767, 4768, 4772, 4773, 4775, 4776, 4780, 4783, 4786, 4793, 4794, 4796, 4797, 4804, 4808, 4814, 4815, 4820, 4821, 4824, 4825, 4829, 4831, 4832, 4833, 4834, 4836, 4837, 4840, 4841, 4846, 4849, 4851, 4853, 4854, 4856, 4859, 4864, 4865, 4867, 4872, 4874, 4875, 4882, 4884, 4888, 4891, 4897, 4901, 4902, 4903, 4904, 4906, 4907, 4908, 4910, 4911, 4918, 4920, 4921, 4922, 4929, 4930, 4932, 4934, 4936, 4939, 4941, 4942, 4943, 4944, 4946, 4947, 4951, 4954, 4956, 4960, 4962, 4972, 4973, 4977, 4981, 4982, 4985, 4986, 4987, 4992, 4993, 4995, 4997 };

            int min, max;

            MinMaxStandard(n2, out min, out max);

            MinMax(n2, out min, out max);
        }
    }

cheers00 avatar Mar 30 '15 22:03 cheers00

I think this is related to dotnet/runtime#13947

jcotton42 avatar Mar 31 '15 17:03 jcotton42

@mellinoe Can you take a look?

ellismg avatar Mar 31 '15 22:03 ellismg

Unfortunately, this is going to be broken on preview versions of VS 2015 and the .NET 4.6 preview right now. In the meantime, I believe (not 100% sure) that it is possible to build the library yourself from source and use it, as long as the one you build yourself has a sufficiently high version number. When we release the final version of .NET 4.6, we will have a much better story for using the library, but in the current preview versions, it is not good, unfortunately :(

mellinoe avatar Apr 02 '15 06:04 mellinoe

@mellinoe This is still broken in VS 2015 RC.

cheers00 avatar May 29 '15 18:05 cheers00

This should be fully addressed in 2015 RTM, or rather with 4.6 RTM installed. Let me know if there are any lingering incompatibilities.

mellinoe avatar Sep 24 '15 15:09 mellinoe