Skip to content

Commit

Permalink
gdb fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lee218llnl committed May 7, 2018
1 parent bd6fb44 commit a310176
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions examples/src/cuda_example.cu
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ __device__ void foo()
#ifdef NOHANG
for (i = 0; i <= 1000000; i++)
#else
for (i = 0; i >=0; i++)
for (i = 0; i >= 0; i++)
#endif
{
x = i;
Expand Down Expand Up @@ -70,15 +70,18 @@ void add2(int *a, int *b)
int main(int argc, char **argv)
{
int ha[N], hb[N], hc[N];
char hostname[256];
gethostname(hostname, 256);
#ifdef USEMPI
int numtasks, rank;
char hostname[256];
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD, &numtasks);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
gethostname(hostname, 256);
printf("Hello world from %s %d/%d\n", hostname, rank, numtasks);
#else
printf("Hello serial world from %s\n", hostname);
#endif
fflush(stdout);
int *da, *db;
cudaMalloc((void **)&da, N*sizeof(int));
cudaMalloc((void **)&db, N*sizeof(int));
Expand Down
2 changes: 2 additions & 0 deletions scripts/gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import signal
import os
import logging
import time
from datetime import datetime

def init_logging(input_loglevel, input_logfile):
Expand Down Expand Up @@ -115,6 +116,7 @@ def readlines(self, breakstring=None):
line = ''
lines = []
while True:
time.sleep(.00001) # the poll sometimes would hang in the absence of a short sleep
ret = self.subprocess.poll()
if ret != None:
error_msg = 'Subprocess terminated with ret code %d\n' %(ret)
Expand Down
2 changes: 1 addition & 1 deletion scripts/stat_cuda_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def new_gdb_instance(pid, gdb_type='gdb'):
# (cudbgApiAttach) will be abandoned.
# When the function is done executing, GDB will silently stop.
if "TMPDIR" not in os.environ:
os.environ["TMPDIR"]="/var/tmp/%s" %(pwd.getpwuid( os.getuid() ).pw_name)
os.environ["TMPDIR"]="/var/tmp"

try:
if 'cuda-gdb' in os.environ['STAT_GDB']:
Expand Down

0 comments on commit a310176

Please sign in to comment.