Stxxl  1.4.0
utils/pq_param.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *  utils/pq_param.cpp
00003  *
00004  *  Part of the STXXL. See http://stxxl.sourceforge.net
00005  *
00006  *  Copyright (C) 2003 Roman Dementiev <dementiev@mpi-sb.mpg.de>
00007  *
00008  *  Distributed under the Boost Software License, Version 1.0.
00009  *  (See accompanying file LICENSE_1_0.txt or copy at
00010  *  http://www.boost.org/LICENSE_1_0.txt)
00011  **************************************************************************/
00012 
00013 #include <iostream>
00014 #include <cmath>
00015 #include <stxxl/types>
00016 
00017 typedef stxxl::int64 int64;
00018 
00019 int64 D(int64 m, int64 k, int64 MaxS, int64 E, int64 B)
00020 {
00021     return (m * m / 4 - (MaxS * E / (k - m)) / B);
00022 }
00023 
00024 using std::cout;
00025 using std::endl;
00026 
00027 int main()
00028 {
00029     int64 IntM = 128 * 1024 * 1024;
00030     int64 E = 4;
00031     int64 B = 8 * 1024 * 1024;
00032     //int64 Bstep = 128 * 1024;
00033     int64 MaxS = (int64(128) * int64(1024 * 1024 * 1024)) / E;
00034 
00035     for ( ; B > 4096; B = B / 2)
00036     {
00037         int64 m = 1;
00038         int64 k = IntM / B;
00039         for ( ; m < k; ++m)
00040         {
00041             int64 c = (k - m);
00042             //if( D(m,k,MaxS,E,B)>= 0 && c > 10)
00043             if ((k - m) * m * m * B / (E * 4) >= MaxS)
00044             {
00045                 cout << (k - m) * (m) * (m * B / (E * 4)) << endl;
00046                 cout << MaxS << endl;
00047                 cout << "D: " << D(m, k, MaxS, E, B) << endl;
00048                 cout << "B: " << B << endl;
00049                 cout << "c: " << c << endl;
00050                 cout << "k: " << k << endl;
00051                 int64 Ae = m / 2;
00052                 int64 Ae1 = Ae + int64(sqrt((double)D(m, k, MaxS, E, B)));
00053                 int64 Ae2 = Ae - int64(sqrt((double)D(m, k, MaxS, E, B)));
00054                 int64 x = c * B / E;
00055                 int64 N = x / 4096;
00056                 cout << "Ae : " << Ae << endl;
00057                 cout << "Ae1: " << Ae1 << endl;
00058                 cout << "Ae2: " << Ae2 << endl;
00059                 cout << "minAe :" << (MaxS / (x * Ae)) << endl;
00060                 cout << "x  : " << x << endl;
00061                 cout << "N  : " << N << endl;
00062                 int64 Cons = x * E + B * (m / 2) + MaxS * B / (x * (m / 2));
00063                 cout << "COns : " << Cons << endl;
00064                 return 0;
00065             }
00066         }
00067     }
00068 
00069     cout << "No valid parameter found" << endl;
00070 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines