Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,40 @@ uninstall:
rm -rf $(INSTALLED_LIBS) $(INSTALLED_HEADERS)


# Tests
# Build the test programs against the freshly built libraries and run the
# GPU-vs-CPU correctness tests for each supported integration order. The
# backend selected above determines which test Makefile and binaries are used.
ifeq ($(BACKEND), CUDA)
TEST_MAKEFILE := Makefile
TEST_SUFFIX := cuda
else
TEST_MAKEFILE := Makefile_ocl
TEST_SUFFIX := ocl
endif

CORRECTNESS_TESTS := test_gravity_block_$(TEST_SUFFIX) \
test_gravity_block_g5_$(TEST_SUFFIX) \
test_gravity_block_6th_$(TEST_SUFFIX)

.PHONY: build-tests
build-tests: all
$(MAKE) -C tests -f $(TEST_MAKEFILE) CXX="$(CXX)" CC="$(CC)" \
$(if $(CUDA_TK),CUDA_TK="$(CUDA_TK)")

.PHONY: test
test: build-tests
@for t in $(CORRECTNESS_TESTS); do \
echo "=== Running $$t ==="; \
( cd tests && LD_LIBRARY_PATH="$(CURDIR):$$LD_LIBRARY_PATH" ./$$t ) || exit 1; \
done


# Clean-up
.PHONY: clean
clean:
rm -f *.a *.so src/*.o src/SSE_AVX/SSE/*.o src/SSE_AVX/AVX/*.o
rm -f src/CUDA/*.ptx src/CUDA/*.ptxh src/OpenCL/*.cle src/OpenCL/*.clh
$(MAKE) -C tests -f Makefile clean
$(MAKE) -C tests -f Makefile_ocl clean

21 changes: 18 additions & 3 deletions src/ocldev.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,29 @@ namespace dev {
oclSafeCall(clGetPlatformInfo(PlatformIDs[dev], CL_PLATFORM_NAME, sizeof(platform_string), &platform_string, NULL));
std::cerr << " " << dev << ": " << platform_string << "\n";
}
fprintf(stderr, "Using platform %d \n", platform_id);
PlatformID = PlatformIDs[platform_id];

// Prefer NVIDIA platform if available.
int selected_platform = platform_id;
if (platform_id == 0 && numPlatforms > 1) {
for (cl_uint p = 0; p < numPlatforms; p++) {
char platform_string[1024];
oclSafeCall(clGetPlatformInfo(PlatformIDs[p], CL_PLATFORM_NAME, sizeof(platform_string), &platform_string, NULL));
if (strstr(platform_string, "NVIDIA") != NULL) {
std::cerr << "Found NVIDIA platform at index " << p << ", preferring it over others.\n";
selected_platform = p;
break;
}
}
}

fprintf(stderr, "Using platform %d \n", selected_platform);
PlatformID = PlatformIDs[selected_platform];

oclSafeCall(clGetDeviceIDs(PlatformID, DeviceType, 0, NULL, &DeviceCount));

Devices.resize(DeviceCount);
oclSafeCall(clGetDeviceIDs(PlatformID, DeviceType, DeviceCount, &Devices[0], &DeviceCount));

std::cerr << "Found " << DeviceCount << " suitable devices: \n";
for (cl_uint dev = 0; dev < DeviceCount; dev++) {
char device_string[1024];
Expand Down
4 changes: 2 additions & 2 deletions tests/Makefile_ocl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CXX ?= g++
.SUFFIXES: .o .cpp .ptx .cu

SAPPOROPATH=..
SAPLIB2 = sapporo
SAPLIB2 = sapporo2
SAPLIB = lib$(SAPLIB2).a
SAPLIBG6 = sapporoG6

Expand All @@ -28,7 +28,7 @@ PROG = test_gravity_block_ocl test_gravity_block_6th_ocl test_performance_rangeN
all: $(OBJ) $(PROG) kernels

kernels:
rm -f OpenCL && ln -s $(SAPPOROPATH)/OpenCL OpenCL
rm -f OpenCL && ln -s $(SAPPOROPATH)/src/OpenCL OpenCL

test_gravity_block_ocl : test_gravity_block_ocl.o
$(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS)
Expand Down