Skip to content

Commit 078308c

Browse files
committed
Add CUDA unit test and fix CUDA build configuration
This commit includes the following changes: 1. Add new CUDA unit test file (unittest_cuda.cpp) with RMSNorm CUDA kernel tests 2. Reorganize CUDA operations directory structure by moving subdir inclusion from nntrainer/meson.build to nntrainer/tensor/meson.build 3. Add CUDA test target in test/unittest/meson.build 4. Fix CUDA linking issues by adding proper link arguments (-NOIMPLIB, -NOEXP) to prevent generation of unnecessary .lib and .exp files 5. Add CUDA dependencies handling in unit test build configuration The changes ensure proper CUDA support in the build system and add comprehensive unit tests for CUDA operations. Signed-off-by: Daekyoung Jung <[email protected]>
1 parent 42922de commit 078308c

File tree

4 files changed

+390
-6
lines changed

4 files changed

+390
-6
lines changed

nntrainer/meson.build

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ foreach elem : nntrainer_elements
9595
nntrainer_inc_abs += meson.current_source_dir() / elem
9696
endforeach
9797

98-
# Add CUDA operations subdir if CUDA is enabled
99-
if get_option('enable-cuda')
100-
subdir('tensor/cuda_operations')
101-
endif
102-
10398
nntrainer_common_sources = [
10499
'nntrainer_logger.cpp',
105100
'app_context.cpp',

nntrainer/tensor/meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ if get_option('enable-opencl')
9090
nntrainer_inc_abs += meson.current_source_dir() / 'cl_operations'
9191
endif
9292

93+
if get_option('enable-cuda')
94+
subdir('cuda_operations')
95+
nntrainer_inc += include_directories('cuda_operations')
96+
nntrainer_inc_abs += meson.current_source_dir() / 'cuda_operations'
97+
endif
98+
9399
foreach s : tensor_sources
94100
nntrainer_sources += meson.current_source_dir() / s
95101
endforeach

test/unittest/meson.build

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ if get_option('enable-opencl')
8484
test_target += [['unittest_attention_kernels_cl', []]]
8585
endif
8686

87+
if get_option('enable-cuda')
88+
test_target += [['unittest_cuda', []]]
89+
endif
90+
8791
if get_option('enable-fp16')
8892
test_target += [['unittest_nntrainer_tensor_fp16', []]]
8993
test_target += [['unittest_nntrainer_tensor_pool_fp16', []]]
@@ -96,12 +100,20 @@ if get_option('enable-profile')
96100
endif
97101

98102
foreach target: test_target
103+
cuda_deps = []
104+
cuda_link_args = []
105+
if target[0] == 'unittest_cuda' and get_option('enable-cuda')
106+
cuda_deps = [cuda_dep]
107+
cuda_link_args = ['-NODEFAULTLIB:LIBCMT', '-NOIMPLIB', '-NOEXP']
108+
endif
109+
99110
exe = executable(
100111
target[0],
101112
[target[0] + '.cpp'] + [target[1]],
102113
# below is temporary measure, we will eventually remove unittest_nntrainer_models
103114
include_directories: include_directories('models'),
104-
dependencies: unittest_nntrainer_deps,
115+
dependencies: unittest_nntrainer_deps + cuda_deps,
116+
link_args: cuda_link_args,
105117
install: get_option('enable-test'),
106118
install_dir: application_install_dir
107119
)

0 commit comments

Comments
 (0)