Skip to content

Commit 036ba13

Browse files
committed
Merge branch 'feature/60-python-api' of https://github.com/GPUEngineering/GPUtils into feature/60-python-api
2 parents ea33238 + 07d4b64 commit 036ba13

File tree

5 files changed

+31
-34
lines changed

5 files changed

+31
-34
lines changed

CMakeLists.txt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@
22
# GPUtils
33
# ====================================================================
44
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
5-
65
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.29")
76
cmake_policy(SET CMP0135 NEW)
87
endif()
9-
8+
# ----
109
# Set C++ version and SM architecture
1110
if (NOT DEFINED CPPVERSION)
1211
set(CPPVERSION 20) # A40: 20, Orin: 17
1312
endif()
1413
if (NOT DEFINED SM_ARCH)
1514
set(SM_ARCH 86)# A40: 86, Orin: 87
1615
endif()
17-
18-
16+
# ----
1917
project(GPUtils
2018
DESCRIPTION "Easy use of vectors and matrices on GPGPU devices."
2119
HOMEPAGE_URL "https://github.com/GPUEngineering/GPUtils"
@@ -31,8 +29,8 @@ set(CMAKE_CUDA_FLAGS "-std=c++${CPPVERSION}")
3129
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; "-std=c++${CPPVERSION}")
3230
enable_language(CUDA)
3331
# ----
34-
add_library(device_compiler_flags INTERFACE)
35-
target_compile_features(device_compiler_flags INTERFACE cxx_std_${CPPVERSION})
32+
add_library(gputils_compiler_flags INTERFACE)
33+
target_compile_features(gputils_compiler_flags INTERFACE cxx_std_${CPPVERSION})
3634
set(CMAKE_CXX_EXTENSIONS OFF)
3735
# ----
3836
add_library(developer_flags INTERFACE)
@@ -45,30 +43,31 @@ target_compile_options(developer_flags
4543
# flags for CUDA builds
4644
$<$<COMPILE_LANGUAGE:CUDA>:${cuda_flags}>
4745
)
48-
target_link_libraries(device_compiler_flags INTERFACE $<BUILD_INTERFACE:developer_flags>)
46+
target_link_libraries(gputils_compiler_flags INTERFACE $<BUILD_INTERFACE:developer_flags>)
4947
# ----
50-
51-
52-
# ====================================================================
53-
# comment out for release
54-
# ====================================================================
55-
add_executable(main)
56-
target_sources(main
48+
add_executable(gputils_main)
49+
target_sources(gputils_main
5750
PRIVATE
5851
main.cu
5952
)
60-
target_link_libraries(main
53+
target_link_libraries(gputils_main
6154
PRIVATE
62-
device_compiler_flags
55+
gputils_compiler_flags
6356
cublas
6457
cusolver
6558
cudadevrt
6659
)
67-
target_include_directories(main
60+
target_include_directories(gputils_main
6861
PRIVATE
6962
"${PROJECT_BINARY_DIR}"
7063
"${PROJECT_SOURCE_DIR}/include"
7164
)
7265
# ----
73-
add_subdirectory(test)
66+
if(NOT GPUTILS_BUILD_TEST)
67+
set(GPUTILS_BUILD_TEST OFF) # Set to ON for local testing (or add `-DGPUTILS_BUILD_TEST=ON` to your CMake profile)
68+
endif()
69+
if (GPUTILS_BUILD_TEST)
70+
add_subdirectory(test)
71+
endif()
72+
unset(GPUTILS_BUILD_TEST CACHE)
7473
# ----

ci/script.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tests() {
77
cpp_version=17 # default
88
sm_arch=86 # default
99
hwInfoOrin=`lshw | grep Orin` ||
10-
if [ ! -z "${hwInfoOrin}" ]; then
10+
if [ -n "${hwInfoOrin}" ]; then
1111
echo "Running on Orin";
1212
sm_arch=87
1313
cpp_version=17
@@ -36,7 +36,7 @@ tests() {
3636
# ------------------------------------
3737

3838
# -- create build files
39-
cmake -DCPPVERSION=${cpp_version} -DSM_ARCH=${sm_arch} -S . -B ./build -Wno-dev
39+
cmake -DCPPVERSION=${cpp_version} -DSM_ARCH=${sm_arch} -DGPUTILS_BUILD_TEST=ON -S . -B ./build -Wno-dev
4040

4141
# -- build files in build folder
4242
cmake --build ./build
@@ -48,7 +48,7 @@ tests() {
4848

4949
# -- run compute sanitizer
5050
pushd ./build/test
51-
mem=$(/usr/local/cuda/bin/compute-sanitizer --tool memcheck --leak-check=full ./device_test)
51+
mem=$(/usr/local/cuda/bin/compute-sanitizer --tool memcheck --leak-check=full ./gputils_test)
5252
grep "0 errors" <<< "$mem"
5353
popd
5454

@@ -58,7 +58,7 @@ tests() {
5858

5959
# -- create build files
6060
cd example
61-
cmake -DCPPVERSION=${cpp_version} -DSM_ARCH=${sm_arch} -S . -B ./build -Wno-dev
61+
cmake -DCPPVERSION=${cpp_version} -DSM_ARCH=${sm_arch} -S . -B ./build -Wno-dev
6262

6363
# -- build files in build folder
6464
cmake --build ./build

example/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ target_compile_options(example_developer_flags
2828
# flags for CUDA builds
2929
$<$<COMPILE_LANGUAGE:CUDA>:${cuda_flags}>
3030
)
31-
target_link_libraries(example_compiler_flags INTERFACE $<BUILD_INTERFACE:example_developer_flags>
32-
)
31+
target_link_libraries(example_compiler_flags INTERFACE $<BUILD_INTERFACE:example_developer_flags>)
3332
# ----
34-
set(GPUTILS_BUILD_TESTING OFF)
3533
include(FetchContent)
3634
FetchContent_Declare(
3735
gputils

include/tensor.cuh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ data_t<T> vectorFromTextFile(std::string path_to_file) {
608608
data_t<T> dataStruct;
609609
std::ifstream file;
610610
file.open(path_to_file, std::ios::in);
611-
if (!file.is_open()) { throw std::invalid_argument("the file you provided does not exist"); };
611+
if (!file.is_open()) { throw std::invalid_argument("[vectorFromTextFile] the file does not exist"); }
612612

613613
std::string line;
614614
getline(file, line); dataStruct.numRows = atoi(line.c_str());
@@ -655,6 +655,7 @@ data_t<T> vectorFromBinaryFile(std::string path_to_file) {
655655
/* Read from binary file */
656656
std::ifstream inFile;
657657
inFile.open(path_to_file, std::ios::binary);
658+
if (!inFile.is_open()) { throw std::invalid_argument("[vectorFromBinaryFile] the file does not exist"); }
658659
inFile.read(reinterpret_cast<char *>(&(dataStruct.numRows)), sizeof(uint64_t));
659660
inFile.read(reinterpret_cast<char *>(&(dataStruct.numCols)), sizeof(uint64_t));
660661
inFile.read(reinterpret_cast<char *>(&(dataStruct.numMats)), sizeof(uint64_t));
@@ -723,7 +724,7 @@ void DTensor<T>::reshape(size_t newNumRows, size_t newNumCols, size_t newNumMats
723724
char errMessage[256];
724725
sprintf(errMessage,
725726
"DTensor[%lu x %lu x %lu] with %lu elements cannot be reshaped into DTensor[%lu x %lu x %lu] (%lu elements)",
726-
numRows(), numRows(), numMats(), numEl(), newNumRows, newNumCols, newNumMats, newNumElements);
727+
numRows(), numCols(), numMats(), numEl(), newNumRows, newNumCols, newNumMats, newNumElements);
727728
throw std::invalid_argument(errMessage);
728729
}
729730

test/CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,23 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
99
FetchContent_MakeAvailable(googletest)
1010
# ----
1111
enable_testing()
12-
add_executable(device_test)
13-
14-
target_sources(device_test # add files
12+
add_executable(gputils_test)
13+
target_sources(gputils_test # add files
1514
PRIVATE
1615
testTensor.cu
1716
)
18-
target_link_libraries(device_test
17+
target_link_libraries(gputils_test
1918
PRIVATE
20-
device_compiler_flags
19+
gputils_compiler_flags
2120
cublas
2221
cusolver
2322
cudadevrt
2423
GTest::gtest_main)
25-
target_include_directories(device_test
24+
target_include_directories(gputils_test
2625
PRIVATE
2726
"${PROJECT_BINARY_DIR}"
2827
"${PROJECT_SOURCE_DIR}/include"
2928
)
3029
include(GoogleTest)
31-
gtest_discover_tests(device_test)
30+
gtest_discover_tests(gputils_test)
3231
# ----

0 commit comments

Comments
 (0)