Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / erasure-code / isa / xor_op.h
1 /*
2  * Ceph - scalable distributed file system
3  *
4  * Copyright (C) 2014 CERN (Switzerland)
5  *                                                                                                                                                                                                           \
6  * Author: Andreas-Joachim Peters <Andreas.Joachim.Peters@cern.ch>                                                                                                                                           \
7  *
8  *  This library is free software; you can redistribute it and/or
9  *  modify it under the terms of the GNU Lesser General Public
10  *  License as published by the Free Software Foundation; either
11  *  version 2.1 of the License, or (at your option) any later version.
12  *
13  */
14
15 #ifndef EC_ISA_XOR_OP_H
16 #define EC_ISA_XOR_OP_H
17
18 // -----------------------------------------------------------------------------
19 #include <assert.h>
20 #include <stdint.h>
21 // -----------------------------------------------------------------------------
22
23 // -------------------------------------------------------------------------
24 // declaration of 64/128-bit vector operations depending on availability
25 // -------------------------------------------------------------------------
26 // -------------------------------------------------------------------------
27
28 #define EC_ISA_ADDRESS_ALIGNMENT 32u
29 #define EC_ISA_VECTOR_SSE2_WORDSIZE 64u
30
31 #if __GNUC__ > 4 || \
32   ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 4) ) ||\
33   (__clang__ == 1 )
34 #ifdef EC_ISA_VECTOR_OP_DEBUG
35 #pragma message "* using 128-bit vector operations in " __FILE__
36 #endif
37
38 // -------------------------------------------------------------------------
39 // use 128-bit pointer
40 // -------------------------------------------------------------------------
41 typedef long vector_op_t __attribute__((vector_size(16)));
42 #define EC_ISA_VECTOR_OP_WORDSIZE 16
43 #else
44 // -------------------------------------------------------------------------
45 // use 64-bit pointer
46 // -------------------------------------------------------------------------
47 typedef unsigned long long vector_op_t;
48 #define EC_ISA_VECTOR_OP_WORDSIZE 8
49 #endif
50
51
52 // -------------------------------------------------------------------------
53 // check if a pointer is aligend to byte_count
54 // -------------------------------------------------------------------------
55 #define is_aligned(POINTER, BYTE_COUNT) \
56   (((uintptr_t)(const void *)(POINTER)) % (BYTE_COUNT) == 0)
57
58 // -------------------------------------------------------------------------
59 // compute byte-wise XOR of cw and dw block, ew contains the end address of cw
60 // -------------------------------------------------------------------------
61 void
62 byte_xor(unsigned char* cw, unsigned char* dw, unsigned char* ew);
63
64 // -------------------------------------------------------------------------
65 // compute word-wise XOR of cw and dw block, ew contains the end address of cw
66 // -------------------------------------------------------------------------
67 void
68 vector_xor(vector_op_t* cw, vector_op_t* dw, vector_op_t* ew);
69
70 // -------------------------------------------------------------------------
71 // compute region XOR like parity = src[0] ^ src[1] ... ^ src[src_size-]
72 // -------------------------------------------------------------------------
73 void
74 region_xor(unsigned char** src, unsigned char* parity, int src_size, unsigned size);
75
76 // -------------------------------------------------------------------------
77 // compute region XOR like parity = src[0] ^ src[1] ... ^ src[src_size-]
78 // using SSE2 64-byte operations
79 // -------------------------------------------------------------------------
80 void
81 region_sse2_xor(char** src /* array of 64-byte aligned source pointer to xor */,
82                 char* parity /* 64-byte aligned output pointer containing the parity */,
83                 int src_size /* size of the source pointer array */,
84                 unsigned size /* size of the region to xor */);
85
86
87 #endif // EC_ISA_XOR_OP_H