Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: dart/tests/html/typed_arrays_simd_test.dart

Issue 59073003: Version 0.8.10.4 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library TypedArraysSimdTest; 5 library TypedArraysSimdTest;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_config.dart'; 7 import '../../pkg/unittest/lib/html_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:typed_data'; 9 import 'dart:typed_data';
10 10
(...skipping 19 matching lines...) Expand all
30 if (Platform.supportsSimd) { 30 if (Platform.supportsSimd) {
31 final val = new Float32x4(1.0, 2.0, 3.0, 4.0); 31 final val = new Float32x4(1.0, 2.0, 3.0, 4.0);
32 expect(val.x, floatEquals(1.0)); 32 expect(val.x, floatEquals(1.0));
33 expect(val.y, floatEquals(2.0)); 33 expect(val.y, floatEquals(2.0));
34 expect(val.z, floatEquals(3.0)); 34 expect(val.z, floatEquals(3.0));
35 expect(val.w, floatEquals(4.0)); 35 expect(val.w, floatEquals(4.0));
36 final val2 = val + val; 36 final val2 = val + val;
37 expect(val2.x, floatEquals(2.0)); 37 expect(val2.x, floatEquals(2.0));
38 expect(val2.y, floatEquals(4.0)); 38 expect(val2.y, floatEquals(4.0));
39 expect(val2.z, floatEquals(6.0)); 39 expect(val2.z, floatEquals(6.0));
40 » expect(val2.w, floatEquals(8.0));» 40 » expect(val2.w, floatEquals(8.0));
41 }» 41 }
42 }); 42 });
43 43
44 test('test Float32x4List', () { 44 test('test Float32x4List', () {
45 var counter; 45 var counter;
46 final list = new Float32List(12); 46 final list = new Float32List(12);
47 for (int i = 0; i < list.length; ++i) { 47 for (int i = 0; i < list.length; ++i) {
48 list[i] = i * 1.0; 48 list[i] = i * 1.0;
49 } 49 }
50 if (Platform.supportsSimd) { 50 if (Platform.supportsSimd) {
51 counter = new Float32x4.zero(); 51 counter = new Float32x4.zero();
52 final simdlist = new Float32x4List.view(list.buffer); 52 final simdlist = new Float32x4List.view(list.buffer);
53 for (int i = 0; i < simdlist.length; ++i) { 53 for (int i = 0; i < simdlist.length; ++i) {
54 counter += simdlist[i]; 54 counter += simdlist[i];
55 } 55 }
56 } else { 56 } else {
57 counter = new MyFloat32x4(); 57 counter = new MyFloat32x4();
58 for (int i = 0; i < list.length; i += 4) { 58 for (int i = 0; i < list.length; i += 4) {
59 counter.x += list[i]; 59 counter.x += list[i];
60 counter.y += list[i+1]; 60 counter.y += list[i+1];
61 counter.z += list[i+2]; 61 counter.z += list[i+2];
62 counter.w += list[i+3]; 62 counter.w += list[i+3];
63 } 63 }
64 } 64 }
65 expect(counter.x, floatEquals(12.0)); 65 expect(counter.x, floatEquals(12.0));
66 expect(counter.y, floatEquals(15.0)); 66 expect(counter.y, floatEquals(15.0));
67 expect(counter.z, floatEquals(18.0)); 67 expect(counter.z, floatEquals(18.0));
68 expect(counter.w, floatEquals(21.0)); 68 expect(counter.w, floatEquals(21.0));
69 }); 69 });
70 70
71 test('test Uint32x4', () { 71 test('test Int32x4', () {
72 if (Platform.supportsSimd) { 72 if (Platform.supportsSimd) {
73 » final val = new Uint32x4(1, 2, 3, 4); 73 » final val = new Int32x4(1, 2, 3, 4);
74 expect(val.x, equals(1)); 74 expect(val.x, equals(1));
75 expect(val.y, equals(2)); 75 expect(val.y, equals(2));
76 expect(val.z, equals(3)); 76 expect(val.z, equals(3));
77 expect(val.w, equals(4)); 77 expect(val.w, equals(4));
78 final val2 = val ^ val; 78 final val2 = val ^ val;
79 expect(val2.x, equals(0)); 79 expect(val2.x, equals(0));
80 expect(val2.y, equals(0)); 80 expect(val2.y, equals(0));
81 expect(val2.z, equals(0)); 81 expect(val2.z, equals(0));
82 » expect(val2.w, equals(0));» 82 » expect(val2.w, equals(0));
83 }» 83 }
84 }); 84 });
85 } 85 }
OLDNEW
« no previous file with comments | « dart/tests/corelib/corelib.status ('k') | dart/tests/isolate/browser/typed_data_message_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698