G2S 0.99.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. g2s-0.99.0/G2S.egg-info/PKG-INFO +32 -0
  2. g2s-0.99.0/G2S.egg-info/SOURCES.txt +82 -0
  3. g2s-0.99.0/G2S.egg-info/dependency_links.txt +1 -0
  4. g2s-0.99.0/G2S.egg-info/requires.txt +2 -0
  5. g2s-0.99.0/G2S.egg-info/top_level.txt +1 -0
  6. g2s-0.99.0/MANIFEST.in +12 -0
  7. g2s-0.99.0/PKG-INFO +32 -0
  8. g2s-0.99.0/README.md +5 -0
  9. g2s-0.99.0/g2s/__init__.py +37 -0
  10. g2s-0.99.0/g2s/_version.py +1 -0
  11. g2s-0.99.0/include/AcceleratorDevice.hpp +92 -0
  12. g2s-0.99.0/include/CPUThreadAcceleratorDevice.hpp +84 -0
  13. g2s-0.99.0/include/CPUThreadDevice.hpp +116 -0
  14. g2s-0.99.0/include/DataImage.hpp +752 -0
  15. g2s-0.99.0/include/DirectMeasureCPUThreadDevice.hpp +84 -0
  16. g2s-0.99.0/include/FullMeasureCPUThreadDevice.hpp +95 -0
  17. g2s-0.99.0/include/NvidiaGPUAcceleratorDevice.hpp +104 -0
  18. g2s-0.99.0/include/OpenCLGPUDevice.hpp +127 -0
  19. g2s-0.99.0/include/OperationMatrix.hpp +77 -0
  20. g2s-0.99.0/include/calibration.hpp +494 -0
  21. g2s-0.99.0/include/complexMulti.hpp +334 -0
  22. g2s-0.99.0/include/computeDeviceModule.hpp +85 -0
  23. g2s-0.99.0/include/cvtZMQ2WS.hpp +27 -0
  24. g2s-0.99.0/include/dataManagement.hpp +40 -0
  25. g2s-0.99.0/include/fKb.hpp +957 -0
  26. g2s-0.99.0/include/fKs.hpp +843 -0
  27. g2s-0.99.0/include/fKst.hpp +19 -0
  28. g2s-0.99.0/include/jobManager.hpp +47 -0
  29. g2s-0.99.0/include/jobTasking.hpp +32 -0
  30. g2s-0.99.0/include/json/json-forwards.h +458 -0
  31. g2s-0.99.0/include/json/json.h +2492 -0
  32. g2s-0.99.0/include/mexInterrupt.hpp +78 -0
  33. g2s-0.99.0/include/picosha2.h +397 -0
  34. g2s-0.99.0/include/protocol.hpp +37 -0
  35. g2s-0.99.0/include/quantileSamplingModule.hpp +571 -0
  36. g2s-0.99.0/include/samplingModule.hpp +61 -0
  37. g2s-0.99.0/include/sharedMemoryManager.hpp +59 -0
  38. g2s-0.99.0/include/simulation.hpp +834 -0
  39. g2s-0.99.0/include/simulationAugmentedDim.hpp +326 -0
  40. g2s-0.99.0/include/status.hpp +26 -0
  41. g2s-0.99.0/include/thresholdSamplingModule.hpp +278 -0
  42. g2s-0.99.0/include/typeDefine.hpp +29 -0
  43. g2s-0.99.0/include/utils.hpp +148 -0
  44. g2s-0.99.0/include/zmq.h +787 -0
  45. g2s-0.99.0/include/zmq.hpp +2879 -0
  46. g2s-0.99.0/include_interfaces/R_interface.hpp +322 -0
  47. g2s-0.99.0/include_interfaces/interfaceTemplate.hpp +726 -0
  48. g2s-0.99.0/include_interfaces/matlab_interface.hpp +445 -0
  49. g2s-0.99.0/include_interfaces/python3_interface.hpp +455 -0
  50. g2s-0.99.0/pyproject.toml +46 -0
  51. g2s-0.99.0/setup.cfg +4 -0
  52. g2s-0.99.0/setup.py +199 -0
  53. g2s-0.99.0/src/AcceleratorDevice.cpp +146 -0
  54. g2s-0.99.0/src/CPUThreadAcceleratorDevice.cpp +460 -0
  55. g2s-0.99.0/src/CPUThreadDevice.cpp +517 -0
  56. g2s-0.99.0/src/DataImage.cpp +118 -0
  57. g2s-0.99.0/src/DirectMeasureCPUThreadDevice.cpp +237 -0
  58. g2s-0.99.0/src/FullMesaureCPUThreadDevice.cpp +300 -0
  59. g2s-0.99.0/src/NvidiaGPUAcceleratorDevice.cu +727 -0
  60. g2s-0.99.0/src/OpenCLGPUDevice.cpp +631 -0
  61. g2s-0.99.0/src/auto_qs.cpp +774 -0
  62. g2s-0.99.0/src/base.cpp +293 -0
  63. g2s-0.99.0/src/cvtZMQ2WS.cpp +166 -0
  64. g2s-0.99.0/src/dataManagement.cpp +274 -0
  65. g2s-0.99.0/src/ds-l.cpp +868 -0
  66. g2s-0.99.0/src/ds.cpp +296 -0
  67. g2s-0.99.0/src/dsk.cpp +721 -0
  68. g2s-0.99.0/src/echo.cpp +110 -0
  69. g2s-0.99.0/src/errorTest.cpp +91 -0
  70. g2s-0.99.0/src/g2s.cpp +942 -0
  71. g2s-0.99.0/src/g2sRExtension.cpp +861 -0
  72. g2s-0.99.0/src/g2smodule.cpp +1002 -0
  73. g2s-0.99.0/src/jobManager.cpp +97 -0
  74. g2s-0.99.0/src/jobTasking.cpp +374 -0
  75. g2s-0.99.0/src/jsoncpp.cpp +5411 -0
  76. g2s-0.99.0/src/nds.cpp +798 -0
  77. g2s-0.99.0/src/qs.cpp +1163 -0
  78. g2s-0.99.0/src/server.cpp +381 -0
  79. g2s-0.99.0/src/sharedMemoryManager.cpp +129 -0
  80. g2s-0.99.0/src/status.cpp +114 -0
  81. g2s-0.99.0/src/test.cpp +460 -0
  82. g2s-0.99.0/src_interfaces/R_interface.cpp +10 -0
  83. g2s-0.99.0/src_interfaces/matlab_interface.cpp +9 -0
  84. g2s-0.99.0/src_interfaces/python3_interface.cpp +135 -0
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.4
2
+ Name: G2S
3
+ Version: 0.99.0
4
+ Summary: G2S Python interface
5
+ Home-page: https://github.com/GAIA-UNIL/G2S
6
+ Author: Mathieu Gravey
7
+ Author-email: Mathieu Gravey <g2s@mgravey.com>
8
+ License-Expression: LGPL-3.0-only
9
+ Project-URL: Homepage, https://github.com/GAIA-UNIL/G2S
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Programming Language :: C++
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: numpy>=2.0.0
23
+ Requires-Dist: pyzmq>=25.1.0
24
+ Dynamic: author
25
+ Dynamic: home-page
26
+ Dynamic: requires-python
27
+
28
+ # G2S Package description
29
+
30
+ This package containe the interfaces for comunicating with the G2S server. G2S is a flexible MPS (Multiple Point Statistics) framework that provide QS (Quantile Sampling) and NDS (Narrow Distribution Selection).
31
+
32
+ For more infromation please visite [G2S website](https://gaia-unil.github.io/G2S/)
@@ -0,0 +1,82 @@
1
+ MANIFEST.in
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ G2S.egg-info/PKG-INFO
6
+ G2S.egg-info/SOURCES.txt
7
+ G2S.egg-info/dependency_links.txt
8
+ G2S.egg-info/requires.txt
9
+ G2S.egg-info/top_level.txt
10
+ g2s/__init__.py
11
+ g2s/_version.py
12
+ include/AcceleratorDevice.hpp
13
+ include/CPUThreadAcceleratorDevice.hpp
14
+ include/CPUThreadDevice.hpp
15
+ include/DataImage.hpp
16
+ include/DirectMeasureCPUThreadDevice.hpp
17
+ include/FullMeasureCPUThreadDevice.hpp
18
+ include/NvidiaGPUAcceleratorDevice.hpp
19
+ include/OpenCLGPUDevice.hpp
20
+ include/OperationMatrix.hpp
21
+ include/calibration.hpp
22
+ include/complexMulti.hpp
23
+ include/computeDeviceModule.hpp
24
+ include/cvtZMQ2WS.hpp
25
+ include/dataManagement.hpp
26
+ include/fKb.hpp
27
+ include/fKs.hpp
28
+ include/fKst.hpp
29
+ include/jobManager.hpp
30
+ include/jobTasking.hpp
31
+ include/mexInterrupt.hpp
32
+ include/picosha2.h
33
+ include/protocol.hpp
34
+ include/quantileSamplingModule.hpp
35
+ include/samplingModule.hpp
36
+ include/sharedMemoryManager.hpp
37
+ include/simulation.hpp
38
+ include/simulationAugmentedDim.hpp
39
+ include/status.hpp
40
+ include/thresholdSamplingModule.hpp
41
+ include/typeDefine.hpp
42
+ include/utils.hpp
43
+ include/zmq.h
44
+ include/zmq.hpp
45
+ include/json/json-forwards.h
46
+ include/json/json.h
47
+ include_interfaces/R_interface.hpp
48
+ include_interfaces/interfaceTemplate.hpp
49
+ include_interfaces/matlab_interface.hpp
50
+ include_interfaces/python3_interface.hpp
51
+ src/AcceleratorDevice.cpp
52
+ src/CPUThreadAcceleratorDevice.cpp
53
+ src/CPUThreadDevice.cpp
54
+ src/DataImage.cpp
55
+ src/DirectMeasureCPUThreadDevice.cpp
56
+ src/FullMesaureCPUThreadDevice.cpp
57
+ src/NvidiaGPUAcceleratorDevice.cu
58
+ src/OpenCLGPUDevice.cpp
59
+ src/auto_qs.cpp
60
+ src/base.cpp
61
+ src/cvtZMQ2WS.cpp
62
+ src/dataManagement.cpp
63
+ src/ds-l.cpp
64
+ src/ds.cpp
65
+ src/dsk.cpp
66
+ src/echo.cpp
67
+ src/errorTest.cpp
68
+ src/g2s.cpp
69
+ src/g2sRExtension.cpp
70
+ src/g2smodule.cpp
71
+ src/jobManager.cpp
72
+ src/jobTasking.cpp
73
+ src/jsoncpp.cpp
74
+ src/nds.cpp
75
+ src/qs.cpp
76
+ src/server.cpp
77
+ src/sharedMemoryManager.cpp
78
+ src/status.cpp
79
+ src/test.cpp
80
+ src_interfaces/R_interface.cpp
81
+ src_interfaces/matlab_interface.cpp
82
+ src_interfaces/python3_interface.cpp
@@ -0,0 +1,2 @@
1
+ numpy>=2.0.0
2
+ pyzmq>=25.1.0
@@ -0,0 +1 @@
1
+ g2s
g2s-0.99.0/MANIFEST.in ADDED
@@ -0,0 +1,12 @@
1
+ include README.md
2
+ include setup.py
3
+ include pyproject.toml
4
+
5
+ # include C++ sources from parent dirs
6
+ recursive-include src *
7
+ recursive-include src_interfaces *
8
+ recursive-include include *
9
+ recursive-include include_interfaces *
10
+
11
+ recursive-include libzmq/build/bin/Release *
12
+ recursive-include libzmq/build/lib/Release *
g2s-0.99.0/PKG-INFO ADDED
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.4
2
+ Name: G2S
3
+ Version: 0.99.0
4
+ Summary: G2S Python interface
5
+ Home-page: https://github.com/GAIA-UNIL/G2S
6
+ Author: Mathieu Gravey
7
+ Author-email: Mathieu Gravey <g2s@mgravey.com>
8
+ License-Expression: LGPL-3.0-only
9
+ Project-URL: Homepage, https://github.com/GAIA-UNIL/G2S
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Programming Language :: C++
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: numpy>=2.0.0
23
+ Requires-Dist: pyzmq>=25.1.0
24
+ Dynamic: author
25
+ Dynamic: home-page
26
+ Dynamic: requires-python
27
+
28
+ # G2S Package description
29
+
30
+ This package containe the interfaces for comunicating with the G2S server. G2S is a flexible MPS (Multiple Point Statistics) framework that provide QS (Quantile Sampling) and NDS (Narrow Distribution Selection).
31
+
32
+ For more infromation please visite [G2S website](https://gaia-unil.github.io/G2S/)
g2s-0.99.0/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # G2S Package description
2
+
3
+ This package containe the interfaces for comunicating with the G2S server. G2S is a flexible MPS (Multiple Point Statistics) framework that provide QS (Quantile Sampling) and NDS (Narrow Distribution Selection).
4
+
5
+ For more infromation please visite [G2S website](https://gaia-unil.github.io/G2S/)
@@ -0,0 +1,37 @@
1
+ # g2s/__init__.py
2
+ import os
3
+ import sys
4
+
5
+ import ctypes
6
+ import zmq.backend.cython._zmq as _zmq
7
+
8
+ # Export ZMQ symbols globally for g2s.so
9
+ try:
10
+ ctypes.CDLL(_zmq.__file__, mode=ctypes.RTLD_GLOBAL)
11
+ except OSError:
12
+ pass
13
+
14
+
15
+ _extra_dll_dir = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'lib', 'site-packages', 'g2s')
16
+ if sys.platform == 'win32' and os.path.isdir(_extra_dll_dir):
17
+ if sys.version_info >= (3, 8):
18
+ try:
19
+ os.add_dll_directory(_extra_dll_dir)
20
+ except Exception:
21
+ pass
22
+ else:
23
+ os.environ.setdefault('PATH', '')
24
+ os.environ['PATH'] += os.pathsep + _extra_dll_dir
25
+
26
+ from .g2s import run
27
+ from .g2s import run as g2s
28
+
29
+ # Make module callable: g2s(...) acts like g2s.run(...)
30
+ class _CallableModule(sys.modules[__name__].__class__):
31
+ def __call__(self, *args, **kwargs):
32
+ return run(*args, **kwargs)
33
+
34
+ sys.modules[__name__].__class__ = _CallableModule
35
+
36
+ # Optional: preserve both names in tab-completion
37
+ __all__ = ["run", "g2s"]
@@ -0,0 +1 @@
1
+ __version__ = "0.99.0"
@@ -0,0 +1,92 @@
1
+ /*
2
+ * G2S
3
+ * Copyright (C) 2018, Mathieu Gravey (gravey.mathieu@gmail.com) and UNIL (University of Lausanne)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ #ifndef ACCELERATOR_DEVICE_HPP
19
+ #define ACCELERATOR_DEVICE_HPP
20
+
21
+ #include "computeDeviceModule.hpp"
22
+ #ifdef WITH_MKL
23
+ #include <fftw/fftw3_mkl.h>
24
+ #else
25
+ #include <fftw3.h>
26
+ #endif
27
+
28
+ //#if PRECISION == 1
29
+ #define FFTW_PRECISION(Name) fftwf_##Name
30
+ #define dataType_g2s float
31
+ /*#else
32
+ #define FFTW_PRECISION(Name) fftw_##Name
33
+ #define dataType_g2s double
34
+ #endif*/
35
+
36
+
37
+ class AcceleratorDevice : public ComputeDeviceModule
38
+ {
39
+ public:
40
+ AcceleratorDevice(SharedMemoryManager* sharedMemoryManager,std::vector<g2s::OperationMatrix> coeficientMatrix, unsigned int threadRatio=1, bool withCrossMesurement=false, bool circularTI=false);
41
+ ~AcceleratorDevice();
42
+
43
+ void initDim();
44
+
45
+ virtual bool candidateForPatern(std::vector<std::vector<int> > &neighborArrayVector, std::vector<std::vector<float> > &neighborValueArrayVector, std::vector<float> &variablesCoeficient, std::vector<float> delta0);
46
+ virtual std::vector<g2s::spaceFrequenceMemoryAddress> allocAndInitSharedMemory(std::vector<void* > srcMemoryAdress, std::vector<unsigned> srcSize, std::vector<unsigned> fftSize)=0;
47
+ virtual std::vector<g2s::spaceFrequenceMemoryAddress> freeSharedMemory(std::vector<g2s::spaceFrequenceMemoryAddress> sharedMemoryAdress)=0;
48
+
49
+ virtual dataType_g2s* getErrorsArray();
50
+ virtual dataType_g2s* getArray(unsigned);
51
+ virtual unsigned getErrorsArraySize()=0;
52
+ virtual unsigned getArraySize()=0;
53
+ virtual dataType_g2s* getCossErrorArray();
54
+ virtual float getErrorAtPosition(unsigned)=0;
55
+ virtual float getValueAtPosition(unsigned, unsigned)=0;
56
+ virtual float getCroossErrorAtPosition(unsigned)=0;
57
+ virtual unsigned cvtIndexToPosition(unsigned)=0;
58
+ virtual unsigned cvtPositionToIndex(unsigned)=0;
59
+ virtual void setTrueMismatch(bool value);
60
+
61
+ virtual void maskCroossError();
62
+ virtual void maskCroossErrorWithVariable(unsigned );
63
+ virtual void maskLayerWithVariable(unsigned, unsigned )=0;
64
+
65
+ virtual void setValueInErrorArray(unsigned position, float value)=0;
66
+ virtual void setValueInErrorArrayWithRadius(unsigned position, float value, float radius)=0;
67
+ virtual void compensateMissingData()=0;
68
+ virtual void searchKBigest(float* errors,unsigned *encodedPosition, unsigned extendK, float seed)=0;
69
+
70
+ virtual void zerosFrenquencySpaceOutputArray(unsigned layer)=0;
71
+ virtual void computeFreqMismatchMap(std::vector<std::vector<int> > neighborArray, std::vector<std::vector<float> > &neighborValueArrayVector)=0;
72
+ virtual void computeRealMissmatchAndRemoveWrongPattern(float* delta0)=0;
73
+
74
+ protected:
75
+ unsigned _threadRatio=1;
76
+
77
+ std::vector<g2s::spaceFrequenceMemoryAddress> _srcCplx;
78
+
79
+ std::vector<dataType_g2s*> _realSpaceArray;
80
+
81
+ std::vector<int> _min,_max;// to init
82
+ std::vector<unsigned> _fftSize;// to init
83
+ std::vector<unsigned> _srcSize;// to init
84
+ unsigned _fftSpaceSize;// to init
85
+ unsigned _realSpaceSize;
86
+
87
+ bool _trueMismatch=true;
88
+ bool _crossMesurement=false;
89
+ bool _circularTI=false;
90
+ };
91
+
92
+ #endif
@@ -0,0 +1,84 @@
1
+ /*
2
+ * G2S
3
+ * Copyright (C) 2018, Mathieu Gravey (gravey.mathieu@gmail.com) and UNIL (University of Lausanne)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ //To use only for debugging purpose
19
+
20
+ #ifndef CPU_THREAD_ACCELERATOR_DEVICE_DEVICE_HPP
21
+ #define CPU_THREAD_ACCELERATOR_DEVICE_DEVICE_HPP
22
+
23
+ #include "AcceleratorDevice.hpp"
24
+
25
+ //#if PRECISION == 1
26
+ #define FFTW_PRECISION(Name) fftwf_##Name
27
+ #define dataType_g2s float
28
+ /*#else
29
+ #define FFTW_PRECISION(Name) fftw_##Name
30
+ #define dataType_g2s double
31
+ #endif*/
32
+
33
+
34
+ class CPUThreadAcceleratorDevice : public AcceleratorDevice
35
+ {
36
+ public:
37
+ CPUThreadAcceleratorDevice(SharedMemoryManager* sharedMemoryManager,std::vector<g2s::OperationMatrix> coeficientMatrix, unsigned int threadRatio=1, bool withCrossMesurement=false, bool circularTI=false);
38
+ ~CPUThreadAcceleratorDevice();
39
+
40
+ std::vector<g2s::spaceFrequenceMemoryAddress> allocAndInitSharedMemory(std::vector<void* > srcMemoryAdress, std::vector<unsigned> srcSize, std::vector<unsigned> fftSize);
41
+ std::vector<g2s::spaceFrequenceMemoryAddress> freeSharedMemory(std::vector<g2s::spaceFrequenceMemoryAddress> sharedMemoryAdress);
42
+
43
+ unsigned getErrorsArraySize();
44
+ unsigned getArraySize();
45
+ float getErrorAtPosition(unsigned);
46
+ float getValueAtPosition(unsigned, unsigned);
47
+ float getCroossErrorAtPosition(unsigned);
48
+ unsigned cvtIndexToPosition(unsigned);
49
+ unsigned cvtPositionToIndex(unsigned);
50
+
51
+ void maskLayerWithVariable(unsigned, unsigned );
52
+
53
+ void setValueInErrorArray(unsigned position, float value);
54
+ void setValueInErrorArrayWithRadius(unsigned position, float value, float radius);
55
+ void compensateMissingData();
56
+ void searchKBigest(float* errors,unsigned *encodedPosition, unsigned extendK, float seed);
57
+
58
+ void zerosFrenquencySpaceOutputArray(unsigned layer);
59
+ void computeFreqMismatchMap(std::vector<std::vector<int> > neighborArray, std::vector<std::vector<float> > &neighborValueArrayVector);
60
+ void computeRealMissmatchAndRemoveWrongPattern(float* delta0);
61
+
62
+ private:
63
+
64
+ FFTW_PRECISION(complex)* _frenquencySpaceInput=nullptr;
65
+ std::vector<FFTW_PRECISION(complex)*> _frenquencySpaceOutputArray;
66
+
67
+ FFTW_PRECISION(plan) _pInv;
68
+ FFTW_PRECISION(plan) _p;
69
+
70
+ FFTW_PRECISION(plan) _pPatchM;
71
+ FFTW_PRECISION(plan)* _pPatchL;
72
+
73
+ inline unsigned index( std::vector<int> &deltaVect){
74
+ unsigned finalValue=deltaVect.back();
75
+ for (int i = deltaVect.size()-2; i >=0; i--)
76
+ {
77
+ finalValue*=_fftSize[i];
78
+ finalValue+=deltaVect[i];
79
+ }
80
+ return finalValue;
81
+ }
82
+ };
83
+
84
+ #endif
@@ -0,0 +1,116 @@
1
+ /*
2
+ * G2S
3
+ * Copyright (C) 2018, Mathieu Gravey (gravey.mathieu@gmail.com) and UNIL (University of Lausanne)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ #ifndef CPU_THREAD_DEVICE_HPP
19
+ #define CPU_THREAD_DEVICE_HPP
20
+
21
+ #include "computeDeviceModule.hpp"
22
+ #ifdef WITH_MKL
23
+ #include <fftw/fftw3_mkl.h>
24
+ #else
25
+ #include <fftw3.h>
26
+ #endif
27
+
28
+ //#if PRECISION == 1
29
+ #define FFTW_PRECISION(Name) fftwf_##Name
30
+ #define dataType_g2s float
31
+ /*#else
32
+ #define FFTW_PRECISION(Name) fftw_##Name
33
+ #define dataType_g2s double
34
+ #endif*/
35
+
36
+
37
+ class CPUThreadDevice : public ComputeDeviceModule
38
+ {
39
+ public:
40
+ CPUThreadDevice(SharedMemoryManager* sharedMemoryManager,std::vector<g2s::OperationMatrix> coeficientMatrix, unsigned int threadRatio=1, bool withCrossMesurement=false, bool circularTI=false);
41
+ ~CPUThreadDevice();
42
+
43
+ bool candidateForPatern(std::vector<std::vector<int> > &neighborArrayVector, std::vector<std::vector<float> > &neighborValueArrayVector, std::vector<float> &variablesCoeficient, std::vector<float> delta0);
44
+ std::vector<g2s::spaceFrequenceMemoryAddress> allocAndInitSharedMemory(std::vector<void* > srcMemoryAdress, std::vector<unsigned> srcSize, std::vector<unsigned> fftSize);
45
+ std::vector<g2s::spaceFrequenceMemoryAddress> freeSharedMemory(std::vector<g2s::spaceFrequenceMemoryAddress> sharedMemoryAdress);
46
+
47
+ dataType_g2s* getErrorsArray();
48
+ dataType_g2s* getArray(unsigned);
49
+ unsigned getErrorsArraySize();
50
+ unsigned getArraySize();
51
+ dataType_g2s* getCossErrorArray();
52
+ float getErrorAtPosition(unsigned);
53
+ float getValueAtPosition(unsigned, unsigned);
54
+ float getCroossErrorAtPosition(unsigned);
55
+ unsigned cvtIndexToPosition(unsigned);
56
+ unsigned cvtPositionToIndex(unsigned);
57
+
58
+ void setValueInErrorArrayWithRadius(unsigned, float, float);
59
+ void setTrueMismatch(bool value);
60
+
61
+ void maskCroossError();
62
+ void maskCroossErrorWithVariable(unsigned );
63
+ void maskLayerWithVariable(unsigned, unsigned );
64
+
65
+ private:
66
+ void recursiveSetValueInRadius (unsigned position, float value, float radius2, unsigned level, unsigned distance2);
67
+ unsigned _threadRatio=1;
68
+
69
+ std::vector<g2s::spaceFrequenceMemoryAddress> _srcCplx;
70
+
71
+ FFTW_PRECISION(complex)* _frenquencySpaceInput=nullptr;
72
+ std::vector<FFTW_PRECISION(complex)*> _frenquencySpaceOutputArray;
73
+ std::vector<dataType_g2s*> _realSpaceArray;
74
+
75
+ FFTW_PRECISION(plan) _pInv;
76
+ FFTW_PRECISION(plan) _p;
77
+
78
+ FFTW_PRECISION(plan) _pPatchM;
79
+ FFTW_PRECISION(plan)* _pPatchL;
80
+
81
+ std::vector<int> _min,_max;// to init
82
+ std::vector<unsigned> _fftSize;// to init
83
+ std::vector<unsigned> _srcSize;// to init
84
+ unsigned _fftSpaceSize;// to init
85
+ unsigned _realSpaceSize;
86
+
87
+ // inline unsigned index( std::vector<int> &deltaVect){
88
+ // unsigned finalValue=0;
89
+ // for (int i = 0; i < deltaVect.size(); ++i)
90
+ // {
91
+ // unsigned val=deltaVect[i];
92
+ // for (int j = 0; j < i; ++j)
93
+ // {
94
+ // val*=_fftSize[j];
95
+ // }
96
+ // finalValue+=val;
97
+ // }
98
+ // return finalValue;
99
+ // }
100
+
101
+ inline unsigned index( std::vector<int> &deltaVect){
102
+ unsigned finalValue=deltaVect.back();
103
+ for (int i = deltaVect.size()-2; i >=0; i--)
104
+ {
105
+ finalValue*=_fftSize[i];
106
+ finalValue+=deltaVect[i];
107
+ }
108
+ return finalValue;
109
+ }
110
+
111
+ bool _trueMismatch=true;
112
+ bool _crossMesurement=false;
113
+ bool _circularTI=false;
114
+ };
115
+
116
+ #endif