Commit aaf31c54 by Zoltan Karsa

fix kernel pr

parent 301a5e9c
...@@ -24,10 +24,10 @@ def gen_angels_to_pick(n, plot = False): ...@@ -24,10 +24,10 @@ def gen_angels_to_pick(n, plot = False):
parosit = cp.RawKernel(r''' parosit = cp.RawKernel(r'''
extern "C" extern "C"
__global__ __global__
void my_add(const double* x1, const double* x2, double* a, double* b, const size_t m, const float PI) { void parosit(const double* x1, const double* x2, double* a, double* b, const int m, const float PI) {
int tid = blockDim.x * blockIdx.x + threadIdx.x; int tid = blockDim.x * blockIdx.x + threadIdx.x;
float alpha = x1[tid]; float alpha = x1[tid];
for (size_t i = 0; i < m; i++) { for (int i = 0; i < m; i++) {
float betha = x2[i]; float betha = x2[i];
if ((alpha + betha) < PI && betha > alpha && alpha > 0.0) { if ((alpha + betha) < PI && betha > alpha && alpha > 0.0) {
a[tid*m+i] = alpha; a[tid*m+i] = alpha;
...@@ -40,6 +40,25 @@ void my_add(const double* x1, const double* x2, double* a, double* b, const size ...@@ -40,6 +40,25 @@ void my_add(const double* x1, const double* x2, double* a, double* b, const size
} }
''', 'parosit') ''', 'parosit')
parosit2 = cp.RawKernel(r'''
extern "C"
__global__
void parosit2(const double* x1, const double* x2, double* a, double* b, const int m, const float PI) {
int tid = blockDim.x * blockIdx.x + threadIdx.x;
float alpha = x1[tid];
for (int i = 0; i < m; i++) {
float betha = x2[i];
if ((alpha + betha) < PI && alpha > 0.0) {
a[tid*m+i] = alpha;
b[tid*m+i] = betha;
} else {
a[tid*m+i] = -1.0;
b[tid*m+i] = -1.0;
}
}
}
''', 'parosit2')
def angles_alap(anglestopick, plot = False): def angles_alap(anglestopick, plot = False):
m = anglestopick.size m = anglestopick.size
alpha_arr = cp.zeros((m, m), dtype=cp.float64) alpha_arr = cp.zeros((m, m), dtype=cp.float64)
...@@ -49,9 +68,9 @@ def angles_alap(anglestopick, plot = False): ...@@ -49,9 +68,9 @@ def angles_alap(anglestopick, plot = False):
tompa_beta_arr = beta_arr[beta_arr > cp.pi] tompa_beta_arr = beta_arr[beta_arr > cp.pi]
tompa_beta_mpi_arr = tompa_beta_arr - cp.pi/2 tompa_beta_mpi_arr = tompa_beta_arr - cp.pi/2
hegyes_beta_arr = beta_arr[beta_arr <= cp.pi] hegyes_beta_arr = beta_arr[(beta_arr <= cp.pi) & (beta_arr > 0.0)]
tompa_alpha_arr = alpha_arr[beta_arr > cp.pi] tompa_alpha_arr = alpha_arr[beta_arr > cp.pi]
hegyes_alpha_arr = alpha_arr[alpha_arr <= cp.pi] hegyes_alpha_arr = alpha_arr[(beta_arr <= cp.pi) & (beta_arr > 0.0)]
tghB = cp.tan(hegyes_beta_arr) tghB = cp.tan(hegyes_beta_arr)
tghA = cp.tan(hegyes_alpha_arr) tghA = cp.tan(hegyes_alpha_arr)
...@@ -77,20 +96,17 @@ def angles_alap(anglestopick, plot = False): ...@@ -77,20 +96,17 @@ def angles_alap(anglestopick, plot = False):
def angles_ratet(anglestopick, plot = False): def angles_ratet(anglestopick, plot = False):
alpha_arr = cp.array([]) m = anglestopick.size
beta_arr = cp.array([]) alpha_arr = cp.zeros((m, m), dtype=cp.float64)
beta_arr = cp.zeros((m, m), dtype=cp.float64)
for alpha in anglestopick: parosit2((1,), (m,), (anglestopick, anglestopick, alpha_arr, beta_arr, m, cp.pi))
for beta in anglestopick:
if alpha + beta < cp.pi and alpha != 0.0: # vigyázni
alpha_arr = cp.put(alpha_arr, 0, alpha)
beta_arr = cp.put(beta_arr, 0, beta)
tompa_beta_arr = beta_arr[beta_arr > cp.pi] tompa_beta_arr = beta_arr[beta_arr > cp.pi]
tompa_beta_mpi_arr = tompa_beta_arr - cp.pi/2 tompa_beta_mpi_arr = tompa_beta_arr - cp.pi/2
hegyes_beta_arr = beta_arr[beta_arr <= cp.pi] hegyes_beta_arr = beta_arr[(beta_arr <= cp.pi) & (beta_arr > 0.0)]
tompa_alpha_arr = alpha_arr[beta_arr > cp.pi] tompa_alpha_arr = alpha_arr[beta_arr > cp.pi]
hegyes_alpha_arr = alpha_arr[alpha_arr <= cp.pi] hegyes_alpha_arr = alpha_arr[(beta_arr <= cp.pi) & (beta_arr > 0.0)]
tghB = cp.tan(hegyes_beta_arr) tghB = cp.tan(hegyes_beta_arr)
tghA = cp.tan(hegyes_alpha_arr) tghA = cp.tan(hegyes_alpha_arr)
......
...@@ -37,11 +37,15 @@ def main(argv): ...@@ -37,11 +37,15 @@ def main(argv):
space = gen_angels_to_pick(n, PLOT) space = gen_angels_to_pick(n, PLOT)
Cx, Cy = angles_alap(space, PLOT) Cx, Cy = angles_alap(space, PLOT)
print(Cx)
print(Cy)
Dx, Dy, Dz = angles_ratet(space) Dx, Dy, Dz = angles_ratet(space)
res = start_kernel(Cx, Cy, Dx, Dy, Dz, v, w) res = start_kernel(Cx, Cy, Dx, Dy, Dz, v, w)
print(res) #print(res)
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv[1:]) main(sys.argv[1:])
\ No newline at end of file
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