Commit a3790eec by Zoltan Karsa

binary support

parent e1c5288c
...@@ -53,3 +53,4 @@ docs/_build/ ...@@ -53,3 +53,4 @@ docs/_build/
*.out *.out
*.full *.full
*.npy
\ No newline at end of file
...@@ -26,39 +26,6 @@ __device__ inline vec3 cross(const vec3& v1, const vec3& v2) { ...@@ -26,39 +26,6 @@ __device__ inline vec3 cross(const vec3& v1, const vec3& v2) {
__device__ inline vec3 operator*(double a, const vec3& v) { return vec3(v.x * a, v.y * a, v.z * a); } __device__ inline vec3 operator*(double a, const vec3& v) { return vec3(v.x * a, v.y * a, v.z * a); }
//---------------------------
struct mat3 { // row-major matrix 4x4
//---------------------------
vec3 rows[4];
public:
__device__ mat3() {}
__device__ mat3(double m00, double m01, double m02,
double m10, double m11, double m12,
double m20, double m21, double m22,
double m30, double m31, double m32) {
rows[0][0] = m00; rows[0][1] = m01; rows[0][2] = m02;
rows[1][0] = m10; rows[1][1] = m11; rows[1][2] = m12;
rows[2][0] = m20; rows[2][1] = m21; rows[2][2] = m22;
rows[3][0] = m30; rows[3][1] = m31; rows[3][2] = m32;
}
__device__ mat3(vec3 it, vec3 jt, vec3 kt) {
rows[0] = it; rows[1] = jt; rows[2] = kt;
}
__device__ vec3& operator[](int i) { return rows[i]; }
__device__ vec3 operator[](int i) const { return rows[i]; }
__device__ operator double*() const { return (double*)this; }
};
__device__ inline vec3 operator*(const vec3& v, const mat3& mat) {
return v.x * mat[0] + v.y * mat[1] + v.z * mat[2];
}
__device__ inline mat3 operator*(const mat3& left, const mat3& right) {
mat3 result;
for (int i = 0; i < 4; i++) result.rows[i] = left.rows[i] * right;
return result;
}
__device__ inline double signeddistance(const vec3& planeNN, const vec3& planeP, const vec3& Q) { __device__ inline double signeddistance(const vec3& planeNN, const vec3& planeP, const vec3& Q) {
vec3 PQ = Q - planeP; vec3 PQ = Q - planeP;
......
import sys, getopt import sys, getopt
import numpy as np import numpy as np
import cupy as cp
import os
from genax import gen_angels_to_pick, angles_alap, angles_ratet from genax import gen_angels_to_pick, angles_alap, angles_ratet
from gpu import start_kernel from gpu import start_kernel
from utils import convert, printresults, search, exact_one, exact_one_gpu, filter_gpu, writetofile, writetofile2 from utils import convert, printresults, search, exact_one, exact_one_gpu, filter_gpu, writetofile, writetofile2
...@@ -11,9 +13,10 @@ def main(argv): ...@@ -11,9 +13,10 @@ def main(argv):
w = 3 w = 3
PLOT = False PLOT = False
mpi = False mpi = False
binary = False
try: try:
opts, args = getopt.getopt(argv,"hpn:v:w:d:o:m:") opts, args = getopt.getopt(argv,"hpn:v:w:d:o:mb")
except getopt.GetoptError as err: except getopt.GetoptError as err:
print(err) print(err)
print ('tetrarun.py -n <range division:int> -v <> -w <> -o <outputfile>') print ('tetrarun.py -n <range division:int> -v <> -w <> -o <outputfile>')
...@@ -36,6 +39,8 @@ def main(argv): ...@@ -36,6 +39,8 @@ def main(argv):
PLOT = True PLOT = True
elif opt in ("-m", "--mpi"): elif opt in ("-m", "--mpi"):
mpi = True mpi = True
elif opt in ("-b", "--bin"):
binary = True
space = gen_angels_to_pick(n) space = gen_angels_to_pick(n)
...@@ -43,9 +48,7 @@ def main(argv): ...@@ -43,9 +48,7 @@ def main(argv):
Dx, Dy, Dz = angles_ratet(space, mpi) Dx, Dy, Dz = angles_ratet(space, mpi)
del space if outputfile and not binary:
res = start_kernel(Cx, Cy, Dx, Dy, Dz, v, w)
Cx_cpu = np.zeros(Cx.size, dtype=np.float64) Cx_cpu = np.zeros(Cx.size, dtype=np.float64)
Cx.get(out=Cx_cpu) Cx.get(out=Cx_cpu)
...@@ -57,13 +60,27 @@ def main(argv): ...@@ -57,13 +60,27 @@ def main(argv):
Dy.get(out=Dy_cpu) Dy.get(out=Dy_cpu)
Dz_cpu = np.zeros(Dz.size, dtype=np.float64) Dz_cpu = np.zeros(Dz.size, dtype=np.float64)
Dz.get(out=Dz_cpu) Dz.get(out=Dz_cpu)
del space
res = start_kernel(Cx, Cy, Dx, Dy, Dz, v, w)
mtx_cpu = np.zeros(res.size, dtype=np.int8).reshape(res.shape) mtx_cpu = np.zeros(res.size, dtype=np.int8).reshape(res.shape)
res.get(out=mtx_cpu) res.get(out=mtx_cpu)
if outputfile:
writetofile(outputfile+'.full', Cx_cpu, Cy_cpu, Dx_cpu, Dy_cpu, Dz_cpu, mtx_cpu, mpi) writetofile(outputfile+'.full', Cx_cpu, Cy_cpu, Dx_cpu, Dy_cpu, Dz_cpu, mtx_cpu, mpi)
writetofile2(outputfile, Cx_cpu, Cy_cpu, Dx_cpu, Dy_cpu, Dz_cpu, mtx_cpu, mpi) writetofile2(outputfile, Cx_cpu, Cy_cpu, Dx_cpu, Dy_cpu, Dz_cpu, mtx_cpu, mpi)
if outputfile and binary:
res = start_kernel(Cx, Cy, Dx, Dy, Dz, v, w)
os.mkdir(outputfile)
cp.save(outputfile+'/Cx.npy', Cx)
cp.save(outputfile+'/Cy.npy', Cy)
cp.save(outputfile+'/Dx.npy', Dx)
cp.save(outputfile+'/Dy.npy', Dy)
cp.save(outputfile+'/Dz.npy', Dz)
cp.save(outputfile+'/mtx.npy', res)
#printresults(res) #printresults(res)
#print("Exact one 3-3") #print("Exact one 3-3")
#exact_one_gpu(res, 3-1, 3-1) #exact_one_gpu(res, 3-1, 3-1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment