Skip to content

Commit

Permalink
[WIP] Update backprop OpenMP GPU version
Browse files Browse the repository at this point in the history
After hours of debugging, it's still not working.

1. Fix missing headers, function declarations, etc.
2. Use 1D array instead of 2D array due to OpenMP data mapping issue.
3. Fix data allocation and usage. Original code maps data[0:size] but use data[0:size+1] on the device.

The memory allocation is problematic. Depending on the input size, e.g. 64, 128, 1024, 65536 ..., the program will crash at different places.
The default input size 65536 may cause data overflow.
  • Loading branch information
ouankou committed Sep 5, 2022
1 parent 9c797a5 commit 45a787f
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 299 deletions.
16 changes: 8 additions & 8 deletions openmp-gpu/backprop/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# C compiler
#CC = pathcc
#CC_FLAGS = -acc -O2
CC = pgcc
CC_FLAGS = -acc -O3 -Minfo -I /usr/include/i386-linux-gnu/ -L /usr/lib/i386-linux-gnu/
CC = clang
CC_FLAGS = -g -O3 -fopenmp -fopenmp-targets=nvptx64


backprop: backprop.o facetrain.o imagenet.o backprop_kernel.o
$(CC) $(CC_FLAGS) backprop.o facetrain.o imagenet.o backprop_kernel.o -o backprop -lm
backprop.out: backprop.o facetrain.o imagenet.o backprop_kernel.o
$(CC) $(CC_FLAGS) backprop.o facetrain.o imagenet.o backprop_kernel.o -o backprop.out -lm

%.o: %.[ch]
$(CC) $(CC_FLAGS) $< -c
Expand All @@ -23,6 +20,9 @@ backprop_kernel.o: backprop_kernel.c backprop.h
imagenet.o: imagenet.c backprop.h
$(CC) $(CC_FLAGS) imagenet.c -c

.PHONY: run clean
run: backprop.out
./backprop.out 65536

clean:
rm -f *.o *~ backprop backprop_cuda.linkinfo
rm -f *.o *.out

0 comments on commit 45a787f

Please sign in to comment.