lisaanalysistools 1.0.5__tar.gz → 1.0.7__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.

Potentially problematic release.


This version of lisaanalysistools might be problematic. Click here for more details.

Files changed (60) hide show
  1. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7/LISAanalysistools.egg-info}/PKG-INFO +12 -6
  2. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/LISAanalysistools.egg-info/SOURCES.txt +16 -4
  3. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/LISAanalysistools.egg-info/top_level.txt +0 -1
  4. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/MANIFEST.in +1 -1
  5. {lisaanalysistools-1.0.5/LISAanalysistools.egg-info → lisaanalysistools-1.0.7}/PKG-INFO +12 -6
  6. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/README.md +10 -4
  7. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/_version.py +1 -1
  8. lisaanalysistools-1.0.7/lisatools/cutils/include/Detector.hpp +78 -0
  9. lisaanalysistools-1.0.7/lisatools/cutils/include/global.hpp +28 -0
  10. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7/lisatools/cutils}/src/Detector.cpp +55 -0
  11. lisaanalysistools-1.0.7/lisatools/cutils/src/Detector.cu +210 -0
  12. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7/lisatools/cutils}/src/pycppdetector.cpp +1910 -1301
  13. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7/lisatools/cutils}/src/pycppdetector.pyx +16 -0
  14. lisaanalysistools-1.0.7/lisatools/cutils/src/pycppdetector_cpu.cpp +15888 -0
  15. lisaanalysistools-1.0.7/lisatools/cutils/src/pycppdetector_cpu.pyx +199 -0
  16. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/datacontainer.py +24 -6
  17. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/detector.py +59 -14
  18. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/diagnostic.py +4 -4
  19. lisaanalysistools-1.0.7/lisatools/sampling/moves/__init__.py +0 -0
  20. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/sensitivity.py +1 -0
  21. lisaanalysistools-1.0.7/lisatools/sources/__init__.py +0 -0
  22. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/sources/emri/tdiwaveform.py +3 -2
  23. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/stochastic.py +2 -1
  24. lisaanalysistools-1.0.7/lisatools/utils/__init__.py +0 -0
  25. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/utils/utility.py +2 -3
  26. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/pyproject.toml +1 -1
  27. lisaanalysistools-1.0.7/requirements-sources.txt +4 -0
  28. lisaanalysistools-1.0.7/requirements.txt +8 -0
  29. lisaanalysistools-1.0.7/scripts/prebuild.py +20 -0
  30. lisaanalysistools-1.0.7/scripts/space_2050_install.sh +113 -0
  31. lisaanalysistools-1.0.7/setup.py +234 -0
  32. lisaanalysistools-1.0.7/src/pycppdetector.cpp +16790 -0
  33. lisaanalysistools-1.0.5/include/Detector.hpp +0 -75
  34. lisaanalysistools-1.0.5/setup.py +0 -92
  35. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/CHANGELOG +0 -0
  36. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/LICENSE +0 -0
  37. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/LISAanalysistools.egg-info/dependency_links.txt +0 -0
  38. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/LISAanalysistools.egg-info/not-zip-safe +0 -0
  39. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/Makefile +0 -0
  40. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/__init__.py +0 -0
  41. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/analysiscontainer.py +0 -0
  42. {lisaanalysistools-1.0.5/lisatools/sampling → lisaanalysistools-1.0.7/lisatools/cutils}/__init__.py +0 -0
  43. {lisaanalysistools-1.0.5/lisatools/sampling/moves → lisaanalysistools-1.0.7/lisatools/cutils/include}/__init__.py +0 -0
  44. {lisaanalysistools-1.0.5/lisatools/sources → lisaanalysistools-1.0.7/lisatools/cutils/src}/__init__.py +0 -0
  45. {lisaanalysistools-1.0.5/lisatools/utils → lisaanalysistools-1.0.7/lisatools/sampling}/__init__.py +0 -0
  46. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/sampling/likelihood.py +0 -0
  47. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/sampling/moves/skymodehop.py +0 -0
  48. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/sampling/prior.py +0 -0
  49. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/sampling/stopping.py +0 -0
  50. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/sampling/utility.py +0 -0
  51. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/sources/emri/__init__.py +0 -0
  52. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/utils/constants.py +0 -0
  53. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/lisatools/utils/pointeradjust.py +0 -0
  54. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/scripts/data_download.py +0 -0
  55. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/scripts/generate-changelog.bash +0 -0
  56. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/scripts/install-hooks.bash +0 -0
  57. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/scripts/post-commit.bash +0 -0
  58. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/scripts/run-tests.bash +0 -0
  59. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/scripts/to_conda.bash +0 -0
  60. {lisaanalysistools-1.0.5 → lisaanalysistools-1.0.7}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lisaanalysistools
3
- Version: 1.0.5
4
- Home-page: https://github.com/mikekatz04/lisa-on-gpu
3
+ Version: 1.0.7
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. If you do this, you will also need # TODO: add.
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/BlackHolePerturbationToolkit/FastEMRIWaveforms/tags).
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.5
69
+ Current Version: 1.0.7
64
70
 
65
71
  ## Authors/Developers
66
72
 
@@ -4,12 +4,13 @@ MANIFEST.in
4
4
  Makefile
5
5
  README.md
6
6
  pyproject.toml
7
+ requirements-sources.txt
8
+ requirements.txt
7
9
  setup.py
8
10
  LISAanalysistools.egg-info/PKG-INFO
9
11
  LISAanalysistools.egg-info/SOURCES.txt
10
12
  LISAanalysistools.egg-info/dependency_links.txt
11
13
  LISAanalysistools.egg-info/top_level.txt
12
- include/Detector.hpp
13
14
  lisaanalysistools.egg-info/PKG-INFO
14
15
  lisaanalysistools.egg-info/SOURCES.txt
15
16
  lisaanalysistools.egg-info/dependency_links.txt
@@ -23,6 +24,17 @@ lisatools/detector.py
23
24
  lisatools/diagnostic.py
24
25
  lisatools/sensitivity.py
25
26
  lisatools/stochastic.py
27
+ lisatools/cutils/__init__.py
28
+ lisatools/cutils/include/Detector.hpp
29
+ lisatools/cutils/include/__init__.py
30
+ lisatools/cutils/include/global.hpp
31
+ lisatools/cutils/src/Detector.cpp
32
+ lisatools/cutils/src/Detector.cu
33
+ lisatools/cutils/src/__init__.py
34
+ lisatools/cutils/src/pycppdetector.cpp
35
+ lisatools/cutils/src/pycppdetector.pyx
36
+ lisatools/cutils/src/pycppdetector_cpu.cpp
37
+ lisatools/cutils/src/pycppdetector_cpu.pyx
26
38
  lisatools/sampling/__init__.py
27
39
  lisatools/sampling/likelihood.py
28
40
  lisatools/sampling/prior.py
@@ -41,8 +53,8 @@ scripts/data_download.py
41
53
  scripts/generate-changelog.bash
42
54
  scripts/install-hooks.bash
43
55
  scripts/post-commit.bash
56
+ scripts/prebuild.py
44
57
  scripts/run-tests.bash
58
+ scripts/space_2050_install.sh
45
59
  scripts/to_conda.bash
46
- src/Detector.cpp
47
- src/pycppdetector.cpp
48
- src/pycppdetector.pyx
60
+ src/pycppdetector.cpp
@@ -27,4 +27,4 @@ recursive-include scripts *
27
27
  include tutorial/*.ipynb
28
28
 
29
29
  # Include include files
30
- include include/*
30
+ # include include/*
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lisaanalysistools
3
- Version: 1.0.5
4
- Home-page: https://github.com/mikekatz04/lisa-on-gpu
3
+ Version: 1.0.7
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. If you do this, you will also need # TODO: add.
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/BlackHolePerturbationToolkit/FastEMRIWaveforms/tags).
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.5
69
+ Current Version: 1.0.7
64
70
 
65
71
  ## Authors/Developers
66
72
 
@@ -19,7 +19,9 @@ pip install lisaanalysistools
19
19
 
20
20
  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.
21
21
 
22
- 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.
22
+ 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.
23
+
24
+ For an easy full install, follow these instructions.
23
25
 
24
26
  First, clone the repo and `cd` to the `LATW` directory.:
25
27
  ```
@@ -33,7 +35,11 @@ bash install.sh
33
35
  ```
34
36
  Running `bash install.sh -h` will also give you some basic install options.
35
37
 
36
- If you want more flexibility, you can install each package given above separately. If you do this, you will also need # TODO: add.
38
+ If you want more flexibility, you can install each package given above separately.
39
+
40
+ 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.
41
+
42
+ 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.
37
43
 
38
44
  ## Contributing
39
45
 
@@ -41,9 +47,9 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduc
41
47
 
42
48
  ## Versioning
43
49
 
44
- We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/BlackHolePerturbationToolkit/FastEMRIWaveforms/tags).
50
+ We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/mikekatz04/LISAanalysistools/tags).
45
51
 
46
- Current Version: 1.0.5
52
+ Current Version: 1.0.7
47
53
 
48
54
  ## Authors/Developers
49
55
 
@@ -1,4 +1,4 @@
1
- __version__ = '1.0.5'
1
+ __version__ = '1.0.7'
2
2
  __copyright__ = "Michael L. Katz 2024"
3
3
  __name__ = "lisaanalysistools"
4
4
  __author__ = "Michael L. Katz"
@@ -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__
@@ -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__
@@ -1,10 +1,12 @@
1
1
  #include "stdio.h"
2
+ #include "global.hpp"
2
3
  #include "Detector.hpp"
3
4
  #include <iostream>
4
5
  #include <stdexcept>
5
6
  #include <string>
6
7
  #include <sstream>
7
8
 
9
+ CUDA_DEVICE
8
10
  int Orbits::get_window(double t)
9
11
  {
10
12
  int out = int(t / dt);
@@ -14,6 +16,7 @@ int Orbits::get_window(double t)
14
16
  return out;
15
17
  }
16
18
 
19
+ CUDA_DEVICE
17
20
  int Orbits::get_link_ind(int link)
18
21
  {
19
22
  if (link == 12)
@@ -37,6 +40,7 @@ int Orbits::get_link_ind(int link)
37
40
  return -1;
38
41
  }
39
42
 
43
+ CUDA_DEVICE
40
44
  int Orbits::get_sc_ind(int sc)
41
45
  {
42
46
  if (sc == 1)
@@ -60,6 +64,7 @@ int Orbits::get_sc_ind(int sc)
60
64
  return 0;
61
65
  }
62
66
 
67
+ CUDA_DEVICE
63
68
  double Orbits::interpolate(double t, double *in_arr, int window, int major_ndim, int major_ind, int ndim, int pos)
64
69
  {
65
70
  double up = in_arr[((window + 1) * major_ndim + major_ind) * ndim + pos]; // down_ind * ndim + pos];
@@ -73,6 +78,7 @@ double Orbits::interpolate(double t, double *in_arr, int window, int major_ndim,
73
78
  return fin;
74
79
  }
75
80
 
81
+ CUDA_DEVICE
76
82
  void Orbits::get_normal_unit_vec_ptr(Vec *vec, double t, int link)
77
83
  {
78
84
  Vec _tmp = get_normal_unit_vec(t, link);
@@ -81,6 +87,7 @@ void Orbits::get_normal_unit_vec_ptr(Vec *vec, double t, int link)
81
87
  vec->z = _tmp.z;
82
88
  }
83
89
 
90
+ CUDA_DEVICE
84
91
  Vec Orbits::get_normal_unit_vec(double t, int link)
85
92
  {
86
93
  int window = get_window(t);
@@ -105,6 +112,7 @@ Vec Orbits::get_normal_unit_vec(double t, int link)
105
112
  return Vec(x_out, y_out, z_out);
106
113
  }
107
114
 
115
+ CUDA_DEVICE
108
116
  double Orbits::get_light_travel_time(double t, int link)
109
117
  {
110
118
  int window = get_window(t);
@@ -126,6 +134,7 @@ double Orbits::get_light_travel_time(double t, int link)
126
134
  return ltt_out;
127
135
  }
128
136
 
137
+ CUDA_DEVICE
129
138
  Vec Orbits::get_pos(double t, int sc)
130
139
  {
131
140
  int window = get_window(t);
@@ -146,10 +155,56 @@ Vec Orbits::get_pos(double t, int sc)
146
155
  return Vec(x_out, y_out, z_out);
147
156
  }
148
157
 
158
+ CUDA_DEVICE
149
159
  void Orbits::get_pos_ptr(Vec *vec, double t, int sc)
150
160
  {
151
161
  Vec _tmp = get_pos(t, sc);
152
162
  vec->x = _tmp.x;
153
163
  vec->y = _tmp.y;
154
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__
155
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
+ }