tests: Delete authors lists from test files.
[gem5.git] / tests / test-progs / asmtest / src / riscv / isa / rv64uamt / amomax_d.S
1 /*
2 * Copyright (c) 2018, Cornell University
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or
6 * without modification, are permitted provided that the following
7 * conditions are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials provided
15 * with the distribution.
16 *
17 * Neither the name of Cornell University nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 //------------------------------------------------------------------------
37 // This code tests amomax_d instruction in multi-threading system.
38 // All threads execute an amomax_w instruction.
39 // Master thread (i.e., thread 0) waits for all threads to complete by
40 // spinning on the barrier variable until all threads update the variable.
41 // Then, the master thread checks the shared variable's value.
42 //------------------------------------------------------------------------
43
44 #include "riscv_test.h"
45 #include "test_macros.h"
46 #include "test_macros_mt.h"
47
48 RVTEST_RV64U
49 RVTEST_CODE_BEGIN
50
51 #define RESULT 0x12343eeaaf423451
52
53 //------------------------------------------------------------------------
54 // Reinitialize shared_var to 0x8000000000000000
55 //------------------------------------------------------------------------
56 la a0, shared_var
57 li t0, 0x8000000000000000
58 sd t0, (a0)
59
60 //------------------------------------------------------------------------
61 // Master thread creates new threads, waits for all threads to complete,
62 // deallocates threads and checks result
63 //------------------------------------------------------------------------
64 call _create_threads
65 call _join
66 call _delete_threads
67 call _check
68
69 RVTEST_CODE_END
70
71 //------------------------------------------------------------------------
72 // mt_test function executed in child threads
73 // A child thread signals its completion by atomicaly adding 1 to barrier
74 //------------------------------------------------------------------------
75 _mt_test:
76 la a0, shared_var
77 la t0, array_index
78 li t1, 8
79 amoadd.d t1, t1, (t0) // get my array_index
80
81 la t0, array
82 add t0, t0, t1
83 ld t0, (t0) // get array[array_index]
84
85 amomax.d zero, t0, (a0)
86
87 li t0, 1
88 la a0, barrier
89 amoadd.d zero, t0, (a0)
90
91 RVTEST_CODE_END
92
93 //------------------------------------------------------------------------
94 // Master thread checks result
95 //------------------------------------------------------------------------
96 _check:
97 la a0, shared_var
98 li a1, RESULT
99 ld a0, (a0)
100 bne a0, a1, _fail
101 li a0, SUCCESS
102 ret
103
104 _fail:
105 li a0, FAILURE
106 ret
107
108 .data
109
110 MT_DATA
111 array_index: .dword 0;