aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/vector_avx2.h
AgeCommit message (Expand)AuthorFilesLines
2020-03-16rdma: add Mellanox mlx5 Direct Verbs receive supportDamjan Marion1-0/+10
2019-04-16vppinfra: more AVX2 and AVX512 inlinesDamjan Marion1-0/+26
2019-04-08vppinfra: u32x8 transposeDamjan Marion1-0/+56
2019-03-26ipsec: esp-encrypt reworkDamjan Marion1-0/+13
2018-11-20vppinfra: add 128 and 256 bit vector scatter/gather inlinesDamjan Marion1-0/+59
2018-10-17bond: tx optimizationsDamjan Marion1-0/+12
2018-07-16vppinfra: AVX2 interleave functionsDamjan Marion1-3/+14
2018-07-12Revert "vppinfra: AVX2 blend"Dave Barach1-6/+0
2018-07-12vppinfra: AVX2 blendDamjan Marion1-0/+6
2018-06-28ip: vectorized ip checksumDamjan Marion1-0/+28
2018-06-27vppinfra: add vector horizontal add and byte swap (SSE4.2 & AVX2)Damjan Marion1-0/+16
2018-05-25Vectorized bihash_{48,40,24,16}_8 key compareDamjan Marion1-20/+25
2018-05-22vppinfra: add clib_count_equal_uXX and clib_memset_uXX functionsDamjan Marion1-2/+2
2018-05-20vector functions cleanup and improvementsDamjan Marion1-4/+11
2018-05-18Add vlib_buffer_enqueue_to_next inline functionDamjan Marion1-0/+6
2018-05-17Add buffer pointer-to-index and index-to-pointer array functionsDamjan Marion1-0/+22
2018-05-09dpdk: tx code reworkDamjan Marion1-0/+12
2018-04-25dpdk: complete rework of the dpdk-input nodeDamjan Marion1-0/+80
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <vppinfra/vec.h> #include <vppinfra/mem.h> /* Vector resize operator. Called as needed by various macros such as vec_add1() when we need to allocate memory. */ void * vec_resize_allocate_memory (void *v, word length_increment, uword data_bytes, uword header_bytes, uword data_align) { vec_header_t *vh = _vec_find (v); uword old_alloc_bytes, new_alloc_bytes; void *old, *new; header_bytes = vec_header_bytes (header_bytes); data_bytes += header_bytes; if (!v) { new = clib_mem_alloc_aligned_at_offset (data_bytes, data_align, header_bytes, 1 /* yes, call os_out_of_memory */ ); data_bytes = clib_mem_size (new); memset (new, 0, data_bytes); v = new + header_bytes; _vec_len (v) = length_increment; return v; } vh->len += length_increment; old = v - header_bytes; /* Vector header must start heap object. */ ASSERT (clib_mem_is_heap_object (old)); old_alloc_bytes = clib_mem_size (old); /* Need to resize? */ if (data_bytes <= old_alloc_bytes) return v; new_alloc_bytes = (old_alloc_bytes * 3) / 2; if (new_alloc_bytes < data_bytes) new_alloc_bytes = data_bytes; new = clib_mem_alloc_aligned_at_offset (new_alloc_bytes, data_align, header_bytes, 1 /* yes, call os_out_of_memory */ ); /* FIXME fail gracefully. */ if (!new) clib_panic ("vec_resize fails, length increment %d, data bytes %d, alignment %d", length_increment, data_bytes, data_align); clib_memcpy (new, old, old_alloc_bytes); clib_mem_free (old); v = new; /* Allocator may give a bit of extra room. */ new_alloc_bytes = clib_mem_size (v); /* Zero new memory. */ memset (v + old_alloc_bytes, 0, new_alloc_bytes - old_alloc_bytes); return v + header_bytes; } uword clib_mem_is_vec_h (void *v, uword header_bytes) { return clib_mem_is_heap_object (vec_header (v, header_bytes)); } /** \cond */ #ifdef TEST #include <stdio.h> void main (int argc, char *argv[]) { word n = atoi (argv[1]); word i, *x = 0; typedef struct { word x, y, z; } FOO; FOO *foos = vec_init (FOO, 10), *f; vec_validate (foos, 100); foos[100].x = 99; _vec_len (foos) = 0; for (i = 0; i < n; i++) { vec_add1 (x, i); vec_add2 (foos, f, 1); f->x = 2 * i; f->y = 3 * i; f->z = 4 * i; } { word n = 2; word m = 42; vec_delete (foos, n, m); } { word n = 2; word m = 42; vec_insert (foos, n, m); } vec_free (x); vec_free (foos); exit (0); } #endif /** \endcond */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */