]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/isa-l/crc/crc16_t10dif_op_perf.c
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / isa-l / crc / crc16_t10dif_op_perf.c
CommitLineData
9f95a23c
TL
1/**********************************************************************
2 Copyright(c) 2011-2017 Intel Corporation All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28**********************************************************************/
29
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33#include <stdint.h>
34#include "crc.h"
35#include "test.h"
36
37#define BLKSIZE (512)
38
39//#define CACHED_TEST
40#ifdef CACHED_TEST
41// Cached test, loop many times over small dataset
42# define NBLOCKS 100
9f95a23c
TL
43# define TEST_TYPE_STR "_warm"
44#else
45// Uncached test. Pull from large mem base.
46# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */
47# define TEST_LEN (2 * GT_L3_CACHE)
48# define NBLOCKS (TEST_LEN / BLKSIZE)
9f95a23c
TL
49# define TEST_TYPE_STR "_cold"
50#endif
51
52#ifndef TEST_SEED
53# define TEST_SEED 0x1234
54#endif
55
56struct blk {
57 uint8_t data[BLKSIZE];
58};
59
60struct blk_ext {
61 uint8_t data[BLKSIZE];
62 uint32_t tag;
63 uint16_t meta;
64 uint16_t crc;
65};
66
f67539c2
TL
67void crc16_t10dif_copy_perf(struct blk *blks, struct blk *blkp, struct blk_ext *blks_ext,
68 struct blk_ext *blkp_ext, uint16_t * crc)
69{
70 int i;
71 for (i = 0, blkp = blks, blkp_ext = blks_ext; i < NBLOCKS; i++) {
72 *crc = crc16_t10dif_copy(TEST_SEED, blkp_ext->data, blkp->data,
73 sizeof(blks->data));
74 blkp_ext->crc = *crc;
75 blkp++;
76 blkp_ext++;
77 }
78}
79
9f95a23c
TL
80int main(int argc, char *argv[])
81{
9f95a23c
TL
82 uint16_t crc;
83 struct blk *blks, *blkp;
84 struct blk_ext *blks_ext, *blkp_ext;
f67539c2 85 struct perf start;
9f95a23c
TL
86
87 printf("crc16_t10dif_streaming_insert_perf:\n");
88
89 if (posix_memalign((void *)&blks, 1024, NBLOCKS * sizeof(*blks))) {
90 printf("alloc error: Fail");
91 return -1;
92 }
93 if (posix_memalign((void *)&blks_ext, 1024, NBLOCKS * sizeof(*blks_ext))) {
94 printf("alloc error: Fail");
95 return -1;
96 }
97
98 printf(" size blk: %ld, blk_ext: %ld, blk data: %ld, stream: %ld\n",
99 sizeof(*blks), sizeof(*blks_ext), sizeof(blks->data),
100 NBLOCKS * sizeof(blks->data));
101 memset(blks, 0xe5, NBLOCKS * sizeof(*blks));
102 memset(blks_ext, 0xe5, NBLOCKS * sizeof(*blks_ext));
103
104 printf("Start timed tests\n");
105 fflush(0);
106
107 // Copy and insert test
f67539c2
TL
108 BENCHMARK(&start, BENCHMARK_TIME,
109 crc16_t10dif_copy_perf(blks, blkp, blks_ext, blkp_ext, &crc));
110
9f95a23c 111 printf("crc16_t10pi_op_copy_insert" TEST_TYPE_STR ": ");
f67539c2 112 perf_print(start, (long long)sizeof(blks->data) * NBLOCKS);
9f95a23c
TL
113
114 printf("finish 0x%x\n", crc);
115 return 0;
116}