Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
rkube committed Mar 3, 2020
2 parents 5ec14ad + 24ceaf1 commit 9f1af79
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 3 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ Generators, processors, and backends read their configuration from a shared json
implementations don't have a common syntax yet.

Here is a diagram of the framework:

(https://github.com/rkube/delta/blob/master/Streaming%20analysis%20architecture.png)
![Delta Architecture](https://github.com/rkube/delta/blob/master/doc/delta_architecture.png "Delta Architecture")

# Implemented Workflows

Expand Down Expand Up @@ -195,4 +194,4 @@ for change in cursor():
print("")
```

Visualizers are implemented separately, see f.ex. the web-based
Visualizers are implemented separately, see f.ex. the web-based dashboard: [https://github.com/rkube/dashboard_v2](https://github.com/rkube/dashboard_v2)
111 changes: 111 additions & 0 deletions analysis/lib/kernels.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include <stdio.h>
#include <complex.h>
#include <math.h>

#include "kernels.h"


void kernel_coherence(double complex* fft_data,
double* result,
size_t* ch1_idx_arr,
size_t* ch2_idx_arr,
size_t num_idx,
size_t num_fft,
size_t num_bins)
{
double complex tmp = 0.0;
double complex Pxx = 0.0;
double complex Pyy = 0.0;
size_t idx3_ch1;
size_t idx3_ch2;

#pragma omp parallel for
for(size_t cidx = 0; cidx < num_idx; cidx++)
{
for(size_t nn = 0; nn < num_fft; nn++)
{
tmp = 0.0 + 0.0 * I;
#pragma omp simd
for(size_t bb = 0; bb < num_bins; bb++)
{
idx3_ch1 = bb + num_bins * (nn + num_fft * ch1_idx_arr[cidx]);
idx3_ch2 = bb + num_bins * (nn + num_fft * ch2_idx_arr[cidx]);

Pxx = fft_data[idx3_ch1] * conj(fft_data[idx3_ch1]);
Pyy = fft_data[idx3_ch2] * conj(fft_data[idx3_ch2]);
tmp = tmp + fft_data[idx3_ch1] * conj(fft_data[idx3_ch2]) / csqrt(Pxx * Pyy);
}
result[nn + num_fft * cidx] = creal(cabs(tmp)) / (double) num_bins;
}
}
}


void kernel_crossphase(double complex* fft_data,
double* result,
size_t* ch1_idx_arr,
size_t* ch2_idx_arr,
size_t num_idx,
size_t num_fft,
size_t num_bins)
{
double complex tmp = 0.0;
double complex Pxx = 0.0;
double complex Pyy = 0.0;
size_t idx3_ch1;
size_t idx3_ch2;

#pragma omp parallel for
for(size_t cidx = 0; cidx < num_idx; cidx++)
{
for(size_t nn = 0; nn < num_fft; nn++)
{
tmp = 0.0 + 0.0 * I;
#pragma omp simd
for(size_t bb = 0; bb < num_bins; bb++)
{

idx3_ch1 = bb + num_bins * (nn + num_fft * ch1_idx_arr[cidx]);
idx3_ch2 = bb + num_bins * (nn + num_fft * ch2_idx_arr[cidx]);
tmp = tmp + fft_data[idx3_ch1] * conj(fft_data[idx3_ch2]);
}
tmp = tmp / (double) num_bins;
result[nn + num_fft * cidx] = atan2(cimag(tmp), creal(tmp));
}
}
}


void kernel_crosspower(double complex* fft_data,
double* result,
size_t* ch1_idx_arr,
size_t* ch2_idx_arr,
size_t num_idx,
size_t num_fft,
size_t num_bins)
{
double complex tmp = 0.0;
double complex Pxx = 0.0;
double complex Pyy = 0.0;
size_t idx3_ch1;
size_t idx3_ch2;

#pragma omp parallel for
for(size_t cidx = 0; cidx < num_idx; cidx++)
{
for(size_t nn = 0; nn < num_fft; nn++)
{
tmp = 0.0 + 0.0 * I;
#pragma omp simd
for(size_t bb = 0; bb < num_bins; bb++)
{

idx3_ch1 = bb + num_bins * (nn + num_fft * ch1_idx_arr[cidx]);
idx3_ch2 = bb + num_bins * (nn + num_fft * ch2_idx_arr[cidx]);
tmp = tmp + fft_data[idx3_ch1] * conj(fft_data[idx3_ch2]);
}

result[nn + num_fft * cidx] = cabs(tmp) / (double) num_bins;
}
}
}

0 comments on commit 9f1af79

Please sign in to comment.