Skip to content

Commit

Permalink
Fix various build errors (#1152)
Browse files Browse the repository at this point in the history
Fix various build errors I encountered as I tried to build RAFT locally on my workstation. (Command used: `./build.sh -g raft-dask pylibraft libraft tests bench --compile-libs`)

* Add `gtest` as a link dependency of the C++ benchmark suite, to fix the error
```
[266/332] Building CUDA object CMakeFiles/NEIGHBORS_BENCH.dir/bench/neighbors/refine.cu.o
FAILED: CMakeFiles/NEIGHBORS_BENCH.dir/bench/neighbors/refine.cu.o
In file included from /home/phcho/Desktop/raft/cpp/bench/neighbors/../../test/neighbors/../test_utils.cuh:19,
from /home/phcho/Desktop/raft/cpp/bench/neighbors/../../test/neighbors/ann_utils.cuh:28,
from /home/phcho/Desktop/raft/cpp/bench/neighbors/../../test/neighbors/refine_helper.cuh:18,
from /home/phcho/Desktop/raft/cpp/bench/neighbors/refine.cu:39:
/home/phcho/Desktop/raft/cpp/bench/neighbors/../../test/neighbors/../test_utils.h:22:10: fatal error:
gtest/gtest.h: No such file or directory
22 | #include <gtest/gtest.h>
   |          ^~~~~~~~~~~~~~~
compilation terminated. 
```

* Explicitly specify the namespace for `alignTo`.
* Cast pointers into an integral type prior to passing it to `alignTo`.
* When calling `areSameAlignOffsets()`, pass the underlying pointers of the mdspan objects. Passing an mdspan to `areSameAlignOffsets()` is an error.

Authors:
  - Philip Hyunsu Cho (https://github.com/hcho3)

Approvers:
  - Micka (https://github.com/lowener)
  - Robert Maynard (https://github.com/robertmaynard)
  - Artem M. Chirkin (https://github.com/achirkin)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #1152
  • Loading branch information
hcho3 authored Jan 19, 2023
1 parent 187ff9e commit a7399cb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cpp/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2022, NVIDIA CORPORATION.
# Copyright (c) 2022-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
Expand Down Expand Up @@ -32,6 +32,7 @@ function(ConfigureBench)
PRIVATE raft::raft
$<$<BOOL:${ConfigureBench_DIST}>:raft::distance>
$<$<BOOL:${ConfigureBench_NN}>:raft::nn>
GTest::gtest
benchmark::benchmark
Threads::Threads
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
Expand Down
6 changes: 4 additions & 2 deletions cpp/include/raft/core/device_mdspan.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-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.
Expand Down Expand Up @@ -197,7 +197,9 @@ auto make_device_aligned_matrix_view(ElementType* ptr, IndexType n_rows, IndexTy
detail::alignment::value>::data_handle_type;
static_assert(std::is_same<LayoutPolicy, layout_left_padded<ElementType>>::value ||
std::is_same<LayoutPolicy, layout_right_padded<ElementType>>::value);
assert(ptr == alignTo(ptr, detail::alignment::value));
assert(reinterpret_cast<std::uintptr_t>(ptr) ==
std::experimental::details::alignTo(reinterpret_cast<std::uintptr_t>(ptr),
detail::alignment::value));

data_handle_type aligned_pointer = ptr;

Expand Down
6 changes: 4 additions & 2 deletions cpp/include/raft/core/host_mdspan.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-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.
Expand Down Expand Up @@ -144,7 +144,9 @@ auto make_host_aligned_matrix_view(ElementType* ptr, IndexType n_rows, IndexType

static_assert(std::is_same<LayoutPolicy, layout_left_padded<ElementType>>::value ||
std::is_same<LayoutPolicy, layout_right_padded<ElementType>>::value);
assert(ptr == alignTo(ptr, detail::alignment::value));
assert(reinterpret_cast<std::uintptr_t>(ptr) ==
std::experimental::details::alignTo(reinterpret_cast<std::uintptr_t>(ptr),
detail::alignment::value));
data_handle_type aligned_pointer = ptr;

matrix_extent<IndexType> extents{n_rows, n_cols};
Expand Down
5 changes: 3 additions & 2 deletions cpp/include/raft/matrix/detail/linewise_op.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
* Copyright (c) 2021-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.
Expand Down Expand Up @@ -796,7 +796,8 @@ struct MatrixLinewiseOp {
"layout for in and out must be either padded row or col major");

// also statically assert padded matrix alignment == 2^i*VecBytes
assert(raft::Pow2<VecBytes>::areSameAlignOffsets(in, out));
RAFT_EXPECTS(raft::Pow2<VecBytes>::areSameAlignOffsets(in.data_handle(), out.data_handle()),
"The matrix views in and out does not have correct alignment");

if (alongLines)
return matrixLinewiseVecRowsSpan<Type,
Expand Down

0 comments on commit a7399cb

Please sign in to comment.