silx-kit / dynamix Goto Github PK
View Code? Open in Web Editor NEWXPCS project
License: MIT License
XPCS project
License: MIT License
The way FFT is computed is a bit difficult to understand. A big FFT of 2*Nt*Np
points is computed, where Nt
is the number of frames, and Np
is the total number of pixels in the current bin. After multiplication and inverse FFT, the result is obtained with a non-trivial slicing.
A more straightforward (and efficient) approach would be to compute Np
batched FFTS of 2*Nt
points.
The theoretical number of operations with this approach is
2 * Np * Nt * (1 + 3 * log(2 * Nt))
(2 forward batched FFT, 1 batched inverse FFT, 1 multiplication on 2*Nt*Np
points),
while the number of operations for the direct mat-mul method is
Nt * Nt * Np
That being said, I don't get impressive results with FFT in practice (FFTW and CUFFT).
Moreover, the memory needed for the FFT method is higher:
6 * Np * Nt
floats with the Fourier methodNt * (Np + Nt)
with the direct methodso the Fourier method consumes more memory as soon as Np > Nt/5
, which is often the case.
/nobackup/lid02gpu11/conda3/envs/dahu/lib/python3.7/site-packages/pyopencl/cache.py:501: UserWarning: PyOpenCL compiler caching failed with an exception:
[begin exception]
Traceback (most recent call last):
File "/nobackup/lid02gpu11/conda3/envs/dahu/lib/python3.7/site-packages/pyopencl/cache.py", line 478, in create_built_program_from_source_cached
include_path=include_path)
File "/nobackup/lid02gpu11/conda3/envs/dahu/lib/python3.7/site-packages/pyopencl/cache.py", line 398, in _create_built_program_from_source_cached
prg.build(options_bytes, [devices[i] for i in to_be_built_indices])
File "/nobackup/lid02gpu11/conda3/envs/dahu/lib/python3.7/site-packages/pyopencl/__init__.py", line 714, in program_build
raise err
pyopencl._cl.RuntimeError: clBuildProgram failed: <unknown error -9999> - clBuildProgram failed: <unknown error -9999>
Build on <pyopencl.Device 'Tesla K20m' on 'NVIDIA CUDA' at 0x55ecb43b4d70>:
ptxas error : Entry function 'compute_sums_dense' uses too much shared data (0x14004 bytes, 0xc000 max)
There is a bug when qmask values have no pixel contributing ... It would be best to have n_bins to be the max value of qmask.
pyfftw looks like a nice python binding to the FFTw which performances should be fast enough to allow testing and offer a golden reference.
How comes Yuriy pushed directly to the master without PR nor review ??!!
Hey Guys,
I was trying your correlator and stumbled across some issues during the installation.
pip install dynamix
does not work. Apparently the package cannot be found on the index. Installation from GitHub works.
numpy
needs to be installed before installing dynamix
, otherwise it will not work.
silx
is not installed during the installation of dynamix
which leads to an import error when trying your example.
Greetings from Hamburg,
Mario
Below is the code Yuriy usea to calculation correlation function with the
standard error.
def y_dense_correlator(xpcs_data, mask):
"""
version of YC
Reference implementation of the dense correlator.
Parameters
-----------
xpcs_data: numpy.ndarray
Stack of XPCS frames with shape (n_frames, n_rows, n_columns)
mask: numpy.ndarray
Mask of bins in the format (n_rows, n_columns).
Zero pixels indicate unused pixels.
"""
ind = np.where(mask > 0) # unused pixels are 0
xpcs_data = xpcs_data[:, ind[0], ind[1]] # (n_tau, n_pix)
del ind
ltimes, lenmatr = np.shape(xpcs_data) # n_tau, n_pix
meanmatr = np.array(np.mean(xpcs_data, axis=1),np.float32) #
xpcs_data.sum(axis=-1).sum(axis=-1)/n_pix
meanmatr.shape = 1, ltimes
if ltimes*lenmatr>3000*512*512:
nn = 16
newlen = lenmatr//nn
num = np.dot(np.array(xpcs_data[:,:newlen],np.float32),
np.array(xpcs_data[:,:newlen],np.float32).T)
xpcs_data = xpcs_data[:,newlen:] + 0
for i in range(1,nn-1,1):
num +=
np.dot(np.array(xpcs_data[:,:newlen],np.float32),np.array(xpcs_data[:,:
newlen],np.float32).T)
xpcs_data = xpcs_data[:,newlen:] + 0
num += np.dot(np.array(xpcs_data,np.float32),
np.array(xpcs_data,np.float32).T)
else:
num = np.dot(np.array(xpcs_data,np.float32),
np.array(xpcs_data,np.float32).T)
num /= lenmatr
denom = np.dot(meanmatr.T, meanmatr)
del meanmatr
res = np.zeros((ltimes-1,3)) # was ones()
for i in range(1,ltimes,1): # was ltimes-1, so res[-1] was always 1
!
dia_n = np.diag(num, k=i)
sdia_d = np.diag(denom, k=i)
res[i-1,0] = i
res[i-1,1] = np.sum(dia_n)/np.sum(sdia_d)
res[i-1,2] = np.std(dia_n/sdia_d) / len(sdia_d)**0.5
return res
The command is:
oclgrind python3 run_tests.py -vv dynamix.correlator.test.test_dense.TestDense.test_dense_correlator
spots:
Kernel: compute_sums_dense
Work-group: (0,165,0)
Only 32 out of 128 work-items executed barrier
call spir_func void @_Z7barrierj(i32 1) #4, !dbg !161
At line 119 (column 9) of input.cl:
(source not available)
Work-group divergence detected (barrier)
Kernel: compute_sums_dense
Work-group: (0,165,0)
Only 16 out of 128 work-items executed barrier
call spir_func void @_Z7barrierj(i32 1) #4, !dbg !173
At line 123 (column 9) of input.cl:
(source not available)
Work-group divergence detected (barrier)
Kernel: compute_sums_dense
Work-group: (0,165,0)
Only 8 out of 128 work-items executed barrier
call spir_func void @_Z7barrierj(i32 1) #4, !dbg !185
At line 128 (column 9) of input.cl:
(source not available)
Work-group divergence detected (barrier)
Kernel: compute_sums_dense
Work-group: (0,165,0)
Only 4 out of 128 work-items executed barrier
call spir_func void @_Z7barrierj(i32 1) #4, !dbg !197
At line 132 (column 9) of input.cl:
(source not available)
Work-group divergence detected (barrier)
Kernel: compute_sums_dense
Work-group: (0,165,0)
Only 2 out of 128 work-items executed barrier
call spir_func void @_Z7barrierj(i32 1) #4, !dbg !209
At line 136 (column 9) of input.cl:
(source not available)
Work-group divergence detected (barrier)
Kernel: compute_sums_dense
Work-group: (0,165,0)
Only 1 out of 128 work-items executed barrier
call spir_func void @_Z7barrierj(i32 1) #4, !dbg !221
At line 140 (column 9) of input.cl:
(source not available)
Work-group divergence detected (barrier)
Kernel: compute_sums_dense
Work-group: (0,167,0)
Only 32 out of 128 work-items executed barrier
call spir_func void @_Z7barrierj(i32 1) #4, !dbg !161
At line 119 (column 9) of input.cl:
(source not available)
They can be generated from molecular dynamics using:
https://github.com/aryabhatt/xpcs-baseline
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.