Пример #1
0
        public void RunLclFldScenario()
        {
            var test   = new SimpleUnaryOpTest__InsertByte52();
            var result = Avx.Insert(test._fld, (byte)2, 52);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld, _dataTable.outArrayPtr);
        }
Пример #2
0
        private static void InsertByte52()
        {
            var test = new SimpleUnaryOpTest__InsertByte52();

            try
            {
                if (test.IsSupported)
                {
                    // Validates basic functionality works, using Unsafe.Read
                    test.RunBasicScenario_UnsafeRead();

                    if (Avx.IsSupported)
                    {
                        // Validates basic functionality works, using Load
                        test.RunBasicScenario_Load();

                        // Validates basic functionality works, using LoadAligned
                        test.RunBasicScenario_LoadAligned();
                    }

                    // Validates calling via reflection works, using Unsafe.Read
                    test.RunReflectionScenario_UnsafeRead();

                    if (Avx.IsSupported)
                    {
                        // Validates calling via reflection works, using Load
                        test.RunReflectionScenario_Load();

                        // Validates calling via reflection works, using LoadAligned
                        test.RunReflectionScenario_LoadAligned();
                    }

                    // Validates passing a static member works
                    test.RunClsVarScenario();

                    // Validates passing a local works, using Unsafe.Read
                    test.RunLclVarScenario_UnsafeRead();

                    if (Avx.IsSupported)
                    {
                        // Validates passing a local works, using Load
                        test.RunLclVarScenario_Load();

                        // Validates passing a local works, using LoadAligned
                        test.RunLclVarScenario_LoadAligned();
                    }

                    // Validates passing the field of a local works
                    test.RunLclFldScenario();

                    // Validates passing an instance member works
                    test.RunFldScenario();
                }
                else
                {
                    // Validates we throw on unsupported hardware
                    test.RunUnsupportedScenario();
                }
            }
            catch (PlatformNotSupportedException)
            {
                test.Succeeded = true;
            }

            if (!test.Succeeded)
            {
                throw new Exception("One or more scenarios did not complete as expected.");
            }
        }