mpich2 2 executables standard output - gdb

I need to launch 2 executables (program1 and program2) with the same mpirun (mpich) command, and I'm trying to debug program1 with gdb. I use this command:
mpirun -n 1 gdb program1 : -n 1 program2
The command correctly opens the gdb console, but if I set a breakpoint somewhere after mpi_init, the screen gets flooded with the standard output of program2. Is there a simple way to redirect the standard output of program2 (only program2) to a file?
My fast solution was to hard-code a cut of stdout in program2, but I'm sure there must be a more elegant one ...

You could try this:
create a wrapper.sh that redirect the stdout and stderr to the file output :
cat > wrapper.sh << EOF
#!/bin/bash
\$* 1>>output 2>&1
EOF
make it executable
chmod +x wrapper.sh
mpirun with the wrapper
mpirun -n 1 gdb program1 : -n 1 ./wrapper.sh program2

Related

OpenMPI Multiple Instructions Multiple Data (MIMD) syntax

One of my MPI programs keeps crashing and I want to write specific debugging output for each task to a file. The file to which is written is specified via a command line argument. I read in the OpenMPI documentation that there is the possibility of launching several commands via the syntax
mpirun [global options] [local options 1] ./main --file debug.log1 : [local options 2] ./main --file debug.log2 : ...
However I was not able to find which flags are considered global and which ones local. Most important I don't know about the number of processes, i.e. "-np". Should I give it as a global option or a local one.
mpirun --map-by node --bind-to none -np 3 ./main --file debug.log1 : ./main --file debug.log2 : ./main --file debug.log3
or
mpirun --map-by node --bind-to none -np 1 ./main --file debug.log1 : -np 1 ./main --file debug.log2 : -np 1 ./main --file debug.log3
If the latter is true, does every binary get "-np 1" or "-np [#nodes]"? I suppose arguments like "--map-by" and "--bind-to" are global, is that correct?

Sending pcap file via packetgen dpdk

Sending a pcap file on port 0. I get the following error. Any fix would be appreciated!
The command used is:
sudo ./app/x86_64-native-linuxapp-gcc/pktgen -c 0X01 -n 1 --file-prefix=pg -w 4:00.1 -- -m 1.0 -T -P -s 0:~/Downloads/bigFlows.pcap
There are 2 obvious reasons for the failure.
Number of CPU cores for pktgen to work is 1 + number of ports in use
you have extra argument in comamnd executed in pktgen.
Checking the link, it show the command used is sudo ./app/x86_64-native-linuxapp-gcc/pktgen -c 0X01 -n 1 --file-prefix=pg -w 4:00.1 -- -m 1.0 -T -P -s 0:[~/Downloads/bigFlows.pcap]. You should not sue [] instead use 0:actual path to pcap.
Note: #SaifUllah during the live debug both core and pcap were show cased for you.

how to hold xterm during debugging an mpi program?

I run the debugger via
mpirun -n 4 xterm -e gdb -x commands.gdb ./my_mpi_programm
where the file "commands.gdb" just contains the commands
start
continue
The problem is that my 4 xterm immediately close before I get a chance to inspect the error message or do any debugging.
I'm using the latest ubuntu distribution. However, on my friend's old Suse-distribution, xterm is held open.
How can I force the xterms to stay?
EDIT: the "-hold" option doesnt work as well as
mpirun -n 4 xterm -e "gdb -x commands.gdb ./my_mpi_programm;bash"
Try
mpirun -n 4 xterm -e bash -c 'gdb -x commands.gdb ./my_mpi_programm; sleep 60'

How can make my makefile overwrite a file?

descript: progam.cpp
g++ progam.cpp -o descript
./descript 2>output.txt | tee -a output.txt
From my understanding, first command compiles program.cpp and the second command sends the output to both terminal and a textfile.
Is there a way to adjust this so that I :
Use "make".Go through program prompts. Output is saved in output.txt
Use "./descript" or some command a second time and overwrite output.txt with new output
I'm fairly new to linux commands in general so anything would help.
It may be helpful to include a make clean function in your Makefile.
Example make clean function could include:
make clean:
rm -f output.txt
Then, insert the make clean at the beginning of your descript portion of the Makefile to auto-remove the previous output.

Using a script to run 2 programs, both with blocking functions

I'm trying to run 2 C++ programs simultaneously. Both programs make use of inotify to each watch a folder for file creation, then handle the events (in a different manner) respectively. The programs also run indefinitely so they are forever watching their respective folders for new files.
I have a shell script that simply does the following:
./program1 -i input_file -o output_file
./program2 -i input_file -o output_file
I'm worried that because program1 is blocking and runs indefinitely, program2 will never get to execute. Is this the case? How should I work around this then?
Will ./program1 -i input_file -o output_file & ./program2 -i input_file -o output_file work?