May 11, 2017

Build / Debug c/c++ synchronized projects behind ssh remote gateway via Eclipse ( Client-Server type)

I found tunneling a remote gateway very slow and figured out a better way to work with synchronized projects. {This is very easy  via ssh with -xy enabled on server and tunnel through x-window system (Xming For windows)}.
Login as
ssh -XY username@xx.yy.org in both the gateway and the machine.


I couldn't find a way to use Netbeans for remote C/C++/Fortran projects with a gateway yet. Below method is using  Eclipse for linux or windows.


Files you have  edit

Remote:

 Your bashrc script or bash_profile - This  is hidden in /home/username
                                  Do : ll  -a  then vi  bash_profile
 Remote development by synchronized projects uses git. You need git installed on your remote machine. So we need to add the lines below to the end of your bash_profile script.


module load git
git config --global pack.windowMemory "100m"
git config --global pack.SizeLimit "100m"
git config --global pack.threads "1"

Local:
Eclipse seem to support Git inherently. So we only need to install eclipse  neon for parallel C/C++ development


Eclipse settings --------------------------------------------------------------------------------

Goto Window>Preferences>Add


Add your gateway as the first connection. Give the Host name and your username. ( equivalent to , ssh username@host.org etc). Connection name could be anything you want. Here I set it as 'xcams gateway'.Choose password based connection, if you want to use a password. Then click finish.


Next we add the actual connection that is behind the gateway. Click Add a new connection again.
Give the connection name , host and username as before. Then click Advanced. In SSH Proxy settings, click Remote, and select the Gateway we created before. Now click finish. 


Then click open button on the right hand side. This will open up the connection. If you didn't save your password, you have to enter the password now.

Next go to menu File>New>Other from the menu.


Then select Synchronized C/C++ projects from 'Other'.                                                                          


Click Next. Then select the ssh connection (not the gateway).                                                               



Then select the Remote directory by clicking 'Browse' button.                                                             


Then Click the project folder you want to synchronize with.                                                                
                                                     

Click ok. Give the Project name the same name as the project you selected.                                      

Select the project type as GNU Auto Tools (This could be different depending on your project.) and select 'Empty project'. 
**I had to do little bit more settings on windows to work because we need to support cross compilation with windows and our Linux based remote system. But it just works if you are using a linux machine.


Now choose to synchronize the project by right clicking on it unless auto sync is on by default. Screen shot is a windows system. But on Linux you need to specifically set it to sync. This may take a while if you have a rather large system on the remote machine.

                                                                     

** On windows 10 (This should be available on most windows OS) 
goto control panel> Turn windows features on >           
Click the check box saying, Windows subsystem for Linux

{This step is not necessary on Ubuntu}



                                                       




 credit: https://www.earthsystemcog.org/projects/cupid/proxyconnections and the great WWW!



******************************************************************************
More on setting up include paths for the remote synchronized project to run using remote machine:

(If needed, Click the link to goto eclipse help location which I'm quoting below )

"There are several places where include files are important to the editing, analyzing, building, and running of your program. A Synchronized Project mirrors the source files on the local machine as well as the remote target machine. Usually you edit locally, but build and run on the remote target. So this complicates things with respect to include files.
    By default, a synchronized project uses the normal CDT discovery mechanism, which reads the local environment. To configure the new discovery elements, follow these instructions after creating a new synchronized project. Go to Project > Properties > C/C++ General > Preprocessor Include Paths, Macros etc. Make sure the remote configuration is selected at the top of the dialog. Under the Providers tab, deselect all CDT providers, except for "CDT User Setting Entries" if you would like to enter your own paths. Next, select the two Sync providers, "Sync GCC Build Output Parser" and "Sync GCC Builtin Compiler Settings." The latter provider runs a specially-crafted compiler command to get compiler-specific settings. It will run immediately after "OK" is selected. The former provider will execute simultaneously with builds. It intercepts the build output and attempts to find environment information. Thus, a build must be run before this provider is useful.

    Now, make sure that indexing is enabled and invoke a remote build. In order for the build output parser to be useful, builds must produce verbose output. The method for setting up such a build varies per project, but see the Mozilla Project CDT setup page for a good example. Repeat these steps for each remote build configuration. For local configurations, both the standard CDT or new Sync providers should work. If you would like the environment to update automatically when build configurations are switched, go to Project > Properties > C/C++ General > Indexer and select "Use active build configuration" for "Build configuration for the indexer." The downside of this is that the indexer will run each time you switch configurations."


    Here if you are connecting through a gateway remember to use the name of the ssh connection (2nd) instead of the full path name. Otherwise Eclipse tries to
    login to the machine directly.

    E.g: See below. Instead of using //nxxx.x.org/opt/../include use //ConnectionName/opt/../include when you set include files from remote location.




    May 9, 2017

    REMOTE C/C++ through gateways using Eclipse

    Eclipse Neon + toolkits(CDT , RSE-Remote System Explorer,  PTP-Parllel Tools Platform components)

    See May 11 post for complete setup!


    http://janaxelson.com/eclipse1.htm

    connecting from a gateway:

    https://www.cyberciti.biz/faq/linux-unix-ssh-proxycommand-passing-through-one-host-gateway-server/


    -----------------------------------------------------------------------------------

     -tt uxxal@exxxxxl.gov ssh -tt uxxa@nxxxxxxx.gov

    Another way:

    On your "gateway"...

    vi ~/.ssh/config
    Host remote
       ProxyCommand ssh -C gateway '/usr/bin/nc 22'
    On "local"...

    $ ssh -t user@gateway 'ssh user@remote'

    Remote gatway debugging without ssh tunneling

    https://www.earthsystemcog.org/projects/cupid/proxyconnections

    May 5, 2017

    GAMESS build notes

     and add the lines below (logged into excl not newark yet.
    . /opt/shared/sw/x86_64-unknown-linux-gnu/modules-tcl85/default/init/bash
    module load modules
    module use /opt/shared/sw/x86_64-unknown-linux-gnu/modulefiles/rhel6
    #module use /opt/shared/sw/x86_64-unknown-linux-gnu/modulefiles/rhel7

    then source or login again

    . ~/.bashrc  - sourcing bashrc: need to be in bash shell for this command

    doesn't work for tcsh. no modules available in tcsh? why?

    ****If you are out of newark and load modules when u are in newark the paths are still there.Run config file in tcsh this way ; else it can't find modules




    modules loaded in newark

    d Modulefiles:
      1) modules              3) boost/1.54.0-intel   5) python/2.7.11        7) hdf5/1.8.10-intel
      2) m4/1.4.15            4) openssl/1.0.2c       6) openmpi/1.10.1-gnu


    set env variables for games

    export GMS_BUILD_DIR='/home/umunipala/gamess/gamess-kris-simgms
    '
    export GMS_TARGET=''
    export GMS_PATH='/home/umunipala/gamess/gamess-kris-simgms
    '
    export GMS_FORTRAN='ifort'
    export GMS_MATHLIB=''
    set GMS_DDI_COMM=''

       export GMS_TARGET=linux64
       export GMS_PATH=/home/umunipala/gamess/gamess-kris-simgms

    check if shell is interactive
    [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'

    ----------------------------------------------4/13
    Currently Loaded Modulefiles:
    Currently Loaded Modulefiles: openssl is loaded by openmpi
      1) modules              4) hdf5/1.8.10-intel    7) boost/1.60.0-gnu5
      2) openssl/1.0.2c       5) openmpi/1.10.1-gnu   8) mkl/2013.5.192
      3) python/2.7.11        6) m4/1.4.15            9) intel/2013.5.192



    RUNNING CONFIG
    >tcsh
    >source ./config

    Errors: gcc gfortran didn't show up . Logged in and out and its shown in
    [umunipala@newark ~]$ which gcc
    /usr/lib64/ccache/gcc

    Thread model: posix
    gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
       Alas, your version of gfortran does not support REAL*16,
       so relativistic integrals cannot use quadruple precision.
       Other than this, everything will work properly.

    MKL configuration
    MKL version (or 'proceed')? proceed
    Math library 'mkl' will be taken from /opt/intel/mkl/lib/intel64

    ---------------------------
    Currently Loaded Modulefiles:
      1) modules              6) hdf5/1.8.10-intel
      2) mkl/2013.5.192       7) m4/1.4.15
      3) intel/2013.5.192     8) boost/1.54.0-intel
      4) openssl/1.0.2c       9) openmpi/1.10.1-gnu
      5) python/2.7.11       10) mpich/3.1.2-gnu


    mpich path::

    set to::

    /opt/shared/sw/x86_64-unknown-linux-gnu/mpich/3.1.2-gnu-rhel6

    bin is here.

    5) The subdirectory gamess/ddi contains a script 'compddi' to compile
        the computer science support for parallel GAMESS, known as the
        Distributed Data Interface (DDI).

        There is one possible customization of 'compddi' that must be done
        by hand-editing 'compddi', prior to running it.  If your system's
        number of cores per node or total number of nodes is large, reset
        the defaults of MAXCPUS=8 and MAXNODES=128.

    >did not change coz its only 8
    >compddi : got error due to mpi

    /opt/shared/sw/x86_64-unknown-linux-gnu/mpich/include/mpi.h

    fixed it by changing mpi path to this(above)

    compiled::
    games>./compall

    Thu Apr 13 15:17:10 EDT 2017
    0.063u 0.018s 0:00.10 70.0%     0+0k 16+24io 0pf+0w
    ------------------- done with all compilations --------------------

    linking failure : missing simgms.o

    ------------------4-17

    **./comp simgms add line to compall
    >./compal : no errors.
    goto games/machines>
    look in readme.unix step 7
    goto games> run lked script to link libraries
        ./lked gamess 01 >& lked.log &

    ** change set SIMGMSLIBS line in lked script (this is not set for current user;hardcoded.)
     set SIMGMSLIBS = "-L/home/kris/gamess/simgms/Debug -lsimgms -lstdc++ -L/home/kris/gamess/simgms/simint/lib -lsimint"
    change the above to:

    set SIMGMSLIBS = "-L/home/umunipala/gamess/gamess-kris-simgms/simgms/Debug -lsimgms -lstdc++ -L/home/umunipala/gamess/gamess-kris-simgms/simgms/simint/lib -lsimint"

    /home/umunipala/gamess/gamess-kris-simgms/simgms>>>
    Readme says,
    Add simgms.src to gamess source directory and use modified lked to link with gamess binary
    /home/umunipala/gamess/gamess-kris-simgms/simgms/gamess_files>>
    there is a lked and simgms.src
    lked looks like the original config script

    *****************************************Above might not be necessory
    move simgms to source directory.
    goto:
     /home/umunipala/gamess/gamess-kris-simgms/simgms/gamess_files>>
    cp simgms.src ../../source/simgms.src

    ran the lked in this directory: asks to run config.
    replaced original lked in games>> same error
    ./lked gamess 01 >& lked.log &

    run /.compal
    _____________________________________________________4/18 changed mkl path in config
    lked errors, makefile in simgms/debug had licencing errors with intel
    >Going back to configuring with gcc because the makefile is autogenerated.

    /opt/intel/composer_xe_2013.5.192/mkl
    changed modules

    in readme.unix that is in machines folder says
    If you are using the Ubuntu version of Linux, you will get better  results by changing the top line of each script to read
     #!/bin/tcsh in all the scripts below:
    config compall comp lked rungms runall




    run the compddi in gamess/ddi
    run compall after going back to bash and loading modules.
    reverted from tcsh to bash and changed to  #!/bin/csh in compall

    goto games/simgms/Debug> make -icpc=cc

    ran ./lked gamess 01 >& lked.log & and still there is no libsimgms.a or .so
    checked with find . -name libsimgms*
    not available.

    module load gcc
    module load make
    module load python/2.7.11
    module load openmpi/1.10.1-gnu
    module load hdf5/1.8.10-intel
    module load boost/1.60.0-gnu5
    module load mkl/2013.5.192
    module load mpich/3.1.2-gnu



    ____________________4/24/17
    changing makefiles in Debug folder

    subdir.mk : contains wrong path

    /opt/intel/composer_xe_2013.5.192/mkl/lib/intel64 is mkl lib and they are shared/dynamic

     -std=gnu++11 -lmkl_intel_ilp64 -lmkl_gnu_thread


    /opt/intel/composer_xe_2013.5.192/mkl/lib/intel64
    setenv LD_LIBRARY_PATH /opt/intel/composer_xe_2013.5.192/mkl/lib/intel64:$LD_LIBRARY_PATH

    -----------------------------4/26---------
    fix intrinsics_avx.h error
    ________________________-approach 1--didn't work
    goto /home/umunipala/gamess/gamess-kris-simgms/simgms/simint/include/simint/vectorization
    >>
    current files here are:

    intrinsics_avx512.h  intrinsics_scalar.h  vectorization.h
    intrinsics_avx.h     intrinsics_sse.h

    >> Now adding headers..
    change the header from <> to "immintrin.h" in  intrinsics_avx.h

    >>gcc libs
    /opt/shared/sw/x86_64-unknown-linux-gnu/gcc/5.3.0-rhel6/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include
    -------------------------------approach 2-----------------

     define your own macro like this in intrinsics_avx.h

    #define _mm256_set_m128d(vh, vl) \
            _mm256_insertf128_pd(_mm256_castpd128_pd256(vl), (vh), 1)

    Instead #define SIMINT_GCC in intrinsics_avx.h

    ------------------------------------------------------------make o/p
    [umunipala@newark Debug]$ make
    Building file: ../simgms_init.cpp
    Invoking: G++ Compiler
    g++ -g -O -O1 -std=c++11 -L/opt/intel/composer_xe_2013.5.192/mkl/lib/intel64 -libmkl_lapack95_lp64 -libmkl_intel_lp64 -libmkl_core -lmkl_gnu_thread -I/home/umunipala/gamess/gamess-kris-simgms/simgms/simint/include  -DDEBUG -DMKL_ILP64 -MMD -MP -MF"simgms_init.d" -MT"simgms_init.d" -c -o "simgms_init.o" "../simgms_init.cpp"
    In file included from /home/umunipala/gamess/gamess-kris-simgms/simgms/simint/incl
    ude/simint/vectorization/vectorization.h:11:0,
                     from /home/umunipala/gamess/gamess-kris-simgms/simgms/simint/incl
    ude/simint/ostei/ostei_config.h:3,
                     from /home/umunipala/gamess/gamess-kris-simgms/simgms/simint/incl
    ude/simint/simint.h:5,
                     from ../simgms_init.h:3,
                     from ../simgms_init.cpp:3:
    /home/umunipala/gamess/gamess-kris-simgms/simgms/simint/include/simint/vectorizati
    on/intrinsics_avx.h: In function '__m256d simint_exp_vec4(__m256d)':
    /home/umunipala/gamess/gamess-kris-simgms/simgms/simint/include/simint/vectorizati
    on/intrinsics_avx.h:25:48: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
     static inline __m256d simint_exp_vec4(__m256d x)
                                                    ^
    Finished building: ../simgms_init.cpp

    Building file: ../simgms_math.cpp
    Invoking: G++ Compiler
    g++ -g -O -O1 -std=c++11 -L/opt/intel/composer_xe_2013.5.192/mkl/lib/intel64 -libmkl_lapack95_lp64 -libmkl_intel_lp64 -libmkl_core -lmkl_gnu_thread -I/home/umunipala/gamess/gamess-kris-simgms/simgms/simint/include  -DDEBUG -DMKL_ILP64 -MMD -MP -MF"simgms_math.d" -MT"simgms_math.d" -c -o "simgms_math.o" "../simgms_math.cpp"
    ../simgms_math.cpp:2:25: fatal error: mkl_lapacke.h: No such file or directory
    compilation terminated.
    ---------------------------------
    /opt/intel/composer_xe_2013.5.192/mkl????????????????? sometimes this path shows as available and sometimes not? why?
    /opt/intel/composer_xe_2013.5.192/mkl/include
    has mkl_lapack.h file
    -----------------------------------------------------------

    generated libsimint.a in libs and there is two more files simgms_init.d and simgms_init.o generated.

    compiling lked script in main directory
    ./lked gamess 01 >& lked.log &


    -------------------------------------------------current build error
    gcc  -mavx -g -O -O1 -std=c++11 -L/opt/intel/composer_xe_2013.5.192/mkl/lib/intel64 -libmkl_mc -libmkl_sequential -libmkl_gf_ilp64 -libmkl_avx -libmkl_lapack95_lp64 -libmkl_intel_lp64 -libmkl_core -lmkl_gnu_thread -I/home/umunipala/gamess/gamess-kris-simgms/simgms/simint/include  -DDEBUG -DMKL_ILP64 -MMD -MP -MF"simgms_math.d" -MT"simgms_math.d" -c -o "simgms_math.o" "../simgms_math.cpp"
    In file included from ../simgms_math.cpp:2:0:
    ../mkl_lapacke.h:32:23: fatal error: mkl_types.h: No such file or directory
    compilation terminated.
    subdir.mk:31: recipe for target 'simgms_math.o' failed
    make: *** [simgms_math.o] Error 1

    -------------------------------------
    simgms/Debug>
    got an error 'CBLAS_LAYOUT undeclared
    fixed it with adding line typedef CBLAS_ORDER CBLAS_LAYOUT; /* this for backward compatibility with CBLAS_ORDER */
    to simgms_math.cpp

    Ran make in Debug folder.
    This generated libsimgs.a

    go up to main lked script



    ________________________________modified headers in simgms_math.cpp

    added include files.
    /opt/intel/composer_xe_2013.5.192/compiler/lib/intel64

    ./lked gamess 01 >& lked_may_1.log &


    libs gcc
    /opt/shared/sw/x86_64-unknown-linux-gnu/gcc/5.3.0-rhel6/lib64
    added this line to simint.
    define

    look for files in /opt/intel/composer_xe_2013.5.192/compiler/lib/intel64

     gcc -I/opt/intel/composer_xe_2013.5.192/compiler/include-L/opt/intel/composer_xe_2013.5.192/compiler/lib/intel64 __intel_ssse3_rep_memcpy
    -----

    added macro #define SIMINT_GC in simgms_init.cpp and simgms_oei.cpp --- not sure: bcoz it was mentioned in vectorization.h
    ---------------------may 1
    copied all the header files from the Debug directory generated from the files like simgms_math, simgms_oie etc (which we in Debug )into the folder below.
    Then added the bath in subdir.mk
    -I/home/umunipala/gamess/gamess-kris-simgms/simgms/simint/include/simint/debug
    ./lked gamess 01 >& lked_may_1.log &

    *** Run makefile from following directory:

    /home/umunipala/gamess/gamess-kris-simgms/simgms/oed
    changed ifort to gfortran in Makefile
    FC=gfortran

    This generates the libraries for oed

    ----------Edit lked script----------------------
    in lked script CHANGE THIS LINE ADDING OED LIB

    if($SIMGMS == true) then
       set SIMGMSLIBS = "-L$GMS_BUILD_DIR/simgms/Debug -lsimgms -L$GMS_BUILD_DIR/simgms/oed -liboed -liboedlib  -lstdc++ -L$GMS_BUILD_DIR/simgms/simint/lib -lsimint"
    -liboed -liboedlib was wrong
    Replace by -loed -loedlib

    if($SIMGMS == true) then
       set SIMGMSLIBS = "-L$GMS_BUILD_DIR/simgms/Debug -lsimgms -L$GMS_BUILD_DIR/simgms/oed -loed -loedlib  -lstdc++ -L$GMS_BUILD_DIR/simgms/simint/lib -lsimint"
    ./lked gamess 01 >& lked_may_1.log &

    changed file with wrong paths that were hardcoded
    Debug/simgms_diagonalize.d


    ---------------------may 3---

    changed linked order to simgms, simint ... etc

    ran lked

    ./lked gamess 01 >& lked_may_3.log &

    openmpi path is wrong in $PATH
    rhe16 doesn't exist
    available directory is:
    /opt/shared/sw/x86_64-unknown-linux-gnu/openmpi

    Errors in lked are from intel function calls from these files:
    1. shell.h , there is no shell.c


    /home/umunipala/gamess/gamess-kris-simgms/simgms/simint/include/simint

    change simint_config.h
    remove #define SIMINT_INTEL and add #define SIMINT_GCC
    now simint need to be compiled
    how do we do this???
    ------------------------------------------------------may 5 ------------------

    extracted and renamed simint version 7 to simint
    created build directory in simint dir
    First run cmake in the toplevel and this creates the subdirectory simint and the cmakelist there.

    ran cmake command with avx
    simint>> CC=gcc CXX=g++ cmake . -DSIMINT_VECTOR=avx

    simgms/simint>> make
    This builds all *.o objects
    But its very slow.. next time try -j8. Then ran make all

    [umunipala@newark simint]$ pwd
    /home/umunipala/gamess/gamess-kris-simgms/simgms/simint
    [umunipala@newark simint]$ make all DESTDIR=.
     ------------------------
    Now we have to run cmake in the subdirectories examples and then in simint.

    1)
    now goto /siminit/examples>> run cmake
    CC=gcc CXX=g++ cmake . -DSIMINT_VECTOR=avx -DCMAKE_INSTALL_LIBDIR=./lib -DCMAKE_INSTALL_INCLUDEDIR=./include

    2)
    now goto /siminit/simint>> and run cmake to build the library
    Also create lib and include directories here and give them as cmake variables.

    [umunipala@newark simint]$ pwd            
    /home/umunipala/gamess/gamess-kris-simgms/simgms/simint/simint

    [umunipala@newark simint]$ CC=gcc CXX=g++ cmake . -DSIMINT_VECTOR=avx -DCMAKE_INSTALL_LIBDIR=./lib -DCMAKE_INSTALL_INCLUDEDIR=./include

    added this line to the beginning of file CMakeLists in simgms/simgms dir before running cmake :
    cmake_minimum_required(VERSION 3.3)

    make
    make all

    libsimint.a is created in simint. copy this to simint/lib

    -----------------------------
    goto lked and run it.

    ./lked gamess 01 >& lked_may_5.log &
    errors libmkl_gnu_thread.so: undefined reference to `omp_in_parallel' etc
    added -lgomp to mkl Lib path


    ---------------5/26----------------
    missing
    #define SIMINT_GCC in the current buld from the new simgms version,in 'simgms_init.cpp'





    May 3, 2017

    Visustin :: Code Analyzer / Diagram generator

    http://www.aivosto.com/vbcatalog.html

    Followers