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

Add github action for C++ clang-format style check #1597

Merged
merged 9 commits into from
Nov 28, 2023
34 changes: 34 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# A workflow to check clang format
name: clang format check

on:
pull_request:
Copy link
Collaborator Author

@yinqingh yinqingh Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to pull_request event

types: [opened, synchronize, reopened]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: pre-commit/[email protected]
with:
extra_args: clang-format --all-files
16 changes: 9 additions & 7 deletions src/main/cpp/src/DateTimeRebaseJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,31 @@
extern "C" {

JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_DateTimeRebase_rebaseGregorianToJulian(
JNIEnv *env, jclass, jlong input) {
JNIEnv* env, jclass, jlong input)
{
JNI_NULL_CHECK(env, input, "input column is null", 0);

try {
cudf::jni::auto_set_device(env);
auto const input_cv = reinterpret_cast<cudf::column_view const *>(input);
auto output = spark_rapids_jni::rebase_gregorian_to_julian(*input_cv);
auto const input_cv = reinterpret_cast<cudf::column_view const*>(input);
auto output = spark_rapids_jni::rebase_gregorian_to_julian(*input_cv);
return reinterpret_cast<jlong>(output.release());
}
CATCH_STD(env, 0);
}

JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_DateTimeRebase_rebaseJulianToGregorian(
JNIEnv *env, jclass, jlong input) {
JNIEnv* env, jclass, jlong input)
{
JNI_NULL_CHECK(env, input, "input column is null", 0);

try {
cudf::jni::auto_set_device(env);
auto const input_cv = reinterpret_cast<cudf::column_view const *>(input);
auto output = spark_rapids_jni::rebase_julian_to_gregorian(*input_cv);
auto const input_cv = reinterpret_cast<cudf::column_view const*>(input);
auto output = spark_rapids_jni::rebase_julian_to_gregorian(*input_cv);
return reinterpret_cast<jlong>(output.release());
}
CATCH_STD(env, 0);
}

} // extern "C"
} // extern "C"
21 changes: 11 additions & 10 deletions src/main/cpp/src/HistogramJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,41 @@
extern "C" {

JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_Histogram_createHistogramIfValid(
JNIEnv *env, jclass, jlong values_handle, jlong frequencies_handle, jboolean output_as_lists) {
JNIEnv* env, jclass, jlong values_handle, jlong frequencies_handle, jboolean output_as_lists)
{
JNI_NULL_CHECK(env, values_handle, "values_handle is null", 0);
JNI_NULL_CHECK(env, frequencies_handle, "frequencies_handle is null", 0);

try {
cudf::jni::auto_set_device(env);

auto const values = reinterpret_cast<cudf::column_view const *>(values_handle);
auto const frequencies = reinterpret_cast<cudf::column_view const *>(frequencies_handle);
auto const values = reinterpret_cast<cudf::column_view const*>(values_handle);
auto const frequencies = reinterpret_cast<cudf::column_view const*>(frequencies_handle);
return cudf::jni::ptr_as_jlong(
spark_rapids_jni::create_histogram_if_valid(*values, *frequencies, output_as_lists)
.release());
spark_rapids_jni::create_histogram_if_valid(*values, *frequencies, output_as_lists)
.release());
}
CATCH_STD(env, 0);
}

JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_Histogram_percentileFromHistogram(
JNIEnv *env, jclass, jlong input_handle, jdoubleArray jpercentages, jboolean output_as_lists) {
JNIEnv* env, jclass, jlong input_handle, jdoubleArray jpercentages, jboolean output_as_lists)
{
JNI_NULL_CHECK(env, input_handle, "input_handle is null", 0);
JNI_NULL_CHECK(env, jpercentages, "jpercentages is null", 0);

try {
cudf::jni::auto_set_device(env);

auto const input = reinterpret_cast<cudf::column_view const *>(input_handle);
auto const input = reinterpret_cast<cudf::column_view const*>(input_handle);
auto const percentages = [&] {
auto const native_percentages = cudf::jni::native_jdoubleArray(env, jpercentages);
return std::vector<double>(native_percentages.begin(), native_percentages.end());
}();
return cudf::jni::ptr_as_jlong(
spark_rapids_jni::percentile_from_histogram(*input, percentages, output_as_lists)
.release());
spark_rapids_jni::percentile_from_histogram(*input, percentages, output_as_lists).release());
}
CATCH_STD(env, 0);
}

} // extern "C"
} // extern "C"
2 changes: 1 addition & 1 deletion src/main/cpp/src/cast_string_to_float.cu
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class string_to_float {
int decimal_pos = 0; // absolute decimal pos

// have we seen a valid digit yet?
bool seen_valid_digit = false;
bool seen_valid_digit = false;
do {
int num_chars = _blen - _bpos;

Expand Down
Loading