Skylark (Sketching Library)  0.1
/var/lib/jenkins/jobs/Skylark/workspace/examples/hp_dense.cpp
Go to the documentation of this file.
00001 
00002 
00004 // #define ROOT_OUTPUT
00005 
00007 // #define LOCAL
00008 
00010 #define ROWWISE
00011 
00012 
00014 
00015 #include <boost/mpi.hpp>
00016 #include <elemental.hpp>
00017 #include <skylark.hpp>
00018 #include <iostream>
00019 
00020 
00023 typedef elem::Matrix<double>     dense_matrix_t;
00024 
00025 typedef elem::DistMatrix<double> dist_dense_matrix_t;
00026 typedef elem::DistMatrix<double, elem::VC, elem::STAR>
00027 dist_VC_STAR_dense_matrix_t;
00028 typedef elem::DistMatrix<double, elem::VR, elem::STAR>
00029 dist_VR_STAR_dense_matrix_t;
00030 typedef elem::DistMatrix<double, elem::STAR, elem::VC>
00031 dist_STAR_VC_dense_matrix_t;
00032 typedef elem::DistMatrix<double, elem::STAR, elem::VR>
00033 dist_STAR_VR_dense_matrix_t;
00034 
00035 typedef elem::DistMatrix<double, elem::CIRC, elem::CIRC>
00036 dist_CIRC_CIRC_dense_matrix_t;
00037 
00038 typedef elem::DistMatrix<double, elem::STAR, elem::STAR>
00039 dist_STAR_STAR_dense_matrix_t;
00040 
00041 
00042 /* Set the following 2 typedefs for various matrix-type tests */
00043 typedef dist_dense_matrix_t input_matrix_t;
00044 typedef dist_dense_matrix_t output_matrix_t;
00045 
00046 typedef skylark::sketch::JLT_t<input_matrix_t, output_matrix_t>
00047 sketch_transform_t;
00048 
00049 
00050 int main(int argc, char* argv[]) {
00051 
00053     boost::mpi::environment env(argc, argv);
00054     boost::mpi::communicator world;
00055 
00057     elem::Initialize (argc, argv);
00058 
00059     MPI_Comm mpi_world(world);
00060     elem::Grid grid(mpi_world);
00061 
00063     int height      = 20;
00064     int width       = 10;
00065     int sketch_size = 5;
00066 
00069 #ifdef LOCAL
00070     input_matrix_t A;
00071     elem::Uniform(A, height, width);
00072 #else
00073     dist_CIRC_CIRC_dense_matrix_t A_CIRC_CIRC(grid);
00074     input_matrix_t A(grid);
00075     elem::Uniform(A_CIRC_CIRC, height, width);
00076     A = A_CIRC_CIRC;
00077 #endif
00078 
00080     skylark::base::context_t context(0);
00081 
00082 #ifdef ROWWISE
00083 
00085     int size = width;
00087     output_matrix_t sketched_A(height, sketch_size);
00088     sketch_transform_t sketch_transform(size, sketch_size, context);
00089     sketch_transform.apply(A, sketched_A, skylark::sketch::rowwise_tag());
00090 
00091 #else
00092 
00094     int size = height;
00096     output_matrix_t sketched_A(sketch_size, width);
00097     sketch_transform_t sketch_transform(size, sketch_size, context);
00098     sketch_transform.apply(A, sketched_A, skylark::sketch::columnwise_tag());
00099 
00100 #endif
00101 
00102 #ifdef ROOT_OUTPUT
00103     if (world.rank() == 0) {
00104 #endif
00105         elem::Print(sketched_A, "sketched_A");
00106 #ifdef ROOT_OUTPUT
00107     }
00108 #endif
00109     elem::Finalize();
00110     return 0;
00111 }