1 /*
2 
3    BLIS
4    An object-based framework for developing high-performance BLAS-like
5    libraries.
6 
7    Copyright (C) 2018 - 2019, Advanced Micro Devices, Inc.
8 
9    Redistribution and use in source and binary forms, with or without
10    modification, are permitted provided that the following conditions are
11    met:
12     - Redistributions of source code must retain the above copyright
13       notice, this list of conditions and the following disclaimer.
14     - Redistributions in binary form must reproduce the above copyright
15       notice, this list of conditions and the following disclaimer in the
16       documentation and/or other materials provided with the distribution.
17     - Neither the name(s) of the copyright holder(s) 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 CONTRIBUTORS
22    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 */
34 
35 #ifndef BLIS_ARRAY_H
36 #define BLIS_ARRAY_H
37 
38 // -- Array type --
39 
40 /*
41 typedef struct
42 {
43 	void*     buf;
44 
45 	siz_t     num_elem;
46 	siz_t     elem_size;
47 
48 } array_t;
49 */
50 
51 
52 // Array entry query
53 
bli_array_buf(array_t * array)54 BLIS_INLINE void* bli_array_buf( array_t* array )
55 {
56 	return array->buf;
57 }
58 
bli_array_num_elem(array_t * array)59 BLIS_INLINE siz_t bli_array_num_elem( array_t* array )
60 {
61 	return array->num_elem;
62 }
63 
bli_array_elem_size(array_t * array)64 BLIS_INLINE siz_t bli_array_elem_size( array_t* array )
65 {
66 	return array->elem_size;
67 }
68 
69 // Array entry modification
70 
bli_array_set_buf(void * buf,array_t * array)71 BLIS_INLINE void bli_array_set_buf( void* buf, array_t* array ) \
72 {
73 	array->buf = buf;
74 }
75 
bli_array_set_num_elem(siz_t num_elem,array_t * array)76 BLIS_INLINE void bli_array_set_num_elem( siz_t num_elem, array_t* array ) \
77 {
78 	array->num_elem = num_elem;
79 }
80 
bli_array_set_elem_size(siz_t elem_size,array_t * array)81 BLIS_INLINE void bli_array_set_elem_size( siz_t elem_size, array_t* array ) \
82 {
83 	array->elem_size = elem_size;
84 }
85 
86 // -----------------------------------------------------------------------------
87 
88 void bli_array_init
89      (
90        const siz_t       num_elem,
91        const siz_t       elem_size,
92        array_t* restrict array
93      );
94 void bli_array_resize
95      (
96        const siz_t       num_elem_new,
97        array_t* restrict array
98      );
99 void bli_array_finalize
100      (
101        array_t* restrict array
102      );
103 
104 void* bli_array_elem
105      (
106        const siz_t       index,
107        array_t* restrict array
108      );
109 void bli_array_set_elem
110      (
111        void*    restrict elem,
112        const siz_t       index,
113        array_t* restrict array
114      );
115 
116 #endif
117 
118