mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Added LICENSE & coding changes required
This commit is contained in:
parent
8f21b0e931
commit
139723d3b8
|
@ -1,3 +1,17 @@
|
||||||
|
# Copyright 2020 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
project(pffft CXX C)
|
project(pffft CXX C)
|
||||||
|
@ -13,7 +27,7 @@ add_library(pffft STATIC
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(pffft_main
|
add_executable(pffft_main
|
||||||
main_pffft.c
|
test_pffft.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(pffft_main PRIVATE
|
target_link_libraries(pffft_main PRIVATE
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
CXXFLAGS ?= -std=c++17
|
|
||||||
|
|
||||||
pffft_main: test_pffft.o libpffft.a
|
|
||||||
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^
|
|
||||||
|
|
||||||
libpffft.a: pffft.o fftpack.o
|
|
||||||
ar rcs $@ $^
|
|
||||||
|
|
||||||
pffft.c: pffft.h
|
|
||||||
|
|
||||||
fftpack.c: fftpack.h
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -f *.o *.a pffft_main
|
|
|
@ -1,14 +1,23 @@
|
||||||
# Sandboxing PFFFT library
|
# Sandboxing PFFFT library
|
||||||
|
|
||||||
Builder: CMake
|
Build System: CMake
|
||||||
OS: Linux
|
OS: Linux
|
||||||
|
|
||||||
|
### Check out the PFFFT library & CMake set up
|
||||||
|
`mkdir -p build && cd build`
|
||||||
|
|
||||||
|
`git clone https://bitbucket.org/jpommier/pffft.git`
|
||||||
|
|
||||||
|
`cmake .. -G Ninja -DPFFFT_ROOT_DIR=$PWD`
|
||||||
|
|
||||||
|
`ninja`
|
||||||
|
|
||||||
### For testing:
|
### For testing:
|
||||||
`cd build`, then `./pffft_sandboxed`
|
`cd build`, then `./pffft_sandboxed`
|
||||||
|
|
||||||
### For debug:
|
### For debug:
|
||||||
`SAPI_VLOG_LEVEL=1 ./pffft_sandboxed --v=100
|
display custom info with
|
||||||
--sandbox2_danger_danger_permit_all_and_log <auxiliar file>`
|
`./pffft_sandboxed --logtostderr`
|
||||||
|
|
||||||
## ***About the project***
|
## ***About the project***
|
||||||
*PFFFT library is concerned with 1D Fast-Fourier Transformations finding a
|
*PFFFT library is concerned with 1D Fast-Fourier Transformations finding a
|
||||||
|
@ -38,22 +47,22 @@ it is taken into account while testing.
|
||||||
In the end, the performance of PFFFT library it is outlined by the output.*
|
In the end, the performance of PFFFT library it is outlined by the output.*
|
||||||
|
|
||||||
#### CMake observations resume:
|
#### CMake observations resume:
|
||||||
* linking pffft and fftpack (which contains necessary functions for pffft)
|
* linking pffft and fftpack (which contains necessary functions for pffft)
|
||||||
* set math library
|
* set math library
|
||||||
|
|
||||||
#### Sandboxed main observations resume:
|
#### Sandboxed main observations resume:
|
||||||
* containing two testing parts (fft / pffft benchmarks)
|
* containing two testing parts (fft / pffft benchmarks)
|
||||||
* showing the performance of the transformations implies
|
* showing the performance of the transformations implies
|
||||||
testing them through various FFT dimenstions.
|
testing them through various FFT dimenstions.
|
||||||
Variable N, the input length, will take specific values
|
Variable N, the input length, will take specific values
|
||||||
meaning the number of points to which it is set the calculus
|
meaning the number of points to which it is set the calculus
|
||||||
(more details of mathematical purpose of N - https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm).
|
(more details of mathematical purpose of N - https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm).
|
||||||
* output shows speed depending on the input length
|
* output shows speed depending on the input length
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Bugs history
|
### Bugs history
|
||||||
- [Solved] pffft benchmark bug: "Sandbox not active"
|
1. [Solved] pffft benchmark bug: "Sandbox not active"
|
||||||
N = 64, status OK, pffft_transform generates error
|
N = 64, status OK, pffft_transform generates error
|
||||||
N > 64, status not OK
|
N > 64, status not OK
|
||||||
Problem on initialising sapi::StatusOr<PFFFT_Setup *> s; the memory that stays
|
Problem on initialising sapi::StatusOr<PFFFT_Setup *> s; the memory that stays
|
||||||
|
@ -66,7 +75,7 @@ In the end, the performance of PFFFT library it is outlined by the output.*
|
||||||
Solution: using "sapi::v::RemotePtr" instead of "sapi::v::GenericPtr"
|
Solution: using "sapi::v::RemotePtr" instead of "sapi::v::GenericPtr"
|
||||||
to access the memory of object s
|
to access the memory of object s
|
||||||
|
|
||||||
- [Unresolved] compiling bug: "No space left on device"
|
2. [Unresolved] compiling bug: "No space left on device"
|
||||||
The building process creates some `embed` files that use lots of
|
The building process creates some `embed` files that use lots of
|
||||||
memory, trying to write them on /tmp.
|
memory, trying to write them on /tmp.
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
// Copyright 2020 Google LLC
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -17,7 +31,7 @@
|
||||||
ABSL_DECLARE_FLAG(string, sandbox2_danger_danger_permit_all);
|
ABSL_DECLARE_FLAG(string, sandbox2_danger_danger_permit_all);
|
||||||
ABSL_DECLARE_FLAG(string, sandbox2_danger_danger_permit_all_and_log);
|
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(
|
std::unique_ptr<sandbox2::Policy> ModifyPolicy(
|
||||||
sandbox2::PolicyBuilder*) override {
|
sandbox2::PolicyBuilder*) override {
|
||||||
|
@ -60,28 +74,26 @@ void ShowOutput(const char* name, int N, int cplx, float flops, float t0,
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
/*
|
|
||||||
* Initialize Google's logging library.
|
// Initialize Google's logging library.
|
||||||
*/
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
google::InitGoogleLogging(argv[0]);
|
||||||
|
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
/*
|
|
||||||
* Nvalues is a vector keeping the values by which iterates N, its value
|
// Nvalues is a vector keeping the values by which iterates N, its value
|
||||||
* representing the input length. More concrete, N is the number of
|
// representing the input length. More concrete, N is the number of
|
||||||
* data points the caclulus is up to (determinating its accuracy).
|
// data points the caclulus is up to (determinating its accuracy).
|
||||||
* To show the performance of Fast-Fourier Transformations the program is
|
// To show the performance of Fast-Fourier Transformations the program is
|
||||||
* testing for various values of N.
|
// testing for various values of N.
|
||||||
*/
|
|
||||||
int Nvalues[] = {64, 96, 128, 160, 192, 256,
|
int Nvalues[] = {64, 96, 128, 160, 192, 256,
|
||||||
384, 5 * 96, 512, 5 * 128, 3 * 256, 800,
|
384, 5 * 96, 512, 5 * 128, 3 * 256, 800,
|
||||||
1024, 2048, 2400, 4096, 8192, 9 * 1024,
|
1024, 2048, 2400, 4096, 8192, 9 * 1024,
|
||||||
16384, 32768, 256 * 1024, 1024 * 1024, -1};
|
16384, 32768};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
LOG(INFO) << "Initializing sandbox...\n";
|
LOG(INFO) << "Initializing sandbox...\n";
|
||||||
|
|
||||||
pffftSapiSandbox sandbox;
|
PffftSapiSandbox sandbox;
|
||||||
absl::Status init_status = sandbox.Init();
|
absl::Status init_status = sandbox.Init();
|
||||||
|
|
||||||
LOG(INFO) << "Initialization: " << init_status.ToString().c_str() << "\n";
|
LOG(INFO) << "Initialization: " << init_status.ToString().c_str() << "\n";
|
||||||
|
@ -112,13 +124,9 @@ int main(int argc, char* argv[]) {
|
||||||
X[k] = 0;
|
X[k] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// FFTPack benchmark
|
||||||
* FFTPack benchmark
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
/*
|
// SIMD_SZ == 4 (returning value of pffft_simd_size())
|
||||||
* SIMD_SZ == 4 (returning value of pffft_simd_size())
|
|
||||||
*/
|
|
||||||
int max_iter_ = max_iter / 4;
|
int max_iter_ = max_iter / 4;
|
||||||
|
|
||||||
if (max_iter_ == 0) max_iter_ = 1;
|
if (max_iter_ == 0) max_iter_ = 1;
|
||||||
|
@ -144,10 +152,8 @@ int main(int argc, char* argv[]) {
|
||||||
(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);
|
||||||
ShowOutput("FFTPack", N, cplx, flops, t0, t1, max_iter_);
|
ShowOutput("FFTPack", N, cplx, flops, t0, t1, max_iter_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// PFFFT benchmark
|
||||||
* PFFFT benchmark
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
@ -155,27 +161,30 @@ int main(int argc, char* argv[]) {
|
||||||
LOG(INFO) << "Setup status is: " << s.status().ToString().c_str()
|
LOG(INFO) << "Setup status is: " << s.status().ToString().c_str()
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
if (s.ok()) {
|
if (!s.ok()) {
|
||||||
sapi::v::RemotePtr s_reg(s.value());
|
printf("Sandbox failed.\n");
|
||||||
|
return 1;
|
||||||
t0 = UclockSec();
|
|
||||||
for (iter = 0; iter < max_iter; ++iter) {
|
|
||||||
api.pffft_transform(&s_reg, X_.PtrBoth(), Z_.PtrBoth(),
|
|
||||||
Y_.PtrBoth(), PFFFT_FORWARD)
|
|
||||||
.IgnoreError();
|
|
||||||
api.pffft_transform(&s_reg, X_.PtrBoth(), Z_.PtrBoth(),
|
|
||||||
Y_.PtrBoth(), PFFFT_FORWARD)
|
|
||||||
.IgnoreError();
|
|
||||||
}
|
|
||||||
|
|
||||||
t1 = UclockSec();
|
|
||||||
api.pffft_destroy_setup(&s_reg).IgnoreError();
|
|
||||||
|
|
||||||
flops =
|
|
||||||
(max_iter * 2) * ((cplx ? 5 : 2.5) * N * log((double)N) / M_LN2);
|
|
||||||
ShowOutput("PFFFT", N, cplx, flops, t0, t1, max_iter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sapi::v::RemotePtr s_reg(s.value());
|
||||||
|
|
||||||
|
t0 = UclockSec();
|
||||||
|
for (iter = 0; iter < max_iter; ++iter) {
|
||||||
|
api.pffft_transform(&s_reg, X_.PtrBoth(), Z_.PtrBoth(),
|
||||||
|
Y_.PtrBoth(), PFFFT_FORWARD)
|
||||||
|
.IgnoreError();
|
||||||
|
api.pffft_transform(&s_reg, X_.PtrBoth(), Z_.PtrBoth(),
|
||||||
|
Y_.PtrBoth(), PFFFT_FORWARD)
|
||||||
|
.IgnoreError();
|
||||||
|
}
|
||||||
|
|
||||||
|
t1 = UclockSec();
|
||||||
|
api.pffft_destroy_setup(&s_reg).IgnoreError();
|
||||||
|
|
||||||
|
flops =
|
||||||
|
(max_iter * 2) * ((cplx ? 5 : 2.5) * N * log((double)N) / M_LN2);
|
||||||
|
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