-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cu
38 lines (34 loc) · 965 Bytes
/
main.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "ising.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/time.h>
int main()
{
FILE* fin = fopen("test/conf-init.bin","rb");
FILE* fout = fopen("test/conf-11.ans","wb");
int n=20000, k=5;
float weights[5][5] = { {0.004f,0.016f,0.026f,0.016f,0.004f},
{0.016f,0.071f,0.117f,0.071f,0.016f},
{0.026f,0.117f,0.000f,0.117f,0.026f},
{0.016f,0.071f,0.117f,0.071f,0.016f},
{0.004f,0.016f,0.026f,0.016f,0.004f}};
int8_t *latticeArr = ( int8_t* ) malloc(n*n*sizeof(int8_t));
//read from binary
for (int row=0; row<n; row++)
for (int col=0; col<n; col++)
{
int spin;
fread(&spin,sizeof(int),1,fin);
latticeArr[row*n +col] = (int8_t)spin;
}
ising(latticeArr,(float*)weights,k,n); // !!!Actual computation
//write to binary
for (int row=0; row<n; row++)
for (int col=0; col<n; col++)
{
int spin = latticeArr[row*n +col];
fwrite(&spin,sizeof(int),1,fout);
}
return 0;
}