mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Coding style adaptation
This commit is contained in:
parent
deb8869bb6
commit
50921e222d
|
@ -1,14 +1,13 @@
|
||||||
#include "fftpack.h"
|
#include <assert.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syscall.h>
|
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
|
#include <syscall.h>
|
||||||
|
#include <time.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"
|
||||||
#include "sandboxed_api/vars.h"
|
#include "sandboxed_api/vars.h"
|
||||||
|
@ -18,7 +17,8 @@ ABSL_DECLARE_FLAG(string, sandbox2_danger_danger_permit_all_and_log);
|
||||||
|
|
||||||
class pffftSapiSandbox : public pffftSandbox {
|
class pffftSapiSandbox : public pffftSandbox {
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<sandbox2::Policy> ModifyPolicy(sandbox2::PolicyBuilder*) override {
|
std::unique_ptr<sandbox2::Policy> ModifyPolicy(
|
||||||
|
sandbox2::PolicyBuilder*) override {
|
||||||
return sandbox2::PolicyBuilder()
|
return sandbox2::PolicyBuilder()
|
||||||
.AllowStaticStartup()
|
.AllowStaticStartup()
|
||||||
.AllowOpen()
|
.AllowOpen()
|
||||||
|
@ -36,25 +36,25 @@ class pffftSapiSandbox : public pffftSandbox {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
double frand() {
|
double frand() { return rand() / (double)RAND_MAX; }
|
||||||
return rand()/(double)RAND_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
double uclock_sec(void) {
|
double uclock_sec(void) { return (double)clock() / (double)CLOCKS_PER_SEC; }
|
||||||
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, float t1, int max_iter) {
|
void show_output(const char* name, int N, int cplx, float flops, float t0,
|
||||||
float mflops = flops/1e6/(t1 - t0 + 1e-16);
|
float t1, int max_iter) {
|
||||||
|
float mflops = flops / 1e6 / (t1 - t0 + 1e-16);
|
||||||
if (array_output_format) {
|
if (array_output_format) {
|
||||||
if (flops != -1) {
|
if (flops != -1) {
|
||||||
printf("|%9.0f ", mflops);
|
printf("|%9.0f ", mflops);
|
||||||
} else printf("| n/a ");
|
} else
|
||||||
|
printf("| n/a ");
|
||||||
} else {
|
} else {
|
||||||
if (flops != -1) {
|
if (flops != -1) {
|
||||||
printf("N=%5d, %s %16s : %6.0f MFlops [t=%6.0f ns, %d runs]\n", N, (cplx?"CPLX":"REAL"), name, mflops, (t1-t0)/2/max_iter * 1e9, max_iter);
|
printf("N=%5d, %s %16s : %6.0f MFlops [t=%6.0f ns, %d runs]\n", N,
|
||||||
|
(cplx ? "CPLX" : "REAL"), name, mflops,
|
||||||
|
(t1 - t0) / 2 / max_iter * 1e9, max_iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -62,12 +62,16 @@ void show_output(const char *name, int N, int cplx, float flops, float t0, float
|
||||||
|
|
||||||
/*
|
/*
|
||||||
For debug:
|
For debug:
|
||||||
SAPI_VLOG_LEVEL=1 ./pffft_sandboxed --v=100 --sandbox2_danger_danger_permit_all_and_log my_aux_file
|
SAPI_VLOG_LEVEL=1 ./pffft_sandboxed --v=100
|
||||||
|
--sandbox2_danger_danger_permit_all_and_log my_aux_file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
int Nvalues[] = { 64, 96, 128, 160, 192, 256, 384, 5*96, 512, 5*128, 3*256, 800, 1024, 2048, 2400, 4096, 8192, 9*1024, 16384, 32768, 256*1024, 1024*1024, -1 };
|
int Nvalues[] = {64, 96, 128, 160, 192, 256,
|
||||||
|
384, 5 * 96, 512, 5 * 128, 3 * 256, 800,
|
||||||
|
1024, 2048, 2400, 4096, 8192, 9 * 1024,
|
||||||
|
16384, 32768, 256 * 1024, 1024 * 1024, -1};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
printf("initializing sandbox...\n");
|
printf("initializing sandbox...\n");
|
||||||
|
@ -108,10 +112,10 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
double t0, t1, flops;
|
double t0, t1, flops;
|
||||||
|
|
||||||
int max_iter = 5120000/N*4;
|
int max_iter = 5120000 / N * 4;
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
max_iter /= 4;
|
max_iter /= 4;
|
||||||
#endif
|
#endif
|
||||||
int iter;
|
int iter;
|
||||||
|
|
||||||
for (k = 0; k < Nfloat; ++k) {
|
for (k = 0; k < Nfloat; ++k) {
|
||||||
|
@ -120,7 +124,8 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
// FFTPack benchmark
|
// FFTPack benchmark
|
||||||
{
|
{
|
||||||
int max_iter_ = max_iter/4; // SIMD_SZ == 4 (returning value of pffft_simd_size())
|
int max_iter_ =
|
||||||
|
max_iter / 4; // SIMD_SZ == 4 (returning value of pffft_simd_size())
|
||||||
if (max_iter_ == 0) max_iter_ = 1;
|
if (max_iter_ == 0) max_iter_ = 1;
|
||||||
if (cplx) {
|
if (cplx) {
|
||||||
api.cffti(N, wrk_.PtrBoth()).IgnoreError();
|
api.cffti(N, wrk_.PtrBoth()).IgnoreError();
|
||||||
|
@ -142,7 +147,6 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
flops = (max_iter_ * 2) * ((cplx ? 5 : 2.5) * N * log((double)N) / M_LN2);
|
flops = (max_iter_ * 2) * ((cplx ? 5 : 2.5) * N * log((double)N) / M_LN2);
|
||||||
show_output("FFTPack", N, cplx, flops, t0, t1, max_iter_);
|
show_output("FFTPack", N, cplx, flops, t0, t1, max_iter_);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user