mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Coding style update
This commit is contained in:
parent
a2873ac099
commit
8f21b0e931
|
@ -1,15 +1,14 @@
|
||||||
#define GOOGLE_STRIP_LOG 1
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <math.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
#include "fftpack.h"
|
#include "fftpack.h"
|
||||||
#include "pffft_sapi.sapi.h"
|
#include "pffft_sapi.sapi.h"
|
||||||
#include "sandboxed_api/util/flag.h"
|
#include "sandboxed_api/util/flag.h"
|
||||||
|
@ -38,13 +37,11 @@ class pffftSapiSandbox : public pffftSandbox {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
double frand() { return rand() / (double)RAND_MAX; }
|
double UclockSec(void) { return (double)clock() / (double)CLOCKS_PER_SEC; }
|
||||||
|
|
||||||
double uclock_sec(void) { return (double)clock() / (double)CLOCKS_PER_SEC; }
|
|
||||||
|
|
||||||
int array_output_format = 0;
|
int array_output_format = 0;
|
||||||
|
|
||||||
void show_output(const char* name, int N, int cplx, float flops, float t0,
|
void ShowOutput(const char* name, int N, int cplx, float flops, float t0,
|
||||||
float t1, int max_iter) {
|
float t1, int max_iter) {
|
||||||
float mflops = flops / 1e6 / (t1 - t0 + 1e-16);
|
float mflops = flops / 1e6 / (t1 - t0 + 1e-16);
|
||||||
if (array_output_format) {
|
if (array_output_format) {
|
||||||
|
@ -85,39 +82,21 @@ int main(int argc, char* argv[]) {
|
||||||
LOG(INFO) << "Initializing sandbox...\n";
|
LOG(INFO) << "Initializing sandbox...\n";
|
||||||
|
|
||||||
pffftSapiSandbox sandbox;
|
pffftSapiSandbox sandbox;
|
||||||
sandbox.Init().IgnoreError();
|
absl::Status init_status = sandbox.Init();
|
||||||
|
|
||||||
LOG(INFO) << "Initialization: " << sandbox.Init().ToString().c_str() << "\n";
|
LOG(INFO) << "Initialization: " << init_status.ToString().c_str() << "\n";
|
||||||
|
|
||||||
pffftApi api(&sandbox);
|
pffftApi api(&sandbox);
|
||||||
|
int cplx = 0;
|
||||||
int N, cplx;
|
|
||||||
|
|
||||||
cplx = 0;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < 23; i++) {
|
for (int N : Nvalues) {
|
||||||
N = Nvalues[i];
|
const int Nfloat = N * (cplx ? 2 : 1);
|
||||||
|
|
||||||
int Nfloat = N * (cplx ? 2 : 1);
|
|
||||||
int Nbytes = Nfloat * sizeof(float);
|
int Nbytes = Nfloat * sizeof(float);
|
||||||
int pass;
|
|
||||||
|
|
||||||
float ref[Nbytes], in[Nbytes], out[Nbytes], tmp[Nbytes], tmp2[Nbytes];
|
float wrk[2 * Nfloat + 15 * sizeof(float)];
|
||||||
|
sapi::v::Array<float> wrk_(wrk, 2 * Nfloat + 15 * sizeof(float));
|
||||||
|
|
||||||
sapi::v::Array<float> ref_(ref, Nbytes);
|
|
||||||
sapi::v::Array<float> in_(in, Nbytes);
|
|
||||||
sapi::v::Array<float> out_(out, Nbytes);
|
|
||||||
sapi::v::Array<float> tmp_(tmp, Nbytes);
|
|
||||||
sapi::v::Array<float> tmp2_(tmp2, Nbytes);
|
|
||||||
|
|
||||||
float wrk[2 * Nbytes + 15 * sizeof(float)];
|
|
||||||
sapi::v::Array<float> wrk_(wrk, 2 * Nbytes + 15 * sizeof(float));
|
|
||||||
|
|
||||||
float ref_max = 0;
|
|
||||||
int k;
|
|
||||||
|
|
||||||
Nfloat = (cplx ? N * 2 : N);
|
|
||||||
float X[Nbytes], Y[Nbytes], Z[Nbytes];
|
float X[Nbytes], Y[Nbytes], Z[Nbytes];
|
||||||
sapi::v::Array<float> X_(X, Nbytes), Y_(Y, Nbytes), Z_(Z, Nbytes);
|
sapi::v::Array<float> X_(X, Nbytes), Y_(Y, Nbytes), Z_(Z, Nbytes);
|
||||||
|
|
||||||
|
@ -127,7 +106,7 @@ int main(int argc, char* argv[]) {
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
max_iter /= 4;
|
max_iter /= 4;
|
||||||
#endif
|
#endif
|
||||||
int iter;
|
int iter, k;
|
||||||
|
|
||||||
for (k = 0; k < Nfloat; ++k) {
|
for (k = 0; k < Nfloat; ++k) {
|
||||||
X[k] = 0;
|
X[k] = 0;
|
||||||
|
@ -148,7 +127,7 @@ int main(int argc, char* argv[]) {
|
||||||
} else {
|
} else {
|
||||||
api.rffti(N, wrk_.PtrBoth()).IgnoreError();
|
api.rffti(N, wrk_.PtrBoth()).IgnoreError();
|
||||||
}
|
}
|
||||||
t0 = uclock_sec();
|
t0 = UclockSec();
|
||||||
|
|
||||||
for (iter = 0; iter < max_iter_; ++iter) {
|
for (iter = 0; iter < max_iter_; ++iter) {
|
||||||
if (cplx) {
|
if (cplx) {
|
||||||
|
@ -159,11 +138,11 @@ int main(int argc, char* argv[]) {
|
||||||
api.rfftb(N, X_.PtrBoth(), wrk_.PtrBoth()).IgnoreError();
|
api.rfftb(N, X_.PtrBoth(), wrk_.PtrBoth()).IgnoreError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t1 = uclock_sec();
|
t1 = UclockSec();
|
||||||
|
|
||||||
flops =
|
flops =
|
||||||
(max_iter_ * 2) * ((cplx ? 5 : 2.5) * N * log((double)N) / M_LN2);
|
(max_iter_ * 2) * ((cplx ? 5 : 2.5) * N * log((double)N) / M_LN2);
|
||||||
show_output("FFTPack", N, cplx, flops, t0, t1, max_iter_);
|
ShowOutput("FFTPack", N, cplx, flops, t0, t1, max_iter_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -173,12 +152,13 @@ int main(int argc, char* argv[]) {
|
||||||
sapi::StatusOr<PFFFT_Setup*> s =
|
sapi::StatusOr<PFFFT_Setup*> s =
|
||||||
api.pffft_new_setup(N, cplx ? PFFFT_COMPLEX : PFFFT_REAL);
|
api.pffft_new_setup(N, cplx ? PFFFT_COMPLEX : PFFFT_REAL);
|
||||||
|
|
||||||
LOG(INFO) << "Setup status is: " << s.status().ToString().c_str() << "\n";
|
LOG(INFO) << "Setup status is: " << s.status().ToString().c_str()
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
sapi::v::RemotePtr s_reg(s.value());
|
sapi::v::RemotePtr s_reg(s.value());
|
||||||
|
|
||||||
t0 = uclock_sec();
|
t0 = UclockSec();
|
||||||
for (iter = 0; iter < max_iter; ++iter) {
|
for (iter = 0; iter < max_iter; ++iter) {
|
||||||
api.pffft_transform(&s_reg, X_.PtrBoth(), Z_.PtrBoth(),
|
api.pffft_transform(&s_reg, X_.PtrBoth(), Z_.PtrBoth(),
|
||||||
Y_.PtrBoth(), PFFFT_FORWARD)
|
Y_.PtrBoth(), PFFFT_FORWARD)
|
||||||
|
@ -188,12 +168,12 @@ int main(int argc, char* argv[]) {
|
||||||
.IgnoreError();
|
.IgnoreError();
|
||||||
}
|
}
|
||||||
|
|
||||||
t1 = uclock_sec();
|
t1 = UclockSec();
|
||||||
api.pffft_destroy_setup(&s_reg).IgnoreError();
|
api.pffft_destroy_setup(&s_reg).IgnoreError();
|
||||||
|
|
||||||
flops =
|
flops =
|
||||||
(max_iter * 2) * ((cplx ? 5 : 2.5) * N * log((double)N) / M_LN2);
|
(max_iter * 2) * ((cplx ? 5 : 2.5) * N * log((double)N) / M_LN2);
|
||||||
show_output("PFFFT", N, cplx, flops, t0, t1, max_iter);
|
ShowOutput("PFFFT", N, cplx, flops, t0, t1, max_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "N = " << N << " SUCCESSFULLY\n\n";
|
LOG(INFO) << "N = " << N << " SUCCESSFULLY\n\n";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user