-
Notifications
You must be signed in to change notification settings - Fork 0
/
other.py
37 lines (31 loc) · 963 Bytes
/
other.py
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
import numpy as np
from numba import cuda
from numba.core.errors import NumbaPerformanceWarning
import warnings
import math
warnings.simplefilter('ignore', category=NumbaPerformanceWarning)
@cuda.jit
def hamming_distance(src, dst, result):
stride = cuda.gridsize(1)
idx = cuda.grid(1)
for i in range(idx, len(src), stride):
tmp = src[i] ^ dst[i]
cuda.syncthreads()
while(tmp):
result[i] += tmp & 1
tmp >>= 1
@cuda.jit
def find_strings(src, result):
stride = cuda.gridsize(1)
idx = cuda.grid(1)
for i in range(idx, len(src), stride):
cuda.syncthreads()
y = 1
cuda.syncthreads()
if 33 <= src[i] <= 126:
if not(33 <= src[i-1] <= 126):
result[i][0] = src[i]
if i + y < len(src):
while (33 <= src[i + y] <= 126):
result[i][y] = src[i + y]
y += 1