lisaanalysistools 1.0.4__cp312-cp312-macosx_10_9_x86_64.whl → 1.0.6__cp312-cp312-macosx_10_9_x86_64.whl
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.
Potentially problematic release.
This version of lisaanalysistools might be problematic. Click here for more details.
- {lisaanalysistools-1.0.4.dist-info → lisaanalysistools-1.0.6.dist-info}/METADATA +12 -6
- lisaanalysistools-1.0.6.dist-info/RECORD +36 -0
- {lisaanalysistools-1.0.4.dist-info → lisaanalysistools-1.0.6.dist-info}/WHEEL +1 -1
- {lisaanalysistools-1.0.4.dist-info → lisaanalysistools-1.0.6.dist-info}/top_level.txt +0 -1
- lisatools/_version.py +1 -1
- lisatools/cutils/__init__.py +0 -0
- lisatools/cutils/detector_cpu.cpython-312-darwin.so +0 -0
- lisatools/cutils/include/Detector.hpp +78 -0
- lisatools/cutils/include/__init__.py +0 -0
- lisatools/cutils/include/global.hpp +28 -0
- lisatools/cutils/src/Detector.cpp +210 -0
- lisatools/cutils/src/Detector.cu +210 -0
- lisatools/cutils/src/__init__.py +0 -0
- lisatools/cutils/src/pycppdetector.pyx +199 -0
- lisatools/datacontainer.py +23 -6
- lisatools/detector.py +59 -15
- lisatools/sensitivity.py +8 -6
- lisatools/stochastic.py +1 -1
- lisaanalysistools-1.0.4.dist-info/RECORD +0 -37
- lisatools/cutils/detector.cpython-312-darwin.so +0 -0
- lisatools/glitch.py +0 -193
- lisatools/sampling/moves/gbgroupstretch.py +0 -53
- lisatools/sampling/moves/gbmultipletryrj.py +0 -1287
- lisatools/sampling/moves/gbspecialgroupstretch.py +0 -671
- lisatools/sampling/moves/gbspecialstretch.py +0 -1836
- lisatools/sampling/moves/mbhspecialmove.py +0 -286
- lisatools/sampling/moves/placeholder.py +0 -16
- lisatools/sampling/moves/specialforegroundmove.py +0 -564
- lisatools/utils/multigpudataholder.py +0 -730
- {lisaanalysistools-1.0.4.dist-info → lisaanalysistools-1.0.6.dist-info}/LICENSE +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lisaanalysistools
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Home-page: https://github.com/mikekatz04/
|
|
3
|
+
Version: 1.0.6
|
|
4
|
+
Home-page: https://github.com/mikekatz04/LISAanalysistools
|
|
5
5
|
Author: Michael Katz
|
|
6
6
|
Author-email: mikekatz04@gmail.com
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -36,7 +36,9 @@ pip install lisaanalysistools
|
|
|
36
36
|
|
|
37
37
|
If you want to install all of the tools associated with LISA Analysis Tools (Fast EMRI Waveforms, BBHx, GBGPU, fastlisaresponse, eryn), see the following instructions.
|
|
38
38
|
|
|
39
|
-
LISA Analysis Tools leverages conda environments to install and use necessary packages. If you do not have [Anaconda](https://www.anaconda.com/download) or [miniconda](https://docs.anaconda.com/free/miniconda/index.html) installed, you must do this first and load your `base` conda environment.
|
|
39
|
+
LISA Analysis Tools leverages conda environments to install and use necessary packages. If you do not have [Anaconda](https://www.anaconda.com/download) or [miniconda](https://docs.anaconda.com/free/miniconda/index.html) installed, you must do this first and load your `base` conda environment. Recommended components for install in your conda environment are `lapack`, `gsl`, `hdf5`, which are needed for various waveform packages.
|
|
40
|
+
|
|
41
|
+
For an easy full install, follow these instructions.
|
|
40
42
|
|
|
41
43
|
First, clone the repo and `cd` to the `LATW` directory.:
|
|
42
44
|
```
|
|
@@ -50,7 +52,11 @@ bash install.sh
|
|
|
50
52
|
```
|
|
51
53
|
Running `bash install.sh -h` will also give you some basic install options.
|
|
52
54
|
|
|
53
|
-
If you want more flexibility, you can install each package given above separately.
|
|
55
|
+
If you want more flexibility, you can install each package given above separately.
|
|
56
|
+
|
|
57
|
+
To install this software for use with NVIDIA GPUs (compute capability >5.0), you need the [CUDA toolkit](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html) and [CuPy](https://cupy.chainer.org/). The CUDA toolkit must have cuda version >8.0. Be sure to properly install CuPy within the correct CUDA toolkit version. Make sure the nvcc binary is on `$PATH` or set it as the `CUDA_HOME` environment variable.
|
|
58
|
+
|
|
59
|
+
We are currently working on building wheels and making the GPU version pip installable. For now, to work with GPUs, git clone the repository and install it from source.
|
|
54
60
|
|
|
55
61
|
## Contributing
|
|
56
62
|
|
|
@@ -58,9 +64,9 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduc
|
|
|
58
64
|
|
|
59
65
|
## Versioning
|
|
60
66
|
|
|
61
|
-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/
|
|
67
|
+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/mikekatz04/LISAanalysistools/tags).
|
|
62
68
|
|
|
63
|
-
Current Version: 1.0.
|
|
69
|
+
Current Version: 1.0.6
|
|
64
70
|
|
|
65
71
|
## Authors/Developers
|
|
66
72
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
lisatools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
lisatools/_version.py,sha256=14imVuUDlv1B9HhbSkkcqdP6lnMYhzyYQVjZiFvzp6k,123
|
|
3
|
+
lisatools/analysiscontainer.py,sha256=ePwTBUTEBJn2TK93_afARate9SAqUKK8c8T6DcGUx1Y,15321
|
|
4
|
+
lisatools/datacontainer.py,sha256=m4gp8E2qOIFq1JPEid3jA450hdNo0yWQu770AVJdrDI,9809
|
|
5
|
+
lisatools/detector.py,sha256=4XYWi8bSdM_97IL1L0EKKInO1fjRM4-FuW3gE8xeEEM,15262
|
|
6
|
+
lisatools/diagnostic.py,sha256=CfPpfvDys1XyZRWmmTqTSWb0SY2eH0G_8TRnt1OxBFo,34174
|
|
7
|
+
lisatools/sensitivity.py,sha256=rckXeJ_5U3cRRgbYDmt0kaTyJRjkrYfgBwos12QJJfw,27297
|
|
8
|
+
lisatools/stochastic.py,sha256=XL6ZbqprfcM1rsDw3PhrqdflpQiCnZ5x4y_k4QZ9YGg,9423
|
|
9
|
+
lisatools/cutils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
lisatools/cutils/detector_cpu.cpython-312-darwin.so,sha256=QQFxyuqx9L7HciApuIiw2tLkh-7Qqs4PRkiOWkqcClM,126912
|
|
11
|
+
lisatools/cutils/include/Detector.hpp,sha256=dzdo8QUrrcAnfrTyytlZkQrYmVk_QWXXTL68p4COpZ8,1926
|
|
12
|
+
lisatools/cutils/include/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
lisatools/cutils/include/global.hpp,sha256=3VPiqglTMRrIBXlEvDUJO2-CjKy_SLUXZt-9A1fH6lQ,572
|
|
14
|
+
lisatools/cutils/src/Detector.cpp,sha256=RbPYrK70m0heUZyFha-2_FJOW8Fg9vKfZQzNIXvOqUQ,5188
|
|
15
|
+
lisatools/cutils/src/Detector.cu,sha256=RbPYrK70m0heUZyFha-2_FJOW8Fg9vKfZQzNIXvOqUQ,5188
|
|
16
|
+
lisatools/cutils/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
lisatools/cutils/src/pycppdetector.pyx,sha256=N0AyF5YPPqmHaBKuj4gZVXOt67z9qKwzpB6jlh9zWRY,5581
|
|
18
|
+
lisatools/sampling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
+
lisatools/sampling/likelihood.py,sha256=G2kAQ43qlhAzIFWvYsrSmHXd7WKJAzcCN2o07vRE8vc,29585
|
|
20
|
+
lisatools/sampling/prior.py,sha256=1K1PMStpwO9WT0qG0aotKSyoNjuehXNbzTDtlk8Q15M,21407
|
|
21
|
+
lisatools/sampling/stopping.py,sha256=Q8q7nM0wnJervhRduf2tBXZZHUVza5kJiAUAMUQXP5o,9682
|
|
22
|
+
lisatools/sampling/utility.py,sha256=rOGotS0Aj8-DAWqsTVy2xWNsxsoz74BVrHEnG2mOkwU,14340
|
|
23
|
+
lisatools/sampling/moves/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
+
lisatools/sampling/moves/skymodehop.py,sha256=0nf72eFhFMGwi0dLJci6XZz-bIMGqco2B2_J72hQvf8,3348
|
|
25
|
+
lisatools/sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
+
lisatools/sources/emri/__init__.py,sha256=HjsWS4mjog_gRE4N90My6ahLKQGjNwrHIeA40R7qzw0,41
|
|
27
|
+
lisatools/sources/emri/tdiwaveform.py,sha256=jaKL2PO8RlJrHP45zCa4BpRniLfdnMIP1QsIB-6jVq4,2297
|
|
28
|
+
lisatools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
+
lisatools/utils/constants.py,sha256=r1kVwkpbZS13JTOxj2iRxT5sMgTYX30y-S0JdVmD5Oo,1354
|
|
30
|
+
lisatools/utils/pointeradjust.py,sha256=2sT-7qeYWr1pd_sHk9leVHUTSJ7jJgYIRoWQOtYqguE,2995
|
|
31
|
+
lisatools/utils/utility.py,sha256=3mJoJKNGrm3KuNXIa2RUKi9WKd593V4q9XjjQZCQD0M,6831
|
|
32
|
+
lisaanalysistools-1.0.6.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
33
|
+
lisaanalysistools-1.0.6.dist-info/METADATA,sha256=1T8XjHyoWcJMiuLG2DpQXqh181FMwc_K2adouVyiuO0,4109
|
|
34
|
+
lisaanalysistools-1.0.6.dist-info/WHEEL,sha256=wTFHiv6xiwExbw_CBGcw1b3hAKzFq_QaWIv4Plh5P0w,110
|
|
35
|
+
lisaanalysistools-1.0.6.dist-info/top_level.txt,sha256=qXUn8Xi8yvK0vr3QH0vvT5cmoccjSj-UPeKGLAxdYGo,10
|
|
36
|
+
lisaanalysistools-1.0.6.dist-info/RECORD,,
|
lisatools/_version.py
CHANGED
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#ifndef __DETECTOR_HPP__
|
|
2
|
+
#define __DETECTOR_HPP__
|
|
3
|
+
|
|
4
|
+
#include "global.hpp"
|
|
5
|
+
#include <iostream>
|
|
6
|
+
|
|
7
|
+
class Vec
|
|
8
|
+
{
|
|
9
|
+
public:
|
|
10
|
+
double x;
|
|
11
|
+
double y;
|
|
12
|
+
double z;
|
|
13
|
+
|
|
14
|
+
CUDA_DEVICE
|
|
15
|
+
Vec(double x_, double y_, double z_)
|
|
16
|
+
{
|
|
17
|
+
x = x_;
|
|
18
|
+
y = y_;
|
|
19
|
+
z = z_;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class Orbits
|
|
24
|
+
{
|
|
25
|
+
public:
|
|
26
|
+
double dt;
|
|
27
|
+
int N;
|
|
28
|
+
double *n_arr;
|
|
29
|
+
double *ltt_arr;
|
|
30
|
+
double *x_arr;
|
|
31
|
+
int nlinks;
|
|
32
|
+
int nspacecraft;
|
|
33
|
+
int *links;
|
|
34
|
+
int *sc_r;
|
|
35
|
+
int *sc_e;
|
|
36
|
+
|
|
37
|
+
Orbits(double dt_, int N_, double *n_arr_, double *ltt_arr_, double *x_arr_, int *links_, int *sc_r_, int *sc_e_)
|
|
38
|
+
{
|
|
39
|
+
dt = dt_;
|
|
40
|
+
N = N_;
|
|
41
|
+
n_arr = n_arr_;
|
|
42
|
+
ltt_arr = ltt_arr_;
|
|
43
|
+
x_arr = x_arr_;
|
|
44
|
+
nlinks = 6;
|
|
45
|
+
nspacecraft = 3;
|
|
46
|
+
|
|
47
|
+
sc_r = sc_r_;
|
|
48
|
+
sc_e = sc_e_;
|
|
49
|
+
links = links_;
|
|
50
|
+
|
|
51
|
+
// std::cout << " START " << std::endl;
|
|
52
|
+
// for (int i = 0; i < nlinks; i += 1)
|
|
53
|
+
// {
|
|
54
|
+
// sc_r[i] = sc_r_[i];
|
|
55
|
+
// sc_e[i] = sc_e_[i];
|
|
56
|
+
// links[i] = links_[i];
|
|
57
|
+
// // std::cout << i << " HAHAHAH " << sc_r_[i] << " " << sc_e_[i] << std::endl;
|
|
58
|
+
// }
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
CUDA_DEVICE int get_window(double t);
|
|
62
|
+
CUDA_DEVICE Vec get_normal_unit_vec(double t, int link);
|
|
63
|
+
CUDA_DEVICE double interpolate(double t, double *in_arr, int window, int major_ndim, int major_ind, int ndim, int pos);
|
|
64
|
+
CUDA_DEVICE int get_link_ind(int link);
|
|
65
|
+
CUDA_DEVICE int get_sc_ind(int sc);
|
|
66
|
+
CUDA_DEVICE double get_light_travel_time(double t, int link);
|
|
67
|
+
CUDA_DEVICE Vec get_pos(double t, int sc);
|
|
68
|
+
CUDA_DEVICE void get_normal_unit_vec_ptr(Vec *vec, double t, int link);
|
|
69
|
+
CUDA_DEVICE void get_pos_ptr(Vec *vec, double t, int sc);
|
|
70
|
+
void get_light_travel_time_arr(double *ltt, double *t, int *link, int num);
|
|
71
|
+
void dealloc(){
|
|
72
|
+
// delete[] links;
|
|
73
|
+
// delete[] sc_r;
|
|
74
|
+
// delete[] sc_e;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
#endif // __DETECTOR_HPP__
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#ifndef __GLOBAL_HPP__
|
|
2
|
+
#define __GLOBAL_HPP__
|
|
3
|
+
|
|
4
|
+
#ifdef __CUDACC__
|
|
5
|
+
#define CUDA_KERNEL __global__
|
|
6
|
+
#define CUDA_DEVICE __device__
|
|
7
|
+
|
|
8
|
+
#else // __CUDACC__
|
|
9
|
+
#define CUDA_KERNEL
|
|
10
|
+
#define CUDA_DEVICE
|
|
11
|
+
|
|
12
|
+
#endif // __CUDACC__
|
|
13
|
+
|
|
14
|
+
#ifdef __CUDACC__
|
|
15
|
+
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
|
|
16
|
+
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
|
|
17
|
+
{
|
|
18
|
+
if (code != cudaSuccess)
|
|
19
|
+
{
|
|
20
|
+
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
|
|
21
|
+
if (abort) exit(code);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#endif // __GLOBAL_HPP__
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#include "stdio.h"
|
|
2
|
+
#include "global.hpp"
|
|
3
|
+
#include "Detector.hpp"
|
|
4
|
+
#include <iostream>
|
|
5
|
+
#include <stdexcept>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <sstream>
|
|
8
|
+
|
|
9
|
+
CUDA_DEVICE
|
|
10
|
+
int Orbits::get_window(double t)
|
|
11
|
+
{
|
|
12
|
+
int out = int(t / dt);
|
|
13
|
+
if ((out < 0) || (out >= N))
|
|
14
|
+
return -1;
|
|
15
|
+
else
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
CUDA_DEVICE
|
|
20
|
+
int Orbits::get_link_ind(int link)
|
|
21
|
+
{
|
|
22
|
+
if (link == 12)
|
|
23
|
+
return 0;
|
|
24
|
+
else if (link == 23)
|
|
25
|
+
return 1;
|
|
26
|
+
else if (link == 31)
|
|
27
|
+
return 2;
|
|
28
|
+
else if (link == 13)
|
|
29
|
+
return 3;
|
|
30
|
+
else if (link == 32)
|
|
31
|
+
return 4;
|
|
32
|
+
else if (link == 21)
|
|
33
|
+
return 5;
|
|
34
|
+
else
|
|
35
|
+
#ifdef __CUDACC__
|
|
36
|
+
printf("BAD link ind. Must be 12, 23, 31, 13, 32, 21.");
|
|
37
|
+
#else
|
|
38
|
+
throw std::invalid_argument("Bad link ind. Must be 12, 23, 31, 13, 32, 21.");
|
|
39
|
+
#endif // __CUDACC__
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
CUDA_DEVICE
|
|
44
|
+
int Orbits::get_sc_ind(int sc)
|
|
45
|
+
{
|
|
46
|
+
if (sc == 1)
|
|
47
|
+
return 0;
|
|
48
|
+
else if (sc == 2)
|
|
49
|
+
return 1;
|
|
50
|
+
else if (sc == 3)
|
|
51
|
+
return 2;
|
|
52
|
+
else
|
|
53
|
+
{
|
|
54
|
+
#ifdef __CUDACC__
|
|
55
|
+
printf("BAD sc ind. Must be 1,2,3. %d\n", sc);
|
|
56
|
+
#else
|
|
57
|
+
std::ostringstream oss;
|
|
58
|
+
int xxxx = 1;
|
|
59
|
+
oss << "Bad sc ind. Must be 1,2,3. Input sc is " << sc << " " << xxxx;
|
|
60
|
+
std::string var = oss.str();
|
|
61
|
+
throw std::invalid_argument(var);
|
|
62
|
+
#endif // __CUDACC__
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
CUDA_DEVICE
|
|
68
|
+
double Orbits::interpolate(double t, double *in_arr, int window, int major_ndim, int major_ind, int ndim, int pos)
|
|
69
|
+
{
|
|
70
|
+
double up = in_arr[((window + 1) * major_ndim + major_ind) * ndim + pos]; // down_ind * ndim + pos];
|
|
71
|
+
double down = in_arr[(window * major_ndim + major_ind) * ndim + pos];
|
|
72
|
+
|
|
73
|
+
// m *(x - x0) + y0
|
|
74
|
+
double fin = ((up - down) / dt) * (t - (dt * window)) + down;
|
|
75
|
+
// if ((ndim == 1))
|
|
76
|
+
// printf("%d %e %e %e %e \n", window, fin, down, up, (t - (dt * window)));
|
|
77
|
+
|
|
78
|
+
return fin;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
CUDA_DEVICE
|
|
82
|
+
void Orbits::get_normal_unit_vec_ptr(Vec *vec, double t, int link)
|
|
83
|
+
{
|
|
84
|
+
Vec _tmp = get_normal_unit_vec(t, link);
|
|
85
|
+
vec->x = _tmp.x;
|
|
86
|
+
vec->y = _tmp.y;
|
|
87
|
+
vec->z = _tmp.z;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
CUDA_DEVICE
|
|
91
|
+
Vec Orbits::get_normal_unit_vec(double t, int link)
|
|
92
|
+
{
|
|
93
|
+
int window = get_window(t);
|
|
94
|
+
if (window == -1)
|
|
95
|
+
{
|
|
96
|
+
// out of bounds
|
|
97
|
+
return Vec(0.0, 0.0, 0.0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
int link_ind = get_link_ind(link);
|
|
101
|
+
|
|
102
|
+
int up_ind = (window + 1) * nlinks + link_ind;
|
|
103
|
+
int down_ind = window * nlinks + link_ind;
|
|
104
|
+
|
|
105
|
+
// x (pos = 0) ndim = 3
|
|
106
|
+
double x_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 0);
|
|
107
|
+
// y (pos = 1)
|
|
108
|
+
double y_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 1);
|
|
109
|
+
// z (pos = 2)
|
|
110
|
+
double z_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 2);
|
|
111
|
+
|
|
112
|
+
return Vec(x_out, y_out, z_out);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
CUDA_DEVICE
|
|
116
|
+
double Orbits::get_light_travel_time(double t, int link)
|
|
117
|
+
{
|
|
118
|
+
int window = get_window(t);
|
|
119
|
+
if (window == -1)
|
|
120
|
+
{
|
|
121
|
+
// out of bounds
|
|
122
|
+
return 0.0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
int link_ind = get_link_ind(link);
|
|
126
|
+
if ((link_ind < 0) || (link_ind >= 6))
|
|
127
|
+
printf("BAD %d\n", link_ind);
|
|
128
|
+
int up_ind = (window + 1) * (nlinks + link_ind);
|
|
129
|
+
int down_ind = window * (nlinks + link_ind);
|
|
130
|
+
|
|
131
|
+
// x (pos = 0), ndim = 1
|
|
132
|
+
double ltt_out = interpolate(t, ltt_arr, window, nlinks, link_ind, 1, 0);
|
|
133
|
+
|
|
134
|
+
return ltt_out;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
CUDA_DEVICE
|
|
138
|
+
Vec Orbits::get_pos(double t, int sc)
|
|
139
|
+
{
|
|
140
|
+
int window = get_window(t);
|
|
141
|
+
if (window == -1)
|
|
142
|
+
{
|
|
143
|
+
// out of bounds
|
|
144
|
+
return Vec(0.0, 0.0, 0.0);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
int sc_ind = get_sc_ind(sc);
|
|
148
|
+
|
|
149
|
+
// x (pos = 0), ndim = 3
|
|
150
|
+
double x_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 0);
|
|
151
|
+
// y (pos = 1), ndim = 3
|
|
152
|
+
double y_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 1);
|
|
153
|
+
// z (pos = 2), ndim = 3
|
|
154
|
+
double z_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 2);
|
|
155
|
+
return Vec(x_out, y_out, z_out);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
CUDA_DEVICE
|
|
159
|
+
void Orbits::get_pos_ptr(Vec *vec, double t, int sc)
|
|
160
|
+
{
|
|
161
|
+
Vec _tmp = get_pos(t, sc);
|
|
162
|
+
vec->x = _tmp.x;
|
|
163
|
+
vec->y = _tmp.y;
|
|
164
|
+
vec->z = _tmp.z;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#define NUM_THREADS 64
|
|
168
|
+
|
|
169
|
+
CUDA_KERNEL
|
|
170
|
+
void get_light_travel_time_kernel(double *ltt, double *t, int *link, int num, Orbits& orbits)
|
|
171
|
+
{
|
|
172
|
+
int start, end, increment;
|
|
173
|
+
#ifdef __CUDACC__
|
|
174
|
+
start = blockIdx.x * blockDim.x + threadIdx.x;
|
|
175
|
+
end = num;
|
|
176
|
+
increment = gridDim.x * blockDim.x;
|
|
177
|
+
#else // __CUDACC__
|
|
178
|
+
start = 0;
|
|
179
|
+
end = num;
|
|
180
|
+
increment = 1;
|
|
181
|
+
#endif // __CUDACC__
|
|
182
|
+
|
|
183
|
+
for (int i = start; i < end; i += increment)
|
|
184
|
+
{
|
|
185
|
+
ltt[i] = orbits.get_light_travel_time(t[i], link[i]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void Orbits::get_light_travel_time_arr(double *ltt, double *t, int *link, int num)
|
|
190
|
+
{
|
|
191
|
+
#ifdef __CUDACC__
|
|
192
|
+
int num_blocks = std::ceil((num + NUM_THREADS - 1) / NUM_THREADS);
|
|
193
|
+
|
|
194
|
+
// copy self to GPU
|
|
195
|
+
Orbits *orbits_gpu;
|
|
196
|
+
gpuErrchk(cudaMalloc(&orbits_gpu, sizeof(Orbits)));
|
|
197
|
+
gpuErrchk(cudaMemcpy(orbits_gpu, this, sizeof(Orbits), cudaMemcpyHostToDevice));
|
|
198
|
+
|
|
199
|
+
get_light_travel_time_kernel<<<num_blocks, NUM_THREADS>>>(ltt, t, link, num, *orbits_gpu);
|
|
200
|
+
cudaDeviceSynchronize();
|
|
201
|
+
gpuErrchk(cudaGetLastError());
|
|
202
|
+
|
|
203
|
+
gpuErrchk(cudaFree(orbits_gpu));
|
|
204
|
+
|
|
205
|
+
#else // __CUDACC__
|
|
206
|
+
|
|
207
|
+
get_light_travel_time_kernel(ltt, t, link, num, *this);
|
|
208
|
+
|
|
209
|
+
#endif // __CUDACC__
|
|
210
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#include "stdio.h"
|
|
2
|
+
#include "global.hpp"
|
|
3
|
+
#include "Detector.hpp"
|
|
4
|
+
#include <iostream>
|
|
5
|
+
#include <stdexcept>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <sstream>
|
|
8
|
+
|
|
9
|
+
CUDA_DEVICE
|
|
10
|
+
int Orbits::get_window(double t)
|
|
11
|
+
{
|
|
12
|
+
int out = int(t / dt);
|
|
13
|
+
if ((out < 0) || (out >= N))
|
|
14
|
+
return -1;
|
|
15
|
+
else
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
CUDA_DEVICE
|
|
20
|
+
int Orbits::get_link_ind(int link)
|
|
21
|
+
{
|
|
22
|
+
if (link == 12)
|
|
23
|
+
return 0;
|
|
24
|
+
else if (link == 23)
|
|
25
|
+
return 1;
|
|
26
|
+
else if (link == 31)
|
|
27
|
+
return 2;
|
|
28
|
+
else if (link == 13)
|
|
29
|
+
return 3;
|
|
30
|
+
else if (link == 32)
|
|
31
|
+
return 4;
|
|
32
|
+
else if (link == 21)
|
|
33
|
+
return 5;
|
|
34
|
+
else
|
|
35
|
+
#ifdef __CUDACC__
|
|
36
|
+
printf("BAD link ind. Must be 12, 23, 31, 13, 32, 21.");
|
|
37
|
+
#else
|
|
38
|
+
throw std::invalid_argument("Bad link ind. Must be 12, 23, 31, 13, 32, 21.");
|
|
39
|
+
#endif // __CUDACC__
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
CUDA_DEVICE
|
|
44
|
+
int Orbits::get_sc_ind(int sc)
|
|
45
|
+
{
|
|
46
|
+
if (sc == 1)
|
|
47
|
+
return 0;
|
|
48
|
+
else if (sc == 2)
|
|
49
|
+
return 1;
|
|
50
|
+
else if (sc == 3)
|
|
51
|
+
return 2;
|
|
52
|
+
else
|
|
53
|
+
{
|
|
54
|
+
#ifdef __CUDACC__
|
|
55
|
+
printf("BAD sc ind. Must be 1,2,3. %d\n", sc);
|
|
56
|
+
#else
|
|
57
|
+
std::ostringstream oss;
|
|
58
|
+
int xxxx = 1;
|
|
59
|
+
oss << "Bad sc ind. Must be 1,2,3. Input sc is " << sc << " " << xxxx;
|
|
60
|
+
std::string var = oss.str();
|
|
61
|
+
throw std::invalid_argument(var);
|
|
62
|
+
#endif // __CUDACC__
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
CUDA_DEVICE
|
|
68
|
+
double Orbits::interpolate(double t, double *in_arr, int window, int major_ndim, int major_ind, int ndim, int pos)
|
|
69
|
+
{
|
|
70
|
+
double up = in_arr[((window + 1) * major_ndim + major_ind) * ndim + pos]; // down_ind * ndim + pos];
|
|
71
|
+
double down = in_arr[(window * major_ndim + major_ind) * ndim + pos];
|
|
72
|
+
|
|
73
|
+
// m *(x - x0) + y0
|
|
74
|
+
double fin = ((up - down) / dt) * (t - (dt * window)) + down;
|
|
75
|
+
// if ((ndim == 1))
|
|
76
|
+
// printf("%d %e %e %e %e \n", window, fin, down, up, (t - (dt * window)));
|
|
77
|
+
|
|
78
|
+
return fin;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
CUDA_DEVICE
|
|
82
|
+
void Orbits::get_normal_unit_vec_ptr(Vec *vec, double t, int link)
|
|
83
|
+
{
|
|
84
|
+
Vec _tmp = get_normal_unit_vec(t, link);
|
|
85
|
+
vec->x = _tmp.x;
|
|
86
|
+
vec->y = _tmp.y;
|
|
87
|
+
vec->z = _tmp.z;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
CUDA_DEVICE
|
|
91
|
+
Vec Orbits::get_normal_unit_vec(double t, int link)
|
|
92
|
+
{
|
|
93
|
+
int window = get_window(t);
|
|
94
|
+
if (window == -1)
|
|
95
|
+
{
|
|
96
|
+
// out of bounds
|
|
97
|
+
return Vec(0.0, 0.0, 0.0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
int link_ind = get_link_ind(link);
|
|
101
|
+
|
|
102
|
+
int up_ind = (window + 1) * nlinks + link_ind;
|
|
103
|
+
int down_ind = window * nlinks + link_ind;
|
|
104
|
+
|
|
105
|
+
// x (pos = 0) ndim = 3
|
|
106
|
+
double x_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 0);
|
|
107
|
+
// y (pos = 1)
|
|
108
|
+
double y_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 1);
|
|
109
|
+
// z (pos = 2)
|
|
110
|
+
double z_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 2);
|
|
111
|
+
|
|
112
|
+
return Vec(x_out, y_out, z_out);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
CUDA_DEVICE
|
|
116
|
+
double Orbits::get_light_travel_time(double t, int link)
|
|
117
|
+
{
|
|
118
|
+
int window = get_window(t);
|
|
119
|
+
if (window == -1)
|
|
120
|
+
{
|
|
121
|
+
// out of bounds
|
|
122
|
+
return 0.0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
int link_ind = get_link_ind(link);
|
|
126
|
+
if ((link_ind < 0) || (link_ind >= 6))
|
|
127
|
+
printf("BAD %d\n", link_ind);
|
|
128
|
+
int up_ind = (window + 1) * (nlinks + link_ind);
|
|
129
|
+
int down_ind = window * (nlinks + link_ind);
|
|
130
|
+
|
|
131
|
+
// x (pos = 0), ndim = 1
|
|
132
|
+
double ltt_out = interpolate(t, ltt_arr, window, nlinks, link_ind, 1, 0);
|
|
133
|
+
|
|
134
|
+
return ltt_out;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
CUDA_DEVICE
|
|
138
|
+
Vec Orbits::get_pos(double t, int sc)
|
|
139
|
+
{
|
|
140
|
+
int window = get_window(t);
|
|
141
|
+
if (window == -1)
|
|
142
|
+
{
|
|
143
|
+
// out of bounds
|
|
144
|
+
return Vec(0.0, 0.0, 0.0);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
int sc_ind = get_sc_ind(sc);
|
|
148
|
+
|
|
149
|
+
// x (pos = 0), ndim = 3
|
|
150
|
+
double x_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 0);
|
|
151
|
+
// y (pos = 1), ndim = 3
|
|
152
|
+
double y_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 1);
|
|
153
|
+
// z (pos = 2), ndim = 3
|
|
154
|
+
double z_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 2);
|
|
155
|
+
return Vec(x_out, y_out, z_out);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
CUDA_DEVICE
|
|
159
|
+
void Orbits::get_pos_ptr(Vec *vec, double t, int sc)
|
|
160
|
+
{
|
|
161
|
+
Vec _tmp = get_pos(t, sc);
|
|
162
|
+
vec->x = _tmp.x;
|
|
163
|
+
vec->y = _tmp.y;
|
|
164
|
+
vec->z = _tmp.z;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#define NUM_THREADS 64
|
|
168
|
+
|
|
169
|
+
CUDA_KERNEL
|
|
170
|
+
void get_light_travel_time_kernel(double *ltt, double *t, int *link, int num, Orbits& orbits)
|
|
171
|
+
{
|
|
172
|
+
int start, end, increment;
|
|
173
|
+
#ifdef __CUDACC__
|
|
174
|
+
start = blockIdx.x * blockDim.x + threadIdx.x;
|
|
175
|
+
end = num;
|
|
176
|
+
increment = gridDim.x * blockDim.x;
|
|
177
|
+
#else // __CUDACC__
|
|
178
|
+
start = 0;
|
|
179
|
+
end = num;
|
|
180
|
+
increment = 1;
|
|
181
|
+
#endif // __CUDACC__
|
|
182
|
+
|
|
183
|
+
for (int i = start; i < end; i += increment)
|
|
184
|
+
{
|
|
185
|
+
ltt[i] = orbits.get_light_travel_time(t[i], link[i]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void Orbits::get_light_travel_time_arr(double *ltt, double *t, int *link, int num)
|
|
190
|
+
{
|
|
191
|
+
#ifdef __CUDACC__
|
|
192
|
+
int num_blocks = std::ceil((num + NUM_THREADS - 1) / NUM_THREADS);
|
|
193
|
+
|
|
194
|
+
// copy self to GPU
|
|
195
|
+
Orbits *orbits_gpu;
|
|
196
|
+
gpuErrchk(cudaMalloc(&orbits_gpu, sizeof(Orbits)));
|
|
197
|
+
gpuErrchk(cudaMemcpy(orbits_gpu, this, sizeof(Orbits), cudaMemcpyHostToDevice));
|
|
198
|
+
|
|
199
|
+
get_light_travel_time_kernel<<<num_blocks, NUM_THREADS>>>(ltt, t, link, num, *orbits_gpu);
|
|
200
|
+
cudaDeviceSynchronize();
|
|
201
|
+
gpuErrchk(cudaGetLastError());
|
|
202
|
+
|
|
203
|
+
gpuErrchk(cudaFree(orbits_gpu));
|
|
204
|
+
|
|
205
|
+
#else // __CUDACC__
|
|
206
|
+
|
|
207
|
+
get_light_travel_time_kernel(ltt, t, link, num, *this);
|
|
208
|
+
|
|
209
|
+
#endif // __CUDACC__
|
|
210
|
+
}
|
|
File without changes
|