Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable memcheck for jni unit tests #1321

Merged
merged 9 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ target/

## VSCode IDE
.vscode

#Generated files
cufile.log
rmm_log.txt
sanitizer_for_pid_*.log
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,39 @@ in errors finding libraries. The script `build/run-in-docker` was created to hel
situation. A test can be run directly using this script or the script can be run without any
arguments to get into an interactive shell inside the container.
```build/run-in-docker target/cmake-build/gtests/ROW_CONVERSION```

#### Testing with Compute Sanitizer
[Compute Sanitizer](https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html) is a
functional correctness checking suite included in the CUDA toolkit. And the RAPIDS Accelerator JNI now
firestarman marked this conversation as resolved.
Show resolved Hide resolved
supports leveraging the Compute Sanitizer in memcheck mode in the unit tests to help catch any kernels
that may be doing something incorrectly. To run the unit tests with the Compute Sanitizer, append the
`-DUSE_SANITIZER=ON` to the build command. e.g.
```
> ./build/build-in-docker clean package -DUSE_SANITIZER=ON
```

The Compute Sanitizer will output its report into one or multiple log files named as
`sanitizer_for_pid_<pid number>.log` under the current workspace root path.

Please note not all the unit tests can run with Compute Sanitizer. For example, `RmmTest#testEventHandler`,
a problematic test, intentionally tries an illegal allocation because of a too big size as part of the
test, but Compute Sanitier will still report the errors and fail the whole build process. And
firestarman marked this conversation as resolved.
Show resolved Hide resolved
`UnsafeMemoryAccessorTest` is for host memory only, so there is no need to run it with Compute Sanitier either.
firestarman marked this conversation as resolved.
Show resolved Hide resolved

If you think your tests are not suitable for Compute Sanitier, please add the JUnit5 tag (`@Tag("noSanitizer")`)
firestarman marked this conversation as resolved.
Show resolved Hide resolved
to the tests or the test class.
```
@Tag("noSanitizer")
class ExceptionCaseTest { ... }

# or for a single test
class NormalCaseTest {

@Tag("noSanitizer")
public void testOneErrorCase(){ ... }
}
```

### Benchmarks
Benchmarks exist for c++ benchmarks using NVBench and are in the `src/main/cpp/benchmarks` directory.
To build these benchmarks requires the `-DBUILD_BENCHMARKS` build option. Once built, the benchmarks
Expand Down
5 changes: 5 additions & 0 deletions build/sanitizer-java/bin/java
jlowe marked this conversation as resolved.
Show resolved Hide resolved
jlowe marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compute-sanitizer --tool memcheck \
jlowe marked this conversation as resolved.
Show resolved Hide resolved
--launch-timeout 600 \
--error-exitcode -2 \
--log-file "./sanitizer_for_pid_%p.log" \
java "$@"
3 changes: 2 additions & 1 deletion ci/nightly-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ ${MVN} clean package ${MVN_MIRROR} \
-DCPP_PARALLEL_LEVEL=${PARALLEL_LEVEL} \
-Dlibcudf.build.configure=true \
-DUSE_GDS=${USE_GDS} -Dtest=*,!CuFileTest,!CudaFatalTest,!ColumnViewNonEmptyNullsTest \
-DBUILD_TESTS=ON -Dcuda.version=$CUDA_VER
-DBUILD_TESTS=ON -Dcuda.version=$CUDA_VER \
-DUSE_SANITIZER=ON
2 changes: 1 addition & 1 deletion ci/premerge-build.sh
jlowe marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ ${MVN} verify ${MVN_MIRROR} \
-DCPP_PARALLEL_LEVEL=${PARALLEL_LEVEL} \
-Dlibcudf.build.configure=true \
-DUSE_GDS=ON -Dtest=*,!CuFileTest,!CudaFatalTest,!ColumnViewNonEmptyNullsTest \
-DBUILD_TESTS=ON
-DBUILD_TESTS=ON -DUSE_SANITIZER=ON
jlowe marked this conversation as resolved.
Show resolved Hide resolved
49 changes: 46 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
Expand Down Expand Up @@ -199,14 +205,51 @@
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>test-with-sanitizer</id>
<activation>
<property>
<name>USE_SANITIZER</name>
<value>ON</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>!noSanitizer</groups>
<jvm>${project.basedir}/build/sanitizer-java/bin/java</jvm>
</configuration>
</execution>
<execution>
<!-- Some tests (e.g. error cases) are not suitable to run with sanitizer, so run them separately here -->
<id>sanitizer-excluded-cases-test</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>noSanitizer</groups>
</configuration>
</execution>
<execution>
<id>non-empty-null-test</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<argLine>-da:ai.rapids.cudf.AssertEmptyNulls</argLine>
<test>ColumnViewNonEmptyNullsTest</test>
jlowe marked this conversation as resolved.
Show resolved Hide resolved
<jvm>${project.basedir}/build/sanitizer-java/bin/java</jvm>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -250,7 +293,7 @@
</plugins>
</build>
</profile>
<profile>
<profile>
<id>test-cpp</id>
<activation>
<property>
Expand Down