Skip to content

Commit 4677923

Browse files
committed
update
1 parent 4faf842 commit 4677923

11 files changed

+3595
-0
lines changed

genesis/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
sha256_avx1:*.asm *.c sha256_avx1.o
2+
gcc -O4 -o $@ main.c $@.o
3+
4+
sha256_sse4:*.asm *.c sha256_sse4.o
5+
gcc -O4 -Dsha256=sha256_sse4 -o $@ main.c $@.o
6+
7+
sha256_avx2_rorx8:*.asm *.c sha256_avx2_rorx8.o
8+
gcc -O4 -Dsha256=sha256_rorx_x8ms -o $@ main.c $@.o
9+
10+
sha256_avx2_rorx2:*.asm *.c sha256_avx2_rorx2.o
11+
gcc -O4 -Dsha256=sha256_rorx -o $@ main.c $@.o
12+
13+
%.o:%.asm
14+
yasm -f x64 -f elf64 -X gnu -g dwarf2 -D LINUX -o $@ $^

genesis/main.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include <stdint.h>
2+
#include <stdio.h>
3+
#include <assert.h>
4+
#include <sys/time.h>
5+
6+
#ifndef sha256
7+
#define sha256 sha256_avx
8+
#endif
9+
10+
void sha256(void *input_data, uint32_t digest[8], uint32_t num_blks);
11+
int main(int argc, char *argv[]) {
12+
static const uint32_t ostate[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
13+
uint32_t state[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
14+
uint8_t block[64] = "AnatolyYakovenko11/2/201712pmPSTAnatolyYakovenko11/2/201712pmPST";
15+
uint32_t *blkptr = (void*)block;
16+
uint64_t i=0;
17+
FILE *f = fopen(argv[1], "a+");
18+
struct timeval start, now;
19+
if(!fseek(f, -40, SEEK_END)) {
20+
assert(8 == fread(&i, 1, 8, f));
21+
i = i<<20;
22+
assert(32 == fread(blkptr, 1, 32, f));
23+
blkptr[8] = blkptr[0];
24+
blkptr[9] = blkptr[1];
25+
blkptr[10] = blkptr[2];
26+
blkptr[11] = blkptr[3];
27+
blkptr[12] = blkptr[4];
28+
blkptr[13] = blkptr[5];
29+
blkptr[14] = blkptr[6];
30+
blkptr[15] = blkptr[7];
31+
assert(0 == fseek(f, 0, SEEK_END));
32+
}
33+
printf("block %04x%04x%04x%04x\n", blkptr[0], blkptr[1], blkptr[2], blkptr[3]);
34+
printf(" %04x%04x%04x%04x\n", blkptr[4], blkptr[5], blkptr[6], blkptr[7]);
35+
printf(" %04x%04x%04x%04x\n", blkptr[8], blkptr[9], blkptr[10], blkptr[11]);
36+
printf(" %04x%04x%04x%04x\n", blkptr[12], blkptr[13], blkptr[14], blkptr[15]);
37+
printf("state %04x%04x%04x%04x\n", state[0], state[1], state[2], state[3]);
38+
printf(" %04x%04x%04x%04x\n", state[4], state[5], state[6], state[7]);
39+
assert(!gettimeofday(&start, 0));
40+
for(i; ;++i) {
41+
if(__builtin_expect((i & 0xfffff) == 0, 0)) {
42+
double total;
43+
uint64_t ix = i >> 20;
44+
assert(!gettimeofday(&now, 0));
45+
total = now.tv_usec + (double)now.tv_sec * 1000000 ;
46+
total = total - (start.tv_usec + (double)start.tv_sec * 1000000);
47+
fwrite(&ix, 8, 1, f);
48+
fwrite(blkptr, 4, 8, f);
49+
fflush(f);
50+
printf("block %04x%04x%04x%04x\n", blkptr[0], blkptr[1], blkptr[2], blkptr[3]);
51+
printf(" %04x%04x%04x%04x\n", blkptr[4], blkptr[5], blkptr[6], blkptr[7]);
52+
printf(" %04x%04x%04x%04x\n", blkptr[8], blkptr[9], blkptr[10], blkptr[11]);
53+
printf(" %04x%04x%04x%04x\n", blkptr[12], blkptr[13], blkptr[14], blkptr[15]);
54+
printf("speed %lu %G %G\n", i, total, i/total);
55+
}
56+
sha256(block, state, 1);
57+
blkptr[0] = state[0];
58+
blkptr[1] = state[1];
59+
blkptr[2] = state[2];
60+
blkptr[3] = state[3];
61+
blkptr[4] = state[4];
62+
blkptr[5] = state[5];
63+
blkptr[6] = state[6];
64+
blkptr[7] = state[7];
65+
blkptr[8] = state[0];
66+
blkptr[9] = state[1];
67+
blkptr[10] = state[2];
68+
blkptr[11] = state[3];
69+
blkptr[12] = state[4];
70+
blkptr[13] = state[5];
71+
blkptr[14] = state[6];
72+
blkptr[15] = state[7];
73+
74+
state[0] = ostate[0];
75+
state[1] = ostate[1];
76+
state[2] = ostate[2];
77+
state[3] = ostate[3];
78+
state[4] = ostate[4];
79+
state[5] = ostate[5];
80+
state[6] = ostate[6];
81+
state[7] = ostate[7];
82+
83+
}
84+
}
85+

genesis/open_software_license.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Copyright (c) 2012, Intel Corporation
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are
7+
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 copyright
13+
notice, this list of conditions and the following disclaimer in the
14+
documentation and/or other materials provided with the
15+
distribution.
16+
17+
* Neither the name of the Intel Corporation nor the names of its
18+
contributors may be used to endorse or promote products derived from
19+
this software without specific prior written permission.
20+
21+
22+
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY
23+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR
26+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

genesis/sha256_avx1

15 KB
Binary file not shown.

0 commit comments

Comments
 (0)