From 139723d3b8ea803417ed1c654302d26991bbdbd0 Mon Sep 17 00:00:00 2001 From: doinachiroiu Date: Wed, 26 Aug 2020 14:18:31 +0000 Subject: [PATCH] Added LICENSE & coding changes required --- oss-internship-2020/pffft/CMakeLists.txt | 16 +++- oss-internship-2020/pffft/Makefile | 15 --- oss-internship-2020/pffft/README.md | 29 ++++-- .../{pffft_library_notes.txt => README.txt} | 0 .../pffft/main_pffft_sandboxed.cc | 93 ++++++++++--------- .../pffft/{main_pffft.c => test_pffft.c} | 0 6 files changed, 85 insertions(+), 68 deletions(-) delete mode 100644 oss-internship-2020/pffft/Makefile rename oss-internship-2020/pffft/{pffft_library_notes.txt => README.txt} (100%) rename oss-internship-2020/pffft/{main_pffft.c => test_pffft.c} (100%) diff --git a/oss-internship-2020/pffft/CMakeLists.txt b/oss-internship-2020/pffft/CMakeLists.txt index 6c7e776..442bb74 100644 --- a/oss-internship-2020/pffft/CMakeLists.txt +++ b/oss-internship-2020/pffft/CMakeLists.txt @@ -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) project(pffft CXX C) @@ -13,7 +27,7 @@ add_library(pffft STATIC ) add_executable(pffft_main - main_pffft.c + test_pffft.c ) target_link_libraries(pffft_main PRIVATE diff --git a/oss-internship-2020/pffft/Makefile b/oss-internship-2020/pffft/Makefile deleted file mode 100644 index 326fd90..0000000 --- a/oss-internship-2020/pffft/Makefile +++ /dev/null @@ -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 \ No newline at end of file diff --git a/oss-internship-2020/pffft/README.md b/oss-internship-2020/pffft/README.md index 8b8b2bd..6cef583 100644 --- a/oss-internship-2020/pffft/README.md +++ b/oss-internship-2020/pffft/README.md @@ -1,14 +1,23 @@ # Sandboxing PFFFT library -Builder: CMake +Build System: CMake 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: `cd build`, then `./pffft_sandboxed` ### For debug: -`SAPI_VLOG_LEVEL=1 ./pffft_sandboxed --v=100 ---sandbox2_danger_danger_permit_all_and_log ` +display custom info with +`./pffft_sandboxed --logtostderr` ## ***About the project*** *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.* #### CMake observations resume: - * linking pffft and fftpack (which contains necessary functions for pffft) - * set math library +* linking pffft and fftpack (which contains necessary functions for pffft) +* set math library #### Sandboxed main observations resume: - * containing two testing parts (fft / pffft benchmarks) - * showing the performance of the transformations implies +* containing two testing parts (fft / pffft benchmarks) +* showing the performance of the transformations implies testing them through various FFT dimenstions. Variable N, the input length, will take specific values 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). - * output shows speed depending on the input length +* output shows speed depending on the input length ### 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 not OK Problem on initialising sapi::StatusOr 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" 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 memory, trying to write them on /tmp. diff --git a/oss-internship-2020/pffft/pffft_library_notes.txt b/oss-internship-2020/pffft/README.txt similarity index 100% rename from oss-internship-2020/pffft/pffft_library_notes.txt rename to oss-internship-2020/pffft/README.txt diff --git a/oss-internship-2020/pffft/main_pffft_sandboxed.cc b/oss-internship-2020/pffft/main_pffft_sandboxed.cc index 4da5abd..8b7e6d1 100644 --- a/oss-internship-2020/pffft/main_pffft_sandboxed.cc +++ b/oss-internship-2020/pffft/main_pffft_sandboxed.cc @@ -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 #include #include @@ -17,7 +31,7 @@ ABSL_DECLARE_FLAG(string, sandbox2_danger_danger_permit_all); ABSL_DECLARE_FLAG(string, sandbox2_danger_danger_permit_all_and_log); -class pffftSapiSandbox : public pffftSandbox { +class PffftSapiSandbox : public pffftSandbox { public: std::unique_ptr ModifyPolicy( 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[]) { - /* - * Initialize Google's logging library. - */ + + // Initialize Google's logging library. google::InitGoogleLogging(argv[0]); gflags::ParseCommandLineFlags(&argc, &argv, true); - /* - * Nvalues is a vector keeping the values by which iterates N, its value - * representing the input length. More concrete, N is the number of - * data points the caclulus is up to (determinating its accuracy). - * To show the performance of Fast-Fourier Transformations the program is - * testing for various values of N. - */ + + // Nvalues is a vector keeping the values by which iterates N, its value + // representing the input length. More concrete, N is the number of + // data points the caclulus is up to (determinating its accuracy). + // To show the performance of Fast-Fourier Transformations the program is + // testing for various values of N. 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}; + 16384, 32768}; int i; LOG(INFO) << "Initializing sandbox...\n"; - pffftSapiSandbox sandbox; + PffftSapiSandbox sandbox; absl::Status init_status = sandbox.Init(); LOG(INFO) << "Initialization: " << init_status.ToString().c_str() << "\n"; @@ -112,13 +124,9 @@ int main(int argc, char* argv[]) { 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; 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); ShowOutput("FFTPack", N, cplx, flops, t0, t1, max_iter_); } - - /* - * PFFFT benchmark - */ + + // PFFFT benchmark { sapi::StatusOr s = 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() << "\n"; - if (s.ok()) { - 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); + if (!s.ok()) { + printf("Sandbox failed.\n"); + return 1; } + 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"; } } diff --git a/oss-internship-2020/pffft/main_pffft.c b/oss-internship-2020/pffft/test_pffft.c similarity index 100% rename from oss-internship-2020/pffft/main_pffft.c rename to oss-internship-2020/pffft/test_pffft.c