repo_id
stringlengths
21
96
file_path
stringlengths
31
155
content
stringlengths
1
92.9M
__index_level_0__
int64
0
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_long_float.cu
/* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \ template void raft::neighbors::detail::select_k(const key_t* inK, \ const payload_t* inV, \ size_t n_rows, \ size_t n_cols, \ key_t* outK, \ payload_t* outV, \ bool select_min, \ int k, \ cudaStream_t stream) instantiate_raft_neighbors_detail_select_k(long, float); #undef instantiate_raft_neighbors_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_int64_t_double.cu
/* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \ template void raft::neighbors::detail::select_k(const key_t* inK, \ const payload_t* inV, \ size_t n_rows, \ size_t n_cols, \ key_t* outK, \ payload_t* outV, \ bool select_min, \ int k, \ cudaStream_t stream) instantiate_raft_neighbors_detail_select_k(int64_t, double); #undef instantiate_raft_neighbors_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_pq_compute_similarity_half_fp8_false.cu
/* * 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. */ /* * NOTE: this file is generated by ivf_pq_compute_similarity_00_generate.py * * Make changes there and run in this directory: * * > python ivf_pq_compute_similarity_00_generate.py * */ #include <raft/neighbors/detail/ivf_pq_compute_similarity-inl.cuh> #include <raft/neighbors/detail/ivf_pq_fp_8bit.cuh> #define instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( \ OutT, LutT, IvfSampleFilterT) \ template auto \ raft::neighbors::ivf_pq::detail::compute_similarity_select<OutT, LutT, IvfSampleFilterT>( \ const cudaDeviceProp& dev_props, \ bool manage_local_topk, \ int locality_hint, \ double preferred_shmem_carveout, \ uint32_t pq_bits, \ uint32_t pq_dim, \ uint32_t precomp_data_count, \ uint32_t n_queries, \ uint32_t n_probes, \ uint32_t topk) \ ->raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT>; \ \ template void \ raft::neighbors::ivf_pq::detail::compute_similarity_run<OutT, LutT, IvfSampleFilterT>( \ raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT> s, \ rmm::cuda_stream_view stream, \ uint32_t dim, \ uint32_t n_probes, \ uint32_t pq_dim, \ uint32_t n_queries, \ uint32_t queries_offset, \ raft::distance::DistanceType metric, \ raft::neighbors::ivf_pq::codebook_gen codebook_kind, \ uint32_t topk, \ uint32_t max_samples, \ const float* cluster_centers, \ const float* pq_centers, \ const uint8_t* const* pq_dataset, \ const uint32_t* cluster_labels, \ const uint32_t* _chunk_indices, \ const float* queries, \ const uint32_t* index_list, \ float* query_kths, \ IvfSampleFilterT sample_filter, \ LutT* lut_scores, \ OutT* _out_scores, \ uint32_t* _out_indices); #define COMMA , instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( half, raft::neighbors::ivf_pq::detail::fp_8bit<5u COMMA false>, raft::neighbors::filtering::ivf_to_sample_filter< int64_t COMMA raft::neighbors::filtering::none_ivf_sample_filter>); #undef COMMA #undef instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_flat_interleaved_scan_float_float_int64_t.cu
/* * 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. */ #include <raft/neighbors/detail/ivf_flat_interleaved_scan-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> #define instantiate_raft_neighbors_ivf_flat_detail_ivfflat_interleaved_scan( \ T, AccT, IdxT, IvfSampleFilterT) \ template void \ raft::neighbors::ivf_flat::detail::ivfflat_interleaved_scan<T, AccT, IdxT, IvfSampleFilterT>( \ const raft::neighbors::ivf_flat::index<T, IdxT>& index, \ const T* queries, \ const uint32_t* coarse_query_results, \ const uint32_t n_queries, \ const uint32_t queries_offset, \ const raft::distance::DistanceType metric, \ const uint32_t n_probes, \ const uint32_t k, \ const bool select_min, \ IvfSampleFilterT sample_filter, \ IdxT* neighbors, \ float* distances, \ uint32_t& grid_dim_x, \ rmm::cuda_stream_view stream) instantiate_raft_neighbors_ivf_flat_detail_ivfflat_interleaved_scan( float, float, int64_t, raft::neighbors::filtering::none_ivf_sample_filter); #undef instantiate_raft_neighbors_ivf_flat_detail_ivfflat_interleaved_scan
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_int64_t_half.cu
/* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \ template void raft::neighbors::detail::select_k(const key_t* inK, \ const payload_t* inV, \ size_t n_rows, \ size_t n_cols, \ key_t* outK, \ payload_t* outV, \ bool select_min, \ int k, \ cudaStream_t stream) instantiate_raft_neighbors_detail_select_k(int64_t, half); #undef instantiate_raft_neighbors_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_pq_compute_similarity_float_fp8_true.cu
/* * 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. */ /* * NOTE: this file is generated by ivf_pq_compute_similarity_00_generate.py * * Make changes there and run in this directory: * * > python ivf_pq_compute_similarity_00_generate.py * */ #include <raft/neighbors/detail/ivf_pq_compute_similarity-inl.cuh> #include <raft/neighbors/detail/ivf_pq_fp_8bit.cuh> #define instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( \ OutT, LutT, IvfSampleFilterT) \ template auto \ raft::neighbors::ivf_pq::detail::compute_similarity_select<OutT, LutT, IvfSampleFilterT>( \ const cudaDeviceProp& dev_props, \ bool manage_local_topk, \ int locality_hint, \ double preferred_shmem_carveout, \ uint32_t pq_bits, \ uint32_t pq_dim, \ uint32_t precomp_data_count, \ uint32_t n_queries, \ uint32_t n_probes, \ uint32_t topk) \ ->raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT>; \ \ template void \ raft::neighbors::ivf_pq::detail::compute_similarity_run<OutT, LutT, IvfSampleFilterT>( \ raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT> s, \ rmm::cuda_stream_view stream, \ uint32_t dim, \ uint32_t n_probes, \ uint32_t pq_dim, \ uint32_t n_queries, \ uint32_t queries_offset, \ raft::distance::DistanceType metric, \ raft::neighbors::ivf_pq::codebook_gen codebook_kind, \ uint32_t topk, \ uint32_t max_samples, \ const float* cluster_centers, \ const float* pq_centers, \ const uint8_t* const* pq_dataset, \ const uint32_t* cluster_labels, \ const uint32_t* _chunk_indices, \ const float* queries, \ const uint32_t* index_list, \ float* query_kths, \ IvfSampleFilterT sample_filter, \ LutT* lut_scores, \ OutT* _out_scores, \ uint32_t* _out_indices); #define COMMA , instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( float, raft::neighbors::ivf_pq::detail::fp_8bit<5u COMMA true>, raft::neighbors::filtering::ivf_to_sample_filter< int64_t COMMA raft::neighbors::filtering::none_ivf_sample_filter>); #undef COMMA #undef instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_flat_interleaved_scan_int8_t_int32_t_int64_t.cu
/* * 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. */ #include <raft/neighbors/detail/ivf_flat_interleaved_scan-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> #define instantiate_raft_neighbors_ivf_flat_detail_ivfflat_interleaved_scan( \ T, AccT, IdxT, IvfSampleFilterT) \ template void \ raft::neighbors::ivf_flat::detail::ivfflat_interleaved_scan<T, AccT, IdxT, IvfSampleFilterT>( \ const raft::neighbors::ivf_flat::index<T, IdxT>& index, \ const T* queries, \ const uint32_t* coarse_query_results, \ const uint32_t n_queries, \ const uint32_t queries_offset, \ const raft::distance::DistanceType metric, \ const uint32_t n_probes, \ const uint32_t k, \ const bool select_min, \ IvfSampleFilterT sample_filter, \ IdxT* neighbors, \ float* distances, \ uint32_t& grid_dim_x, \ rmm::cuda_stream_view stream) instantiate_raft_neighbors_ivf_flat_detail_ivfflat_interleaved_scan( int8_t, int32_t, int64_t, raft::neighbors::filtering::none_ivf_sample_filter); #undef instantiate_raft_neighbors_ivf_flat_detail_ivfflat_interleaved_scan
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/refine_host_uint8_t_float.cpp
/* * 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. */ #include <raft/neighbors/detail/refine_host-inl.hpp> #define instantiate_raft_neighbors_refine(IdxT, DataT, DistanceT, ExtentsT) \ template void raft::neighbors::detail::refine_host<IdxT, DataT, DistanceT, ExtentsT>( \ raft::host_matrix_view<const DataT, ExtentsT, row_major> dataset, \ raft::host_matrix_view<const DataT, ExtentsT, row_major> queries, \ raft::host_matrix_view<const IdxT, ExtentsT, row_major> neighbor_candidates, \ raft::host_matrix_view<IdxT, ExtentsT, row_major> indices, \ raft::host_matrix_view<DistanceT, ExtentsT, row_major> distances, \ distance::DistanceType metric); instantiate_raft_neighbors_refine(int64_t, uint8_t, float, int64_t); #undef instantiate_raft_neighbors_refine
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_pq_compute_similarity_half_fp8_true.cu
/* * 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. */ /* * NOTE: this file is generated by ivf_pq_compute_similarity_00_generate.py * * Make changes there and run in this directory: * * > python ivf_pq_compute_similarity_00_generate.py * */ #include <raft/neighbors/detail/ivf_pq_compute_similarity-inl.cuh> #include <raft/neighbors/detail/ivf_pq_fp_8bit.cuh> #define instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( \ OutT, LutT, IvfSampleFilterT) \ template auto \ raft::neighbors::ivf_pq::detail::compute_similarity_select<OutT, LutT, IvfSampleFilterT>( \ const cudaDeviceProp& dev_props, \ bool manage_local_topk, \ int locality_hint, \ double preferred_shmem_carveout, \ uint32_t pq_bits, \ uint32_t pq_dim, \ uint32_t precomp_data_count, \ uint32_t n_queries, \ uint32_t n_probes, \ uint32_t topk) \ ->raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT>; \ \ template void \ raft::neighbors::ivf_pq::detail::compute_similarity_run<OutT, LutT, IvfSampleFilterT>( \ raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT> s, \ rmm::cuda_stream_view stream, \ uint32_t dim, \ uint32_t n_probes, \ uint32_t pq_dim, \ uint32_t n_queries, \ uint32_t queries_offset, \ raft::distance::DistanceType metric, \ raft::neighbors::ivf_pq::codebook_gen codebook_kind, \ uint32_t topk, \ uint32_t max_samples, \ const float* cluster_centers, \ const float* pq_centers, \ const uint8_t* const* pq_dataset, \ const uint32_t* cluster_labels, \ const uint32_t* _chunk_indices, \ const float* queries, \ const uint32_t* index_list, \ float* query_kths, \ IvfSampleFilterT sample_filter, \ LutT* lut_scores, \ OutT* _out_scores, \ uint32_t* _out_indices); #define COMMA , instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( half, raft::neighbors::ivf_pq::detail::fp_8bit<5u COMMA true>, raft::neighbors::filtering::ivf_to_sample_filter< int64_t COMMA raft::neighbors::filtering::none_ivf_sample_filter>); #undef COMMA #undef instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_00_generate.py
# 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. header = """ /* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \\ template void raft::neighbors::detail::select_k(const key_t* inK, \\ const payload_t* inV, \\ size_t n_rows, \\ size_t n_cols, \\ key_t* outK, \\ payload_t* outV, \\ bool select_min, \\ int k, \\ cudaStream_t stream) """ types = dict( uint32_t_float=("uint32_t", "float"), uint32_t_double=("uint32_t", "double"), uint32_t_half=("uint32_t", "half"), int64_t_double=("int64_t", "double"), int64_t_half=("int64_t", "half"), int32_t_float=("int32_t", "float"), long_float=("long", "float"), size_t_double=("size_t", "double"), int_double=("int", "double"), size_t_float=("size_t", "float"), ) for type_path, (payload_t, key_t) in types.items(): path = f"selection_faiss_{type_path}.cu" with open(path, "w") as f: f.write(header) f.write(f"instantiate_raft_neighbors_detail_select_k({payload_t}, {key_t});\n\n") f.write(f"#undef instantiate_raft_neighbors_detail_select_k\n") # for pasting into CMakeLists.txt print(f"src/neighbors/detail/{path}")
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_flat_search.cu
/* * 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 * * 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. */ #include <raft/neighbors/detail/ivf_flat_search-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> #define instantiate_raft_neighbors_ivf_flat_detail_search(T, IdxT, IvfSampleFilterT) \ template void raft::neighbors::ivf_flat::detail::search<T, IdxT, IvfSampleFilterT>( \ raft::resources const& handle, \ const search_params& params, \ const raft::neighbors::ivf_flat::index<T, IdxT>& index, \ const T* queries, \ uint32_t n_queries, \ uint32_t k, \ IdxT* neighbors, \ float* distances, \ rmm::mr::device_memory_resource* mr, \ IvfSampleFilterT sample_filter) instantiate_raft_neighbors_ivf_flat_detail_search( float, int64_t, raft::neighbors::filtering::none_ivf_sample_filter); instantiate_raft_neighbors_ivf_flat_detail_search( int8_t, int64_t, raft::neighbors::filtering::none_ivf_sample_filter); instantiate_raft_neighbors_ivf_flat_detail_search( uint8_t, int64_t, raft::neighbors::filtering::none_ivf_sample_filter); #undef instantiate_raft_neighbors_ivf_flat_detail_search
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_int32_t_float.cu
/* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \ template void raft::neighbors::detail::select_k(const key_t* inK, \ const payload_t* inV, \ size_t n_rows, \ size_t n_cols, \ key_t* outK, \ payload_t* outV, \ bool select_min, \ int k, \ cudaStream_t stream) instantiate_raft_neighbors_detail_select_k(int32_t, float); #undef instantiate_raft_neighbors_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_uint32_t_double.cu
/* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \ template void raft::neighbors::detail::select_k(const key_t* inK, \ const payload_t* inV, \ size_t n_rows, \ size_t n_cols, \ key_t* outK, \ payload_t* outV, \ bool select_min, \ int k, \ cudaStream_t stream) instantiate_raft_neighbors_detail_select_k(uint32_t, double); #undef instantiate_raft_neighbors_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/refine_host_int8_t_float.cpp
/* * 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. */ #include <raft/neighbors/detail/refine_host-inl.hpp> #define instantiate_raft_neighbors_refine(IdxT, DataT, DistanceT, ExtentsT) \ template void raft::neighbors::detail::refine_host<IdxT, DataT, DistanceT, ExtentsT>( \ raft::host_matrix_view<const DataT, ExtentsT, row_major> dataset, \ raft::host_matrix_view<const DataT, ExtentsT, row_major> queries, \ raft::host_matrix_view<const IdxT, ExtentsT, row_major> neighbor_candidates, \ raft::host_matrix_view<IdxT, ExtentsT, row_major> indices, \ raft::host_matrix_view<DistanceT, ExtentsT, row_major> distances, \ distance::DistanceType metric); instantiate_raft_neighbors_refine(int64_t, int8_t, float, int64_t); #undef instantiate_raft_neighbors_refine
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_int_double.cu
/* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \ template void raft::neighbors::detail::select_k(const key_t* inK, \ const payload_t* inV, \ size_t n_rows, \ size_t n_cols, \ key_t* outK, \ payload_t* outV, \ bool select_min, \ int k, \ cudaStream_t stream) instantiate_raft_neighbors_detail_select_k(int, double); #undef instantiate_raft_neighbors_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_pq_compute_similarity_00_generate.py
# 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. header = """ /* * 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. */ /* * NOTE: this file is generated by ivf_pq_compute_similarity_00_generate.py * * Make changes there and run in this directory: * * > python ivf_pq_compute_similarity_00_generate.py * */ #include <raft/neighbors/detail/ivf_pq_compute_similarity-inl.cuh> #include <raft/neighbors/detail/ivf_pq_fp_8bit.cuh> #define instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select(OutT, LutT, IvfSampleFilterT) \\ template auto raft::neighbors::ivf_pq::detail::compute_similarity_select<OutT, LutT, IvfSampleFilterT>( \\ const cudaDeviceProp& dev_props, \\ bool manage_local_topk, \\ int locality_hint, \\ double preferred_shmem_carveout, \\ uint32_t pq_bits, \\ uint32_t pq_dim, \\ uint32_t precomp_data_count, \\ uint32_t n_queries, \\ uint32_t n_probes, \\ uint32_t topk) -> raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT>; \\ \\ template void raft::neighbors::ivf_pq::detail::compute_similarity_run<OutT, LutT, IvfSampleFilterT>( \\ raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT> s, \\ rmm::cuda_stream_view stream, \\ uint32_t dim, \\ uint32_t n_probes, \\ uint32_t pq_dim, \\ uint32_t n_queries, \\ uint32_t queries_offset, \\ raft::distance::DistanceType metric, \\ raft::neighbors::ivf_pq::codebook_gen codebook_kind, \\ uint32_t topk, \\ uint32_t max_samples, \\ const float* cluster_centers, \\ const float* pq_centers, \\ const uint8_t* const* pq_dataset, \\ const uint32_t* cluster_labels, \\ const uint32_t* _chunk_indices, \\ const float* queries, \\ const uint32_t* index_list, \\ float* query_kths, \\ IvfSampleFilterT sample_filter, \\ LutT* lut_scores, \\ OutT* _out_scores, \\ uint32_t* _out_indices); #define COMMA , """ trailer = """ #undef COMMA #undef instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select """ types = dict( half_fp8_false=("half", "raft::neighbors::ivf_pq::detail::fp_8bit<5u COMMA false>"), half_fp8_true=("half", "raft::neighbors::ivf_pq::detail::fp_8bit<5u COMMA true>"), half_half=("half", "half"), float_half=("float", "half"), float_float= ("float", "float"), float_fp8_false=("float", "raft::neighbors::ivf_pq::detail::fp_8bit<5u COMMA false>"), float_fp8_true=("float", "raft::neighbors::ivf_pq::detail::fp_8bit<5u COMMA true>"), ) for path_key, (OutT, LutT) in types.items(): path = f"ivf_pq_compute_similarity_{path_key}.cu" with open(path, "w") as f: f.write(header) f.write(f"instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select({OutT}, {LutT}, raft::neighbors::filtering::ivf_to_sample_filter<int64_t COMMA raft::neighbors::filtering::none_ivf_sample_filter>);\n") f.write(trailer) print(f"src/neighbors/detail/{path}")
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_size_t_float.cu
/* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \ template void raft::neighbors::detail::select_k(const key_t* inK, \ const payload_t* inV, \ size_t n_rows, \ size_t n_cols, \ key_t* outK, \ payload_t* outV, \ bool select_min, \ int k, \ cudaStream_t stream) instantiate_raft_neighbors_detail_select_k(size_t, float); #undef instantiate_raft_neighbors_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_size_t_double.cu
/* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \ template void raft::neighbors::detail::select_k(const key_t* inK, \ const payload_t* inV, \ size_t n_rows, \ size_t n_cols, \ key_t* outK, \ payload_t* outV, \ bool select_min, \ int k, \ cudaStream_t stream) instantiate_raft_neighbors_detail_select_k(size_t, double); #undef instantiate_raft_neighbors_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/refine_host_float_float.cpp
/* * 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. */ #include <raft/neighbors/detail/refine_host-inl.hpp> #define instantiate_raft_neighbors_refine(IdxT, DataT, DistanceT, ExtentsT) \ template void raft::neighbors::detail::refine_host<IdxT, DataT, DistanceT, ExtentsT>( \ raft::host_matrix_view<const DataT, ExtentsT, row_major> dataset, \ raft::host_matrix_view<const DataT, ExtentsT, row_major> queries, \ raft::host_matrix_view<const IdxT, ExtentsT, row_major> neighbor_candidates, \ raft::host_matrix_view<IdxT, ExtentsT, row_major> indices, \ raft::host_matrix_view<DistanceT, ExtentsT, row_major> distances, \ distance::DistanceType metric); instantiate_raft_neighbors_refine(int64_t, float, float, int64_t); #undef instantiate_raft_neighbors_refine
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_pq_compute_similarity_float_float.cu
/* * 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. */ /* * NOTE: this file is generated by ivf_pq_compute_similarity_00_generate.py * * Make changes there and run in this directory: * * > python ivf_pq_compute_similarity_00_generate.py * */ #include <raft/neighbors/detail/ivf_pq_compute_similarity-inl.cuh> #include <raft/neighbors/detail/ivf_pq_fp_8bit.cuh> #define instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( \ OutT, LutT, IvfSampleFilterT) \ template auto \ raft::neighbors::ivf_pq::detail::compute_similarity_select<OutT, LutT, IvfSampleFilterT>( \ const cudaDeviceProp& dev_props, \ bool manage_local_topk, \ int locality_hint, \ double preferred_shmem_carveout, \ uint32_t pq_bits, \ uint32_t pq_dim, \ uint32_t precomp_data_count, \ uint32_t n_queries, \ uint32_t n_probes, \ uint32_t topk) \ ->raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT>; \ \ template void \ raft::neighbors::ivf_pq::detail::compute_similarity_run<OutT, LutT, IvfSampleFilterT>( \ raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT> s, \ rmm::cuda_stream_view stream, \ uint32_t dim, \ uint32_t n_probes, \ uint32_t pq_dim, \ uint32_t n_queries, \ uint32_t queries_offset, \ raft::distance::DistanceType metric, \ raft::neighbors::ivf_pq::codebook_gen codebook_kind, \ uint32_t topk, \ uint32_t max_samples, \ const float* cluster_centers, \ const float* pq_centers, \ const uint8_t* const* pq_dataset, \ const uint32_t* cluster_labels, \ const uint32_t* _chunk_indices, \ const float* queries, \ const uint32_t* index_list, \ float* query_kths, \ IvfSampleFilterT sample_filter, \ LutT* lut_scores, \ OutT* _out_scores, \ uint32_t* _out_indices); #define COMMA , instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( float, float, raft::neighbors::filtering::ivf_to_sample_filter< int64_t COMMA raft::neighbors::filtering::none_ivf_sample_filter>); #undef COMMA #undef instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_pq_compute_similarity_float_fp8_false.cu
/* * 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. */ /* * NOTE: this file is generated by ivf_pq_compute_similarity_00_generate.py * * Make changes there and run in this directory: * * > python ivf_pq_compute_similarity_00_generate.py * */ #include <raft/neighbors/detail/ivf_pq_compute_similarity-inl.cuh> #include <raft/neighbors/detail/ivf_pq_fp_8bit.cuh> #define instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( \ OutT, LutT, IvfSampleFilterT) \ template auto \ raft::neighbors::ivf_pq::detail::compute_similarity_select<OutT, LutT, IvfSampleFilterT>( \ const cudaDeviceProp& dev_props, \ bool manage_local_topk, \ int locality_hint, \ double preferred_shmem_carveout, \ uint32_t pq_bits, \ uint32_t pq_dim, \ uint32_t precomp_data_count, \ uint32_t n_queries, \ uint32_t n_probes, \ uint32_t topk) \ ->raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT>; \ \ template void \ raft::neighbors::ivf_pq::detail::compute_similarity_run<OutT, LutT, IvfSampleFilterT>( \ raft::neighbors::ivf_pq::detail::selected<OutT, LutT, IvfSampleFilterT> s, \ rmm::cuda_stream_view stream, \ uint32_t dim, \ uint32_t n_probes, \ uint32_t pq_dim, \ uint32_t n_queries, \ uint32_t queries_offset, \ raft::distance::DistanceType metric, \ raft::neighbors::ivf_pq::codebook_gen codebook_kind, \ uint32_t topk, \ uint32_t max_samples, \ const float* cluster_centers, \ const float* pq_centers, \ const uint8_t* const* pq_dataset, \ const uint32_t* cluster_labels, \ const uint32_t* _chunk_indices, \ const float* queries, \ const uint32_t* index_list, \ float* query_kths, \ IvfSampleFilterT sample_filter, \ LutT* lut_scores, \ OutT* _out_scores, \ uint32_t* _out_indices); #define COMMA , instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select( float, raft::neighbors::ivf_pq::detail::fp_8bit<5u COMMA false>, raft::neighbors::filtering::ivf_to_sample_filter< int64_t COMMA raft::neighbors::filtering::none_ivf_sample_filter>); #undef COMMA #undef instantiate_raft_neighbors_ivf_pq_detail_compute_similarity_select
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/selection_faiss_uint32_t_float.cu
/* * 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. */ /* * NOTE: this file is generated by selection_faiss_00_generate.py * * Make changes there and run in this directory: * * > python selection_faiss_00_generate.py * */ #include <cstddef> // size_t #include <cstdint> // uint32_t #include <raft/neighbors/detail/selection_faiss-inl.cuh> #define instantiate_raft_neighbors_detail_select_k(payload_t, key_t) \ template void raft::neighbors::detail::select_k(const key_t* inK, \ const payload_t* inV, \ size_t n_rows, \ size_t n_cols, \ key_t* outK, \ payload_t* outV, \ bool select_min, \ int k, \ cudaStream_t stream) instantiate_raft_neighbors_detail_select_k(uint32_t, float); #undef instantiate_raft_neighbors_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/neighbors
rapidsai_public_repos/raft/cpp/src/neighbors/detail/ivf_flat_interleaved_scan_uint8_t_uint32_t_int64_t.cu
/* * 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. */ #include <raft/neighbors/detail/ivf_flat_interleaved_scan-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> #define instantiate_raft_neighbors_ivf_flat_detail_ivfflat_interleaved_scan( \ T, AccT, IdxT, IvfSampleFilterT) \ template void \ raft::neighbors::ivf_flat::detail::ivfflat_interleaved_scan<T, AccT, IdxT, IvfSampleFilterT>( \ const raft::neighbors::ivf_flat::index<T, IdxT>& index, \ const T* queries, \ const uint32_t* coarse_query_results, \ const uint32_t n_queries, \ const uint32_t queries_offset, \ const raft::distance::DistanceType metric, \ const uint32_t n_probes, \ const uint32_t k, \ const bool select_min, \ IvfSampleFilterT sample_filter, \ IdxT* neighbors, \ float* distances, \ uint32_t& grid_dim_x, \ rmm::cuda_stream_view stream) instantiate_raft_neighbors_ivf_flat_detail_ivfflat_interleaved_scan( uint8_t, uint32_t, int64_t, raft::neighbors::filtering::none_ivf_sample_filter); #undef instantiate_raft_neighbors_ivf_flat_detail_ivfflat_interleaved_scan
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_int8_uint32_dim512_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 32, 512, int8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_uint8_uint32_dim512_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 32, 512, uint8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_uint8_uint32_dim128_t8.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 8, 128, uint8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_uint8_uint32_dim1024_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 32, 1024, uint8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_float_uint32_dim128_t8.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 8, 128, float, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_float_uint64_dim128_t8.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 8, 128, float, uint64_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_float_uint64_dim256_t16.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 16, 256, float, uint64_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_int8_uint32_dim128_t8.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 8, 128, int8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_float_uint32_dim256_t16.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 16, 256, float, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_00_generate.py
# 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. header = """ /* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \\ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \\ template void \\ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \\ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \\ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \\ INDEX_T* const topk_indices_ptr, \\ DISTANCE_T* const topk_distances_ptr, \\ const DATA_T* const queries_ptr, \\ const uint32_t num_queries, \\ const INDEX_T* dev_seed_ptr, \\ uint32_t* const num_executed_iterations, \\ uint32_t topk, \\ uint32_t num_itopk_candidates, \\ uint32_t block_size, \\ uint32_t smem_size, \\ int64_t hash_bitlen, \\ INDEX_T* hashmap_ptr, \\ size_t small_hash_bitlen, \\ size_t small_hash_reset_interval, \\ uint32_t num_random_samplings, \\ uint64_t rand_xor_mask, \\ uint32_t num_seeds, \\ size_t itopk_size, \\ size_t search_width, \\ size_t min_iterations, \\ size_t max_iterations, \\ SAMPLE_FILTER_T sample_filter, \\ cudaStream_t stream); """ trailer = """ #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search """ mxdim_team = [(128, 8), (256, 16), (512, 32), (1024, 32)] # block = [(64, 16), (128, 8), (256, 4), (512, 2), (1024, 1)] # itopk_candidates = [64, 128, 256] # itopk_size = [64, 128, 256, 512] # mxelem = [64, 128, 256] # rblock = [(256, 4), (512, 2), (1024, 1)] # rcandidates = [32] # rsize = [256, 512] search_types = dict( float_uint32=("float", "uint32_t", "float"), # data_t, idx_t, distance_t int8_uint32=("int8_t", "uint32_t", "float"), uint8_uint32=("uint8_t", "uint32_t", "float"), float_uint64=("float", "uint64_t", "float"), ) # knn for type_path, (data_t, idx_t, distance_t) in search_types.items(): for (mxdim, team) in mxdim_team: path = f"search_single_cta_{type_path}_dim{mxdim}_t{team}.cu" with open(path, "w") as f: f.write(header) f.write( f"instantiate_single_cta_select_and_run(\n {team}, {mxdim}, {data_t}, {idx_t}, {distance_t}, raft::neighbors::filtering::none_cagra_sample_filter);\n" ) f.write(trailer) # For pasting into CMakeLists.txt print(f"src/neighbors/detail/cagra/{path}")
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_int8_uint32_dim1024_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 32, 1024, int8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_float_uint32_dim1024_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 32, 1024, float, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_float_uint64_dim1024_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 32, 1024, float, uint64_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_uint8_uint32_dim1024_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 32, 1024, uint8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_float_uint64_dim512_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 32, 512, float, uint64_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_int8_uint32_dim256_t16.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 16, 256, int8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_float_uint64_dim512_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 32, 512, float, uint64_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_float_uint32_dim512_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 32, 512, float, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_00_generate.py
# 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. header = """ /* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \\ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \\ template void \\ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \\ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \\ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \\ INDEX_T* const topk_indices_ptr, \\ DISTANCE_T* const topk_distances_ptr, \\ const DATA_T* const queries_ptr, \\ const uint32_t num_queries, \\ const INDEX_T* dev_seed_ptr, \\ uint32_t* const num_executed_iterations, \\ uint32_t topk, \\ uint32_t block_size, \\ uint32_t result_buffer_size, \\ uint32_t smem_size, \\ int64_t hash_bitlen, \\ INDEX_T* hashmap_ptr, \\ uint32_t num_cta_per_query, \\ uint32_t num_random_samplings, \\ uint64_t rand_xor_mask, \\ uint32_t num_seeds, \\ size_t itopk_size, \\ size_t search_width, \\ size_t min_iterations, \\ size_t max_iterations, \\ SAMPLE_FILTER_T sample_filter, \\ cudaStream_t stream); """ trailer = """ #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search """ mxdim_team = [(128, 8), (256, 16), (512, 32), (1024, 32)] # block = [(64, 16), (128, 8), (256, 4), (512, 2), (1024, 1)] # mxelem = [64, 128, 256] load_types = ["uint4"] search_types = dict( float_uint32=( "float", "uint32_t", "float", ), # data_t, vec_idx_t, distance_t int8_uint32=("int8_t", "uint32_t", "float"), uint8_uint32=("uint8_t", "uint32_t", "float"), float_uint64=("float", "uint64_t", "float"), ) # knn for type_path, (data_t, idx_t, distance_t) in search_types.items(): for (mxdim, team) in mxdim_team: path = f"search_multi_cta_{type_path}_dim{mxdim}_t{team}.cu" with open(path, "w") as f: f.write(header) f.write( f"instantiate_kernel_selection(\n {team}, {mxdim}, {data_t}, {idx_t}, {distance_t}, raft::neighbors::filtering::none_cagra_sample_filter);\n" ) f.write(trailer) # For pasting into CMakeLists.txt print(f"src/neighbors/detail/cagra/{path}")
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_float_uint64_dim128_t8.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 8, 128, float, uint64_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_int8_uint32_dim256_t16.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 16, 256, int8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_int8_uint32_dim1024_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 32, 1024, int8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_float_uint32_dim256_t16.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 16, 256, float, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_int8_uint32_dim512_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 32, 512, int8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_float_uint64_dim1024_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 32, 1024, float, uint64_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_float_uint64_dim256_t16.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 16, 256, float, uint64_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_int8_uint32_dim128_t8.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 8, 128, int8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_float_uint32_dim1024_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 32, 1024, float, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_float_uint32_dim128_t8.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 8, 128, float, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_uint8_uint32_dim512_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 32, 512, uint8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_uint8_uint32_dim256_t16.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 16, 256, uint8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_uint8_uint32_dim256_t16.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 16, 256, uint8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_single_cta_float_uint32_dim512_t32.cu
/* * 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. */ /* * NOTE: this file is generated by search_single_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_single_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_single_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::single_cta_search { #define instantiate_single_cta_select_and_run( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t num_itopk_candidates, \ uint32_t block_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ size_t small_hash_bitlen, \ size_t small_hash_reset_interval, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_single_cta_select_and_run( 32, 512, float, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_single_cta_search_kernel } // namespace raft::neighbors::cagra::detail::single_cta_search
0
rapidsai_public_repos/raft/cpp/src/neighbors/detail
rapidsai_public_repos/raft/cpp/src/neighbors/detail/cagra/search_multi_cta_uint8_uint32_dim128_t8.cu
/* * 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. */ /* * NOTE: this file is generated by search_multi_cta_00_generate.py * * Make changes there and run in this directory: * * > python search_multi_cta_00_generate.py * */ #include <raft/neighbors/detail/cagra/search_multi_cta_kernel-inl.cuh> #include <raft/neighbors/sample_filter_types.hpp> namespace raft::neighbors::cagra::detail::multi_cta_search { #define instantiate_kernel_selection( \ TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T) \ template void \ select_and_run<TEAM_SIZE, MAX_DATASET_DIM, DATA_T, INDEX_T, DISTANCE_T, SAMPLE_FILTER_T>( \ raft::device_matrix_view<const DATA_T, int64_t, layout_stride> dataset, \ raft::device_matrix_view<const INDEX_T, int64_t, row_major> graph, \ INDEX_T* const topk_indices_ptr, \ DISTANCE_T* const topk_distances_ptr, \ const DATA_T* const queries_ptr, \ const uint32_t num_queries, \ const INDEX_T* dev_seed_ptr, \ uint32_t* const num_executed_iterations, \ uint32_t topk, \ uint32_t block_size, \ uint32_t result_buffer_size, \ uint32_t smem_size, \ int64_t hash_bitlen, \ INDEX_T* hashmap_ptr, \ uint32_t num_cta_per_query, \ uint32_t num_random_samplings, \ uint64_t rand_xor_mask, \ uint32_t num_seeds, \ size_t itopk_size, \ size_t search_width, \ size_t min_iterations, \ size_t max_iterations, \ SAMPLE_FILTER_T sample_filter, \ cudaStream_t stream); instantiate_kernel_selection( 8, 128, uint8_t, uint32_t, float, raft::neighbors::filtering::none_cagra_sample_filter); #undef instantiate_kernel_selection } // namespace raft::neighbors::cagra::detail::multi_cta_search
0
rapidsai_public_repos/raft/cpp/src/linalg
rapidsai_public_repos/raft/cpp/src/linalg/detail/coalesced_reduction.cu
/* * 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 * * 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. */ // #include <raft/linalg/detail/coalesced_reduction-ext.cuh> #include <raft/linalg/detail/coalesced_reduction-inl.cuh> #define instantiate_raft_linalg_detail_coalescedReduction( \ InType, OutType, IdxType, MainLambda, ReduceLambda, FinalLambda) \ template void raft::linalg::detail::coalescedReduction(OutType* dots, \ const InType* data, \ IdxType D, \ IdxType N, \ OutType init, \ cudaStream_t stream, \ bool inplace, \ MainLambda main_op, \ ReduceLambda reduce_op, \ FinalLambda final_op) instantiate_raft_linalg_detail_coalescedReduction( double, double, int, raft::identity_op, raft::min_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( double, double, int, raft::sq_op, raft::add_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( double, double, int, raft::sq_op, raft::add_op, raft::sqrt_op); instantiate_raft_linalg_detail_coalescedReduction( double, double, int, raft::abs_op, raft::add_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( double, double, int, raft::abs_op, raft::max_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, size_t, raft::abs_op, raft::add_op, raft::sqrt_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, int, raft::abs_op, raft::add_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, int, raft::identity_op, raft::add_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, int, raft::identity_op, raft::min_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, int, raft::sq_op, raft::add_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, int, raft::sq_op, raft::add_op, raft::sqrt_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, long, raft::sq_op, raft::add_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, size_t, raft::identity_op, raft::add_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, size_t, raft::sq_op, raft::add_op, raft::identity_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, size_t, raft::abs_op, raft::max_op, raft::sqrt_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, size_t, raft::sq_op, raft::add_op, raft::sqrt_op); instantiate_raft_linalg_detail_coalescedReduction( float, float, unsigned int, raft::sq_op, raft::add_op, raft::identity_op); #undef instantiate_raft_linalg_detail_coalescedReduction
0
rapidsai_public_repos/raft/cpp/src/matrix
rapidsai_public_repos/raft/cpp/src/matrix/detail/select_k_float_int64_t.cu
/* * 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. */ #include <raft/matrix/detail/select_k-inl.cuh> #define instantiate_raft_matrix_detail_select_k(T, IdxT) \ template void raft::matrix::detail::select_k(raft::resources const& handle, \ const T* in_val, \ const IdxT* in_idx, \ size_t batch_size, \ size_t len, \ int k, \ T* out_val, \ IdxT* out_idx, \ bool select_min, \ rmm::mr::device_memory_resource* mr, \ bool sorted) instantiate_raft_matrix_detail_select_k(float, int64_t); #undef instantiate_raft_matrix_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/matrix
rapidsai_public_repos/raft/cpp/src/matrix/detail/select_k_double_uint32_t.cu
/* * 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. */ #include <cstdint> // uint32_t #include <raft/matrix/detail/select_k-inl.cuh> #define instantiate_raft_matrix_detail_select_k(T, IdxT) \ template void raft::matrix::detail::select_k(raft::resources const& handle, \ const T* in_val, \ const IdxT* in_idx, \ size_t batch_size, \ size_t len, \ int k, \ T* out_val, \ IdxT* out_idx, \ bool select_min, \ rmm::mr::device_memory_resource* mr, \ bool sorted) instantiate_raft_matrix_detail_select_k(double, uint32_t); #undef instantiate_raft_matrix_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/matrix
rapidsai_public_repos/raft/cpp/src/matrix/detail/select_k_double_int64_t.cu
/* * 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. */ #include <raft/matrix/detail/select_k-inl.cuh> #define instantiate_raft_matrix_detail_select_k(T, IdxT) \ template void raft::matrix::detail::select_k(raft::resources const& handle, \ const T* in_val, \ const IdxT* in_idx, \ size_t batch_size, \ size_t len, \ int k, \ T* out_val, \ IdxT* out_idx, \ bool select_min, \ rmm::mr::device_memory_resource* mr, \ bool sorted) instantiate_raft_matrix_detail_select_k(double, int64_t); #undef instantiate_raft_matrix_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/matrix
rapidsai_public_repos/raft/cpp/src/matrix/detail/select_k_half_uint32_t.cu
/* * 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. */ #include <raft/matrix/detail/select_k-inl.cuh> #define instantiate_raft_matrix_detail_select_k(T, IdxT) \ template void raft::matrix::detail::select_k(raft::resources const& handle, \ const T* in_val, \ const IdxT* in_idx, \ size_t batch_size, \ size_t len, \ int k, \ T* out_val, \ IdxT* out_idx, \ bool select_min, \ rmm::mr::device_memory_resource* mr, \ bool sorted) instantiate_raft_matrix_detail_select_k(__half, uint32_t); #undef instantiate_raft_matrix_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/matrix
rapidsai_public_repos/raft/cpp/src/matrix/detail/select_k_half_int64_t.cu
/* * 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. */ #include <raft/matrix/detail/select_k-inl.cuh> #define instantiate_raft_matrix_detail_select_k(T, IdxT) \ template void raft::matrix::detail::select_k(raft::resources const& handle, \ const T* in_val, \ const IdxT* in_idx, \ size_t batch_size, \ size_t len, \ int k, \ T* out_val, \ IdxT* out_idx, \ bool select_min, \ rmm::mr::device_memory_resource* mr, \ bool sorted) instantiate_raft_matrix_detail_select_k(__half, int64_t); #undef instantiate_raft_matrix_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/matrix
rapidsai_public_repos/raft/cpp/src/matrix/detail/select_k_float_uint32_t.cu
/* * 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. */ #include <raft/matrix/detail/select_k-inl.cuh> #define instantiate_raft_matrix_detail_select_k(T, IdxT) \ template void raft::matrix::detail::select_k(raft::resources const& handle, \ const T* in_val, \ const IdxT* in_idx, \ size_t batch_size, \ size_t len, \ int k, \ T* out_val, \ IdxT* out_idx, \ bool select_min, \ rmm::mr::device_memory_resource* mr, \ bool sorted) instantiate_raft_matrix_detail_select_k(float, uint32_t); #undef instantiate_raft_matrix_detail_select_k
0
rapidsai_public_repos/raft/cpp/src/matrix
rapidsai_public_repos/raft/cpp/src/matrix/detail/select_k_float_int32.cu
/* * 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. */ #include <raft/matrix/detail/select_k-inl.cuh> #define instantiate_raft_matrix_detail_select_k(T, IdxT) \ template void raft::matrix::detail::select_k(raft::resources const& handle, \ const T* in_val, \ const IdxT* in_idx, \ size_t batch_size, \ size_t len, \ int k, \ T* out_val, \ IdxT* out_idx, \ bool select_min, \ rmm::mr::device_memory_resource* mr, \ bool sorted) instantiate_raft_matrix_detail_select_k(float, int); #undef instantiate_raft_matrix_detail_select_k
0
rapidsai_public_repos/raft/cpp
rapidsai_public_repos/raft/cpp/doxygen/main_page.md
# libraft RAFT contains fundamental widely-used algorithms and primitives for data science, graph and machine learning. The algorithms are CUDA-accelerated and form building-blocks for rapidly composing analytics. By taking a primitives-based approach to algorithm development, RAFT - accelerates algorithm construction time, - reduces the maintenance burden by maximizing reuse across projects, and - centralizes core reusable computations, allowing future optimizations to benefit all algorithms that use them. While not exhaustive, the following general categories help summarize the accelerated functions in RAFT: ##### | Category | Examples | | --- | --- | | **Data Formats** | sparse & dense, conversions, data generation | | **Dense Linear Algebra** | matrix arithmetic, norms, factorization, least squares, svd & eigenvalue problems | | **Spatial** | pairwise distances, nearest neighbors, neighborhood graph construction | | **Sparse Operations** | linear algebra, eigenvalue problems, slicing, symmetrization, labeling | | **Basic Clustering** | spectral clustering, hierarchical clustering, k-means | | **Solvers** | combinatorial optimization, iterative solvers | | **Statistics** | sampling, moments and summary statistics, metrics | | **Distributed Tools** | multi-node multi-gpu infrastructure |
0
rapidsai_public_repos/raft/cpp
rapidsai_public_repos/raft/cpp/doxygen/Doxyfile
# Doxyfile 1.8.20 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a double hash (##) is considered a comment and is placed in # front of the TAG it is preceding. # # All text after a single hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the configuration # file that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by # double-quotes, unless you are using Doxywizard) that should identify the # project for which the documentation is generated. This name is used in the # title of most generated pages and in a few other places. # The default value is: My Project. PROJECT_NAME = "RAFT C++ API" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. PROJECT_NUMBER = "24.02" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and # will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes # performance problems for the file system. # The default value is: NO. CREATE_SUBDIRS = NO # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode # U+3044. # The default value is: NO. ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, # Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), # Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, # Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, # Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, # Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, # Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English # The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all generated output in the proper direction. # Possible values are: None, LTR, RTL and Context. # The default value is: None. OUTPUT_TEXT_DIRECTION = None # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description # # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. # The default value is: YES. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator that is # used to form the text in various listings. Each string in this list, if found # as the leading text of the brief description, will be stripped from the text # and the result, after processing the whole list, is used as the annotated # text. Otherwise, the brief description is used as-is. If left blank, the # following values are used ($name is automatically replaced with the name of # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief # description. # The default value is: NO. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. # The default value is: NO. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. FULL_PATH_NAMES = YES # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand # part of the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the path to # strip. # # Note that you can specify absolute paths here, but also relative paths, which # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which # header file to include in order to use a class. If left blank only the name of # the header file containing the class definition is used. Otherwise one should # specify the list of include paths that are normally passed to the compiler # using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't # support long names like on DOS, Mac, or CD-ROM. # The default value is: NO. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the # first line (until the first dot) of a Javadoc-style comment as the brief # description. If set to NO, the Javadoc-style will behave just like regular Qt- # style comments (thus requiring an explicit @brief command for a brief # description.) # The default value is: NO. JAVADOC_AUTOBRIEF = NO # If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line # such as # /*************** # as being the beginning of a Javadoc-style comment "banner". If set to NO, the # Javadoc-style will behave just like regular comments and it will not be # interpreted by doxygen. # The default value is: NO. JAVADOC_BANNER = NO # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus # requiring an explicit \brief command for a brief description.) # The default value is: NO. QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a # multi-line C++ special comment block (i.e. a block of //! or /// comments) as # a brief description. This used to be the default behavior. The new default is # to treat a multi-line C++ comment block as a detailed description. Set this # tag to YES if you prefer the old behavior instead. # # Note that setting this tag to YES also means that rational rose comments are # not recognized any more. # The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO # By default Python docstrings are displayed as preformatted text and doxygen's # special commands cannot be used. By setting PYTHON_DOCSTRING to NO the # doxygen's special commands can be used and the contents of the docstring # documentation blocks is shown as doxygen documentation. # The default value is: YES. PYTHON_DOCSTRING = YES # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new # page for each member. If set to NO, the documentation of a member will be part # of the file/class/namespace that contains it. # The default value is: NO. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen # uses this value to replace tabs by spaces in code fragments. # Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that act as commands in # the documentation. An alias has the form: # name=value # For example adding # "sideeffect=@par Side Effects:\n" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines (in the resulting output). You can put ^^ in the value part of an # alias to insert a newline as if a physical newline was in the original file. # When you need a literal { or } or , in the value part of an alias you have to # escape them by means of a backslash (\), this can lead to conflicts with the # commands \{ and \} for these it is advised to use the version @{ and @} or use # a double escape (\\{ and \\}) ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all # members will be omitted, etc. # The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored # for that language. For instance, namespaces will be presented as packages, # qualified scopes will look different, etc. # The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources. Doxygen will then generate output that is tailored for Fortran. # The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for VHDL. # The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO # Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice # sources only. Doxygen will then generate output that is more tailored for that # language. For instance, namespaces will be presented as modules, types will be # separated into more groups, etc. # The default value is: NO. OPTIMIZE_OUTPUT_SLICE = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and # language is one of the parsers supported by doxygen: IDL, Java, JavaScript, # Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, # Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: # FortranFree, unknown formatted Fortran: Fortran. In the later case the parser # tries to guess whether the code is fixed or free formatted code, this is the # default for Fortran type files). For instance to make doxygen treat .inc files # as Fortran files (default is PHP), and .f files as C (default is Fortran), # use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. EXTENSION_MAPPING = cu=C++ \ cuh=C++ # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable # documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. # The default value is: YES. MARKDOWN_SUPPORT = YES # When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up # to that level are automatically included in the table of contents, even if # they do not have an id attribute. # Note: This feature currently applies only to Markdown headings. # Minimum value: 0, maximum value: 99, default value: 5. # This tag requires that the tag MARKDOWN_SUPPORT is set to YES. TOC_INCLUDE_HEADINGS = 5 # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this # tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); # versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. # The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. # The default value is: NO. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES will make # doxygen to replace the get and set methods by a property in the documentation. # This will only work if the methods are indeed getting or setting a simple # type. If this is not the case, or you want to show the methods anyway, you # should set this option to NO. # The default value is: YES. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. # The default value is: NO. DISTRIBUTE_GROUP_DOC = NO # If one adds a struct or class to a group and this option is enabled, then also # any nested class or struct is added to the same group. By default this option # is disabled and one has to add nested compounds explicitly via \ingroup. # The default value is: NO. GROUP_NESTED_COMPOUNDS = NO # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent # subgrouping. Alternatively, this can be done per class using the # \nosubgrouping command. # The default value is: YES. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions # are shown inside the group in which they are included (e.g. using \ingroup) # instead of on a separate page (for HTML and Man pages) or section (for LaTeX # and RTF). # # Note that this feature does not work in combination with # SEPARATE_MEMBER_PAGES. # The default value is: NO. INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in # the documentation of the scope in which they are defined (i.e. file, # namespace, or group documentation), provided this scope is documented. If set # to NO, structs, classes, and unions are shown on a separate page (for HTML and # Man pages) or section (for LaTeX and RTF). # The default value is: NO. INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically be # useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. TYPEDEF_HIDES_STRUCT = NO # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be # an expensive process and often the same symbol appears multiple times in the # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small # doxygen will become slower. If the cache is too large, memory is wasted. The # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 # symbols. At the end of a run doxygen will report the cache usage and suggest # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 # The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use # during processing. When set to 0 doxygen will based this on the number of # cores available in the system. You can set it explicitly to a value larger # than 0 to get more control over the balance between CPU load and processing # speed. At this moment only the input processing can be done using multiple # threads. Since this is still an experimental feature the default is set to 1, # which efficively disables parallel processing. Please report any issues you # encounter. Generating dot graphs in parallel is controlled by the # DOT_NUM_THREADS setting. # Minimum value: 0, maximum value: 32, default value: 1. NUM_PROC_THREADS = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in # documentation are documented, even if no documentation was available. Private # class members and static file members will be hidden unless the # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. # Note: This will also disable the warnings about undocumented members that are # normally produced when WARNINGS is set to YES. # The default value is: NO. EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. EXTRACT_PRIVATE = NO # If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual # methods of a class will be included in the documentation. # The default value is: NO. EXTRACT_PRIV_VIRTUAL = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES, all static members of a file will be # included in the documentation. # The default value is: NO. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, # only classes defined in header files are included. Does not have any effect # for Java sources. # The default value is: YES. EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are # included in the documentation. If set to NO, only methods in the interface are # included. # The default value is: NO. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base name of # the file that contains the anonymous namespace. By default anonymous namespace # are hidden. # The default value is: NO. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation # section is generated. This option has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option # has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # declarations. If set to NO, these declarations will be included in the # documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any # documentation blocks found inside the body of a function. If set to NO, these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation that is typed after a # \internal command is included. If the tag is set to NO then the documentation # will be excluded. Set it to YES to include the internal documentation. # The default value is: NO. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file # names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # (including Cygwin) and Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the # scope will be hidden. # The default value is: NO. HIDE_SCOPE_NAMES = NO # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to # YES the compound reference will be hidden. # The default value is: NO. HIDE_COMPOUND_REFERENCE= NO # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. SHOW_INCLUDE_FILES = YES # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader # which file to include in order to use the member. # The default value is: NO. SHOW_GROUPED_MEMB_INC = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. # The default value is: YES. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. # The default value is: YES. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. Note that # this will also influence the order of the classes in the class list. # The default value is: NO. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the # (brief and detailed) documentation of class members so that constructors and # destructors are listed first. If set to NO the constructors will appear in the # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief # member documentation. # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting # detailed member documentation. # The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy # of group names into alphabetical order. If set to NO the group names will # appear in their defined order. # The default value is: NO. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will # be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the alphabetical # list. # The default value is: NO. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper # type resolution of all parameters of a function it will reject a match between # the prototype and the implementation of a member function even if there is # only one candidate or it is obvious which candidate to choose by doing a # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still # accept a match between prototype and implementation in such cases. # The default value is: NO. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo # list. This list is created by putting \todo commands in the documentation. # The default value is: YES. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test # list. This list is created by putting \test commands in the documentation. # The default value is: YES. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional documentation # sections, marked by \if <section_label> ... \endif and \cond <section_label> # ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the # documentation. If the initializer consists of more lines than specified here # it will be hidden. Use a value of 0 to hide initializers completely. The # appearance of the value of individual variables and macros / defines can be # controlled using \showinitializer or \hideinitializer command in the # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. # The default value is: YES. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the # Folder Tree View (if specified). # The default value is: YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command command input-file, where command is the value of the # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml # will be used as the name of the layout file. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool # to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated to # standard output by doxygen. If QUIET is set to YES this implies that the # messages are off. # The default value is: NO. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES # this implies that the warnings are on. # # Tip: Turn warnings on while writing the documentation. # The default value is: YES. WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters # in a documented function, or documenting parameters that don't exist or using # markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete # parameter documentation, but not about the absence of documentation. If # EXTRACT_ALL is set to YES then this flag will automatically be disabled. # The default value is: NO. WARN_NO_PARAMDOC = YES # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. # The default value is: NO. WARN_AS_ERROR = YES # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard # error (stderr). WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag is used to specify the files and/or directories that contain # documented source files. You may enter file names like myfile.cpp or # directories like /usr/src/myproject. Separate the files or directories with # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. INPUT = main_page.md \ ../include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: https://www.gnu.org/software/libiconv/) for the list of # possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), # *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen # C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, # *.vhdl, *.ucf, *.qsf and *.ice. FILE_PATTERNS = *.hpp \ *.cuh # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = ../include/raft/sparse/linalg/symmetrize.hpp \ ../include/raft/cache \ ../include/raft/common \ ../include/raft/lap \ ../include/raft/sparse/selection \ ../include/raft/sparse/csr.hpp \ ../include/raft/linalg/lanczos.cuh \ ../include/raft/linalg/lanczos.hpp \ ../include/raft/util/cuda_utils.cuh \ ../include/raft/util/cudart_utils.hpp \ ../include/raft/util/device_atomics.cuh \ ../include/raft/util/device_utils.cuh \ ../include/raft/core/error.hpp \ ../include/raft/core/handle.hpp \ ../include/raft/util/integer_utils.hpp \ ../include/raft/util/pow2_utils.cuh \ ../include/raft/util/vectorized.cuh \ ../include/raft/raft.hpp \ ../include/raft/core/cudart_utils.hpp \ ../include/raft/matrix/math.cuh \ ../include/raft/matrix/matrix.cuh # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. # The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* # TODO: remove specializations from exclude patterns when headers have been removed. EXCLUDE_PATTERNS = */detail/* \ */specializations/* \ */thirdparty/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = detail # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank all # files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands # irrespective of the value of the RECURSIVE tag. # The default value is: NO. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or directories # that contain images that are to be included in the documentation (see the # \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command: # # <filter> <input-file> # # where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the # name of an input file. Doxygen will then use the output that the filter # program writes to standard output. If FILTER_PATTERNS is specified, this tag # will be ignored. # # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: pattern=filter # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). # The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and # it is also possible to disable source filtering for a specific pattern using # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = main_page.md #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will be # generated. Documented entities will be cross-referenced with these sources. # # Note: To get rid of all source code in the generated output, make sure that # also VERBATIM_HEADERS is set to NO. # The default value is: NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. # The default value is: NO. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any # special comment blocks from generated source code fragments. Normal C, C++ and # Fortran comments will always remain visible. # The default value is: YES. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented # entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES then for each documented function # all documented entities called/used by that function will be listed. # The default value is: NO. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set # to YES then the hyperlinks from functions in REFERENCES_RELATION and # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will # link to the documentation. # The default value is: YES. REFERENCES_LINK_SOURCE = YES # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the # source code will show a tooltip with additional information such as prototype, # brief description and links to the definition and documentation. Since this # will make the HTML file larger and loading of large files a bit slower, you # can opt to disable this feature. # The default value is: YES. # This tag requires that the tag SOURCE_BROWSER is set to YES. SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system # (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global # - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # # Doxygen will invoke htags (and that will in turn invoke gtags), so these # tools must be available from the command line (i.e. in the search path). # # The result: instead of the source browser generated by doxygen, the links to # source code will now point to the output of htags. # The default value is: NO. # This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a # verbatim copy of the header file for each class for which an include is # specified. Set to NO to disable this. # See also: Section \class. # The default value is: YES. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all # compounds will be generated. Enable this if the project contains a lot of # classes, structs, unions or interfaces. # The default value is: YES. ALPHABETICAL_INDEX = YES # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in # which the alphabetical index list will be split. # Minimum value: 1, maximum value: 20, default value: 5. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. GENERATE_HTML = NO # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). # The default value is: .html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a user-defined HTML header file for # each generated HTML page. If the tag is left blank doxygen will generate a # standard header. # # To get valid HTML the header file that includes any scripts and style sheets # that doxygen needs, which is dependent on the configuration options used (e.g. # the setting GENERATE_TREEVIEW). It is highly recommended to start with a # default header using # doxygen -w html new_header.html new_footer.html new_stylesheet.css # YourConfigFile # and then modify the file new_header.html. See also section "Doxygen usage" # for information on how to generate the default header that doxygen normally # uses. # Note: The header is subject to change so you typically have to regenerate the # default header when upgrading to a newer version of doxygen. For a description # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = header.html # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard # footer. See HTML_HEADER for more information on how to generate a default # footer and what special commands can be used inside the footer. See also # section "Doxygen usage" for information on how to generate the default footer # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of # the HTML output. If left blank doxygen will generate a default style sheet. # See also section "Doxygen usage" for information on how to generate the style # sheet that doxygen normally uses. # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as # it is more robust and this tag (HTML_STYLESHEET) will in the future become # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the # standard style sheet and is therefore more robust against future updates. # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that the # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see # https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 266 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 255 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 # gradually make the output lighter, whereas values above 100 make the output # darker. The value divided by 100 is the actual gamma applied, so 80 represents # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not # change the gamma. # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 52 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this # to YES can help to show when doxygen was last run and thus if the # documentation is up to date. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # documentation will contain a main index with vertical navigation menus that # are dynamically created via JavaScript. If disabled, the navigation index will # consists of multiple levels of tabs that are statically embedded in every HTML # page. Disable this option to support browsers that do not have JavaScript, # like the Qt help browser. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_MENUS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand # and collapse entries dynamically later on. Doxygen will expand the tree to # such a level that at most the specified number of entries are visible (unless # a fully collapsed tree already exceeds this amount). So setting the number of # entries 1 will produce a full collapsed tree by default. 0 is a special value # representing an infinite number of entries and will result in a full expanded # tree by default. # Minimum value: 0, maximum value: 9999, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development # environment (see: https://developer.apple.com/xcode/), introduced with OSX # 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy # genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO # This tag determines the name of the docset feed. A documentation feed provides # an umbrella under which multiple documentation sets from a single provider # (such as a company or product suite) can be grouped. # The default value is: Doxygen generated docs. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. # The default value is: org.doxygen.Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop # (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML # files are now used as the Windows 98 help format, and will replace the old # Windows help format (.hlp) on all Windows platforms in the future. Compressed # HTML files also contain an index, a table of contents, and you can search for # words in the documentation. The HTML workshop also contains a viewer for # compressed HTML files. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO # The CHM_FILE tag can be used to specify the file name of the resulting .chm # file. You can add a path in front of the file if the result should not be # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, # doxygen will try to run the HTML help compiler on the generated index.hhp. # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO # The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it # enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members to # the table of contents of the HTML help documentation and to the tree view. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help # (.qch) of the generated HTML documentation. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify # the file name of the resulting .qch file. The path specified is relative to # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace # (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual # Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- # folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom # Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom # Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To # install this plugin and make it available under the help contents menu in # Eclipse, the contents of the directory containing the HTML and XML files needs # to be copied into the plugins directory of eclipse. The name of the directory # within the plugins directory should be the same as the ECLIPSE_DOC_ID value. # After copying Eclipse needs to be restarted before the help appears. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO # A unique identifier for the Eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have this # name. Each documentation set should have its own identifier. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project # If you want full control over the layout of the generated HTML pages it might # be necessary to disable the index and replace it with your own. The # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top # of each HTML page. A value of NO enables the index and the value YES disables # it. Since the tabs in the index contain the same information as the navigation # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag # value is set to YES, a side panel will be generated containing a tree-like # index structure (just like the one that is generated for HTML Help). For this # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can # further fine-tune the look of the index. As an example, the default style # sheet generated by doxygen has an example that shows how to put an image at # the root of the tree instead of the PROJECT_NAME. Since the tree basically has # the same information as the tab index, you could consider setting # DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # # Note that a value of 0 will completely suppress the enum values from appearing # in the overview section. # Minimum value: 0, maximum value: 20, default value: 4. # This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used # to set the initial width (in pixels) of the frame in which the tree is shown. # Minimum value: 0, maximum value: 1500, default value: 250. # This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 # If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to # external symbols imported via tag files in a separate window. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO # If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg # tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see # https://inkscape.org) to generate formulas as SVG images instead of PNGs for # the HTML output. These images will generally look nicer at scaled resolutions. # Possible values are: png (the default) and svg (looks nicer but requires the # pdf2svg or inkscape tool). # The default value is: png. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FORMULA_FORMAT = png # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML # output directory to force them to be regenerated. # Minimum value: 8, maximum value: 50, default value: 10. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANSPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # # Note that when changing this option you need to delete any form_*.png files in # the HTML output directory before the changes have effect. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES # The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands # to create new LaTeX commands to be used in formulas as building blocks. See # the section "Including formulas" for details. FORMULA_MACROFILE = # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path # to it using the MATHJAX_RELPATH option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = YES # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: # http://docs.mathjax.org/en/latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the HTML # output directory using the MATHJAX_RELPATH option. The destination directory # should contain the MathJax.js script. For instance, if the mathjax directory # is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from https://www.mathjax.org before deployment. # The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site # (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and # should work on any modern browser. Note that when using HTML help # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) # there is already a search function so this one should typically be disabled. # For large projects the javascript based search engine can be slow, then # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to # search using the keyboard; to jump to the search box use <access key> + S # (what the <access key> is depends on the OS and browser, but it is typically # <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down # key> to jump into the search results window, the results can be navigated # using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel # the search. The filter options can be selected when the cursor is inside the # search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys> # to select a filter and <Enter> or <escape> to activate or cancel the filter # option. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing # and searching needs to be provided by external tools. See the section # "External Indexing and Searching" for details. # The default value is: NO. # This tag requires that the tag SEARCHENGINE is set to YES. SERVER_BASED_SEARCH = NO # When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP # script for searching. Instead the search results are written to an XML file # which needs to be processed by an external indexer. Doxygen will invoke an # external search engine pointed to by the SEARCHENGINE_URL option to obtain the # search results. # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library # Xapian (see: https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. # This tag requires that the tag SEARCHENGINE is set to YES. EXTERNAL_SEARCH = NO # The SEARCHENGINE_URL should point to a search engine hosted by a web server # which will return the search results when EXTERNAL_SEARCH is enabled. # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library # Xapian (see: https://xapian.org/). See the section "External Indexing and # Searching" for details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the # SEARCHDATA_FILE tag the name of this file can be specified. # The default file is: searchdata.xml. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHDATA_FILE = searchdata.xml # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the # EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is # useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple # projects and redirect the results back to the right project. # This tag requires that the tag SEARCHENGINE is set to YES. EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are # all added to the same external search index. Each project needs to have a # unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of # to a relative location where the documentation can be found. The format is: # EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... # This tag requires that the tag SEARCHENGINE is set to YES. EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # Configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output. # The default value is: YES. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: latex. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. # # Note that when not enabling USE_PDFLATEX the default is latex when enabling # USE_PDFLATEX the default is pdflatex and when in the later case latex is # chosen this is overwritten by pdflatex. For specific output languages the # default can have been set differently, this depends on the implementation of # the output language. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate # index for LaTeX. # Note: This tag is used in the Makefile / make.bat. # See also: LATEX_MAKEINDEX_CMD for the part in the generated output file # (.tex). # The default file is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. MAKEINDEX_CMD_NAME = makeindex # The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to # generate index for LaTeX. In case there is no backslash (\) as first character # it will be automatically added in the LaTeX code. # Note: This tag is used in the generated output file (.tex). # See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. # The default value is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_MAKEINDEX_CMD = makeindex # If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some # trees in general. # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used by the # printer. # Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x # 14 inches) and executive (7.25 x 10.5 inches). # The default value is: a4. # This tag requires that the tag GENERATE_LATEX is set to YES. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names # that should be included in the LaTeX output. The package can be specified just # by its name or with the correct syntax as to be used with the LaTeX # \usepackage command. To get the times font for instance you can specify : # EXTRA_PACKAGES=times or EXTRA_PACKAGES={times} # To use the option intlimits with the amsmath package you can specify: # EXTRA_PACKAGES=[intlimits]{amsmath} # If left blank no extra packages will be included. # This tag requires that the tag GENERATE_LATEX is set to YES. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for the # generated LaTeX document. The header should contain everything until the first # chapter. If it is left blank doxygen will generate a standard header. See # section "Doxygen usage" for information on how to let doxygen write the # default header to a separate file. # # Note: Only use a user-defined header if you know what you are doing! The # following commands have a special meaning inside the header: $title, # $datetime, $date, $doxygenversion, $projectname, $projectnumber, # $projectbrief, $projectlogo. Doxygen will replace $title with the empty # string, for the replacement values of the other commands the user is referred # to HTML_HEADER. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the # generated LaTeX document. The footer should contain everything after the last # chapter. If it is left blank doxygen will generate a standard footer. See # LATEX_HEADER for more information on how to generate a default footer and what # special commands can be used inside the footer. # # Note: Only use a user-defined footer if you know what you are doing! # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_FOOTER = # The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined # LaTeX style sheets that are included after the standard style sheets created # by doxygen. Using this option one can overrule certain style aspects. Doxygen # will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the # list). # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_EXTRA_STYLESHEET = # The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the LATEX_OUTPUT output # directory. Note that the files will be copied as-is; there are no commands or # markers available. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_EXTRA_FILES = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is # prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will # contain links (just like the HTML output) instead of page references. This # makes the output suitable for online browsing using a PDF viewer. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as # specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX # files. Set this option to YES, to get a higher quality PDF documentation. # # See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode # command to the generated LaTeX files. This will instruct LaTeX to keep running # if errors occur, instead of asking the user for help. This option is also used # when generating formulas in HTML. # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_BATCHMODE = NO # If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the # index chapters (such as File Index, Compound Index, etc.) in the output. # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_HIDE_INDICES = NO # If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source # code with syntax highlighting in the LaTeX output. # # Note that which sources are shown also depends on other settings such as # SOURCE_BROWSER. # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See # https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_BIB_STYLE = plain # If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated # page will contain the date and time when the page was generated. Setting this # to NO can help when comparing the output of multiple runs. # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_TIMESTAMP = NO # The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) # path from which the emoji images will be read. If a relative path is entered, # it will be relative to the LATEX_OUTPUT directory. If left blank the # LATEX_OUTPUT directory will be used. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_EMOJI_DIRECTORY = #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The # RTF output is optimized for Word 97 and may not look too pretty with other RTF # readers/editors. # The default value is: NO. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: rtf. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF # documents. This may be useful for small projects and may help to save some # trees in general. # The default value is: NO. # This tag requires that the tag GENERATE_RTF is set to YES. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will # contain hyperlink fields. The RTF file will contain links (just like the HTML # output) instead of page references. This makes the output suitable for online # browsing using Word or some other Word compatible readers that support those # fields. # # Note: WordPad (write) and others do not support links. # The default value is: NO. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # configuration file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. # # See also section "Doxygen usage" for information on how to generate the # default style sheet that doxygen normally uses. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is # similar to doxygen's configuration file. A template extensions file can be # generated using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_EXTENSIONS_FILE = # If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code # with syntax highlighting in the RTF output. # # Note that which sources are shown also depends on other settings such as # SOURCE_BROWSER. # The default value is: NO. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_SOURCE_CODE = NO #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for # classes and files. # The default value is: NO. GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. A directory man3 will be created inside the directory specified by # MAN_OUTPUT. # The default directory is: man. # This tag requires that the tag GENERATE_MAN is set to YES. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to the generated # man pages. In case the manual section does not start with a number, the number # 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is # optional. # The default value is: .3. # This tag requires that the tag GENERATE_MAN is set to YES. MAN_EXTENSION = .3 # The MAN_SUBDIR tag determines the name of the directory created within # MAN_OUTPUT in which the man pages are placed. If defaults to man followed by # MAN_EXTENSION with the initial . removed. # This tag requires that the tag GENERATE_MAN is set to YES. MAN_SUBDIR = # If the MAN_LINKS tag is set to YES and doxygen generates man output, then it # will generate one additional man file for each entity documented in the real # man page(s). These additional files only source the real man page, but without # them the man command would be unable to find the correct page. # The default value is: NO. # This tag requires that the tag GENERATE_MAN is set to YES. MAN_LINKS = NO #--------------------------------------------------------------------------- # Configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that # captures the structure of the code including all documentation. # The default value is: NO. GENERATE_XML = YES # The XML_OUTPUT tag is used to specify where the XML pages will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: xml. # This tag requires that the tag GENERATE_XML is set to YES. XML_OUTPUT = _xml # If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program # listings (including syntax highlighting and cross-referencing information) to # the XML output. Note that enabling this will significantly increase the size # of the XML output. # The default value is: YES. # This tag requires that the tag GENERATE_XML is set to YES. XML_PROGRAMLISTING = YES # If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include # namespace members in file scope as well, matching the HTML output. # The default value is: NO. # This tag requires that the tag GENERATE_XML is set to YES. XML_NS_MEMB_FILE_SCOPE = NO #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- # If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files # that can be used to generate PDF. # The default value is: NO. GENERATE_DOCBOOK = NO # The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be put in # front of it. # The default directory is: docbook. # This tag requires that the tag GENERATE_DOCBOOK is set to YES. DOCBOOK_OUTPUT = docbook # If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the # program listings (including syntax highlighting and cross-referencing # information) to the DOCBOOK output. Note that enabling this will significantly # increase the size of the DOCBOOK output. # The default value is: NO. # This tag requires that the tag GENERATE_DOCBOOK is set to YES. DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an # AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures # the structure of the code including all documentation. Note that this feature # is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # Configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module # file that captures the structure of the code including all documentation. # # Note that this feature is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary # Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI # output from the Perl module output. # The default value is: NO. # This tag requires that the tag GENERATE_PERLMOD is set to YES. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely # formatted so it can be parsed by a human reader. This is useful if you want to # understand what is going on. On the other hand, if this tag is set to NO, the # size of the Perl module output will be much smaller and Perl will parse it # just the same. # The default value is: YES. # This tag requires that the tag GENERATE_PERLMOD is set to YES. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file are # prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful # so different doxyrules.make files included by the same Makefile don't # overwrite each other's variables. # This tag requires that the tag GENERATE_PERLMOD is set to YES. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all # C-preprocessor directives found in the sources and include files. # The default value is: YES. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names # in the source code. If set to NO, only conditional compilation will be # performed. Macro expansion can be done in a controlled way by setting # EXPAND_ONLY_PREDEF to YES. # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and # EXPAND_AS_DEFINED tags. # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. # The default value is: YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by the # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will be # used. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that are # defined before the preprocessor is started (similar to the -D option of e.g. # gcc). The argument of the tag is a list of macros of the form: name or # name=definition (no spaces). If the definition and the "=" are omitted, "=1" # is assumed. To prevent a macro definition from being undefined via #undef or # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The # macro definition that is found in the sources will be used. Use the PREDEFINED # tag if you want to use a different macro definition that overrules the # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have # an all uppercase name, and do not end with a semicolon. Such function macros # are typically used for boiler-plate code, and will confuse the parser if not # removed. # The default value is: YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration options related to external references #--------------------------------------------------------------------------- # The TAGFILES tag can be used to specify one or more tag files. For each tag # file the location of the external documentation should be added. The format of # a tag file without this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where loc1 and loc2 can be relative or absolute paths or URLs. See the # section "Linking to external documentation" for more information about the use # of tag files. # Note: Each tag file must have a unique name (where the name does NOT include # the path). If a tag file is not located in the directory in which doxygen is # run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create a # tag file that is based on the input files it reads. See section "Linking to # external documentation" for more information about the usage of tag files. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES, all external class will be listed in # the class index. If set to NO, only the inherited external classes will be # listed. # The default value is: NO. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed # in the modules index. If set to NO, only the current project's groups will be # listed. # The default value is: YES. EXTERNAL_GROUPS = YES # If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in # the related pages index. If set to NO, only the current project's pages will # be listed. # The default value is: YES. EXTERNAL_PAGES = YES #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram # (in HTML and LaTeX) for classes with base or super classes. Setting the tag to # NO turns the diagrams off. Note that this option also works with HAVE_DOT # disabled, but it is recommended to install and use dot, since it yields more # powerful graphs. # The default value is: YES. CLASS_DIAGRAMS = YES # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. # If left empty dia is assumed to be found in the default search path. DIA_PATH = # If set to YES the inheritance and collaboration graphs will hide inheritance # and usage relations if the target is undocumented or is not a class. # The default value is: YES. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz (see: # http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent # Bell Labs. The other options in this section have no effect if this option is # set to NO # The default value is: NO. HAVE_DOT = # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed # to run in parallel. When set to 0 doxygen will base this on the number of # processors available in the system. You can set it explicitly to a value # larger than 0 to get control over the balance between CPU load and processing # speed. # Minimum value: 0, maximum value: 32, default value: 0. # This tag requires that the tag HAVE_DOT is set to YES. DOT_NUM_THREADS = 0 # When you want a differently looking font in the dot files that doxygen # generates you can specify the font name using DOT_FONTNAME. You need to make # sure dot is able to find the font, which can be done by putting it in a # standard location or by setting the DOTFONTPATH environment variable or by # setting DOT_FONTPATH to the directory containing the font. # The default value is: Helvetica. # This tag requires that the tag HAVE_DOT is set to YES. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size (in points) of the font of # dot graphs. # Minimum value: 4, maximum value: 24, default value: 10. # This tag requires that the tag HAVE_DOT is set to YES. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the default font as specified with # DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set # the path where dot can find it using this tag. # This tag requires that the tag HAVE_DOT is set to YES. DOT_FONTPATH = # If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for # each documented class showing the direct and indirect inheritance relations. # Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a # graph for each documented class showing the direct and indirect implementation # dependencies (inheritance, containment, and class references variables) of the # class with other documented classes. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for # groups, showing the direct groups dependencies. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES, doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. UML_LOOK = YES # If the UML_LOOK tag is enabled, the fields and methods are shown inside the # class node. If there are many fields or methods and many nodes the graph may # become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the # number of items for each type to make the size more manageable. Set this to 0 # for no limit. Note that the threshold may be exceeded by 50% before the limit # is enforced. So when you set the threshold to 10, up to 15 fields may appear, # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. # This tag requires that the tag HAVE_DOT is set to YES. UML_LIMIT_NUM_FIELDS = 10 # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. TEMPLATE_RELATIONS = NO # If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to # YES then doxygen will generate a graph for each documented file showing the # direct and indirect include dependencies of the file with other documented # files. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. INCLUDE_GRAPH = YES # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are # set to YES then doxygen will generate a graph for each documented file showing # the direct and indirect include dependencies of the file with other documented # files. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH tag is set to YES then doxygen will generate a call # dependency graph for every global function or class method. # # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. Disabling a call graph can be # accomplished by means of the command \hidecallgraph. # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. CALL_GRAPH = NO # If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller # dependency graph for every global function or class method. # # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable caller graphs for selected # functions only using the \callergraph command. Disabling a caller graph can be # accomplished by means of the command \hidecallergraph. # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical # hierarchy of all classes instead of a textual one. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the # dependencies a directory has on other directories in a graphical way. The # dependency relations are determined by the #include relations between the # files in the directories. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. For an explanation of the image formats see the section # output formats in the documentation of the dot tool (Graphviz (see: # http://www.graphviz.org/)). # Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order # to make the SVG files visible in IE 9+ (other browsers do not have this # requirement). # Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo, # png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and # png:gdiplus:gdiplus. # The default value is: png. # This tag requires that the tag HAVE_DOT is set to YES. DOT_IMAGE_FORMAT = png # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. # # Note that this requires a modern browser other than Internet Explorer. Tested # and working are Firefox, Chrome, Safari, and Opera. # Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make # the SVG files visible. Older versions of IE do not have SVG support. # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. INTERACTIVE_SVG = NO # The DOT_PATH tag can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. # This tag requires that the tag HAVE_DOT is set to YES. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the \dotfile # command). # This tag requires that the tag HAVE_DOT is set to YES. DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the \mscfile # command). MSCFILE_DIRS = # The DIAFILE_DIRS tag can be used to specify one or more directories that # contain dia files that are included in the documentation (see the \diafile # command). DIAFILE_DIRS = # When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the # path where java can find the plantuml.jar file. If left blank, it is assumed # PlantUML is not used or called during a preprocessing step. Doxygen will # generate a warning when it encounters a \startuml command in this case and # will not generate output for the diagram. PLANTUML_JAR_PATH = # When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a # configuration file for plantuml. PLANTUML_CFG_FILE = # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. PLANTUML_INCLUDE_PATH = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes # that will be shown in the graph. If the number of nodes in a graph becomes # larger than this value, doxygen will truncate the graph, which is visualized # by representing a node as a red box. Note that doxygen if the number of direct # children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that # the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. # Minimum value: 0, maximum value: 10000, default value: 50. # This tag requires that the tag HAVE_DOT is set to YES. DOT_GRAPH_MAX_NODES = 100 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs # generated by dot. A depth value of 3 means that only nodes reachable from the # root by following a path via at most 3 edges will be shown. Nodes that lay # further from the root node will be omitted. Note that setting this option to 1 # or 2 may greatly reduce the computation time needed for large code bases. Also # note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. # Minimum value: 0, maximum value: 1000, default value: 0. # This tag requires that the tag HAVE_DOT is set to YES. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not seem # to support this out of the box. # # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) support # this, this feature is disabled by default. # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page # explaining the meaning of the various boxes and arrows in the dot generated # graphs. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot # files that are used to generate the various graphs. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES
0
rapidsai_public_repos/raft/cpp
rapidsai_public_repos/raft/cpp/doxygen/header.html
<!-- HTML header for doxygen 1.8.20--> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen $doxygenversion"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME--> <!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME--> <link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="$relpath^jquery.js"></script> <script type="text/javascript" src="$relpath^dynsections.js"></script> $treeview $search $mathjax <link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" /> $extrastylesheet <!-- RAPIDS CUSTOM JS & CSS: START, Please add these two lines back after every version upgrade --> <script defer src="https://docs.rapids.ai/assets/js/custom.js"></script> <link rel="stylesheet" href="https://docs.rapids.ai/assets/css/custom.css"> <!-- RAPIDS CUSTOM JS & CSS: END --> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <!--BEGIN TITLEAREA--> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <!--BEGIN PROJECT_LOGO--> <td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td> <!--END PROJECT_LOGO--> <!--BEGIN PROJECT_NAME--> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">$projectname <!--BEGIN PROJECT_NUMBER-->&#160;<span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER--> </div> <!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF--> </td> <!--END PROJECT_NAME--> <!--BEGIN !PROJECT_NAME--> <!--BEGIN PROJECT_BRIEF--> <td style="padding-left: 0.5em;"> <div id="projectbrief">$projectbrief</div> </td> <!--END PROJECT_BRIEF--> <!--END !PROJECT_NAME--> <!--BEGIN DISABLE_INDEX--> <!--BEGIN SEARCHENGINE--> <td>$searchbox</td> <!--END SEARCHENGINE--> <!--END DISABLE_INDEX--> </tr> </tbody> </table> </div> <!--END TITLEAREA--> <!-- end header part -->
0
rapidsai_public_repos/raft/cpp
rapidsai_public_repos/raft/cpp/test/CMakeLists.txt
# ============================================================================= # 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. 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. # ============================================================================= # ################################################################################################## # enable testing ################################################################################ # ################################################################################################## enable_testing() include(rapids-test) rapids_test_init() function(ConfigureTest) set(options OPTIONAL LIB EXPLICIT_INSTANTIATE_ONLY NOCUDA) set(oneValueArgs NAME GPUS PERCENT) set(multiValueArgs PATH TARGETS CONFIGURATIONS) cmake_parse_arguments(_RAFT_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(NOT DEFINED _RAFT_TEST_GPUS AND NOT DEFINED _RAFT_TEST_PERCENT) set(_RAFT_TEST_GPUS 1) set(_RAFT_TEST_PERCENT 30) endif() if(NOT DEFINED _RAFT_TEST_GPUS) set(_RAFT_TEST_GPUS 1) endif() if(NOT DEFINED _RAFT_TEST_PERCENT) set(_RAFT_TEST_PERCENT 100) endif() if(_RAFT_TEST_NOCUDA) set(TEST_NAME "${_RAFT_TEST_NAME}_NOCUDA") else() set(TEST_NAME ${_RAFT_TEST_NAME}) endif() add_executable(${TEST_NAME} ${_RAFT_TEST_PATH}) target_link_libraries( ${TEST_NAME} PRIVATE raft raft_internal $<$<BOOL:${_RAFT_TEST_LIB}>:raft::compiled> GTest::gtest GTest::gtest_main Threads::Threads ${RAFT_CTK_MATH_DEPENDENCIES} $<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX> $<TARGET_NAME_IF_EXISTS:conda_env> ) set_target_properties( ${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<BUILD_INTERFACE:${RAFT_BINARY_DIR}/gtests>" INSTALL_RPATH "\$ORIGIN/../../../lib" CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON ) target_compile_options( ${TEST_NAME} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>" "$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>" ) if(_RAFT_TEST_EXPLICIT_INSTANTIATE_ONLY) target_compile_definitions(${TEST_NAME} PRIVATE "RAFT_EXPLICIT_INSTANTIATE_ONLY") endif() if(_RAFT_TEST_NOCUDA) target_compile_definitions(${TEST_NAME} PRIVATE "RAFT_DISABLE_CUDA") endif() target_include_directories(${TEST_NAME} PUBLIC "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/test>") rapids_test_add( NAME ${TEST_NAME} COMMAND ${TEST_NAME} GPUS ${_RAFT_TEST_GPUS} PERCENT ${_RAFT_TEST_PERCENT} INSTALL_COMPONENT_SET testing ) endfunction() # ################################################################################################## # test sources ################################################################################## # ################################################################################################## # ################################################################################################## # * distance tests ------------------------------------------------------------------------- if(BUILD_TESTS) ConfigureTest( NAME CLUSTER_TEST PATH test/cluster/kmeans.cu test/cluster/kmeans_balanced.cu test/cluster/cluster_solvers.cu test/cluster/linkage.cu test/cluster/kmeans_find_k.cu LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest( NAME CORE_TEST PATH test/core/bitset.cu test/core/device_resources_manager.cpp test/core/device_setter.cpp test/core/logger.cpp test/core/math_device.cu test/core/math_host.cpp test/core/operators_device.cu test/core/operators_host.cpp test/core/handle.cpp test/core/interruptible.cu test/core/nvtx.cpp test/core/mdarray.cu test/core/mdspan_copy.cpp test/core/mdspan_copy.cu test/core/mdspan_utils.cu test/core/numpy_serializer.cu test/core/memory_type.cpp test/core/sparse_matrix.cu test/core/sparse_matrix.cpp test/core/span.cpp test/core/span.cu test/core/stream_view.cpp test/core/temporary_device_buffer.cu test/test.cpp LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest( NAME CORE_TEST PATH test/core/stream_view.cpp test/core/mdspan_copy.cpp LIB EXPLICIT_INSTANTIATE_ONLY NOCUDA ) ConfigureTest( NAME DISTANCE_TEST PATH test/distance/dist_adj.cu test/distance/dist_adj_distance_instance.cu test/distance/dist_canberra.cu test/distance/dist_correlation.cu test/distance/dist_cos.cu test/distance/dist_hamming.cu test/distance/dist_hellinger.cu test/distance/dist_inner_product.cu test/distance/dist_jensen_shannon.cu test/distance/dist_kl_divergence.cu test/distance/dist_l1.cu test/distance/dist_l2_exp.cu test/distance/dist_l2_unexp.cu test/distance/dist_l2_sqrt_exp.cu test/distance/dist_l_inf.cu test/distance/dist_lp_unexp.cu test/distance/dist_russell_rao.cu test/distance/masked_nn.cu test/distance/masked_nn_compress_to_bits.cu test/distance/fused_l2_nn.cu test/distance/gram.cu LIB EXPLICIT_INSTANTIATE_ONLY ) list( APPEND EXT_HEADER_TEST_SOURCES test/ext_headers/raft_neighbors_brute_force.cu test/ext_headers/raft_distance_distance.cu test/ext_headers/raft_distance_detail_pairwise_matrix_dispatch.cu test/ext_headers/raft_matrix_detail_select_k.cu test/ext_headers/raft_neighbors_ball_cover.cu test/ext_headers/raft_spatial_knn_detail_fused_l2_knn.cu test/ext_headers/raft_distance_fused_l2_nn.cu test/ext_headers/raft_neighbors_ivf_pq.cu test/ext_headers/raft_util_memory_pool.cpp test/ext_headers/raft_neighbors_ivf_flat.cu test/ext_headers/raft_core_logger.cpp test/ext_headers/raft_neighbors_refine.cu test/ext_headers/raft_neighbors_detail_ivf_flat_search.cu test/ext_headers/raft_neighbors_detail_selection_faiss.cu test/ext_headers/raft_linalg_detail_coalesced_reduction.cu test/ext_headers/raft_spatial_knn_detail_ball_cover_registers.cu test/ext_headers/raft_neighbors_detail_ivf_flat_interleaved_scan.cu test/ext_headers/raft_neighbors_detail_ivf_pq_compute_similarity.cu ) # Test that the split headers compile in isolation with: # # * EXT_HEADERS_TEST_COMPILED_EXPLICIT: RAFT_COMPILED, RAFT_EXPLICIT_INSTANTIATE_ONLY defined # * EXT_HEADERS_TEST_COMPILED_IMPLICIT: RAFT_COMPILED defined # * EXT_HEADERS_TEST_IMPLICIT: no macros defined. ConfigureTest( NAME EXT_HEADERS_TEST_COMPILED_EXPLICIT PATH ${EXT_HEADER_TEST_SOURCES} LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest(NAME EXT_HEADERS_TEST_COMPILED_IMPLICIT PATH ${EXT_HEADER_TEST_SOURCES} LIB) ConfigureTest(NAME EXT_HEADERS_TEST_IMPLICIT PATH ${EXT_HEADER_TEST_SOURCES}) ConfigureTest(NAME LABEL_TEST PATH test/label/label.cu test/label/merge_labels.cu) ConfigureTest( NAME LINALG_TEST PATH test/linalg/add.cu test/linalg/axpy.cu test/linalg/binary_op.cu test/linalg/cholesky_r1.cu test/linalg/coalesced_reduction.cu test/linalg/divide.cu test/linalg/dot.cu test/linalg/eig.cu test/linalg/eig_sel.cu test/linalg/gemm_layout.cu test/linalg/gemv.cu test/linalg/map.cu test/linalg/map_then_reduce.cu test/linalg/matrix_vector.cu test/linalg/matrix_vector_op.cu test/linalg/mean_squared_error.cu test/linalg/multiply.cu test/linalg/norm.cu test/linalg/normalize.cu test/linalg/power.cu test/linalg/randomized_svd.cu test/linalg/reduce.cu test/linalg/reduce_cols_by_key.cu test/linalg/reduce_rows_by_key.cu test/linalg/rsvd.cu test/linalg/sqrt.cu test/linalg/strided_reduction.cu test/linalg/subtract.cu test/linalg/svd.cu test/linalg/ternary_op.cu test/linalg/transpose.cu test/linalg/unary_op.cu ) ConfigureTest( NAME MATRIX_TEST PATH test/matrix/argmax.cu test/matrix/argmin.cu test/matrix/columnSort.cu test/matrix/diagonal.cu test/matrix/gather.cu test/matrix/scatter.cu test/matrix/eye.cu test/matrix/linewise_op.cu test/matrix/math.cu test/matrix/matrix.cu test/matrix/norm.cu test/matrix/reverse.cu test/matrix/slice.cu test/matrix/triangular.cu test/sparse/spectral_matrix.cu LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest(NAME MATRIX_SELECT_TEST PATH test/matrix/select_k.cu LIB EXPLICIT_INSTANTIATE_ONLY) ConfigureTest( NAME MATRIX_SELECT_LARGE_TEST PATH test/matrix/select_large_k.cu LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest( NAME RANDOM_TEST PATH test/random/make_blobs.cu test/random/make_regression.cu test/random/multi_variable_gaussian.cu test/random/rng_pcg_host_api.cu test/random/permute.cu test/random/rng.cu test/random/rng_discrete.cu test/random/rng_int.cu test/random/rmat_rectangular_generator.cu test/random/sample_without_replacement.cu ) ConfigureTest( NAME SOLVERS_TEST PATH test/cluster/cluster_solvers_deprecated.cu test/linalg/eigen_solvers.cu test/lap/lap.cu test/sparse/mst.cu LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest( NAME SPARSE_TEST PATH test/sparse/add.cu test/sparse/convert_coo.cu test/sparse/convert_csr.cu test/sparse/csr_row_slice.cu test/sparse/csr_to_dense.cu test/sparse/csr_transpose.cu test/sparse/degree.cu test/sparse/filter.cu test/sparse/norm.cu test/sparse/normalize.cu test/sparse/reduce.cu test/sparse/row_op.cu test/sparse/sort.cu test/sparse/spgemmi.cu test/sparse/symmetrize.cu ) ConfigureTest( NAME SPARSE_DIST_TEST PATH test/sparse/dist_coo_spmv.cu test/sparse/distance.cu test/sparse/gram.cu LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest( NAME SPARSE_NEIGHBORS_TEST PATH test/sparse/neighbors/cross_component_nn.cu test/sparse/neighbors/brute_force.cu test/sparse/neighbors/knn_graph.cu LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest( NAME NEIGHBORS_TEST PATH test/neighbors/knn.cu test/neighbors/fused_l2_knn.cu test/neighbors/tiled_knn.cu test/neighbors/haversine.cu test/neighbors/ball_cover.cu test/neighbors/epsilon_neighborhood.cu test/neighbors/refine.cu LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest( NAME NEIGHBORS_ANN_CAGRA_TEST PATH test/neighbors/ann_cagra/test_float_uint32_t.cu test/neighbors/ann_cagra/test_int8_t_uint32_t.cu test/neighbors/ann_cagra/test_uint8_t_uint32_t.cu test/neighbors/ann_cagra/test_float_int64_t.cu src/neighbors/detail/cagra/search_multi_cta_float_uint64_dim128_t8.cu src/neighbors/detail/cagra/search_multi_cta_float_uint64_dim256_t16.cu src/neighbors/detail/cagra/search_multi_cta_float_uint64_dim512_t32.cu src/neighbors/detail/cagra/search_multi_cta_float_uint64_dim1024_t32.cu src/neighbors/detail/cagra/search_single_cta_float_uint64_dim128_t8.cu src/neighbors/detail/cagra/search_single_cta_float_uint64_dim256_t16.cu src/neighbors/detail/cagra/search_single_cta_float_uint64_dim512_t32.cu src/neighbors/detail/cagra/search_single_cta_float_uint64_dim1024_t32.cu LIB EXPLICIT_INSTANTIATE_ONLY GPUS 1 PERCENT 100 ) ConfigureTest( NAME NEIGHBORS_ANN_IVF_TEST PATH test/neighbors/ann_ivf_flat/test_filter_float_int64_t.cu test/neighbors/ann_ivf_flat/test_float_int64_t.cu test/neighbors/ann_ivf_flat/test_int8_t_int64_t.cu test/neighbors/ann_ivf_flat/test_uint8_t_int64_t.cu test/neighbors/ann_ivf_pq/test_float_uint32_t.cu test/neighbors/ann_ivf_pq/test_float_int64_t.cu test/neighbors/ann_ivf_pq/test_int8_t_int64_t.cu test/neighbors/ann_ivf_pq/test_uint8_t_int64_t.cu test/neighbors/ann_ivf_pq/test_filter_float_int64_t.cu test/neighbors/ann_ivf_pq/test_filter_int8_t_int64_t.cu LIB EXPLICIT_INSTANTIATE_ONLY GPUS 1 PERCENT 100 ) ConfigureTest( NAME NEIGHBORS_ANN_NN_DESCENT_TEST PATH test/neighbors/ann_nn_descent/test_float_uint32_t.cu test/neighbors/ann_nn_descent/test_int8_t_uint32_t.cu test/neighbors/ann_nn_descent/test_uint8_t_uint32_t.cu LIB EXPLICIT_INSTANTIATE_ONLY GPUS 1 PERCENT 100 ) ConfigureTest( NAME NEIGHBORS_SELECTION_TEST PATH test/neighbors/selection.cu LIB EXPLICIT_INSTANTIATE_ONLY GPUS 1 PERCENT 50 ) ConfigureTest( NAME STATS_TEST PATH test/stats/accuracy.cu test/stats/adjusted_rand_index.cu test/stats/completeness_score.cu test/stats/contingencyMatrix.cu test/stats/cov.cu test/stats/dispersion.cu test/stats/entropy.cu test/stats/histogram.cu test/stats/homogeneity_score.cu test/stats/information_criterion.cu test/stats/kl_divergence.cu test/stats/mean.cu test/stats/meanvar.cu test/stats/mean_center.cu test/stats/minmax.cu test/stats/mutual_info_score.cu test/stats/neighborhood_recall.cu test/stats/r2_score.cu test/stats/rand_index.cu test/stats/regression_metrics.cu test/stats/silhouette_score.cu test/stats/stddev.cu test/stats/sum.cu test/stats/trustworthiness.cu test/stats/weighted_mean.cu test/stats/v_measure.cu LIB EXPLICIT_INSTANTIATE_ONLY ) ConfigureTest( NAME UTILS_TEST PATH test/core/seive.cu test/util/bitonic_sort.cu test/util/cudart_utils.cpp test/util/device_atomics.cu test/util/integer_utils.cpp test/util/integer_utils.cu test/util/pow2_utils.cu test/util/reduction.cu ) endif() # ################################################################################################## # Install tests #################################################################################### # ################################################################################################## rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/gtests/libraft)
0
rapidsai_public_repos/raft/cpp
rapidsai_public_repos/raft/cpp/test/test.cpp
/* * Copyright (c) 2020, 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. */ #include <gtest/gtest.h> #include <iostream> #include <raft.hpp> namespace raft { TEST(Raft, print) { std::cout << test_raft() << std::endl; } } // namespace raft
0
rapidsai_public_repos/raft/cpp
rapidsai_public_repos/raft/cpp/test/test_utils.cuh
/* * Copyright (c) 2018-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. */ #pragma once #include "test_utils.h" #include <gtest/gtest.h> #include <iostream> #include <memory> #include <raft/random/rng.cuh> #include <raft/util/cuda_utils.cuh> #include <raft/util/cudart_utils.hpp> #include <rmm/exec_policy.hpp> #include <thrust/for_each.h> #include <fstream> #include <sstream> #include <stdexcept> #include <string> #include <type_traits> #include <utility> #include <vector> namespace raft { /* * @brief Helper function to compare 2 device n-D arrays with custom comparison * @tparam T the data type of the arrays * @tparam L the comparator lambda or object function * @param expected expected value(s) * @param actual actual values * @param eq_compare the comparator * @param stream cuda stream * @return the testing assertion to be later used by ASSERT_TRUE/EXPECT_TRUE * @{ */ template <typename T, typename L> testing::AssertionResult devArrMatch( const T* expected, const T* actual, size_t size, L eq_compare, cudaStream_t stream = 0) { std::unique_ptr<T[]> exp_h(new T[size]); std::unique_ptr<T[]> act_h(new T[size]); raft::update_host<T>(exp_h.get(), expected, size, stream); raft::update_host<T>(act_h.get(), actual, size, stream); RAFT_CUDA_TRY(cudaStreamSynchronize(stream)); for (size_t i(0); i < size; ++i) { auto exp = exp_h.get()[i]; auto act = act_h.get()[i]; if (!eq_compare(exp, act)) { return testing::AssertionFailure() << "actual=" << act << " != expected=" << exp << " @" << i; } } return testing::AssertionSuccess(); } template <typename T, typename L> testing::AssertionResult devArrMatch( T expected, const T* actual, size_t size, L eq_compare, cudaStream_t stream = 0) { std::unique_ptr<T[]> act_h(new T[size]); raft::update_host<T>(act_h.get(), actual, size, stream); RAFT_CUDA_TRY(cudaStreamSynchronize(stream)); for (size_t i(0); i < size; ++i) { auto act = act_h.get()[i]; if (!eq_compare(expected, act)) { return testing::AssertionFailure() << "actual=" << act << " != expected=" << expected << " @" << i; } } return testing::AssertionSuccess(); } template <typename T, typename L> testing::AssertionResult devArrMatch(const T* expected, const T* actual, size_t rows, size_t cols, L eq_compare, cudaStream_t stream = 0) { size_t size = rows * cols; std::unique_ptr<T[]> exp_h(new T[size]); std::unique_ptr<T[]> act_h(new T[size]); raft::update_host<T>(exp_h.get(), expected, size, stream); raft::update_host<T>(act_h.get(), actual, size, stream); RAFT_CUDA_TRY(cudaStreamSynchronize(stream)); for (size_t i(0); i < rows; ++i) { for (size_t j(0); j < cols; ++j) { auto idx = i * cols + j; // row major assumption! auto exp = exp_h.get()[idx]; auto act = act_h.get()[idx]; if (!eq_compare(exp, act)) { return testing::AssertionFailure() << "actual=" << act << " != expected=" << exp << " @" << i << "," << j; } } } return testing::AssertionSuccess(); } template <typename T, typename L> testing::AssertionResult devArrMatch( T expected, const T* actual, size_t rows, size_t cols, L eq_compare, cudaStream_t stream = 0) { size_t size = rows * cols; std::unique_ptr<T[]> act_h(new T[size]); raft::update_host<T>(act_h.get(), actual, size, stream); RAFT_CUDA_TRY(cudaStreamSynchronize(stream)); for (size_t i(0); i < rows; ++i) { for (size_t j(0); j < cols; ++j) { auto idx = i * cols + j; // row major assumption! auto act = act_h.get()[idx]; if (!eq_compare(expected, act)) { return testing::AssertionFailure() << "actual=" << act << " != expected=" << expected << " @" << i << "," << j; } } } return testing::AssertionSuccess(); } /* * @brief Helper function to compare a device n-D arrays with an expected array * on the host, using a custom comparison * @tparam T the data type of the arrays * @tparam L the comparator lambda or object function * @param expected_h host array of expected value(s) * @param actual_d device array actual values * @param eq_compare the comparator * @param stream cuda stream * @return the testing assertion to be later used by ASSERT_TRUE/EXPECT_TRUE */ template <typename T, typename L> testing::AssertionResult devArrMatchHost( const T* expected_h, const T* actual_d, size_t size, L eq_compare, cudaStream_t stream = 0) { std::unique_ptr<T[]> act_h(new T[size]); raft::update_host<T>(act_h.get(), actual_d, size, stream); RAFT_CUDA_TRY(cudaStreamSynchronize(stream)); bool ok = true; auto fail = testing::AssertionFailure(); for (size_t i(0); i < size; ++i) { auto exp = expected_h[i]; auto act = act_h.get()[i]; if (!eq_compare(exp, act)) { ok = false; fail << "actual=" << act << " != expected=" << exp << " @" << i << "; "; } } if (!ok) return fail; return testing::AssertionSuccess(); } /** * @brief Helper function to compare host vectors using a custom comparison * @tparam T the element type * @tparam L the comparator lambda or object function * @param expected_h host vector of expected value(s) * @param actual_h host vector actual values * @param eq_compare the comparator * @return the testing assertion to be later used by ASSERT_TRUE/EXPECT_TRUE */ template <typename T, typename L> testing::AssertionResult hostVecMatch(const std::vector<T>& expected_h, const std::vector<T>& actual_h, L eq_compare) { auto n = actual_h.size(); if (n != expected_h.size()) return testing::AssertionFailure() << "vector sizez mismatch: " << "actual=" << n << " != expected=" << expected_h.size() << "; "; for (size_t i = 0; i < n; ++i) { auto exp = expected_h[i]; auto act = actual_h[i]; if (!eq_compare(exp, act)) { return testing::AssertionFailure() << "actual=" << act << " != expected=" << exp << " @" << i << "; "; } } return testing::AssertionSuccess(); } /* * @brief Helper function to compare diagonal values of a 2D matrix * @tparam T the data type of the arrays * @tparam L the comparator lambda or object function * @param expected expected value along diagonal * @param actual actual matrix * @param eq_compare the comparator * @param stream cuda stream * @return the testing assertion to be later used by ASSERT_TRUE/EXPECT_TRUE */ template <typename T, typename L> testing::AssertionResult diagonalMatch( T expected, const T* actual, size_t rows, size_t cols, L eq_compare, cudaStream_t stream = 0) { size_t size = rows * cols; std::unique_ptr<T[]> act_h(new T[size]); raft::update_host<T>(act_h.get(), actual, size, stream); RAFT_CUDA_TRY(cudaStreamSynchronize(stream)); for (size_t i(0); i < rows; ++i) { for (size_t j(0); j < cols; ++j) { if (i != j) continue; auto idx = i * cols + j; // row major assumption! auto act = act_h.get()[idx]; if (!eq_compare(expected, act)) { return testing::AssertionFailure() << "actual=" << act << " != expected=" << expected << " @" << i << "," << j; } } } return testing::AssertionSuccess(); } template <typename T, typename IdxT> typename std::enable_if_t<std::is_floating_point_v<T>> gen_uniform(const raft::resources& handle, T* out, raft::random::RngState& rng, IdxT len, T range_min = T(-1), T range_max = T(1)) { raft::random::uniform(handle, rng, out, len, range_min, range_max); } template <typename T, typename IdxT> typename std::enable_if_t<std::is_integral_v<T>> gen_uniform(const raft::resources& handle, T* out, raft::random::RngState& rng, IdxT len, T range_min = T(0), T range_max = T(100)) { raft::random::uniformInt(handle, rng, out, len, range_min, range_max); } template <typename T1, typename T2, typename IdxT> void gen_uniform(const raft::resources& handle, raft::KeyValuePair<T1, T2>* out, raft::random::RngState& rng, IdxT len) { auto stream = resource::get_cuda_stream(handle); rmm::device_uvector<T1> keys(len, stream); rmm::device_uvector<T2> values(len, stream); gen_uniform(handle, keys.data(), rng, len); gen_uniform(handle, values.data(), rng, len); const T1* d_keys = keys.data(); const T2* d_values = values.data(); auto counting = thrust::make_counting_iterator<IdxT>(0); thrust::for_each(rmm::exec_policy(stream), counting, counting + len, [out, d_keys, d_values] __device__(int idx) { out[idx].key = d_keys[idx]; out[idx].value = d_values[idx]; }); } /** @} */ /** time the function call 'func' using cuda events */ #define TIMEIT_LOOP(ms, count, func) \ do { \ cudaEvent_t start, stop; \ RAFT_CUDA_TRY(cudaEventCreate(&start)); \ RAFT_CUDA_TRY(cudaEventCreate(&stop)); \ RAFT_CUDA_TRY(cudaEventRecord(start)); \ for (int i = 0; i < count; ++i) { \ func; \ } \ RAFT_CUDA_TRY(cudaEventRecord(stop)); \ RAFT_CUDA_TRY(cudaEventSynchronize(stop)); \ ms = 0.f; \ RAFT_CUDA_TRY(cudaEventElapsedTime(&ms, start, stop)); \ ms /= args.runs; \ } while (0) inline std::vector<float> read_csv(std::string filename, bool skip_first_n_columns = 1) { std::vector<float> result; std::ifstream myFile(filename); if (!myFile.is_open()) throw std::runtime_error("Could not open file"); std::string line, colname; int val; if (myFile.good()) { std::getline(myFile, line); std::stringstream ss(line); while (std::getline(ss, colname, ',')) {} } int n_lines = 0; while (std::getline(myFile, line)) { std::stringstream ss(line); int colIdx = 0; while (ss >> val) { if (colIdx >= skip_first_n_columns) { result.push_back(val); if (ss.peek() == ',') ss.ignore(); } colIdx++; } n_lines++; } printf("lines read: %d\n", n_lines); myFile.close(); return result; } }; // end namespace raft
0
rapidsai_public_repos/raft/cpp
rapidsai_public_repos/raft/cpp/test/test_utils.h
/* * Copyright (c) 2018-2022, 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. */ #pragma once #include <cmath> #include <iostream> #include <gtest/gtest.h> #include <raft/core/kvp.hpp> namespace raft { template <typename T> struct Compare { bool operator()(const T& a, const T& b) const { return a == b; } }; template <typename Key, typename Value> struct Compare<raft::KeyValuePair<Key, Value>> { bool operator()(const raft::KeyValuePair<Key, Value>& a, const raft::KeyValuePair<Key, Value>& b) const { return a.key == b.key && a.value == b.value; } }; template <typename T> struct CompareApprox { CompareApprox(T eps_) : eps(eps_) {} bool operator()(const T& a, const T& b) const { T diff = std::abs(a - b); T m = std::max(std::abs(a), std::abs(b)); T ratio = diff > eps ? diff / m : diff; return (ratio <= eps); } private: T eps; }; template <typename Key, typename Value> ::std::ostream& operator<<(::std::ostream& os, const raft::KeyValuePair<Key, Value>& kv) { os << "{ " << kv.key << ", " << kv.value << '}'; return os; } template <typename Key, typename Value> struct CompareApprox<raft::KeyValuePair<Key, Value>> { CompareApprox(raft::KeyValuePair<Key, Value> eps) : compare_keys(eps.key), compare_values(eps.value) { } bool operator()(const raft::KeyValuePair<Key, Value>& a, const raft::KeyValuePair<Key, Value>& b) const { return compare_keys(a.key, b.key) && compare_values(a.value, b.value); } private: CompareApprox<Key> compare_keys; CompareApprox<Value> compare_values; }; template <typename T> struct CompareApproxAbs { CompareApproxAbs(T eps_) : eps(eps_) {} bool operator()(const T& a, const T& b) const { T diff = std::abs(std::abs(a) - std::abs(b)); T m = std::max(std::abs(a), std::abs(b)); T ratio = diff >= eps ? diff / m : diff; return (ratio <= eps); } private: T eps; }; template <typename T> struct CompareApproxNoScaling { CompareApproxNoScaling(T eps_) : eps(eps_) {} bool operator()(const T& a, const T& b) const { return (std::abs(a - b) <= eps); } private: T eps; }; template <typename T, typename L> testing::AssertionResult match(const T& expected, const T& actual, L eq_compare) { if (!eq_compare(expected, actual)) { return testing::AssertionFailure() << "actual=" << actual << " != expected=" << expected; } return testing::AssertionSuccess(); } }; // end namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/util/integer_utils.cu
/* * 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. */ #include "../test_utils.cuh" #include <gtest/gtest.h> #include <raft/core/resource/cuda_stream.hpp> #include <raft/util/integer_utils.hpp> #include <rmm/device_scalar.hpp> namespace raft { namespace util { struct MulInputs { uint64_t expected_high; uint64_t expected_low; uint64_t operand_1; uint64_t operand_2; }; RAFT_KERNEL mul64_test_kernel(uint64_t* result_high, uint64_t* result_low, uint64_t* swapped_result_high, uint64_t* swapped_result_low, const uint64_t op1, const uint64_t op2) { using raft::wmul_64bit; wmul_64bit(*result_high, *result_low, op1, op2); wmul_64bit(*swapped_result_high, *swapped_result_low, op2, op1); } class Multiplication64bit : public testing::TestWithParam<MulInputs> { protected: Multiplication64bit() : stream(resource::get_cuda_stream(handle)), d_result_high(stream), d_result_low(stream), d_swapped_result_high(stream), d_swapped_result_low(stream) { } protected: void SetUp() override { using raft::wmul_64bit; params = testing::TestWithParam<MulInputs>::GetParam(); wmul_64bit(result_high, result_low, params.operand_1, params.operand_2); wmul_64bit(swapped_result_high, swapped_result_low, params.operand_2, params.operand_1); mul64_test_kernel<<<1, 1, 0, stream>>>(d_result_high.data(), d_result_low.data(), d_swapped_result_high.data(), d_swapped_result_low.data(), params.operand_1, params.operand_2); } raft::resources handle; cudaStream_t stream; rmm::device_scalar<uint64_t> d_result_high; rmm::device_scalar<uint64_t> d_result_low; rmm::device_scalar<uint64_t> d_swapped_result_high; rmm::device_scalar<uint64_t> d_swapped_result_low; MulInputs params; uint64_t result_high; uint64_t result_low; uint64_t swapped_result_high; uint64_t swapped_result_low; }; const std::vector<MulInputs> inputs = { {0ULL, 0ULL, 0ULL, 0ULL}, {0ULL, 0ULL, UINT64_MAX, 0ULL}, {0ULL, UINT64_MAX, UINT64_MAX, 1ULL}, {UINT64_MAX - 1, 1ULL, UINT64_MAX, UINT64_MAX}, {0x10759F98370FEC6EULL, 0xD5349806F735F69CULL, 0x1D6F160410C23D03ULL, 0x8F27C29767468634ULL}, {0xAF72C5B915A5ABDEULL >> 1, 0xAF72C5B915A5ABDEULL << 63, 0xAF72C5B915A5ABDEULL, 1ULL << 63}, {0xCA82AAEB81C01931ULL >> (64 - 23), 0xCA82AAEB81C01931ULL << 23, 0xCA82AAEB81C01931ULL, 1ULL << 23}}; TEST_P(Multiplication64bit, Result) { ASSERT_EQ(params.expected_high, d_result_high.value(stream)); ASSERT_EQ(params.expected_low, d_result_low.value(stream)); ASSERT_EQ(params.expected_high, d_swapped_result_high.value(stream)); ASSERT_EQ(params.expected_low, d_swapped_result_low.value(stream)); ASSERT_EQ(params.expected_high, result_high); ASSERT_EQ(params.expected_low, result_low); ASSERT_EQ(params.expected_high, swapped_result_high); ASSERT_EQ(params.expected_low, swapped_result_low); } INSTANTIATE_TEST_CASE_P(Mul64bit, Multiplication64bit, testing::ValuesIn(inputs)); }; // end of namespace util }; // end of namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/util/integer_utils.cpp
/* * Copyright (c) 2020-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. */ #include <gtest/gtest.h> #include <iostream> #include <raft/util/integer_utils.hpp> namespace raft { static_assert(!is_narrowing_v<uint32_t, uint64_t>); static_assert(!is_narrowing_v<uint32_t, int64_t>); static_assert(!is_narrowing_v<uint32_t, uint32_t>); static_assert(is_narrowing_v<uint32_t, int32_t>); static_assert(is_narrowing_v<uint32_t, int>); static_assert(!is_narrowing_v<float, double>); static_assert(is_narrowing_v<double, float>); TEST(Raft, rounding_up) { ASSERT_EQ(raft::div_rounding_up_safe(5, 3), 2); ASSERT_EQ(raft::div_rounding_up_safe(0, 3), 0); ASSERT_EQ(raft::div_rounding_up_safe(7, 8), 1); ASSERT_EQ(raft::div_rounding_up_unsafe(5, 3), 2); ASSERT_EQ(raft::div_rounding_up_unsafe(0, 3), 0); ASSERT_EQ(raft::div_rounding_up_unsafe(7, 8), 1); } TEST(Raft, is_a_power_of_two) { ASSERT_EQ(raft::is_a_power_of_two(1 << 5), true); ASSERT_EQ(raft::is_a_power_of_two((1 << 5) + 1), false); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/util/device_atomics.cu
/* * 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 * * 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. */ #include <algorithm> #include <array> #include <cstddef> #include <gtest/gtest.h> #include <iostream> #include <memory> #include <numeric> #include <raft/util/cudart_utils.hpp> #include <raft/util/device_atomics.cuh> #include <rmm/cuda_stream_pool.hpp> #include <rmm/device_scalar.hpp> #include <rmm/device_uvector.hpp> namespace raft { RAFT_KERNEL test_atomic_inc_warp_kernel(int* counter, int* out_array) { int global_tid = blockDim.x * blockIdx.x + threadIdx.x; out_array[atomicIncWarp(counter)] = global_tid; } TEST(Raft, AtomicIncWarp) { const int num_blocks = 1024; const int threads_per_block = 1024; const int num_elts = num_blocks * threads_per_block; rmm::cuda_stream_pool pool{1}; auto s = pool.get_stream(); rmm::device_scalar<int> counter{0, s}; rmm::device_uvector<int> out_device{num_elts, s}; std::array<int, num_elts> out_host{0}; // Write all 1M thread indices to a unique location in `out_device` test_atomic_inc_warp_kernel<<<num_blocks, threads_per_block, 0, s>>>(counter.data(), out_device.data()); // Copy data to host RAFT_CUDA_TRY(cudaMemcpyAsync(out_host.data(), (const void*)out_device.data(), num_elts * sizeof(int), cudaMemcpyDeviceToHost, s)); // Check that count is correct and that each thread index is contained in the // array exactly once. ASSERT_EQ(num_elts, counter.value(s)); // NB: accessing the counter synchronizes `s` std::sort(out_host.begin(), out_host.end()); for (int i = 0; i < num_elts; ++i) { ASSERT_EQ(i, out_host[i]); } } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/util/cudart_utils.cpp
/* * Copyright (c) 2020-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. */ #include <raft/core/resource/cuda_stream.hpp> #include <raft/core/resources.hpp> #include <raft/util/cudart_utils.hpp> #include <vector> #include <rmm/device_uvector.hpp> #include <gtest/gtest.h> #include <iostream> #include <regex> namespace raft { #define TEST_ADD_FILENAME(s) \ { \ s += std::string{__FILE__}; \ } std::string reg_escape(const std::string& s) { static const std::regex SPECIAL_CHARS{R"([-[\]{}()*+?.,\^$|#\s])"}; return std::regex_replace(s, SPECIAL_CHARS, R"(\$&)"); } TEST(Raft, Utils) { ASSERT_NO_THROW(ASSERT(1 == 1, "Should not assert!")); ASSERT_THROW(ASSERT(1 != 1, "Should assert!"), exception); ASSERT_THROW(THROW("Should throw!"), exception); ASSERT_NO_THROW(RAFT_CUDA_TRY(cudaFree(nullptr))); // test for long error message strings std::string test{"This is a test string repeated many times. "}; for (size_t i = 0; i < 6; ++i) test += test; EXPECT_TRUE(test.size() > 2048) << "size of test string is: " << test.size(); auto test_format = test + "%d"; auto* test_format_c = test_format.c_str(); std::string file{}; TEST_ADD_FILENAME(file); std::string reg_file = reg_escape(file); // THROW has to convert the test string into an exception string try { ASSERT(1 != 1, test_format_c, 121); } catch (const raft::exception& e) { std::string msg_full{e.what()}; // only use first line std::string msg = msg_full.substr(0, msg_full.find('\n')); std::string re_exp{"^exception occurred! file="}; re_exp += reg_file; // test code must be at line >10 (copyright), assume line is never >9999 re_exp += " line=\\d{2,4}: "; re_exp += reg_escape(test); re_exp += "121$"; EXPECT_TRUE(std::regex_match(msg, std::regex(re_exp))) << "message:'" << msg << "'" << std::endl << "expected regex:'" << re_exp << "'"; } // Now we test SET_ERROR_MSG instead of THROW std::string msg{"prefix:"}; ASSERT_NO_THROW(SET_ERROR_MSG(msg, "location prefix:", test_format_c, 123)); std::string re_exp{"^prefix:location prefix:file="}; re_exp += reg_file; // test code must be at line >10 (copyright), assume line is never >9999 re_exp += " line=\\d{2,4}: "; re_exp += reg_escape(test); re_exp += "123$"; EXPECT_TRUE(std::regex_match(msg, std::regex(re_exp))) << "message:'" << msg << "'" << std::endl << "expected regex:'" << re_exp << "'"; } TEST(Raft, GetDeviceForAddress) { resources handle; std::vector<int> h(1); ASSERT_EQ(-1, raft::get_device_for_address(h.data())); rmm::device_uvector<int> d(1, resource::get_cuda_stream(handle)); ASSERT_EQ(0, raft::get_device_for_address(d.data())); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/util/pow2_utils.cu
/* * Copyright (c) 2020-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. */ #include <gtest/gtest.h> #include <raft/util/pow2_utils.cuh> namespace raft { template <auto Val, typename TargetT> struct Pow2Test : public ::testing::Test { typedef Pow2<Val> P; std::vector<TargetT> data; void SetUp() override { std::vector<TargetT> pos = {0, 1, 2, 7, 15, 16, 17, 31, 35, 1024, 1623}; data.insert(data.end(), pos.begin(), pos.end()); if constexpr (std::is_signed<TargetT>::value) { std::vector<TargetT> neg = {-0, -1, -2, -5, -15, -16, -17, -156}; data.insert(data.end(), neg.begin(), neg.end()); } data.push_back(std::numeric_limits<TargetT>::min()); data.push_back(std::numeric_limits<TargetT>::max()); } void quotRem() { for (auto x : data) { ASSERT_EQ(P::quot(x), x / P::Value) << " where x = " << x; ASSERT_EQ(P::rem(x), x % P::Value) << " where x = " << x; ASSERT_EQ(x, P::quot(x) * P::Value + P::rem(x)); } } void divMod() { for (auto x : data) { ASSERT_GE(P::mod(x), 0) << " where x = " << x; ASSERT_EQ(x, P::div(x) * P::Value + P::mod(x)); } } void round() { for (auto x : data) { if (x <= std::numeric_limits<TargetT>::max() - TargetT(P::Value)) ASSERT_GE(P::roundUp(x), x); if (x >= std::numeric_limits<TargetT>::min() + TargetT(P::Value)) ASSERT_LE(P::roundDown(x), x); ASSERT_EQ(x - P::roundDown(x), P::mod(x)) << " where x = " << x; ASSERT_EQ(P::mod(P::roundUp(x) + P::mod(x) - x), 0) << " where x = " << x; } } void alignment() { for (auto x : data) { ASSERT_TRUE(P::areSameAlignOffsets(x, x)); if (x <= std::numeric_limits<TargetT>::max() - TargetT(P::Value)) { ASSERT_TRUE(P::areSameAlignOffsets(x, x + TargetT(P::Value))); int aligned_count = 0; int same_aligned_count = 0; for (int i = 0; i < int(P::Value); i++) { aligned_count += P::isAligned(x + i); same_aligned_count += P::areSameAlignOffsets(x, x + i); } ASSERT_EQ(aligned_count, 1) << " where x = " << x; ASSERT_EQ(same_aligned_count, 1) << " where x = " << x; } } } }; #define TEST_IT(T) \ TEST_F(T, quotRem) { divMod(); } \ TEST_F(T, divMod) { divMod(); } \ TEST_F(T, round) { round(); } \ TEST_F(T, alignment) { alignment(); } typedef Pow2Test<16, int> Pow2_i32_i32_16; typedef Pow2Test<1UL, uint64_t> Pow2_u64_u64_1; typedef Pow2Test<128UL, int> Pow2_u64_i32_128; typedef Pow2Test<32LL, uint16_t> Pow2_ll_u16_32; typedef Pow2Test<16, uint64_t> Pow2_i32_u64_16; TEST_IT(Pow2_i32_i32_16); TEST_IT(Pow2_u64_u64_1); TEST_IT(Pow2_u64_i32_128); TEST_IT(Pow2_ll_u16_32); TEST_IT(Pow2_i32_u64_16); TEST(Pow2, pointers) { typedef Pow2<32UL> P; for (ptrdiff_t i = 0; i <= ptrdiff_t(P::Value); i++) { auto* p = reinterpret_cast<float*>(16345 + i); ASSERT_GE(P::roundUp(p), p); ASSERT_LE(P::roundDown(p), p); } } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/util/bitonic_sort.cu
/* * 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 * * 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. */ #include "../test_utils.cuh" #include <raft/random/rng.cuh> #include <raft/util/bitonic_sort.cuh> #include <raft/util/cudart_utils.hpp> #include <gtest/gtest.h> #include <algorithm> #include <numeric> namespace raft::util { constexpr int kMaxBlockSize = 512; constexpr int kMaxCapacity = 128; struct test_spec { int n_inputs; int warp_width; int capacity; bool ascending; [[nodiscard]] auto len() const -> int { return n_inputs * warp_width * capacity; } }; auto operator<<(std::ostream& os, const test_spec& ss) -> std::ostream& { os << "spec{n_inputs: " << ss.n_inputs << ", input_len: " << (ss.warp_width * ss.capacity) << " (" << ss.warp_width << " * " << ss.capacity << ")"; os << (ss.ascending ? "; asc}" : "; dsc}"); return os; } template <int Capacity, typename T> RAFT_KERNEL bitonic_kernel(T* arr, bool ascending, int warp_width, int n_inputs) { const int tid = blockDim.x * blockIdx.x + threadIdx.x; const int subwarp_id = tid / warp_width; const int subwarp_lane = tid % warp_width; T local_arr[Capacity]; // NOLINT // Split the data into chunks of size `warp_width * Capacity`, each thread pointing // to the beginning of its stride within the chunk. T* per_thread_arr = arr + subwarp_id * warp_width * Capacity + subwarp_lane; if (subwarp_id < n_inputs) { #pragma unroll for (int i = 0; i < Capacity; i++) { local_arr[i] = per_thread_arr[i * warp_width]; } } bitonic<Capacity>(ascending, warp_width).sort(local_arr); if (subwarp_id < n_inputs) { #pragma unroll for (int i = 0; i < Capacity; i++) { per_thread_arr[i * warp_width] = local_arr[i]; } } } template <int Capacity> struct bitonic_launch { template <typename T> static void run(const test_spec& spec, T* arr, rmm::cuda_stream_view stream) { ASSERT(spec.capacity <= Capacity, "Invalid input: the requested capacity is too high."); ASSERT(spec.warp_width <= WarpSize, "Invalid input: the requested warp_width must be not larger than the WarpSize."); if constexpr (Capacity > 1) { if (spec.capacity < Capacity) { return bitonic_launch<std::max(1, Capacity / 2)>::run(spec, arr, stream); } } int max_block_size, min_grid_size; RAFT_CUDA_TRY(cudaOccupancyMaxPotentialBlockSize( &min_grid_size, &max_block_size, bitonic_kernel<Capacity, T>, 0, kMaxBlockSize)); const int n_warps = ceildiv(std::min(spec.n_inputs * spec.warp_width, max_block_size), WarpSize); const int block_dim = n_warps * WarpSize; const int n_subwarps = block_dim / spec.warp_width; const int grid_dim = ceildiv(spec.n_inputs, n_subwarps); bitonic_kernel<Capacity, T> <<<grid_dim, block_dim, 0, stream>>>(arr, spec.ascending, spec.warp_width, spec.n_inputs); RAFT_CUDA_TRY(cudaPeekAtLastError()); } }; template <typename T> class BitonicTest : public testing::TestWithParam<test_spec> { // NOLINT protected: const test_spec spec; // NOLINT std::vector<T> in; // NOLINT std::vector<T> out; // NOLINT std::vector<T> ref; // NOLINT raft::resources handle_; void segmented_sort(std::vector<T>& vec, int k, bool ascending) // NOLINT { std::vector<int> p(vec.size()); std::iota(p.begin(), p.end(), 0); std::sort(p.begin(), p.end(), [&vec, k, ascending](int i, int j) { const int ik = i / k; const int jk = j / k; if (ik == jk) { return ascending ? vec[i] < vec[j] : vec[i] > vec[j]; } return ik < jk; }); for (auto i = int(vec.size()) - 1; i > 0; i--) { auto j = p[i]; while (j > i) j = p[j]; std::swap(vec[j], vec[i]); } } void fill_random(rmm::device_uvector<T>& arr) { raft::random::RngState rng(42); if constexpr (std::is_floating_point_v<T>) { return raft::random::normal(handle_, rng, arr.data(), arr.size(), T(10), T(100)); } if constexpr (std::is_integral_v<T>) { return raft::random::normalInt(handle_, rng, arr.data(), arr.size(), T(10), T(100)); } } public: explicit BitonicTest() : spec(testing::TestWithParam<test_spec>::GetParam()), in(spec.len()), out(spec.len()), ref(spec.len()) { auto stream = resource::get_cuda_stream(handle_); // generate input rmm::device_uvector<T> arr_d(spec.len(), stream); fill_random(arr_d); update_host(in.data(), arr_d.data(), arr_d.size(), stream); // calculate the results bitonic_launch<kMaxCapacity>::run(spec, arr_d.data(), stream); update_host(out.data(), arr_d.data(), arr_d.size(), stream); // make sure the results are available on host stream.synchronize(); // calculate the reference std::copy(in.begin(), in.end(), ref.begin()); segmented_sort(ref, spec.warp_width * spec.capacity, spec.ascending); } void run() { ASSERT_TRUE(hostVecMatch(ref, out, Compare<T>())); } }; auto inputs = ::testing::Values(test_spec{1, 1, 1, true}, test_spec{1, 2, 1, true}, test_spec{1, 4, 1, true}, test_spec{1, 8, 1, true}, test_spec{1, 16, 1, false}, test_spec{1, 32, 1, false}, test_spec{1, 32, 2, false}, test_spec{1, 32, 4, true}, test_spec{1, 32, 8, true}, test_spec{5, 32, 2, true}, test_spec{7, 16, 4, true}, test_spec{7, 8, 2, true}, test_spec{70, 4, 32, true}, test_spec{70, 1, 64, true}, test_spec{70, 2, 128, false}); using Floats = BitonicTest<float>; // NOLINT TEST_P(Floats, Run) { run(); } // NOLINT INSTANTIATE_TEST_CASE_P(BitonicTest, Floats, inputs); // NOLINT using Ints = BitonicTest<int>; // NOLINT TEST_P(Ints, Run) { run(); } // NOLINT INSTANTIATE_TEST_CASE_P(BitonicTest, Ints, inputs); // NOLINT using Doubles = BitonicTest<double>; // NOLINT TEST_P(Doubles, Run) { run(); } // NOLINT INSTANTIATE_TEST_CASE_P(BitonicTest, Doubles, inputs); // NOLINT } // namespace raft::util
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/util/reduction.cu
/* * 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. */ #include "../test_utils.cuh" #include <raft/random/device/sample.cuh> #include <raft/random/rng.cuh> #include <raft/util/reduction.cuh> #include <rmm/device_scalar.hpp> #include <rmm/device_uvector.hpp> #include <gtest/gtest.h> #include <algorithm> #include <numeric> namespace raft::util { constexpr int max_warps_per_block = 32; template <typename ReduceLambda> RAFT_KERNEL test_reduction_kernel(const int* input, int* reduction_res, ReduceLambda reduce_op) { assert(gridDim.x == 1); __shared__ int red_buf[max_warps_per_block]; int th_val = input[threadIdx.x]; th_val = raft::blockReduce(th_val, (char*)red_buf, reduce_op); if (threadIdx.x == 0) { reduction_res[0] = th_val; } } template <typename ReduceLambda> RAFT_KERNEL test_ranked_reduction_kernel(const int* input, int* reduction_res, int* out_rank, ReduceLambda reduce_op) { assert(gridDim.x == 1); __shared__ int red_buf[2 * max_warps_per_block]; int th_val = input[threadIdx.x]; int th_rank = threadIdx.x; auto result = raft::blockRankedReduce(th_val, red_buf, th_rank, reduce_op); if (threadIdx.x == 0) { reduction_res[0] = result.first; out_rank[0] = result.second; } } RAFT_KERNEL test_block_random_sample_kernel(const int* input, int* reduction_res) { assert(gridDim.x == 1); __shared__ int red_buf[2 * max_warps_per_block]; raft::random::PCGenerator thread_rng(1234, threadIdx.x, 0); int th_val = input[threadIdx.x]; int th_rank = threadIdx.x; int result = raft::random::device::block_random_sample(thread_rng, red_buf, th_val, th_rank); if (threadIdx.x == 0) { reduction_res[0] = result; } } template <int TPB> RAFT_KERNEL test_binary_reduction_kernel(const int* input, int* reduction_res) { assert(gridDim.x == 1); __shared__ int shared[TPB / WarpSize]; int th_val = input[threadIdx.x]; int result = raft::binaryBlockReduce<TPB>(th_val, shared); if (threadIdx.x == 0) { reduction_res[0] = result; } } struct reduction_launch { template <typename ReduceLambda> static void run(const rmm::device_uvector<int>& arr_d, int ref_val, ReduceLambda reduce_op, rmm::cuda_stream_view stream) { rmm::device_scalar<int> ref_d(stream); const int block_dim = 64; const int grid_dim = 1; test_reduction_kernel<<<grid_dim, block_dim, 0, stream>>>( arr_d.data(), ref_d.data(), reduce_op); stream.synchronize(); RAFT_CUDA_TRY(cudaPeekAtLastError()); ASSERT_EQ(ref_d.value(stream), ref_val); } template <typename ReduceLambda> static void run_ranked(const rmm::device_uvector<int>& arr_d, int ref_val, int rank_ref_val, ReduceLambda reduce_op, rmm::cuda_stream_view stream) { rmm::device_scalar<int> ref_d(stream); rmm::device_scalar<int> rank_d(stream); const int block_dim = 64; const int grid_dim = 1; test_ranked_reduction_kernel<<<grid_dim, block_dim, 0, stream>>>( arr_d.data(), ref_d.data(), rank_d.data(), reduce_op); stream.synchronize(); RAFT_CUDA_TRY(cudaPeekAtLastError()); ASSERT_EQ(ref_d.value(stream), ref_val); ASSERT_EQ(rank_d.value(stream), rank_ref_val); } static void run_random_sample(const rmm::device_uvector<int>& arr_d, int ref_val, rmm::cuda_stream_view stream) { rmm::device_scalar<int> ref_d(stream); const int block_dim = 64; const int grid_dim = 1; test_block_random_sample_kernel<<<grid_dim, block_dim, 0, stream>>>(arr_d.data(), ref_d.data()); stream.synchronize(); RAFT_CUDA_TRY(cudaPeekAtLastError()); ASSERT_EQ(ref_d.value(stream), ref_val); } static void run_binary(const rmm::device_uvector<int>& arr_d, int ref_val, rmm::cuda_stream_view stream) { rmm::device_scalar<int> ref_d(stream); constexpr int block_dim = 64; const int grid_dim = 1; test_binary_reduction_kernel<block_dim> <<<grid_dim, block_dim, 0, stream>>>(arr_d.data(), ref_d.data()); stream.synchronize(); RAFT_CUDA_TRY(cudaPeekAtLastError()); ASSERT_EQ(ref_d.value(stream), ref_val); } }; template <typename T> class ReductionTest : public testing::TestWithParam<std::vector<int>> { // NOLINT protected: const std::vector<int> input; // NOLINT rmm::cuda_stream_view stream; // NOLINT rmm::device_uvector<int> arr_d; // NOLINT public: explicit ReductionTest() : input(testing::TestWithParam<std::vector<int>>::GetParam()), stream(rmm::cuda_stream_default), arr_d(input.size(), stream) { update_device(arr_d.data(), input.data(), input.size(), stream); } void run_reduction() { // calculate the results reduction_launch::run(arr_d, 0, raft::min_op{}, stream); reduction_launch::run(arr_d, 5, raft::max_op{}, stream); reduction_launch::run(arr_d, 158, raft::add_op{}, stream); reduction_launch::run_ranked(arr_d, 5, 15, raft::max_op{}, stream); reduction_launch::run_ranked(arr_d, 0, 26, raft::min_op{}, stream); // value 15 is for the current state of PCgenerator. adjust this if rng changes reduction_launch::run_random_sample(arr_d, 15, stream); } void run_binary_reduction() { reduction_launch::run_binary(arr_d, 24, stream); } }; const std::vector<int> test_vector{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 5, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 0, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}; const std::vector<int> binary_test_vector{ 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0}; auto reduction_input = ::testing::Values(test_vector); auto binary_reduction_input = ::testing::Values(binary_test_vector); using ReductionTestInt = ReductionTest<int>; // NOLINT using BinaryReductionTestInt = ReductionTest<int>; // NOLINT TEST_P(ReductionTestInt, REDUCTIONS) { run_reduction(); } INSTANTIATE_TEST_CASE_P(ReductionTest, ReductionTestInt, reduction_input); // NOLINT TEST_P(BinaryReductionTestInt, BINARY_REDUCTION) { run_binary_reduction(); } // NOLINT INSTANTIATE_TEST_CASE_P(BinaryReductionTest, BinaryReductionTestInt, binary_reduction_input); // NOLINT } // namespace raft::util
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/bitset.cu
/* * 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. */ #include "../test_utils.cuh" #include <raft/core/bitset.cuh> #include <raft/core/device_mdarray.hpp> #include <raft/linalg/init.cuh> #include <raft/random/rng.cuh> #include <gtest/gtest.h> #include <algorithm> #include <numeric> namespace raft::core { struct test_spec_bitset { uint64_t bitset_len; uint64_t mask_len; uint64_t query_len; }; auto operator<<(std::ostream& os, const test_spec_bitset& ss) -> std::ostream& { os << "bitset{bitset_len: " << ss.bitset_len << ", mask_len: " << ss.mask_len << ", query_len: " << ss.query_len << "}"; return os; } template <typename bitset_t, typename index_t> void add_cpu_bitset(std::vector<bitset_t>& bitset, const std::vector<index_t>& mask_idx) { constexpr size_t bitset_element_size = sizeof(bitset_t) * 8; for (size_t i = 0; i < mask_idx.size(); i++) { auto idx = mask_idx[i]; bitset[idx / bitset_element_size] &= ~(bitset_t{1} << (idx % bitset_element_size)); } } template <typename bitset_t, typename index_t> void create_cpu_bitset(std::vector<bitset_t>& bitset, const std::vector<index_t>& mask_idx) { for (size_t i = 0; i < bitset.size(); i++) { bitset[i] = ~bitset_t(0x00); } add_cpu_bitset(bitset, mask_idx); } template <typename bitset_t, typename index_t> void test_cpu_bitset(const std::vector<bitset_t>& bitset, const std::vector<index_t>& queries, std::vector<uint8_t>& result) { constexpr size_t bitset_element_size = sizeof(bitset_t) * 8; for (size_t i = 0; i < queries.size(); i++) { result[i] = uint8_t((bitset[queries[i] / bitset_element_size] & (bitset_t{1} << (queries[i] % bitset_element_size))) != 0); } } template <typename bitset_t> void flip_cpu_bitset(std::vector<bitset_t>& bitset) { for (size_t i = 0; i < bitset.size(); i++) { bitset[i] = ~bitset[i]; } } template <typename bitset_t, typename index_t> class BitsetTest : public testing::TestWithParam<test_spec_bitset> { protected: index_t static constexpr const bitset_element_size = sizeof(bitset_t) * 8; const test_spec_bitset spec; std::vector<bitset_t> bitset_result; std::vector<bitset_t> bitset_ref; raft::resources res; public: explicit BitsetTest() : spec(testing::TestWithParam<test_spec_bitset>::GetParam()), bitset_result(raft::ceildiv(spec.bitset_len, uint64_t(bitset_element_size))), bitset_ref(raft::ceildiv(spec.bitset_len, uint64_t(bitset_element_size))) { } void run() { auto stream = resource::get_cuda_stream(res); // generate input and mask raft::random::RngState rng(42); auto mask_device = raft::make_device_vector<index_t, index_t>(res, spec.mask_len); std::vector<index_t> mask_cpu(spec.mask_len); raft::random::uniformInt(res, rng, mask_device.view(), index_t(0), index_t(spec.bitset_len)); update_host(mask_cpu.data(), mask_device.data_handle(), mask_device.extent(0), stream); resource::sync_stream(res, stream); // calculate the results auto my_bitset = raft::core::bitset<bitset_t, index_t>( res, raft::make_const_mdspan(mask_device.view()), index_t(spec.bitset_len)); update_host(bitset_result.data(), my_bitset.data(), bitset_result.size(), stream); // calculate the reference create_cpu_bitset(bitset_ref, mask_cpu); resource::sync_stream(res, stream); ASSERT_TRUE(hostVecMatch(bitset_ref, bitset_result, raft::Compare<bitset_t>())); auto query_device = raft::make_device_vector<index_t, index_t>(res, spec.query_len); auto result_device = raft::make_device_vector<uint8_t, index_t>(res, spec.query_len); auto query_cpu = std::vector<index_t>(spec.query_len); auto result_cpu = std::vector<uint8_t>(spec.query_len); auto result_ref = std::vector<uint8_t>(spec.query_len); // Create queries and verify the test results raft::random::uniformInt(res, rng, query_device.view(), index_t(0), index_t(spec.bitset_len)); update_host(query_cpu.data(), query_device.data_handle(), query_device.extent(0), stream); my_bitset.test(res, raft::make_const_mdspan(query_device.view()), result_device.view()); update_host(result_cpu.data(), result_device.data_handle(), result_device.extent(0), stream); test_cpu_bitset(bitset_ref, query_cpu, result_ref); resource::sync_stream(res, stream); ASSERT_TRUE(hostVecMatch(result_cpu, result_ref, Compare<uint8_t>())); // Add more sample to the bitset and re-test raft::random::uniformInt(res, rng, mask_device.view(), index_t(0), index_t(spec.bitset_len)); update_host(mask_cpu.data(), mask_device.data_handle(), mask_device.extent(0), stream); resource::sync_stream(res, stream); my_bitset.set(res, mask_device.view()); update_host(bitset_result.data(), my_bitset.data(), bitset_result.size(), stream); add_cpu_bitset(bitset_ref, mask_cpu); resource::sync_stream(res, stream); ASSERT_TRUE(hostVecMatch(bitset_ref, bitset_result, raft::Compare<bitset_t>())); // Flip the bitset and re-test auto bitset_count = my_bitset.count(res); my_bitset.flip(res); ASSERT_EQ(my_bitset.count(res), spec.bitset_len - bitset_count); update_host(bitset_result.data(), my_bitset.data(), bitset_result.size(), stream); flip_cpu_bitset(bitset_ref); resource::sync_stream(res, stream); ASSERT_TRUE(hostVecMatch(bitset_ref, bitset_result, raft::Compare<bitset_t>())); // Test count() operations my_bitset.reset(res, false); ASSERT_EQ(my_bitset.any(res), false); ASSERT_EQ(my_bitset.none(res), true); raft::linalg::range(query_device.data_handle(), query_device.size(), stream); my_bitset.set(res, raft::make_const_mdspan(query_device.view()), true); bitset_count = my_bitset.count(res); ASSERT_EQ(bitset_count, query_device.size()); ASSERT_EQ(my_bitset.any(res), true); ASSERT_EQ(my_bitset.none(res), false); } }; auto inputs_bitset = ::testing::Values(test_spec_bitset{32, 5, 10}, test_spec_bitset{100, 30, 10}, test_spec_bitset{1024, 55, 100}, test_spec_bitset{10000, 1000, 1000}, test_spec_bitset{1 << 15, 1 << 3, 1 << 12}, test_spec_bitset{1 << 15, 1 << 24, 1 << 13}, test_spec_bitset{1 << 25, 1 << 23, 1 << 14}); using Uint16_32 = BitsetTest<uint16_t, uint32_t>; TEST_P(Uint16_32, Run) { run(); } INSTANTIATE_TEST_CASE_P(BitsetTest, Uint16_32, inputs_bitset); using Uint32_32 = BitsetTest<uint32_t, uint32_t>; TEST_P(Uint32_32, Run) { run(); } INSTANTIATE_TEST_CASE_P(BitsetTest, Uint32_32, inputs_bitset); using Uint64_32 = BitsetTest<uint64_t, uint32_t>; TEST_P(Uint64_32, Run) { run(); } INSTANTIATE_TEST_CASE_P(BitsetTest, Uint64_32, inputs_bitset); using Uint8_64 = BitsetTest<uint8_t, uint64_t>; TEST_P(Uint8_64, Run) { run(); } INSTANTIATE_TEST_CASE_P(BitsetTest, Uint8_64, inputs_bitset); using Uint32_64 = BitsetTest<uint32_t, uint64_t>; TEST_P(Uint32_64, Run) { run(); } INSTANTIATE_TEST_CASE_P(BitsetTest, Uint32_64, inputs_bitset); using Uint64_64 = BitsetTest<uint64_t, uint64_t>; TEST_P(Uint64_64, Run) { run(); } INSTANTIATE_TEST_CASE_P(BitsetTest, Uint64_64, inputs_bitset); } // namespace raft::core
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/numpy_serializer.cu
/* * 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. */ #include <gtest/gtest.h> #include <raft/core/host_mdarray.hpp> #include <raft/core/resources.hpp> #include <raft/core/serialize.hpp> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/universal_vector.h> #include <complex> #include <cstdint> #include <sstream> #include <string> #include <vector> namespace { template <class IndexType, std::size_t Rank> using dextents = std::experimental::dextents<IndexType, Rank>; } // anonymous namespace namespace raft { template <typename MDSpanType, typename VectorType, typename... Args> void test_mdspan_roundtrip(const raft::resources& handle, VectorType& vec, Args... dims) { VectorType vec2(vec.size()); auto span = MDSpanType(thrust::raw_pointer_cast(vec.data()), dims...); std::ostringstream oss; serialize_mdspan(handle, oss, span); auto span2 = MDSpanType(thrust::raw_pointer_cast(vec2.data()), dims...); std::istringstream iss(oss.str()); deserialize_mdspan(handle, iss, span2); EXPECT_EQ(vec, vec2); } template <typename T> void run_roundtrip_test_mdspan_serializer() { raft::resources handle{}; thrust::host_vector<T> vec = std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8}; using mdspan_matrix2d_c_layout = raft::host_mdspan<T, dextents<std::size_t, 2>, raft::layout_c_contiguous>; using mdspan_matrix2d_f_layout = raft::host_mdspan<T, dextents<std::size_t, 2>, raft::layout_f_contiguous>; test_mdspan_roundtrip<mdspan_matrix2d_c_layout>(handle, vec, 2, 4); test_mdspan_roundtrip<mdspan_matrix2d_f_layout>(handle, vec, 2, 4); using device_mdspan_matrix3d_c_layout = raft::device_mdspan<T, dextents<std::size_t, 3>, raft::layout_c_contiguous>; using device_mdspan_matrix3d_f_layout = raft::device_mdspan<T, dextents<std::size_t, 3>, raft::layout_f_contiguous>; thrust::device_vector<T> d_vec(vec); test_mdspan_roundtrip<device_mdspan_matrix3d_c_layout>(handle, d_vec, 2, 2, 2); test_mdspan_roundtrip<device_mdspan_matrix3d_f_layout>(handle, d_vec, 2, 2, 2); } TEST(NumPySerializerMDSpan, E2ERoundTrip) { run_roundtrip_test_mdspan_serializer<float>(); run_roundtrip_test_mdspan_serializer<double>(); run_roundtrip_test_mdspan_serializer<std::int32_t>(); run_roundtrip_test_mdspan_serializer<std::uint32_t>(); run_roundtrip_test_mdspan_serializer<std::complex<float>>(); } TEST(NumPySerializerMDSpan, HeaderRoundTrip) { char byteorder = RAFT_NUMPY_HOST_ENDIAN_CHAR; for (char kind : std::vector<char>{'f', 'i', 'u', 'c'}) { for (unsigned int itemsize : std::vector<unsigned int>{1, 2, 4, 8, 16}) { for (bool fortran_order : std::vector<bool>{true, false}) { for (const auto& shape : std::vector<std::vector<detail::numpy_serializer::ndarray_len_t>>{ {10}, {2, 2}, {10, 30, 100}, {}}) { detail::numpy_serializer::dtype_t dtype{byteorder, kind, itemsize}; detail::numpy_serializer::header_t header{dtype, fortran_order, shape}; std::ostringstream oss; detail::numpy_serializer::write_header(oss, header); std::istringstream iss(oss.str()); auto header2 = detail::numpy_serializer::read_header(iss); EXPECT_EQ(header, header2); } } } } } TEST(NumPySerializerMDSpan, ManagedMDSpan) { raft::resources handle{}; thrust::universal_vector<float> vec = std::vector<float>{1, 2, 3, 4, 5, 6, 7, 8}; using managed_mdspan_matrix2d_c_layout = raft::managed_mdspan<float, dextents<std::size_t, 3>, raft::layout_c_contiguous>; test_mdspan_roundtrip<managed_mdspan_matrix2d_c_layout>(handle, vec, 2, 2, 2); } TEST(NumPySerializerMDSpan, Tuple2String) { { std::vector<int> tuple{}; EXPECT_EQ(detail::numpy_serializer::tuple_to_string(tuple), "()"); } { std::vector<int> tuple{2}; EXPECT_EQ(detail::numpy_serializer::tuple_to_string(tuple), "(2,)"); } { std::vector<int> tuple{2, 3}; EXPECT_EQ(detail::numpy_serializer::tuple_to_string(tuple), "(2, 3)"); } { std::vector<int> tuple{2, 3, 10, 20}; EXPECT_EQ(detail::numpy_serializer::tuple_to_string(tuple), "(2, 3, 10, 20)"); } } TEST(NumPySerializerMDSpan, NumPyDType) { const char expected_endian_char = RAFT_SYSTEM_LITTLE_ENDIAN ? '<' : '>'; { const detail::numpy_serializer::dtype_t expected_dtype{ expected_endian_char, 'f', sizeof(float)}; EXPECT_EQ(detail::numpy_serializer::get_numpy_dtype<float>(), expected_dtype); } { const detail::numpy_serializer::dtype_t expected_dtype{ expected_endian_char, 'f', sizeof(long double)}; EXPECT_EQ(detail::numpy_serializer::get_numpy_dtype<long double>(), expected_dtype); } { const detail::numpy_serializer::dtype_t expected_dtype{'|', 'i', sizeof(signed char)}; EXPECT_EQ(detail::numpy_serializer::get_numpy_dtype<signed char>(), expected_dtype); } { const detail::numpy_serializer::dtype_t expected_dtype{ expected_endian_char, 'i', sizeof(std::int64_t)}; EXPECT_EQ(detail::numpy_serializer::get_numpy_dtype<std::int64_t>(), expected_dtype); } { const detail::numpy_serializer::dtype_t expected_dtype{'|', 'u', sizeof(unsigned char)}; EXPECT_EQ(detail::numpy_serializer::get_numpy_dtype<unsigned char>(), expected_dtype); } { const detail::numpy_serializer::dtype_t expected_dtype{ expected_endian_char, 'u', sizeof(std::uint64_t)}; EXPECT_EQ(detail::numpy_serializer::get_numpy_dtype<std::uint64_t>(), expected_dtype); } { const detail::numpy_serializer::dtype_t expected_dtype{ expected_endian_char, 'c', sizeof(std::complex<double>)}; EXPECT_EQ(detail::numpy_serializer::get_numpy_dtype<std::complex<double>>(), expected_dtype); } } TEST(NumPySerializerMDSpan, WriteHeader) { using namespace std::string_literals; std::ostringstream oss; detail::numpy_serializer::header_t header{{'<', 'f', 8}, false, {2, 10, 5}}; detail::numpy_serializer::write_header(oss, header); EXPECT_EQ(oss.str(), "\x93NUMPY\x01\x00"s // magic string + version (1.0) "\x76\x00"s // HEADER_LEN = 118, in little endian "{'descr': '<f8', 'fortran_order': False, 'shape': (2, 10, 5)}"s // header "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"s // padding "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"s "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"s "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"s "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"s "\x20\x20\x20\x20\x20\x20\n"s); } TEST(NumPySerializerMDSpan, ParsePyDict) { std::string dict{"{'apple': 2, 'pie': 'is', 'delicious': True, 'piece of': 'cake'}"}; auto parse = detail::numpy_serializer::parse_pydict(dict, {"apple", "pie", "delicious", "piece of"}); auto expected_parse = std::map<std::string, std::string>{ {"apple", "2"}, {"pie", "'is'"}, {"delicious", "True"}, {"piece of", "'cake'"}}; EXPECT_EQ(parse, expected_parse); } TEST(NumPySerializerMDSpan, ParsePyString) { EXPECT_EQ(detail::numpy_serializer::parse_pystring("'foobar'"), "foobar"); } TEST(NumPySerializerMDSpan, ParsePyTuple) { { std::string tuple_str{"(2,)"}; std::vector<std::string> expected_parse{"2"}; EXPECT_EQ(detail::numpy_serializer::parse_pytuple(tuple_str), expected_parse); } { std::string tuple_str{"(2, 3)"}; std::vector<std::string> expected_parse{"2", "3"}; EXPECT_EQ(detail::numpy_serializer::parse_pytuple(tuple_str), expected_parse); } { std::string tuple_str{"(2, 3, 10, 20)"}; std::vector<std::string> expected_parse{"2", "3", "10", "20"}; EXPECT_EQ(detail::numpy_serializer::parse_pytuple(tuple_str), expected_parse); } } template <typename T> void run_roundtrip_test_scalar_serializer(T scalar) { std::ostringstream oss; detail::numpy_serializer::serialize_scalar(oss, scalar); std::istringstream iss(oss.str()); T tmp = detail::numpy_serializer::deserialize_scalar<T>(iss); EXPECT_EQ(scalar, tmp); } TEST(NumPySerializerScalar, E2ERoundTrip) { using namespace std::complex_literals; run_roundtrip_test_scalar_serializer<float>(2.0f); run_roundtrip_test_scalar_serializer<double>(-2.0); run_roundtrip_test_scalar_serializer<std::int8_t>(-2); run_roundtrip_test_scalar_serializer<std::uint32_t>(0x4FFFFFF); run_roundtrip_test_scalar_serializer<std::complex<double>>(1.0 - 2.0i); } template <typename T> void check_header_scalar_serializer(T scalar) { std::ostringstream oss; detail::numpy_serializer::serialize_scalar(oss, scalar); std::istringstream iss(oss.str()); detail::numpy_serializer::header_t header = detail::numpy_serializer::read_header(iss); EXPECT_TRUE(header.shape.empty()); EXPECT_EQ(header.dtype.to_string(), detail::numpy_serializer::get_numpy_dtype<T>().to_string()); } TEST(NumPySerializerScalar, HeaderCheck) { using namespace std::complex_literals; check_header_scalar_serializer<float>(2.0f); check_header_scalar_serializer<double>(-2.0); check_header_scalar_serializer<std::int8_t>(-2); check_header_scalar_serializer<std::uint32_t>(0x4FFFFFF); check_header_scalar_serializer<std::complex<double>>(1.0 - 2.0i); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/device_setter.cpp
/* * 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. */ #include <cuda_runtime_api.h> #include <gtest/gtest.h> #include <raft/core/device_setter.hpp> #include <raft/core/logger.hpp> #include <raft/util/cuda_rt_essentials.hpp> namespace raft { TEST(DeviceSetter, ScopedDevice) { auto device_a = int{}; auto device_b = int{device_setter::get_device_count() > 1}; if (device_b == device_a) { RAFT_LOG_WARN("Only 1 CUDA device detected. device_setter test will be trivial"); } auto initial_device = 0; RAFT_CUDA_TRY(cudaGetDevice(&initial_device)); auto current_device = initial_device; { auto scoped_device = device_setter{device_a}; // Confirm that device is currently device_a RAFT_CUDA_TRY(cudaGetDevice(&current_device)); EXPECT_EQ(current_device, device_a); // Confirm that get_current_device reports expected device EXPECT_EQ(current_device, device_setter::get_current_device()); } // Confirm that device went back to initial value once setter was out of // scope RAFT_CUDA_TRY(cudaGetDevice(&current_device)); EXPECT_EQ(current_device, initial_device); { auto scoped_device = device_setter{device_b}; // Confirm that device is currently device_b RAFT_CUDA_TRY(cudaGetDevice(&current_device)); EXPECT_EQ(current_device, device_b); // Confirm that get_current_device reports expected device EXPECT_EQ(current_device, device_setter::get_current_device()); } // Confirm that device went back to initial value once setter was out of // scope RAFT_CUDA_TRY(cudaGetDevice(&current_device)); EXPECT_EQ(current_device, initial_device); { auto scoped_device1 = device_setter{device_b}; auto scoped_device2 = device_setter{device_a}; RAFT_CUDA_TRY(cudaGetDevice(&current_device)); // Confirm that multiple setters behave as expected, with the last // constructed taking precedence EXPECT_EQ(current_device, device_a); } } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/mdspan_copy.cu
/* * 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. */ #include "../test_utils.h" #include <cstdint> #include <gtest/gtest.h> #include <raft/core/copy.cuh> #include <raft/core/device_mdarray.hpp> #include <raft/core/device_resources.hpp> #include <raft/core/host_mdarray.hpp> namespace raft { TEST(MDSpanCopy, Mdspan3DDeviceDeviceCuda) { auto res = device_resources{}; auto constexpr const depth = std::uint32_t{50}; auto constexpr const rows = std::uint32_t{30}; auto constexpr const cols = std::uint32_t{20}; auto in_left = make_device_mdarray<int, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto in_right = make_device_mdarray<int, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto gen_unique_entry = [](auto&& x, auto&& y, auto&& z) { return x * 7 + y * 11 + z * 13; }; res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { in_left(i, j, k) = gen_unique_entry(i, j, k); in_right(i, j, k) = gen_unique_entry(i, j, k); } } } res.sync_stream(); // Test dtype conversion without transpose auto out_long = make_device_mdarray<std::int64_t, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_long.view()), decltype(in_left.view())>, "Current implementation should use kernel for this copy"); copy(res, out_long.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_EQ(std::int64_t(out_long(i, j, k)), std::int64_t(gen_unique_entry(i, j, k))); } } } // Test transpose auto out_left = make_device_mdarray<int, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto out_right = make_device_mdarray<int, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_right.view()), decltype(in_left.view())>, "Current implementation should use kernel for this copy"); copy(res, out_right.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_EQ(int(out_right(i, j, k)), int(gen_unique_entry(i, j, k))); } } } static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_left.view()), decltype(in_right.view())>, "Current implementation should use kernel for this copy"); copy(res, out_left.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_EQ(int(out_left(i, j, k)), int(gen_unique_entry(i, j, k))); } } } } TEST(MDSpanCopy, Mdspan2DDeviceDeviceCuda) { auto res = device_resources{}; auto constexpr rows = std::uint32_t{30}; auto constexpr cols = std::uint32_t{20}; auto in_left = make_device_mdarray<float, std::uint32_t, layout_c_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto in_right = make_device_mdarray<float, std::uint32_t, layout_f_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto gen_unique_entry = [](auto&& x, auto&& y) { return x * 7 + y * 11; }; for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { in_left(i, j) = gen_unique_entry(i, j); in_right(i, j) = gen_unique_entry(i, j); } } auto out_left = make_device_mdarray<double, std::uint32_t, layout_c_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto out_right = make_device_mdarray<double, std::uint32_t, layout_f_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); res.sync_stream(); // Test dtype conversion without transpose static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_right.view()), decltype(in_right.view())>, "Current implementation should use kernel for this copy"); copy(res, out_right.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE(match( double(out_right(i, j)), double(gen_unique_entry(i, j)), CompareApprox<double>{0.0001})); } } // Test dtype conversion with transpose static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_right.view()), decltype(in_left.view())>, "Current implementation should use kernel for this copy"); copy(res, out_right.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE(match( double(out_right(i, j)), double(gen_unique_entry(i, j)), CompareApprox<double>{0.0001})); } } static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_left.view()), decltype(in_right.view())>, "Current implementation should use kernel for this copy"); copy(res, out_left.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE(match( double(out_left(i, j)), double(gen_unique_entry(i, j)), CompareApprox<double>{0.0001})); } } } TEST(MDSpanCopy, Mdspan3DDeviceHostCuda) { auto res = device_resources{}; auto constexpr const depth = std::uint32_t{50}; auto constexpr const rows = std::uint32_t{30}; auto constexpr const cols = std::uint32_t{20}; auto in_left = make_device_mdarray<int, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto in_right = make_device_mdarray<int, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto gen_unique_entry = [](auto&& x, auto&& y, auto&& z) { return x * 7 + y * 11 + z * 13; }; res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { in_left(i, j, k) = gen_unique_entry(i, j, k); in_right(i, j, k) = gen_unique_entry(i, j, k); } } } res.sync_stream(); // Test dtype conversion without transpose auto out_long = make_host_mdarray<std::int64_t, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_long.view()), decltype(in_left.view())>, "Current implementation should use kernel for this copy"); copy(res, out_long.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_EQ(std::int64_t(out_long(i, j, k)), std::int64_t(gen_unique_entry(i, j, k))); } } } // Test transpose auto out_left = make_host_mdarray<int, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto out_right = make_host_mdarray<int, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_right.view()), decltype(in_left.view())>, "Current implementation should use kernel for this copy"); copy(res, out_right.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_EQ(int(out_right(i, j, k)), int(gen_unique_entry(i, j, k))); } } } static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_left.view()), decltype(in_right.view())>, "Current implementation should use kernel for this copy"); copy(res, out_left.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_EQ(int(out_left(i, j, k)), int(gen_unique_entry(i, j, k))); } } } } TEST(MDSpanCopy, Mdspan2DDeviceHostCuda) { auto res = device_resources{}; auto constexpr rows = std::uint32_t{30}; auto constexpr cols = std::uint32_t{20}; auto in_left = make_host_mdarray<float, std::uint32_t, layout_c_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto in_right = make_host_mdarray<float, std::uint32_t, layout_f_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto gen_unique_entry = [](auto&& x, auto&& y) { return x * 7 + y * 11; }; for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { in_left(i, j) = gen_unique_entry(i, j); in_right(i, j) = gen_unique_entry(i, j); } } auto out_left = make_device_mdarray<double, std::uint32_t, layout_c_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto out_right = make_device_mdarray<double, std::uint32_t, layout_f_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); res.sync_stream(); // Test dtype conversion without transpose static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_right.view()), decltype(in_right.view())>, "Current implementation should use kernel for this copy"); copy(res, out_right.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE(match( double(out_right(i, j)), double(gen_unique_entry(i, j)), CompareApprox<double>{0.0001})); } } // Test dtype conversion with transpose static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_right.view()), decltype(in_left.view())>, "Current implementation should use kernel for this copy"); copy(res, out_right.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE(match( double(out_right(i, j)), double(gen_unique_entry(i, j)), CompareApprox<double>{0.0001})); } } static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_left.view()), decltype(in_right.view())>, "Current implementation should use kernel for this copy"); copy(res, out_left.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE(match( double(out_left(i, j)), double(gen_unique_entry(i, j)), CompareApprox<double>{0.0001})); } } } TEST(MDSpanCopy, Mdspan3DHostDeviceCuda) { auto res = device_resources{}; auto constexpr const depth = std::uint32_t{50}; auto constexpr const rows = std::uint32_t{30}; auto constexpr const cols = std::uint32_t{20}; auto in_left = make_device_mdarray<int, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto in_right = make_device_mdarray<int, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto gen_unique_entry = [](auto&& x, auto&& y, auto&& z) { return x * 7 + y * 11 + z * 13; }; res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { in_left(i, j, k) = gen_unique_entry(i, j, k); in_right(i, j, k) = gen_unique_entry(i, j, k); } } } res.sync_stream(); // Test dtype conversion without transpose auto out_long = make_device_mdarray<std::int64_t, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_long.view()), decltype(in_left.view())>, "Current implementation should use kernel for this copy"); copy(res, out_long.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_EQ(std::int64_t(out_long(i, j, k)), std::int64_t(gen_unique_entry(i, j, k))); } } } // Test transpose auto out_left = make_device_mdarray<int, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto out_right = make_device_mdarray<int, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_right.view()), decltype(in_left.view())>, "Current implementation should use kernel for this copy"); copy(res, out_right.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_EQ(int(out_right(i, j, k)), int(gen_unique_entry(i, j, k))); } } } static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_left.view()), decltype(in_right.view())>, "Current implementation should use kernel for this copy"); copy(res, out_left.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_EQ(int(out_left(i, j, k)), int(gen_unique_entry(i, j, k))); } } } } TEST(MDSpanCopy, Mdspan2DHostDeviceCuda) { auto res = device_resources{}; auto constexpr rows = std::uint32_t{30}; auto constexpr cols = std::uint32_t{20}; auto in_left = make_device_mdarray<float, std::uint32_t, layout_c_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto in_right = make_device_mdarray<float, std::uint32_t, layout_f_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto gen_unique_entry = [](auto&& x, auto&& y) { return x * 7 + y * 11; }; for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { in_left(i, j) = gen_unique_entry(i, j); in_right(i, j) = gen_unique_entry(i, j); } } auto out_left = make_device_mdarray<double, std::uint32_t, layout_c_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto out_right = make_device_mdarray<double, std::uint32_t, layout_f_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); res.sync_stream(); // Test dtype conversion without transpose static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_right.view()), decltype(in_right.view())>, "Current implementation should use kernel for this copy"); copy(res, out_right.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE(match( double(out_right(i, j)), double(gen_unique_entry(i, j)), CompareApprox<double>{0.0001})); } } // Test dtype conversion with transpose static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_right.view()), decltype(in_left.view())>, "Current implementation should use kernel for this copy"); copy(res, out_right.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE(match( double(out_right(i, j)), double(gen_unique_entry(i, j)), CompareApprox<double>{0.0001})); } } static_assert( detail::mdspan_copyable_with_kernel_v<decltype(out_left.view()), decltype(in_right.view())>, "Current implementation should use kernel for this copy"); copy(res, out_left.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE(match( double(out_left(i, j)), double(gen_unique_entry(i, j)), CompareApprox<double>{0.0001})); } } } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/interruptible.cu
/* * 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 * * 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. */ #include <cstddef> #include <gtest/gtest.h> #include <iostream> #include <memory> #include <omp.h> #include <raft/common/nvtx.hpp> #include <raft/core/detail/macros.hpp> #include <raft/core/interruptible.hpp> #include <rmm/cuda_stream.hpp> #include <thread> #include <vector> namespace raft { RAFT_KERNEL gpu_wait(int millis) { for (auto i = millis; i > 0; i--) { #if __CUDA_ARCH__ >= 700 __nanosleep(1000000); #else // For older CUDA devices: // just do some random work that takes more or less the same time from run to run. volatile double x = 0; for (int i = 0; i < 10000; i++) { x = x + double(i); x /= 2.0; __syncthreads(); } #endif } } TEST(Raft, InterruptibleBasic) { ASSERT_TRUE(interruptible::yield_no_throw()); // Cancel using the token interruptible::get_token()->cancel(); ASSERT_FALSE(interruptible::yield_no_throw()); ASSERT_TRUE(interruptible::yield_no_throw()); // Cancel by thread id interruptible::cancel(std::this_thread::get_id()); ASSERT_FALSE(interruptible::yield_no_throw()); ASSERT_TRUE(interruptible::yield_no_throw()); } TEST(Raft, InterruptibleRepeatedGetToken) { auto i = std::this_thread::get_id(); auto a1 = interruptible::get_token(); auto count = a1.use_count(); auto a2 = interruptible::get_token(); ASSERT_LT(count, a1.use_count()); count = a1.use_count(); auto b1 = interruptible::get_token(i); ASSERT_LT(count, a1.use_count()); count = a1.use_count(); auto b2 = interruptible::get_token(i); ASSERT_LT(count, a1.use_count()); ASSERT_EQ(a1, a2); ASSERT_EQ(a1, b2); ASSERT_EQ(b1, b2); } TEST(Raft, InterruptibleDelayedInit) { std::thread([&]() { auto a = interruptible::get_token(std::this_thread::get_id()); ASSERT_EQ(a.use_count(), 1); // the only pointer here is [a] auto b = interruptible::get_token(); ASSERT_EQ(a.use_count(), 3); // [a, b, thread_local] auto c = interruptible::get_token(); ASSERT_EQ(a.use_count(), 4); // [a, b, c, thread_local] ASSERT_EQ(a.get(), b.get()); ASSERT_EQ(a.get(), c.get()); }).join(); } TEST(Raft, InterruptibleOpenMP) { // number of threads must be smaller than max number of resident grids for GPU const int n_threads = 10; // 1 <= n_expected_succeed <= n_threads const int n_expected_succeed = 5; // How many milliseconds passes between a thread i and i+1 finishes. // i.e. thread i executes (C + i*n_expected_succeed) milliseconds in total. const int thread_delay_millis = 20; common::nvtx::range fun_scope("interruptible"); std::vector<std::shared_ptr<interruptible>> thread_tokens(n_threads); int n_finished = 0; int n_cancelled = 0; omp_set_dynamic(0); omp_set_num_threads(n_threads); #pragma omp parallel reduction(+ : n_finished) reduction(+ : n_cancelled) num_threads(n_threads) { auto i = omp_get_thread_num(); common::nvtx::range omp_scope("interruptible::thread-%d", i); rmm::cuda_stream stream; gpu_wait<<<1, 1, 0, stream.value()>>>(1); interruptible::synchronize(stream); thread_tokens[i] = interruptible::get_token(); #pragma omp barrier try { common::nvtx::range wait_scope("interruptible::wait-%d", i); gpu_wait<<<1, 1, 0, stream.value()>>>((1 + i) * thread_delay_millis); interruptible::synchronize(stream); n_finished = 1; } catch (interrupted_exception&) { n_cancelled = 1; } if (i == n_expected_succeed - 1) { common::nvtx::range cancel_scope("interruptible::cancel-%d", i); for (auto token : thread_tokens) token->cancel(); } #pragma omp barrier // clear the cancellation state to not disrupt other tests interruptible::yield_no_throw(); } ASSERT_EQ(n_finished, n_expected_succeed); ASSERT_EQ(n_cancelled, n_threads - n_expected_succeed); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/stream_view.cpp
/* * 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. */ #include <gtest/gtest.h> #include <raft/core/cuda_support.hpp> #include <raft/core/stream_view.hpp> #ifndef RAFT_DISABLE_CUDA #include <rmm/cuda_stream_view.hpp> #endif namespace raft { TEST(StreamView, Default) { auto stream = stream_view_per_thread; ASSERT_EQ(stream.is_per_thread_default(), raft::CUDA_ENABLED); ASSERT_FALSE(stream.is_default()); if (raft::CUDA_ENABLED) { EXPECT_NO_THROW(stream.synchronize()); EXPECT_NO_THROW(stream.interruptible_synchronize()); } else { EXPECT_THROW(stream.synchronize(), raft::non_cuda_build_error); EXPECT_THROW(stream.interruptible_synchronize(), raft::non_cuda_build_error); } EXPECT_NO_THROW(stream.synchronize_no_throw()); EXPECT_NO_THROW(stream.synchronize_if_cuda_enabled()); #ifndef RAFT_DISABLE_CUDA static_assert(std::is_same_v<decltype(stream.underlying()), rmm::cuda_stream_view>, "underlying should return rmm::cuda_stream_view"); #endif } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/span.cpp
/* * 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 * * 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. */ #include "test_span.hpp" #include <gtest/gtest.h> #include <numeric> // iota #include <raft/core/host_span.hpp> namespace raft { TEST(Span, DlfConstructors) { // Dynamic extent { host_span<int> s; ASSERT_EQ(s.size(), 0); ASSERT_EQ(s.data(), nullptr); host_span<int const> cs; ASSERT_EQ(cs.size(), 0); ASSERT_EQ(cs.data(), nullptr); } // Static extent { host_span<int, 0> s; ASSERT_EQ(s.size(), 0); ASSERT_EQ(s.data(), nullptr); host_span<int const, 0> cs; ASSERT_EQ(cs.size(), 0); ASSERT_EQ(cs.data(), nullptr); } // Init list. { host_span<float> s{}; ASSERT_EQ(s.size(), 0); ASSERT_EQ(s.data(), nullptr); host_span<int const> cs{}; ASSERT_EQ(cs.size(), 0); ASSERT_EQ(cs.data(), nullptr); } } TEST(Span, FromNullPtr) { // dynamic extent { host_span<float> s{nullptr, static_cast<host_span<float>::size_type>(0)}; ASSERT_EQ(s.size(), 0); ASSERT_EQ(s.data(), nullptr); host_span<float const> cs{nullptr, static_cast<host_span<float>::size_type>(0)}; ASSERT_EQ(cs.size(), 0); ASSERT_EQ(cs.data(), nullptr); } // static extent { host_span<float, 0> s{nullptr, static_cast<host_span<float>::size_type>(0)}; ASSERT_EQ(s.size(), 0); ASSERT_EQ(s.data(), nullptr); host_span<float const, 0> cs{nullptr, static_cast<host_span<float>::size_type>(0)}; ASSERT_EQ(cs.size(), 0); ASSERT_EQ(cs.data(), nullptr); } } TEST(Span, FromPtrLen) { float arr[16]; std::iota(arr, arr + 16, 0); // static extent { host_span<float> s(arr, 16); ASSERT_EQ(s.size(), 16); ASSERT_EQ(s.data(), arr); for (host_span<float>::size_type i = 0; i < 16; ++i) { ASSERT_EQ(s[i], arr[i]); } host_span<float const> cs(arr, 16); ASSERT_EQ(cs.size(), 16); ASSERT_EQ(cs.data(), arr); for (host_span<float const>::size_type i = 0; i < 16; ++i) { ASSERT_EQ(cs[i], arr[i]); } } // dynamic extent { host_span<float, 16> s(arr, 16); ASSERT_EQ(s.size(), 16); ASSERT_EQ(s.data(), arr); for (size_t i = 0; i < 16; ++i) { ASSERT_EQ(s[i], arr[i]); } host_span<float const, 16> cs(arr, 16); ASSERT_EQ(cs.size(), 16); ASSERT_EQ(cs.data(), arr); for (host_span<float const>::size_type i = 0; i < 16; ++i) { ASSERT_EQ(cs[i], arr[i]); } } } TEST(Span, FromFirstLast) { float arr[16]; initialize_range(arr, arr + 16); // dynamic extent { host_span<float> s(arr, arr + 16); ASSERT_EQ(s.size(), 16); ASSERT_EQ(s.data(), arr); ASSERT_EQ(s.data() + s.size(), arr + 16); for (size_t i = 0; i < 16; ++i) { ASSERT_EQ(s[i], arr[i]); } host_span<float const> cs(arr, arr + 16); ASSERT_EQ(cs.size(), 16); ASSERT_EQ(cs.data(), arr); ASSERT_EQ(cs.data() + cs.size(), arr + 16); for (size_t i = 0; i < 16; ++i) { ASSERT_EQ(cs[i], arr[i]); } } // static extent { host_span<float, 16> s(arr, arr + 16); ASSERT_EQ(s.size(), 16); ASSERT_EQ(s.data(), arr); ASSERT_EQ(s.data() + s.size(), arr + 16); for (size_t i = 0; i < 16; ++i) { ASSERT_EQ(s[i], arr[i]); } host_span<float const> cs(arr, arr + 16); ASSERT_EQ(cs.size(), 16); ASSERT_EQ(cs.data(), arr); ASSERT_EQ(cs.data() + cs.size(), arr + 16); for (size_t i = 0; i < 16; ++i) { ASSERT_EQ(cs[i], arr[i]); } } } namespace { struct base_class_t { virtual void operator()() {} }; struct derived_class_t : public base_class_t { void operator()() override {} }; } // anonymous namespace TEST(Span, FromOther) { // convert constructor { host_span<derived_class_t> derived; host_span<base_class_t> base{derived}; ASSERT_EQ(base.size(), derived.size()); ASSERT_EQ(base.data(), derived.data()); } float arr[16]; initialize_range(arr, arr + 16); // default copy constructor { host_span<float> s0(arr); host_span<float> s1(s0); ASSERT_EQ(s0.size(), s1.size()); ASSERT_EQ(s0.data(), s1.data()); } } TEST(Span, FromArray) { float arr[16]; initialize_range(arr, arr + 16); { host_span<float> s(arr); ASSERT_EQ(&arr[0], s.data()); ASSERT_EQ(s.size(), 16); for (size_t i = 0; i < 16; ++i) { ASSERT_EQ(arr[i], s[i]); } } { host_span<float, 16> s(arr); ASSERT_EQ(&arr[0], s.data()); ASSERT_EQ(s.size(), 16); for (size_t i = 0; i < 16; ++i) { ASSERT_EQ(arr[i], s[i]); } } } TEST(Span, Assignment) { int status = 1; test_assignment_t<false>{&status}(); ASSERT_EQ(status, 1); } TEST(Span, BeginEnd) { int status = 1; test_beginend_t<false>{&status}(); ASSERT_EQ(status, 1); } TEST(Span, ElementAccess) { float arr[16]; initialize_range(arr, arr + 16); host_span<float> s(arr); size_t j = 0; for (auto i : s) { ASSERT_EQ(i, arr[j]); ++j; } } TEST(Span, Obversers) { int status = 1; test_observers_t<false>{&status}(); ASSERT_EQ(status, 1); } TEST(Span, FrontBack) { { float arr[4]{0, 1, 2, 3}; host_span<float, 4> s(arr); ASSERT_EQ(s.front(), 0); ASSERT_EQ(s.back(), 3); } { std::vector<double> arr{0, 1, 2, 3}; host_span<double> s(arr.data(), arr.size()); ASSERT_EQ(s.front(), 0); ASSERT_EQ(s.back(), 3); } } TEST(Span, FirstLast) { // static extent { float arr[16]; initialize_range(arr, arr + 16); host_span<float> s(arr); host_span<float, 4> first = s.first<4>(); ASSERT_EQ(first.size(), 4); ASSERT_EQ(first.data(), arr); for (size_t i = 0; i < first.size(); ++i) { ASSERT_EQ(first[i], arr[i]); } } { float arr[16]; initialize_range(arr, arr + 16); host_span<float> s(arr); host_span<float, 4> last = s.last<4>(); ASSERT_EQ(last.size(), 4); ASSERT_EQ(last.data(), arr + 12); for (size_t i = 0; i < last.size(); ++i) { ASSERT_EQ(last[i], arr[i + 12]); } } // dynamic extent { float* arr = new float[16]; initialize_range(arr, arr + 16); host_span<float> s(arr, 16); host_span<float> first = s.first(4); ASSERT_EQ(first.size(), 4); ASSERT_EQ(first.data(), s.data()); for (size_t i = 0; i < first.size(); ++i) { ASSERT_EQ(first[i], s[i]); } delete[] arr; } { float* arr = new float[16]; initialize_range(arr, arr + 16); host_span<float> s(arr, 16); host_span<float> last = s.last(4); ASSERT_EQ(last.size(), 4); ASSERT_EQ(last.data(), s.data() + 12); for (size_t i = 0; i < last.size(); ++i) { ASSERT_EQ(s[12 + i], last[i]); } delete[] arr; } } TEST(Span, Subspan) { int arr[16]{0}; host_span<int> s1(arr); auto s2 = s1.subspan<4>(); ASSERT_EQ(s1.size() - 4, s2.size()); auto s3 = s1.subspan(2, 4); ASSERT_EQ(s1.data() + 2, s3.data()); ASSERT_EQ(s3.size(), 4); auto s4 = s1.subspan(2, dynamic_extent); ASSERT_EQ(s1.data() + 2, s4.data()); ASSERT_EQ(s4.size(), s1.size() - 2); } TEST(Span, Compare) { int status = 1; test_compare_t<false>{&status}(); ASSERT_EQ(status, 1); } TEST(Span, AsBytes) { int status = 1; test_as_bytes_t<false>{&status}(); ASSERT_EQ(status, 1); } TEST(Span, AsWritableBytes) { int status = 1; test_as_writable_bytes_t<false>{&status}(); ASSERT_EQ(status, 1); } TEST(Span, Empty) { { host_span<float> s{nullptr, static_cast<host_span<float>::size_type>(0)}; auto res = s.subspan(0); ASSERT_EQ(res.data(), nullptr); ASSERT_EQ(res.size(), 0); res = s.subspan(0, 0); ASSERT_EQ(res.data(), nullptr); ASSERT_EQ(res.size(), 0); } { host_span<float, 0> s{nullptr, static_cast<host_span<float>::size_type>(0)}; auto res = s.subspan(0); ASSERT_EQ(res.data(), nullptr); ASSERT_EQ(res.size(), 0); res = s.subspan(0, 0); ASSERT_EQ(res.data(), nullptr); ASSERT_EQ(res.size(), 0); } { // Should emit compile error // host_span<float, 0> h{nullptr, 0ul}; // device_span<float, 0> d{h}; } } TEST(Span, RBeginREnd) { int32_t status = 1; test_rbeginrend_t<false>{&status}(); ASSERT_EQ(status, 1); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/logger.cpp
/* * Copyright (c) 2020-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. */ // We set RAFT_ACTIVE_LEVEL to a value that would enable testing trace and debug logs // (otherwise trace and debug logs are desabled by default). #undef RAFT_ACTIVE_LEVEL #define RAFT_ACTIVE_LEVEL 6 #include <gtest/gtest.h> #include <raft/core/logger.hpp> #include <string> namespace raft { TEST(logger, Test) { RAFT_LOG_CRITICAL("This is a critical message"); RAFT_LOG_ERROR("This is an error message"); RAFT_LOG_WARN("This is a warning message"); RAFT_LOG_INFO("This is an info message"); logger::get(RAFT_NAME).set_level(RAFT_LEVEL_WARN); ASSERT_EQ(RAFT_LEVEL_WARN, logger::get(RAFT_NAME).get_level()); logger::get(RAFT_NAME).set_level(RAFT_LEVEL_INFO); ASSERT_EQ(RAFT_LEVEL_INFO, logger::get(RAFT_NAME).get_level()); ASSERT_FALSE(logger::get(RAFT_NAME).should_log_for(RAFT_LEVEL_TRACE)); ASSERT_FALSE(logger::get(RAFT_NAME).should_log_for(RAFT_LEVEL_DEBUG)); ASSERT_TRUE(logger::get(RAFT_NAME).should_log_for(RAFT_LEVEL_INFO)); ASSERT_TRUE(logger::get(RAFT_NAME).should_log_for(RAFT_LEVEL_WARN)); } std::string logged = ""; void exampleCallback(int lvl, const char* msg) { logged = std::string(msg); } int flushCount = 0; void exampleFlush() { ++flushCount; } class loggerTest : public ::testing::Test { protected: void SetUp() override { flushCount = 0; logged = ""; logger::get(RAFT_NAME).set_level(RAFT_LEVEL_TRACE); } void TearDown() override { logger::get(RAFT_NAME).set_callback(nullptr); logger::get(RAFT_NAME).set_flush(nullptr); logger::get(RAFT_NAME).set_level(RAFT_LEVEL_INFO); } }; // The logging macros depend on `RAFT_ACTIVE_LEVEL` as well as the logger verbosity; // The verbosity is set to `RAFT_LEVEL_TRACE`, but `RAFT_ACTIVE_LEVEL` is set outside of here. auto check_if_logged(const std::string& msg, int log_level_def) -> bool { bool actually_logged = logged.find(msg) != std::string::npos; bool should_be_logged = RAFT_ACTIVE_LEVEL >= log_level_def; return actually_logged == should_be_logged; } TEST_F(loggerTest, callback) { std::string testMsg; logger::get(RAFT_NAME).set_callback(exampleCallback); testMsg = "This is a critical message"; RAFT_LOG_CRITICAL(testMsg.c_str()); ASSERT_TRUE(check_if_logged(testMsg, RAFT_LEVEL_CRITICAL)); testMsg = "This is an error message"; RAFT_LOG_ERROR(testMsg.c_str()); ASSERT_TRUE(check_if_logged(testMsg, RAFT_LEVEL_ERROR)); testMsg = "This is a warning message"; RAFT_LOG_WARN(testMsg.c_str()); ASSERT_TRUE(check_if_logged(testMsg, RAFT_LEVEL_WARN)); testMsg = "This is an info message"; RAFT_LOG_INFO(testMsg.c_str()); ASSERT_TRUE(check_if_logged(testMsg, RAFT_LEVEL_INFO)); testMsg = "This is a debug message"; RAFT_LOG_DEBUG(testMsg.c_str()); ASSERT_TRUE(check_if_logged(testMsg, RAFT_LEVEL_DEBUG)); testMsg = "This is a trace message"; RAFT_LOG_TRACE(testMsg.c_str()); ASSERT_TRUE(check_if_logged(testMsg, RAFT_LEVEL_TRACE)); } TEST_F(loggerTest, flush) { logger::get(RAFT_NAME).set_flush(exampleFlush); logger::get(RAFT_NAME).flush(); ASSERT_EQ(1, flushCount); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/memory_type.cpp
/* * 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 * * 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. */ #include <gtest/gtest.h> #include <raft/core/memory_type.hpp> namespace raft { TEST(MemoryType, IsDeviceAccessible) { static_assert(!is_device_accessible(memory_type::host)); static_assert(is_device_accessible(memory_type::device)); static_assert(is_device_accessible(memory_type::managed)); static_assert(!is_device_accessible(memory_type::pinned)); } TEST(MemoryType, IsHostAccessible) { static_assert(is_host_accessible(memory_type::host)); static_assert(!is_host_accessible(memory_type::device)); static_assert(is_host_accessible(memory_type::managed)); static_assert(is_host_accessible(memory_type::pinned)); } TEST(MemoryType, IsHostDeviceAccessible) { static_assert(!is_host_device_accessible(memory_type::host)); static_assert(!is_host_device_accessible(memory_type::device)); static_assert(is_host_device_accessible(memory_type::managed)); static_assert(!is_host_device_accessible(memory_type::pinned)); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/mdspan_utils.cu
/* * 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 * * 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. */ #include <gtest/gtest.h> #include <raft/core/device_container_policy.hpp> #include <raft/core/device_mdarray.hpp> #include <raft/core/host_container_policy.hpp> #include <raft/core/host_mdarray.hpp> #include <raft/core/resources.hpp> namespace raft { namespace stdex = std::experimental; template <typename ElementType, typename Extents, typename LayoutPolicy = layout_c_contiguous, typename AccessorPolicy = stdex::default_accessor<ElementType>> struct derived_device_mdspan : public device_mdspan<ElementType, Extents, LayoutPolicy, AccessorPolicy> {}; void test_template_asserts() { // Testing 3d device mdspan to be an mdspan using three_d_extents = extents<int, dynamic_extent, dynamic_extent, dynamic_extent>; using three_d_mdspan = device_mdspan<int, three_d_extents>; using d_mdspan = derived_device_mdspan<int, three_d_extents>; static_assert( std::is_same_v<device_matrix_view<int, int>, device_mdspan<int, matrix_extent<int>>>, "not same"); static_assert(std::is_same_v<device_matrix_view<int, int>, device_mdspan<int, extents<int, dynamic_extent, dynamic_extent>>>, "not same"); // Checking if types are mdspan, supposed to fail for std::vector static_assert(is_mdspan_v<three_d_mdspan>, "3d mdspan type not an mdspan"); static_assert(is_mdspan_v<device_matrix_view<float>>, "device_matrix_view type not an mdspan"); static_assert(is_mdspan_v<const host_vector_view<unsigned long>>, "const host_vector_view type not an mdspan"); static_assert(is_mdspan_v<const host_scalar_view<double>>, "const host_scalar_view type not an mdspan"); static_assert(!is_mdspan_v<std::vector<int>>, "std::vector is an mdspan"); static_assert(is_mdspan_v<d_mdspan>, "Derived device mdspan type is not mdspan"); // Checking if types are device_mdspan static_assert(is_device_mdspan_v<device_matrix_view<float>>, "device_matrix_view type not a device_mdspan"); static_assert(!is_device_mdspan_v<host_matrix_view<float>>, "host_matrix_view type is a device_mdspan"); static_assert(is_device_mdspan_v<d_mdspan>, "Derived device mdspan type is not device_mdspan"); // Checking if types are host_mdspan static_assert(!is_host_mdspan_v<device_matrix_view<float>>, "device_matrix_view type is a host_mdspan"); static_assert(is_host_mdspan_v<host_matrix_view<float>>, "host_matrix_view type is not a host_mdspan"); // checking variadics static_assert(!is_mdspan_v<three_d_mdspan, std::vector<int>>, "variadics mdspans"); static_assert(is_mdspan_v<three_d_mdspan, d_mdspan>, "variadics not mdspans"); } TEST(MDSpan, TemplateAsserts) { test_template_asserts(); } void test_host_flatten() { raft::resources handle; // flatten 3d host mdspan { using three_d_extents = extents<int, dynamic_extent, dynamic_extent, dynamic_extent>; using three_d_mdarray = host_mdarray<int, three_d_extents>; three_d_extents extents{3, 3, 3}; typename three_d_mdarray::mapping_type layout{extents}; typename three_d_mdarray::container_policy_type policy; three_d_mdarray mda{handle, layout, policy}; auto flat_view = flatten(mda); static_assert(std::is_same_v<typename three_d_mdarray::layout_type, typename decltype(flat_view)::layout_type>, "layouts not the same"); ASSERT_EQ(flat_view.extents().rank(), 1); ASSERT_EQ(flat_view.size(), mda.size()); } // flatten host vector { auto hv = make_host_vector<int>(handle, 27); auto flat_view = flatten(hv.view()); ASSERT_EQ(hv.extents().rank(), flat_view.extents().rank()); ASSERT_EQ(hv.extent(0), flat_view.extent(0)); } // flatten host scalar { auto hs = make_host_scalar<int>(handle, 27); auto flat_view = flatten(hs.view()); ASSERT_EQ(flat_view.extent(0), 1); } } TEST(MDArray, HostFlatten) { test_host_flatten(); } void test_device_flatten() { raft::resources handle; // flatten 3d device mdspan { raft::resources handle; using three_d_extents = extents<int, dynamic_extent, dynamic_extent, dynamic_extent>; using three_d_mdarray = device_mdarray<int, three_d_extents>; three_d_extents extents{3, 3, 3}; typename three_d_mdarray::mapping_type layout{extents}; typename three_d_mdarray::container_policy_type policy{}; three_d_mdarray mda{handle, layout, policy}; auto flat_view = flatten(mda); static_assert(std::is_same_v<typename three_d_mdarray::layout_type, typename decltype(flat_view)::layout_type>, "layouts not the same"); ASSERT_EQ(flat_view.extents().rank(), 1); ASSERT_EQ(flat_view.size(), mda.size()); } // flatten device vector { auto dv = make_device_vector<int>(handle, 27); auto flat_view = flatten(dv.view()); ASSERT_EQ(dv.extents().rank(), flat_view.extents().rank()); ASSERT_EQ(dv.extent(0), flat_view.extent(0)); } // flatten device scalar { auto ds = make_device_scalar<int>(handle, 27); auto flat_view = flatten(ds.view()); ASSERT_EQ(flat_view.extent(0), 1); } } TEST(MDArray, DeviceFlatten) { test_device_flatten(); } void test_reshape() { raft::resources handle; // reshape 3d host array to vector { using three_d_extents = extents<int, dynamic_extent, dynamic_extent, dynamic_extent>; using three_d_mdarray = host_mdarray<int, three_d_extents>; three_d_extents extents{3, 3, 3}; typename three_d_mdarray::mapping_type layout{extents}; typename three_d_mdarray::container_policy_type policy; three_d_mdarray mda{handle, layout, policy}; auto flat_view = reshape(mda, raft::extents<int, dynamic_extent>{27}); ASSERT_EQ(flat_view.extents().rank(), 1); ASSERT_EQ(flat_view.size(), mda.size()); } // reshape 4d device array to 2d { raft::resources handle; using four_d_extents = extents<int, dynamic_extent, dynamic_extent, dynamic_extent, dynamic_extent>; using four_d_mdarray = device_mdarray<int, four_d_extents>; four_d_extents extents{2, 2, 2, 2}; typename four_d_mdarray::mapping_type layout{extents}; typename four_d_mdarray::container_policy_type policy{}; four_d_mdarray mda{handle, layout, policy}; auto matrix = reshape(mda, raft::extents<int, dynamic_extent, dynamic_extent>{4, 4}); ASSERT_EQ(matrix.extents().rank(), 2); ASSERT_EQ(matrix.extent(0), 4); ASSERT_EQ(matrix.extent(1), 4); } // reshape 2d host matrix with static extents to vector { using two_d_extents = extents<int, 5, 5>; using two_d_mdarray = host_mdarray<float, two_d_extents>; typename two_d_mdarray::mapping_type layout{two_d_extents{}}; typename two_d_mdarray::container_policy_type policy; two_d_mdarray mda{handle, layout, policy}; auto vector = reshape(mda, extents<int, 25>{}); ASSERT_EQ(vector.extents().rank(), 1); ASSERT_EQ(vector.size(), mda.size()); } } TEST(MDArray, Reshape) { test_reshape(); } void test_const_mdspan() { // 3d host array { raft::resources handle; using two_d_extents = extents<int, 5, 5>; using two_d_mdarray = host_mdarray<float, two_d_extents>; typename two_d_mdarray::mapping_type layout{two_d_extents{}}; typename two_d_mdarray::container_policy_type policy; two_d_mdarray mda{handle, layout, policy}; auto const_mda = make_const_mdspan(mda.view()); static_assert(std::is_same_v<const float, typename decltype(const_mda)::element_type>, "elements not the same"); static_assert(std::is_same_v<typename decltype(mda)::extents_type, typename decltype(const_mda)::extents_type>, "extents not the same"); static_assert(std::is_same_v<typename decltype(mda)::layout_type, typename decltype(const_mda)::layout_type>, "layouts not the same"); ASSERT_EQ(mda.size(), const_mda.size()); } } TEST(MDSpan, ConstMDSpan) { test_const_mdspan(); } void test_contiguous_predicates() { raft::resources handle; extents<std::int64_t, dynamic_extent, dynamic_extent, dynamic_extent> exts{4, 4, 4}; { std::array<std::int64_t, 3> strides{16, 4, 1}; ASSERT_TRUE(is_c_contiguous(exts, strides)); ASSERT_FALSE(is_f_contiguous(exts, strides)); // ensure that we are using the same stride unit (elements v.s. bytes) as mdarray auto arr = make_host_mdarray<float>(handle, exts); for (std::int32_t i = 0; i < 3; ++i) { auto s = arr.stride(i); ASSERT_EQ(s, strides[i]); } } { std::array<std::int64_t, 3> strides{1, 4, 16}; ASSERT_FALSE(is_c_contiguous(exts, strides)); ASSERT_TRUE(is_f_contiguous(exts, strides)); } } TEST(MDArray, Contiguous) { test_contiguous_predicates(); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/nvtx.cpp
/* * 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. * 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. */ #ifdef NVTX_ENABLED #include <gtest/gtest.h> #include <raft/core/detail/nvtx.hpp> /** * tests for the functionality of generating next color based on string * entered in the NVTX Range marker wrappers */ namespace raft { class NvtxNextColorTest : public ::testing::Test { protected: void SetUp() override { const std::string temp1 = "foo"; const std::string temp2 = "bar"; diff_string_diff_color = common::nvtx::detail::generate_next_color(temp1) != common::nvtx::detail::generate_next_color(temp2); same_string_same_color = common::nvtx::detail::generate_next_color(temp1) == common::nvtx::detail::generate_next_color(temp1); } void TearDown() {} bool diff_string_diff_color = false; bool same_string_same_color = false; }; TEST_F(NvtxNextColorTest, generate_next_color) { EXPECT_TRUE(diff_string_diff_color); EXPECT_TRUE(same_string_same_color); } } // end namespace raft #endif
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/handle.cpp
/* * Copyright (c) 2020-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. */ #include <cstddef> #include <cuda_runtime.h> #include <gtest/gtest.h> #include <iostream> #include <memory> #include <raft/core/comms.hpp> #include <raft/core/handle.hpp> #include <raft/core/resource/comms.hpp> #include <raft/core/resource/cuda_stream.hpp> #include <raft/core/resource/cuda_stream_pool.hpp> #include <raft/core/resource/device_memory_resource.hpp> #include <rmm/device_buffer.hpp> #include <rmm/mr/device/device_memory_resource.hpp> #include <rmm/mr/device/pool_memory_resource.hpp> #include <unordered_map> namespace raft { using namespace comms; class mock_comms : public comms_iface { public: mock_comms(int n) : n_ranks(n) {} ~mock_comms() {} int get_size() const override { return n_ranks; } int get_rank() const override { return 0; } std::unique_ptr<comms_iface> comm_split(int color, int key) const { return std::unique_ptr<comms_iface>(new mock_comms(0)); } void barrier() const {} void get_request_id(request_t* req) const {} void isend(const void* buf, size_t size, int dest, int tag, request_t* request) const {} void irecv(void* buf, size_t size, int source, int tag, request_t* request) const {} void waitall(int count, request_t array_of_requests[]) const {} void allreduce(const void* sendbuff, void* recvbuff, size_t count, datatype_t datatype, op_t op, cudaStream_t stream) const { } void bcast(void* buff, size_t count, datatype_t datatype, int root, cudaStream_t stream) const {} void bcast(const void* sendbuff, void* recvbuff, size_t count, datatype_t datatype, int root, cudaStream_t stream) const { } void reduce(const void* sendbuff, void* recvbuff, size_t count, datatype_t datatype, op_t op, int root, cudaStream_t stream) const { } void allgather(const void* sendbuff, void* recvbuff, size_t sendcount, datatype_t datatype, cudaStream_t stream) const { } void allgatherv(const void* sendbuf, void* recvbuf, const size_t* recvcounts, const size_t* displs, datatype_t datatype, cudaStream_t stream) const { } void gather(const void* sendbuff, void* recvbuff, size_t sendcount, datatype_t datatype, int root, cudaStream_t stream) const { } void gatherv(const void* sendbuff, void* recvbuff, size_t sendcount, const size_t* recvcounts, const size_t* displs, datatype_t datatype, int root, cudaStream_t stream) const { } void reducescatter(const void* sendbuff, void* recvbuff, size_t recvcount, datatype_t datatype, op_t op, cudaStream_t stream) const { } status_t sync_stream(cudaStream_t stream) const { return status_t::SUCCESS; } // if a thread is sending & receiving at the same time, use device_sendrecv to avoid deadlock void device_send(const void* buf, size_t size, int dest, cudaStream_t stream) const {} // if a thread is sending & receiving at the same time, use device_sendrecv to avoid deadlock void device_recv(void* buf, size_t size, int source, cudaStream_t stream) const {} void device_sendrecv(const void* sendbuf, size_t sendsize, int dest, void* recvbuf, size_t recvsize, int source, cudaStream_t stream) const { } void device_multicast_sendrecv(const void* sendbuf, std::vector<size_t> const& sendsizes, std::vector<size_t> const& sendoffsets, std::vector<int> const& dests, void* recvbuf, std::vector<size_t> const& recvsizes, std::vector<size_t> const& recvoffsets, std::vector<int> const& sources, cudaStream_t stream) const { } void group_start() const {} void group_end() const {} private: int n_ranks; }; void assert_handles_equal(raft::handle_t& handle_one, raft::handle_t& handle_two) { // Assert shallow copied state ASSERT_EQ(handle_one.get_stream().value(), handle_two.get_stream().value()); ASSERT_EQ(handle_one.get_stream_pool_size(), handle_two.get_stream_pool_size()); // Sanity check to make sure non-corresponding streams are not equal ASSERT_NE(handle_one.get_stream_pool().get_stream(0).value(), handle_two.get_stream_pool().get_stream(1).value()); for (size_t i = 0; i < handle_one.get_stream_pool_size(); ++i) { ASSERT_EQ(handle_one.get_stream_pool().get_stream(i).value(), handle_two.get_stream_pool().get_stream(i).value()); } } TEST(Raft, HandleDefault) { raft::handle_t h; ASSERT_EQ(0, h.get_device()); ASSERT_EQ(rmm::cuda_stream_per_thread, resource::get_cuda_stream(h)); ASSERT_NE(nullptr, h.get_cublas_handle()); ASSERT_NE(nullptr, h.get_cusolver_dn_handle()); ASSERT_NE(nullptr, h.get_cusolver_sp_handle()); ASSERT_NE(nullptr, h.get_cusparse_handle()); } TEST(Raft, Handle) { // test stream pool creation constexpr std::size_t n_streams = 4; auto stream_pool = std::make_shared<rmm::cuda_stream_pool>(n_streams); raft::handle_t h(rmm::cuda_stream_default, stream_pool); ASSERT_EQ(n_streams, h.get_stream_pool_size()); // test non default stream handle cudaStream_t stream; RAFT_CUDA_TRY(cudaStreamCreate(&stream)); rmm::cuda_stream_view stream_view(stream); raft::handle_t handle(stream_view); ASSERT_EQ(stream_view, resource::get_cuda_stream(handle)); resource::sync_stream(handle, stream); RAFT_CUDA_TRY(cudaStreamDestroy(stream)); } TEST(Raft, DefaultConstructor) { raft::handle_t handle; // Make sure waiting on the default stream pool // does not fail. resource::wait_stream_pool_on_stream(handle); resource::sync_stream_pool(handle); auto s1 = resource::get_next_usable_stream(handle); auto s2 = resource::get_cuda_stream(handle); auto s3 = resource::get_next_usable_stream(handle, 5); ASSERT_EQ(s1, s2); ASSERT_EQ(s2, s3); ASSERT_EQ(0, resource::get_stream_pool_size(handle)); } TEST(Raft, GetHandleFromPool) { constexpr std::size_t n_streams = 4; auto stream_pool = std::make_shared<rmm::cuda_stream_pool>(n_streams); raft::handle_t parent(rmm::cuda_stream_default, stream_pool); for (std::size_t i = 0; i < n_streams; i++) { auto worker_stream = parent.get_stream_from_stream_pool(i); raft::handle_t child(worker_stream); ASSERT_EQ(parent.get_stream_from_stream_pool(i), child.get_stream()); } parent.wait_stream_pool_on_stream(); } TEST(Raft, Comms) { raft::handle_t handle; auto comm1 = std::make_shared<comms_t>(std::unique_ptr<comms_iface>(new mock_comms(2))); handle.set_comms(comm1); ASSERT_EQ(resource::get_comms(handle).get_size(), 2); } TEST(Raft, SubComms) { raft::handle_t handle; auto comm1 = std::make_shared<comms_t>(std::unique_ptr<comms_iface>(new mock_comms(1))); handle.set_subcomm("key1", comm1); auto comm2 = std::make_shared<comms_t>(std::unique_ptr<comms_iface>(new mock_comms(2))); handle.set_subcomm("key2", comm2); ASSERT_EQ(handle.get_subcomm("key1").get_size(), 1); ASSERT_EQ(handle.get_subcomm("key2").get_size(), 2); } TEST(Raft, WorkspaceResource) { raft::handle_t handle; // The returned resource is always a limiting adaptor auto* orig_mr = resource::get_workspace_resource(handle)->get_upstream(); // Let's create a pooled resource auto pool_mr = std::shared_ptr<rmm::mr::device_memory_resource>{ new rmm::mr::pool_memory_resource(rmm::mr::get_current_device_resource())}; // A tiny workspace of 1MB size_t max_size = 1024 * 1024; // Replace the resource resource::set_workspace_resource(handle, pool_mr, max_size); auto new_mr = resource::get_workspace_resource(handle); // By this point, the orig_mr likely points to a non-existent resource; don't dereference! ASSERT_NE(orig_mr, new_mr); ASSERT_EQ(pool_mr.get(), new_mr->get_upstream()); // We can safely reset pool_mr, because the shared_ptr to the pool memory stays in the resource pool_mr.reset(); auto stream = resource::get_cuda_stream(handle); rmm::device_buffer buf(max_size / 2, stream, new_mr); // Note, the underlying pool allocator likely uses more space than reported here ASSERT_EQ(max_size, resource::get_workspace_total_bytes(handle)); ASSERT_EQ(buf.size(), resource::get_workspace_used_bytes(handle)); ASSERT_EQ(max_size - buf.size(), resource::get_workspace_free_bytes(handle)); // this should throw, becaise we partially used the space. ASSERT_THROW((rmm::device_buffer{max_size, stream, new_mr}), rmm::bad_alloc); } TEST(Raft, WorkspaceResourceCopy) { raft::handle_t res; auto orig_mr = resource::get_workspace_resource(res); auto orig_size = resource::get_workspace_total_bytes(res); { // create a new handle in the inner scope and update the workspace resource for it. raft::resources tmp_res(res); resource::set_workspace_resource( tmp_res, std::shared_ptr<rmm::mr::device_memory_resource>{ new rmm::mr::pool_memory_resource(rmm::mr::get_current_device_resource())}, orig_size * 2); ASSERT_EQ(orig_mr, resource::get_workspace_resource(res)); ASSERT_EQ(orig_size, resource::get_workspace_total_bytes(res)); ASSERT_NE(orig_mr, resource::get_workspace_resource(tmp_res)); ASSERT_NE(orig_size, resource::get_workspace_total_bytes(tmp_res)); } ASSERT_EQ(orig_mr, resource::get_workspace_resource(res)); ASSERT_EQ(orig_size, resource::get_workspace_total_bytes(res)); } TEST(Raft, HandleCopy) { auto stream_pool = std::make_shared<rmm::cuda_stream_pool>(10); handle_t handle(rmm::cuda_stream_per_thread, stream_pool); handle_t copied_handle(handle); assert_handles_equal(handle, copied_handle); } TEST(Raft, HandleAssign) { auto stream_pool = std::make_shared<rmm::cuda_stream_pool>(10); handle_t handle(rmm::cuda_stream_per_thread, stream_pool); handle_t copied_handle = handle; assert_handles_equal(handle, copied_handle); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/math_host.cpp
/* * 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. */ #include <gtest/gtest.h> #include "../test_utils.h" #include <raft/core/math.hpp> TEST(MathHost, Abs) { // Integer abs ASSERT_TRUE(raft::match(int8_t{123}, raft::abs(int8_t{-123}), raft::Compare<int8_t>())); ASSERT_TRUE(raft::match(12345, raft::abs(-12345), raft::Compare<int>())); ASSERT_TRUE(raft::match(12345l, raft::abs(-12345l), raft::Compare<long int>())); ASSERT_TRUE( raft::match(123451234512345ll, raft::abs(-123451234512345ll), raft::Compare<long long int>())); // Floating-point abs ASSERT_TRUE(raft::match(12.34f, raft::abs(-12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match(12.34, raft::abs(-12.34), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Acos) { ASSERT_TRUE( raft::match(std::acos(0.123f), raft::acos(0.123f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::acos(0.123), raft::acos(0.123), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Asin) { ASSERT_TRUE( raft::match(std::asin(0.123f), raft::asin(0.123f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::asin(0.123), raft::asin(0.123), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Atanh) { ASSERT_TRUE( raft::match(std::atanh(0.123f), raft::atanh(0.123f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::atanh(0.123), raft::atanh(0.123), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Cos) { ASSERT_TRUE( raft::match(std::cos(12.34f), raft::cos(12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::cos(12.34), raft::cos(12.34), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Exp) { ASSERT_TRUE( raft::match(std::exp(12.34f), raft::exp(12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::exp(12.34), raft::exp(12.34), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Log) { ASSERT_TRUE( raft::match(std::log(12.34f), raft::log(12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::log(12.34), raft::log(12.34), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Max2) { ASSERT_TRUE(raft::match(1234, raft::max(-1234, 1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(1234u, raft::max(1234u, 123u), raft::Compare<unsigned int>())); ASSERT_TRUE(raft::match(1234ll, raft::max(-1234ll, 1234ll), raft::Compare<long long int>())); ASSERT_TRUE( raft::match(1234ull, raft::max(1234ull, 123ull), raft::Compare<unsigned long long int>())); ASSERT_TRUE(raft::match(12.34f, raft::max(-12.34f, 12.34f), raft::Compare<float>())); ASSERT_TRUE(raft::match(12.34, raft::max(-12.34, 12.34), raft::Compare<double>())); ASSERT_TRUE(raft::match(12.34, raft::max(-12.34f, 12.34), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE(raft::match(12.34, raft::max(-12.34, 12.34f), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Max3) { ASSERT_TRUE(raft::match(1234, raft::max(1234, 0, -1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(1234, raft::max(-1234, 1234, 0), raft::Compare<int>())); ASSERT_TRUE(raft::match(1234, raft::max(0, -1234, 1234), raft::Compare<int>())); ASSERT_TRUE( raft::match(12.34, raft::max(12.34f, 0., -12.34), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE( raft::match(12.34, raft::max(-12.34, 12.34f, 0.), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE( raft::match(12.34, raft::max(0., -12.34, 12.34f), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Min2) { ASSERT_TRUE(raft::match(-1234, raft::min(-1234, 1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(123u, raft::min(1234u, 123u), raft::Compare<unsigned int>())); ASSERT_TRUE(raft::match(-1234ll, raft::min(-1234ll, 1234ll), raft::Compare<long long int>())); ASSERT_TRUE( raft::match(123ull, raft::min(1234ull, 123ull), raft::Compare<unsigned long long int>())); ASSERT_TRUE(raft::match(-12.34f, raft::min(-12.34f, 12.34f), raft::Compare<float>())); ASSERT_TRUE(raft::match(-12.34, raft::min(-12.34, 12.34), raft::Compare<double>())); ASSERT_TRUE( raft::match(-12.34, raft::min(-12.34f, 12.34), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE( raft::match(-12.34, raft::min(-12.34, 12.34f), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Min3) { ASSERT_TRUE(raft::match(-1234, raft::min(1234, 0, -1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(-1234, raft::min(-1234, 1234, 0), raft::Compare<int>())); ASSERT_TRUE(raft::match(-1234, raft::min(0, -1234, 1234), raft::Compare<int>())); ASSERT_TRUE( raft::match(-12.34, raft::min(12.34f, 0., -12.34), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE( raft::match(-12.34, raft::min(-12.34, 12.34f, 0.), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE( raft::match(-12.34, raft::min(0., -12.34, 12.34f), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Pow) { ASSERT_TRUE(raft::match( std::pow(12.34f, 2.f), raft::pow(12.34f, 2.f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::pow(12.34, 2.), raft::pow(12.34, 2.), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Sgn) { ASSERT_TRUE(raft::match(-1, raft::sgn(-1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(0, raft::sgn(0), raft::Compare<int>())); ASSERT_TRUE(raft::match(1, raft::sgn(1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(-1, raft::sgn(-12.34f), raft::Compare<int>())); ASSERT_TRUE(raft::match(0, raft::sgn(0.f), raft::Compare<int>())); ASSERT_TRUE(raft::match(1, raft::sgn(12.34f), raft::Compare<int>())); } TEST(MathHost, Sin) { ASSERT_TRUE( raft::match(std::sin(12.34f), raft::sin(12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::sin(12.34), raft::sin(12.34), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, SinCos) { float xf = 12.34f; float sf, cf; raft::sincos(xf, &sf, &cf); ASSERT_TRUE(raft::match(std::sin(12.34f), sf, raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match(std::cos(12.34f), cf, raft::CompareApprox<float>(0.0001f))); double xd = 12.34f; double sd, cd; raft::sincos(xd, &sd, &cd); ASSERT_TRUE(raft::match(std::sin(12.34), sd, raft::CompareApprox<double>(0.000001))); ASSERT_TRUE(raft::match(std::cos(12.34), cd, raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Sqrt) { ASSERT_TRUE( raft::match(std::sqrt(12.34f), raft::sqrt(12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::sqrt(12.34), raft::sqrt(12.34), raft::CompareApprox<double>(0.000001))); } TEST(MathHost, Tanh) { ASSERT_TRUE( raft::match(std::tanh(12.34f), raft::tanh(12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(std::tanh(12.34), raft::tanh(12.34), raft::CompareApprox<double>(0.000001))); }
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/span.cu
/* * 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 * * 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. */ #include "test_span.hpp" #include <gtest/gtest.h> #include <numeric> // iota #include <raft/core/device_span.hpp> #include <raft/util/cuda_utils.cuh> #include <raft/util/cudart_utils.hpp> #include <thrust/copy.h> #include <thrust/device_vector.h> #include <thrust/execution_policy.h> #include <thrust/for_each.h> #include <thrust/host_vector.h> #include <thrust/iterator/counting_iterator.h> #include <thrust/memory.h> namespace raft { struct TestStatus { private: int* status_; public: TestStatus() { RAFT_CUDA_TRY(cudaMalloc(&status_, sizeof(int))); int h_status = 1; RAFT_CUDA_TRY(cudaMemcpy(status_, &h_status, sizeof(int), cudaMemcpyHostToDevice)); } ~TestStatus() noexcept(false) { RAFT_CUDA_TRY(cudaFree(status_)); } int Get() { int h_status; RAFT_CUDA_TRY(cudaMemcpy(&h_status, status_, sizeof(int), cudaMemcpyDeviceToHost)); return h_status; } int* Data() { return status_; } }; RAFT_KERNEL TestFromOtherKernel(device_span<float> span) { // don't get optimized out size_t idx = threadIdx.x + blockIdx.x * blockDim.x; if (idx >= span.size()) { return; } } // Test converting different T RAFT_KERNEL TestFromOtherKernelConst(device_span<float const, 16> span) { // don't get optimized out size_t idx = threadIdx.x + blockIdx.x * blockDim.x; if (idx >= span.size()) { return; } } /*! * \brief Here we just test whether the code compiles. */ TEST(GPUSpan, FromOther) { thrust::host_vector<float> h_vec(16); std::iota(h_vec.begin(), h_vec.end(), 0); thrust::device_vector<float> d_vec(h_vec.size()); thrust::copy(h_vec.begin(), h_vec.end(), d_vec.begin()); // dynamic extent { device_span<float> span(d_vec.data().get(), d_vec.size()); TestFromOtherKernel<<<1, 16>>>(span); } { device_span<float> span(d_vec.data().get(), d_vec.size()); TestFromOtherKernelConst<<<1, 16>>>(span); } // static extent { device_span<float, 16> span(d_vec.data().get(), d_vec.data().get() + 16); TestFromOtherKernel<<<1, 16>>>(span); } { device_span<float, 16> span(d_vec.data().get(), d_vec.data().get() + 16); TestFromOtherKernelConst<<<1, 16>>>(span); } } TEST(GPUSpan, Assignment) { TestStatus status; thrust::for_each_n( thrust::make_counting_iterator(0ul), 16, test_assignment_t<true>{status.Data()}); ASSERT_EQ(status.Get(), 1); } TEST(GPUSpan, TestStatus) { TestStatus status; thrust::for_each_n(thrust::make_counting_iterator(0ul), 16, test_test_status_t{status.Data()}); ASSERT_EQ(status.Get(), -1); } template <typename T> struct TestEqual { private: T *lhs_, *rhs_; int* status_; public: TestEqual(T* _lhs, T* _rhs, int* _status) : lhs_(_lhs), rhs_(_rhs), status_(_status) {} HD void operator()(size_t _idx) { bool res = lhs_[_idx] == rhs_[_idx]; SPAN_ASSERT_TRUE(res, status_); } }; TEST(GPUSpan, WithTrust) { // Not advised to initialize span with host_vector, since h_vec.data() is // a host function. thrust::host_vector<float> h_vec(16); std::iota(h_vec.begin(), h_vec.end(), 0); thrust::device_vector<float> d_vec(h_vec.size()); thrust::copy(h_vec.begin(), h_vec.end(), d_vec.begin()); // Can't initialize span with device_vector, since d_vec.data() is not raw // pointer { device_span<float> s(d_vec.data().get(), d_vec.size()); ASSERT_EQ(d_vec.size(), s.size()); ASSERT_EQ(d_vec.data().get(), s.data()); } { TestStatus status; thrust::device_vector<float> d_vec1(d_vec.size()); thrust::copy(thrust::device, d_vec.begin(), d_vec.end(), d_vec1.begin()); device_span<float> s(d_vec1.data().get(), d_vec.size()); thrust::for_each_n( thrust::make_counting_iterator(0ul), 16, TestEqual<float>{thrust::raw_pointer_cast(d_vec1.data()), s.data(), status.Data()}); ASSERT_EQ(status.Get(), 1); } } TEST(GPUSpan, BeginEnd) { TestStatus status; thrust::for_each_n(thrust::make_counting_iterator(0ul), 16, test_beginend_t<true>{status.Data()}); ASSERT_EQ(status.Get(), 1); } TEST(GPUSpan, RBeginREnd) { TestStatus status; thrust::for_each_n( thrust::make_counting_iterator(0ul), 16, test_rbeginrend_t<true>{status.Data()}); ASSERT_EQ(status.Get(), 1); } RAFT_KERNEL TestModifyKernel(device_span<float> span) { size_t idx = threadIdx.x + blockIdx.x * blockDim.x; if (idx >= span.size()) { return; } span[idx] = span.size() - idx; } TEST(GPUSpan, Modify) { thrust::host_vector<float> h_vec(16); std::iota(h_vec.begin(), h_vec.end(), 0); thrust::device_vector<float> d_vec(h_vec.size()); thrust::copy(h_vec.begin(), h_vec.end(), d_vec.begin()); device_span<float> span(d_vec.data().get(), d_vec.size()); TestModifyKernel<<<1, 16>>>(span); for (size_t i = 0; i < d_vec.size(); ++i) { ASSERT_EQ(d_vec[i], d_vec.size() - i); } } TEST(GPUSpan, Observers) { TestStatus status; thrust::for_each_n( thrust::make_counting_iterator(0ul), 16, test_observers_t<true>{status.Data()}); ASSERT_EQ(status.Get(), 1); } TEST(GPUSpan, Compare) { TestStatus status; thrust::for_each_n(thrust::make_counting_iterator(0), 1, test_compare_t<false>{status.Data()}); ASSERT_EQ(status.Get(), 1); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/math_device.cu
/* * 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. */ #include <gtest/gtest.h> #include "../test_utils.h" #include <raft/core/math.hpp> #include <rmm/cuda_stream.hpp> #include <rmm/device_scalar.hpp> #include <cuda/std/type_traits> #ifdef _RAFT_HAS_CUDA #include <cuda_bf16.h> #include <cuda_fp16.h> #endif template <typename OutT, typename OpT, typename... Args> RAFT_KERNEL math_eval_kernel(OutT* out, OpT op, Args... args) { out[0] = op(std::forward<Args>(args)...); } template <typename OpT, typename... Args> auto math_eval(OpT op, Args&&... args) { using OutT = cuda::std::invoke_result_t<OpT, Args...>; auto stream = rmm::cuda_stream_default; rmm::device_scalar<OutT> result(stream); math_eval_kernel<<<1, 1, 0, stream>>>(result.data(), op, std::forward<Args>(args)...); return result.value(stream); } struct abs_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::abs(in); } }; TEST(MathDevice, Abs) { // Integer abs ASSERT_TRUE( raft::match(int8_t{123}, math_eval(abs_test_op{}, int8_t{-123}), raft::Compare<int8_t>())); ASSERT_TRUE(raft::match(12345, math_eval(abs_test_op{}, -12345), raft::Compare<int>())); ASSERT_TRUE(raft::match(12345l, math_eval(abs_test_op{}, -12345l), raft::Compare<long int>())); ASSERT_TRUE(raft::match(123451234512345ll, math_eval(abs_test_op{}, -123451234512345ll), raft::Compare<long long int>())); // Floating-point abs ASSERT_TRUE( raft::match(12.34f, math_eval(abs_test_op{}, -12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE( raft::match(12.34, math_eval(abs_test_op{}, -12.34), raft::CompareApprox<double>(0.000001))); } struct acos_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::acos(in); } }; TEST(MathDevice, Acos) { ASSERT_TRUE(raft::match( std::acos(0.123f), math_eval(acos_test_op{}, 0.123f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match( std::acos(0.123), math_eval(acos_test_op{}, 0.123), raft::CompareApprox<double>(0.000001))); } struct asin_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::asin(in); } }; TEST(MathDevice, Asin) { ASSERT_TRUE(raft::match( std::asin(0.123f), math_eval(asin_test_op{}, 0.123f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match( std::asin(0.123), math_eval(asin_test_op{}, 0.123), raft::CompareApprox<double>(0.000001))); } struct atanh_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::atanh(in); } }; TEST(MathDevice, Atanh) { ASSERT_TRUE(raft::match( std::atanh(0.123f), math_eval(atanh_test_op{}, 0.123f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match( std::atanh(0.123), math_eval(atanh_test_op{}, 0.123), raft::CompareApprox<double>(0.000001))); } struct cos_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::cos(in); } }; struct cos_test_op_device { template <typename Type> constexpr RAFT_DEVICE_INLINE_FUNCTION auto operator()(const Type& in) const { #if (__CUDA_ARCH__ < 530) if constexpr (std::is_same_v<Type, __half>) { return __float2half(raft::cos(__half2float(in))); } #elif (__CUDA_ARCH__ < 800) if constexpr (std::is_same_v<Type, nv_bfloat16>) { return __float2bfloat16(raft::cos(__bfloat162float(in))); } else // else is there to make sure raft::cos(in) is not compiled with __half / nv_bfloat16 #endif return raft::cos(in); } }; TEST(MathDevice, Cos) { ASSERT_TRUE(raft::match(std::cos(12.34f), __half2float(math_eval(cos_test_op_device{}, __float2half(12.34f))), raft::CompareApprox<float>(0.001f))); ASSERT_TRUE( raft::match(std::cos(12.34f), __bfloat162float(math_eval(cos_test_op_device{}, __float2bfloat16(12.34f))), raft::CompareApprox<float>(0.01f))); ASSERT_TRUE(raft::match( std::cos(12.34f), math_eval(cos_test_op{}, 12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match( std::cos(12.34), math_eval(cos_test_op{}, 12.34), raft::CompareApprox<double>(0.000001))); } struct exp_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::exp(in); } }; struct exp_test_op_device { template <typename Type> constexpr RAFT_DEVICE_INLINE_FUNCTION auto operator()(const Type& in) const { #if (__CUDA_ARCH__ < 530) if constexpr (std::is_same_v<Type, __half>) { return __float2half(raft::exp(__half2float(in))); } #elif (__CUDA_ARCH__ < 800) if constexpr (std::is_same_v<Type, nv_bfloat16>) { return __float2bfloat16(raft::exp(__bfloat162float(in))); } else // else is there to make sure raft::exp(in) is not compiled with __half / nv_bfloat16 #endif return raft::exp(in); } }; TEST(MathDevice, Exp) { ASSERT_TRUE(raft::match(std::exp(3.4f), __half2float(math_eval(exp_test_op_device{}, __float2half(3.4f))), raft::CompareApprox<float>(0.001f))); ASSERT_TRUE(raft::match(std::exp(3.4f), __bfloat162float(math_eval(exp_test_op_device{}, __float2bfloat16(3.4f))), raft::CompareApprox<float>(0.01f))); ASSERT_TRUE(raft::match( std::exp(3.4f), math_eval(exp_test_op{}, 3.4f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match( std::exp(3.4), math_eval(exp_test_op{}, 3.4), raft::CompareApprox<double>(0.000001))); } struct log_test_op_device { template <typename Type> constexpr RAFT_DEVICE_INLINE_FUNCTION auto operator()(const Type& in) const { #if (__CUDA_ARCH__ < 530) if constexpr (std::is_same_v<Type, __half>) { return __float2half(raft::log(__half2float(in))); } #elif (__CUDA_ARCH__ < 800) if constexpr (std::is_same_v<Type, nv_bfloat16>) { return __float2bfloat16(raft::log(__bfloat162float(in))); } else // else is there to make sure raft::log(in) is not compiled with __half / nv_bfloat16 #endif return raft::log(in); } }; struct log_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::log(in); } }; TEST(MathDevice, Log) { ASSERT_TRUE(raft::match(std::log(12.34f), __half2float(math_eval(log_test_op_device{}, __float2half(12.34f))), raft::CompareApprox<float>(0.001f))); ASSERT_TRUE( raft::match(std::log(12.34f), __bfloat162float(math_eval(log_test_op_device{}, __float2bfloat16(12.34f))), raft::CompareApprox<float>(0.01f))); ASSERT_TRUE(raft::match( std::log(12.34f), math_eval(log_test_op{}, 12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match( std::log(12.34), math_eval(log_test_op{}, 12.34), raft::CompareApprox<double>(0.000001))); } struct max_test_op { template <typename... Args> constexpr RAFT_INLINE_FUNCTION auto operator()(Args&&... args) const { return raft::max(std::forward<Args>(args)...); } }; TEST(MathDevice, Max2) { ASSERT_TRUE(raft::match(1234, math_eval(max_test_op{}, -1234, 1234), raft::Compare<int>())); ASSERT_TRUE( raft::match(1234u, math_eval(max_test_op{}, 1234u, 123u), raft::Compare<unsigned int>())); ASSERT_TRUE( raft::match(1234ll, math_eval(max_test_op{}, -1234ll, 1234ll), raft::Compare<long long int>())); ASSERT_TRUE(raft::match( 1234ull, math_eval(max_test_op{}, 1234ull, 123ull), raft::Compare<unsigned long long int>())); ASSERT_TRUE( raft::match(12.34f, math_eval(max_test_op{}, -12.34f, 12.34f), raft::Compare<float>())); ASSERT_TRUE(raft::match(12.34, math_eval(max_test_op{}, -12.34, 12.34), raft::Compare<double>())); ASSERT_TRUE(raft::match( 12.34, math_eval(max_test_op{}, -12.34f, 12.34), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE(raft::match( 12.34, math_eval(max_test_op{}, -12.34, 12.34f), raft::CompareApprox<double>(0.000001))); } TEST(MathDevice, Max3) { ASSERT_TRUE(raft::match(1234, math_eval(max_test_op{}, 1234, 0, -1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(1234, math_eval(max_test_op{}, -1234, 1234, 0), raft::Compare<int>())); ASSERT_TRUE(raft::match(1234, math_eval(max_test_op{}, 0, -1234, 1234), raft::Compare<int>())); ASSERT_TRUE(raft::match( 12.34, math_eval(max_test_op{}, 12.34f, 0., -12.34), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE(raft::match( 12.34, math_eval(max_test_op{}, -12.34, 12.34f, 0.), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE(raft::match( 12.34, math_eval(max_test_op{}, 0., -12.34, 12.34f), raft::CompareApprox<double>(0.000001))); } struct min_test_op { template <typename... Args> constexpr RAFT_INLINE_FUNCTION auto operator()(Args&&... args) const { return raft::min(std::forward<Args>(args)...); } }; TEST(MathDevice, Min2) { ASSERT_TRUE(raft::match(-1234, math_eval(min_test_op{}, -1234, 1234), raft::Compare<int>())); ASSERT_TRUE( raft::match(123u, math_eval(min_test_op{}, 1234u, 123u), raft::Compare<unsigned int>())); ASSERT_TRUE(raft::match( -1234ll, math_eval(min_test_op{}, -1234ll, 1234ll), raft::Compare<long long int>())); ASSERT_TRUE(raft::match( 123ull, math_eval(min_test_op{}, 1234ull, 123ull), raft::Compare<unsigned long long int>())); ASSERT_TRUE( raft::match(-12.34f, math_eval(min_test_op{}, -12.34f, 12.34f), raft::Compare<float>())); ASSERT_TRUE( raft::match(-12.34, math_eval(min_test_op{}, -12.34, 12.34), raft::Compare<double>())); ASSERT_TRUE(raft::match( -12.34, math_eval(min_test_op{}, -12.34f, 12.34), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE(raft::match( -12.34, math_eval(min_test_op{}, -12.34, 12.34f), raft::CompareApprox<double>(0.000001))); } TEST(MathDevice, Min3) { ASSERT_TRUE(raft::match(-1234, math_eval(min_test_op{}, 1234, 0, -1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(-1234, math_eval(min_test_op{}, -1234, 1234, 0), raft::Compare<int>())); ASSERT_TRUE(raft::match(-1234, math_eval(min_test_op{}, 0, -1234, 1234), raft::Compare<int>())); ASSERT_TRUE(raft::match( -12.34, math_eval(min_test_op{}, 12.34f, 0., -12.34), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE(raft::match( -12.34, math_eval(min_test_op{}, -12.34, 12.34f, 0.), raft::CompareApprox<double>(0.000001))); ASSERT_TRUE(raft::match( -12.34, math_eval(min_test_op{}, 0., -12.34, 12.34f), raft::CompareApprox<double>(0.000001))); } struct pow_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& x, const Type& y) const { return raft::pow(x, y); } }; TEST(MathDevice, Pow) { ASSERT_TRUE(raft::match(std::pow(12.34f, 2.f), math_eval(pow_test_op{}, 12.34f, 2.f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match(std::pow(12.34, 2.), math_eval(pow_test_op{}, 12.34, 2.), raft::CompareApprox<double>(0.000001))); } struct sgn_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::sgn(in); } }; TEST(MathDevice, Sgn) { ASSERT_TRUE(raft::match(-1, math_eval(sgn_test_op{}, -1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(0, math_eval(sgn_test_op{}, 0), raft::Compare<int>())); ASSERT_TRUE(raft::match(1, math_eval(sgn_test_op{}, 1234), raft::Compare<int>())); ASSERT_TRUE(raft::match(-1, math_eval(sgn_test_op{}, -12.34f), raft::Compare<int>())); ASSERT_TRUE(raft::match(0, math_eval(sgn_test_op{}, 0.f), raft::Compare<int>())); ASSERT_TRUE(raft::match(1, math_eval(sgn_test_op{}, 12.34f), raft::Compare<int>())); } struct sin_test_op_device { template <typename Type> constexpr RAFT_DEVICE_INLINE_FUNCTION auto operator()(const Type& in) const { #if (__CUDA_ARCH__ < 530) if constexpr (std::is_same_v<Type, __half>) { return __float2half(raft::sin(__half2float(in))); } #elif (__CUDA_ARCH__ < 800) if constexpr (std::is_same_v<Type, nv_bfloat16>) { return __float2bfloat16(raft::sin(__bfloat162float(in))); } else // else is there to make sure raft::sin(in) is not compiled with __half / nv_bfloat16 #endif return raft::sin(in); } }; struct sin_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::sin(in); } }; TEST(MathDevice, Sin) { ASSERT_TRUE(raft::match(std::sin(12.34f), __half2float(math_eval(sin_test_op_device{}, __float2half(12.34f))), raft::CompareApprox<float>(0.01f))); ASSERT_TRUE( raft::match(std::sin(12.34f), __bfloat162float(math_eval(sin_test_op_device{}, __float2bfloat16(12.34f))), raft::CompareApprox<float>(0.1f))); ASSERT_TRUE(raft::match( std::sin(12.34f), math_eval(sin_test_op{}, 12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match( std::sin(12.34), math_eval(sin_test_op{}, 12.34), raft::CompareApprox<double>(0.000001))); } struct sincos_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& x, Type* s, Type* c) const { raft::sincos(x, s, c); return x; // unused, just to avoid creating another helper } }; TEST(MathDevice, SinCos) { auto stream = rmm::cuda_stream_default; float xf = 12.34f; rmm::device_scalar<float> sf(stream); rmm::device_scalar<float> cf(stream); math_eval(sincos_test_op{}, xf, sf.data(), cf.data()); ASSERT_TRUE(raft::match(std::sin(12.34f), sf.value(stream), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match(std::cos(12.34f), cf.value(stream), raft::CompareApprox<float>(0.0001f))); double xd = 12.34f; rmm::device_scalar<double> sd(stream); rmm::device_scalar<double> cd(stream); math_eval(sincos_test_op{}, xd, sd.data(), cd.data()); ASSERT_TRUE(raft::match(std::sin(12.34), sd.value(stream), raft::CompareApprox<double>(0.0001f))); ASSERT_TRUE(raft::match(std::cos(12.34), cd.value(stream), raft::CompareApprox<double>(0.0001f))); } struct sqrt_test_op_device { template <typename Type> constexpr RAFT_DEVICE_INLINE_FUNCTION auto operator()(const Type& in) const { #if (__CUDA_ARCH__ < 530) if constexpr (std::is_same_v<Type, __half>) { return __float2half(raft::sqrt(__half2float(in))); } #elif (__CUDA_ARCH__ < 800) if constexpr (std::is_same_v<Type, nv_bfloat16>) { return __float2bfloat16(raft::sqrt(__bfloat162float(in))); } else // else is there to make sure raft::sqrt(in) is not compiled with __half / nv_bfloat16 #endif return raft::sqrt(in); } }; struct sqrt_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::sqrt(in); } }; TEST(MathDevice, Sqrt) { ASSERT_TRUE(raft::match(std::sqrt(12.34f), __half2float(math_eval(sqrt_test_op_device{}, __float2half(12.34f))), raft::CompareApprox<float>(0.001f))); ASSERT_TRUE( raft::match(std::sqrt(12.34f), __bfloat162float(math_eval(sqrt_test_op_device{}, __float2bfloat16(12.34f))), raft::CompareApprox<float>(0.01f))); ASSERT_TRUE(raft::match( std::sqrt(12.34f), math_eval(sqrt_test_op{}, 12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match( std::sqrt(12.34), math_eval(sqrt_test_op{}, 12.34), raft::CompareApprox<double>(0.000001))); } struct tanh_test_op { template <typename Type> constexpr RAFT_INLINE_FUNCTION auto operator()(const Type& in) const { return raft::tanh(in); } }; TEST(MathDevice, Tanh) { ASSERT_TRUE(raft::match( std::tanh(12.34f), math_eval(tanh_test_op{}, 12.34f), raft::CompareApprox<float>(0.0001f))); ASSERT_TRUE(raft::match( std::tanh(12.34), math_eval(tanh_test_op{}, 12.34), raft::CompareApprox<double>(0.000001))); }
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/device_resources_manager.cpp
/* * 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. */ #include <array> #include <cuda_runtime_api.h> #include <gtest/gtest.h> #include <mutex> #include <omp.h> #include <raft/core/device_resources_manager.hpp> #include <raft/core/device_setter.hpp> #include <raft/core/logger.hpp> #include <rmm/mr/device/cuda_memory_resource.hpp> #include <rmm/mr/device/limiting_resource_adaptor.hpp> #include <rmm/mr/device/per_device_resource.hpp> #include <rmm/mr/device/pool_memory_resource.hpp> #include <set> namespace raft { auto get_test_device_ids() { auto devices = std::array<int, 2>{int{}, int{}}; auto device_count = 0; RAFT_CUDA_TRY(cudaGetDeviceCount(&device_count)); devices[1] = int{device_count > 1}; return devices; } TEST(DeviceResourcesManager, ObeysSetters) { auto devices = get_test_device_ids(); auto streams_per_device = 3; auto pools_per_device = 3; auto streams_per_pool = 7; auto workspace_limit = 2048; auto workspace_init = 1024; device_resources_manager::set_streams_per_device(streams_per_device); device_resources_manager::set_stream_pools_per_device(pools_per_device, streams_per_pool); device_resources_manager::set_mem_pool(); device_resources_manager::set_workspace_allocation_limit(workspace_limit); auto unique_streams = std::array<std::set<cudaStream_t>, 2>{}; auto unique_pools = std::array<std::set<rmm::cuda_stream_pool const*>, 2>{}; // Provide lock for counting unique objects auto mtx = std::mutex{}; auto workspace_mrs = std::array<std::shared_ptr<rmm::mr::pool_memory_resource<rmm::mr::cuda_memory_resource>>, 2>{ nullptr, nullptr}; auto alternate_workspace_mrs = std::array<std::shared_ptr<rmm::mr::cuda_memory_resource>, 2>{}; auto upstream_mrs = std::array<rmm::mr::cuda_memory_resource*, 2>{ dynamic_cast<rmm::mr::cuda_memory_resource*>( rmm::mr::get_per_device_resource(rmm::cuda_device_id{devices[0]})), dynamic_cast<rmm::mr::cuda_memory_resource*>( rmm::mr::get_per_device_resource(rmm::cuda_device_id{devices[1]}))}; for (auto i = std::size_t{}; i < devices.size(); ++i) { auto scoped_device = device_setter{devices[i]}; if (upstream_mrs[i] == nullptr) { RAFT_LOG_WARN( "RMM memory resource already set. Tests for device_resources_manger will be incomplete."); } else { workspace_mrs[i] = std::make_shared<rmm::mr::pool_memory_resource<rmm::mr::cuda_memory_resource>>( upstream_mrs[i], workspace_init, workspace_limit); alternate_workspace_mrs[i] = std::make_shared<rmm::mr::cuda_memory_resource>(); } } device_resources_manager::set_workspace_memory_resource(workspace_mrs[0], devices[0]); device_resources_manager::set_workspace_memory_resource(workspace_mrs[1], devices[1]); // Suppress the many warnings from testing use of setters after initial // get_device_resources call auto scoped_log_level = log_level_setter{RAFT_LEVEL_ERROR}; omp_set_dynamic(0); #pragma omp parallel for num_threads(5) for (auto i = std::size_t{}; i < 101; ++i) { thread_local auto prev_streams = std::array<std::optional<cudaStream_t>, 2>{}; auto device = devices[i % devices.size()]; auto const& res = device_resources_manager::get_device_resources(device); auto primary_stream = res.get_stream().value(); prev_streams[device] = prev_streams[device].value_or(primary_stream); // Expect to receive the same stream every time for a given thread EXPECT_EQ(*prev_streams[device], primary_stream); // Using RAII device setter here to avoid changing device in other tests // that depend on a specific device to be set auto scoped_device = device_setter{device}; auto const& res2 = device_resources_manager::get_device_resources(); // Expect device_resources to default to current device EXPECT_EQ(primary_stream, res2.get_stream().value()); auto const& pool = res.get_stream_pool(); EXPECT_EQ(streams_per_pool, pool.get_pool_size()); auto* mr = dynamic_cast<rmm::mr::pool_memory_resource<rmm::mr::cuda_memory_resource>*>( rmm::mr::get_current_device_resource()); auto* workspace_mr = dynamic_cast<rmm::mr::pool_memory_resource<rmm::mr::cuda_memory_resource>*>( dynamic_cast<rmm::mr::limiting_resource_adaptor<rmm::mr::device_memory_resource>*>( res.get_workspace_resource()) ->get_upstream()); if (upstream_mrs[i % devices.size()] != nullptr) { // Expect that the current memory resource is a pool memory resource as requested EXPECT_NE(mr, nullptr); // Expect that the upstream workspace memory resource is a pool memory // resource as requested EXPECT_NE(workspace_mr, nullptr); } { auto lock = std::unique_lock{mtx}; unique_streams[device].insert(primary_stream); unique_pools[device].insert(&pool); } // Ensure that setters have no effect after get_device_resources call device_resources_manager::set_streams_per_device(streams_per_device + 1); device_resources_manager::set_stream_pools_per_device(pools_per_device - 1); device_resources_manager::set_mem_pool(); device_resources_manager::set_workspace_allocation_limit(1024); device_resources_manager::set_workspace_memory_resource( alternate_workspace_mrs[i % devices.size()], devices[i % devices.size()]); } EXPECT_EQ(streams_per_device, unique_streams[devices[0]].size()); EXPECT_EQ(streams_per_device, unique_streams[devices[1]].size()); EXPECT_EQ(pools_per_device, unique_pools[devices[0]].size()); EXPECT_EQ(pools_per_device, unique_pools[devices[1]].size()); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/sparse_matrix.cu
/* * 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 * * 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. */ #include <gtest/gtest.h> #include <raft/core/device_coo_matrix.hpp> #include <raft/core/device_csr_matrix.hpp> #include <raft/core/resources.hpp> #include <type_traits> namespace raft { /** * Example of accepting a value-owning matrix type which doesn't need to adjust sparsity */ template <typename S, typename = std::enable_if_t<is_device_csr_matrix_v<S>>> void test_device_csr_owning_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a csr_matrix which also owns structure and can initialize sparsity */ template <typename S, typename = std::enable_if_t<is_device_csr_sparsity_owning_v<S>>> void test_device_csr_sparsity_owning_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a csr_matrix which does not own the structure */ template <typename S, typename = std::enable_if_t<is_device_csr_sparsity_preserving_v<S>>> void test_device_csr_sparsity_preserving_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a value-owning matrix type which doesn't need to adjust sparsity */ template <typename S, typename = std::enable_if_t<is_device_coo_matrix_v<S>>> void test_device_coo_owning_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a coo_matrix which also owns structure and can initialize sparsity */ template <typename S, typename = std::enable_if_t<is_device_coo_sparsity_owning_v<S>>> void test_device_coo_sparsity_owning_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a coo_matrix which does not own the structure */ template <typename S, typename = std::enable_if_t<is_device_coo_sparsity_preserving_v<S>>> void test_device_coo_sparsity_preserving_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } void test_device_coo_matrix() { raft::resources handle; auto sparsity_owning = raft::make_device_coo_matrix<float, int, int, int>(handle, 5, 5); auto structure_view = sparsity_owning.structure_view(); ASSERT_EQ(structure_view.get_n_cols(), 5); ASSERT_EQ(structure_view.get_n_rows(), 5); ASSERT_EQ(structure_view.get_nnz(), 0); auto coord_struct = raft::make_device_coordinate_structure(handle, 5, 5, 5); auto sparsity_preserving = raft::make_device_coo_matrix<float, int, int>(handle, coord_struct.view()); sparsity_owning.initialize_sparsity(5); auto structure_view2 = sparsity_owning.structure_view(); ASSERT_EQ(structure_view2.get_n_cols(), 5); ASSERT_EQ(structure_view2.get_n_rows(), 5); ASSERT_EQ(structure_view2.get_nnz(), 5); void* d_owning = static_cast<void*>(sparsity_owning.get_elements().data()); void* d_preserving = static_cast<void*>(sparsity_preserving.get_elements().data()); test_device_coo_owning_ref(sparsity_owning, d_owning); test_device_coo_owning_ref(sparsity_preserving, d_preserving); test_device_coo_sparsity_owning_ref(sparsity_owning, d_owning); test_device_coo_sparsity_preserving_ref(sparsity_preserving, d_preserving); } void test_device_csr_matrix() { raft::resources handle; auto sparsity_owning = raft::make_device_csr_matrix<float, int, int, int>(handle, 5, 5); auto comp_struct = raft::make_device_compressed_structure(handle, 5, 5, 5); auto sparsity_preserving = raft::make_device_csr_matrix<float, int, int>(handle, comp_struct.view()); auto structure_view = sparsity_owning.structure_view(); ASSERT_EQ(structure_view.get_n_cols(), 5); ASSERT_EQ(structure_view.get_n_rows(), 5); ASSERT_EQ(structure_view.get_nnz(), 0); sparsity_owning.initialize_sparsity(5); auto structure_view2 = sparsity_owning.structure_view(); ASSERT_EQ(structure_view2.get_n_cols(), 5); ASSERT_EQ(structure_view2.get_n_rows(), 5); ASSERT_EQ(structure_view2.get_nnz(), 5); void* d_owning = static_cast<void*>(sparsity_owning.get_elements().data()); void* d_preserving = static_cast<void*>(sparsity_preserving.get_elements().data()); test_device_csr_owning_ref(sparsity_owning, d_owning); test_device_csr_owning_ref(sparsity_preserving, d_preserving); test_device_csr_sparsity_owning_ref(sparsity_owning, d_owning); test_device_csr_sparsity_preserving_ref(sparsity_preserving, d_preserving); } TEST(DeviceSparseCOOMatrix, Basic) { test_device_coo_matrix(); } TEST(DeviceSparseCSRMatrix, Basic) { test_device_csr_matrix(); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/temporary_device_buffer.cu
/* * 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 * * 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. */ #include "../test_utils.cuh" #include <raft/core/resource/cuda_stream.hpp> #include <raft/core/host_mdarray.hpp> #include <raft/core/resources.hpp> #include <raft/core/temporary_device_buffer.hpp> #include <rmm/device_uvector.hpp> #include <gtest/gtest.h> namespace raft { TEST(TemporaryDeviceBuffer, DevicePointer) { { raft::resources handle; auto exts = raft::make_extents<int>(5); auto array = raft::make_device_mdarray<int, int>(handle, exts); auto d_buf = raft::make_temporary_device_buffer(handle, array.data_handle(), exts); ASSERT_EQ(array.data_handle(), d_buf.view().data_handle()); static_assert(!std::is_const_v<typename decltype(d_buf.view())::element_type>, "element_type should not be const"); } { raft::resources handle; auto exts = raft::make_extents<int>(5); auto array = raft::make_device_mdarray<int, int>(handle, exts); auto d_buf = raft::make_readonly_temporary_device_buffer(handle, array.data_handle(), exts); ASSERT_EQ(array.data_handle(), d_buf.view().data_handle()); static_assert(std::is_const_v<typename decltype(d_buf.view())::element_type>, "element_type should be const"); } } TEST(TemporaryDeviceBuffer, HostPointerWithWriteBack) { raft::resources handle; auto exts = raft::make_extents<int>(5); auto array = raft::make_host_mdarray<int, int>(exts); thrust::fill(array.data_handle(), array.data_handle() + array.extent(0), 1); rmm::device_uvector<int> result(5, resource::get_cuda_stream(handle)); { auto d_buf = raft::make_writeback_temporary_device_buffer(handle, array.data_handle(), exts); auto d_view = d_buf.view(); thrust::fill(rmm::exec_policy(resource::get_cuda_stream(handle)), d_view.data_handle(), d_view.data_handle() + d_view.extent(0), 10); raft::copy( result.data(), d_view.data_handle(), d_view.extent(0), resource::get_cuda_stream(handle)); static_assert(!std::is_const_v<typename decltype(d_buf.view())::element_type>, "element_type should not be const"); } ASSERT_TRUE(raft::devArrMatchHost(array.data_handle(), result.data(), array.extent(0), raft::Compare<int>(), resource::get_cuda_stream(handle))); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/sparse_matrix.cpp
/* * 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 * * 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. */ #include <gtest/gtest.h> #include <raft/core/host_coo_matrix.hpp> #include <raft/core/host_csr_matrix.hpp> #include <raft/core/resources.hpp> #include <type_traits> namespace raft { /** * Example of accepting a value-owning matrix type which doesn't need to adjust sparsity */ template <typename S, typename = std::enable_if_t<is_host_csr_matrix_v<S>>> void test_host_csr_owning_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a csr_matrix which also owns structure and can initialize sparsity */ template <typename S, typename = std::enable_if_t<is_host_csr_sparsity_owning_v<S>>> void test_host_csr_sparsity_owning_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a csr_matrix which does not own the structure */ template <typename S, typename = std::enable_if_t<is_host_csr_sparsity_preserving_v<S>>> void test_host_csr_sparsity_preserving_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a value-owning matrix type which doesn't need to adjust sparsity */ template <typename S, typename = std::enable_if_t<is_host_coo_matrix_v<S>>> void test_host_coo_owning_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a coo_matrix which also owns structure and can initialize sparsity */ template <typename S, typename = std::enable_if_t<is_host_coo_sparsity_owning_v<S>>> void test_host_coo_sparsity_owning_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } /** * Example of accepting a coo_matrix which does not own the structure */ template <typename S, typename = std::enable_if_t<is_host_coo_sparsity_preserving_v<S>>> void test_host_coo_sparsity_preserving_ref(S& mat, void* d) { ASSERT_EQ(static_cast<void*>(mat.get_elements().data()), d); } void test_host_coo_matrix() { raft::resources handle; auto sparsity_owning = raft::make_host_coo_matrix<float, int, int, int>(handle, 5, 5); auto structure_view = sparsity_owning.structure_view(); ASSERT_EQ(structure_view.get_n_cols(), 5); ASSERT_EQ(structure_view.get_n_rows(), 5); ASSERT_EQ(structure_view.get_nnz(), 0); auto coord_struct = raft::make_host_coordinate_structure(handle, 5, 5, 5); auto sparsity_preserving = raft::make_host_coo_matrix<float, int, int>(handle, coord_struct.view()); sparsity_owning.initialize_sparsity(5); auto structure_view2 = sparsity_owning.structure_view(); ASSERT_EQ(structure_view2.get_n_cols(), 5); ASSERT_EQ(structure_view2.get_n_rows(), 5); ASSERT_EQ(structure_view2.get_nnz(), 5); void* d_owning = static_cast<void*>(sparsity_owning.get_elements().data()); void* d_preserving = static_cast<void*>(sparsity_preserving.get_elements().data()); test_host_coo_owning_ref(sparsity_owning, d_owning); test_host_coo_owning_ref(sparsity_preserving, d_preserving); test_host_coo_sparsity_owning_ref(sparsity_owning, d_owning); test_host_coo_sparsity_preserving_ref(sparsity_preserving, d_preserving); } void test_host_csr_matrix() { raft::resources handle; auto sparsity_owning = raft::make_host_csr_matrix<float, int, int, int>(handle, 5, 5); auto comp_struct = raft::make_host_compressed_structure(handle, 5, 5, 5); auto sparsity_preserving = raft::make_host_csr_matrix<float, int, int>(handle, comp_struct.view()); auto structure_view = sparsity_owning.structure_view(); ASSERT_EQ(structure_view.get_n_cols(), 5); ASSERT_EQ(structure_view.get_n_rows(), 5); ASSERT_EQ(structure_view.get_nnz(), 0); sparsity_owning.initialize_sparsity(5); auto structure_view2 = sparsity_owning.structure_view(); ASSERT_EQ(structure_view2.get_n_cols(), 5); ASSERT_EQ(structure_view2.get_n_rows(), 5); ASSERT_EQ(structure_view2.get_nnz(), 5); void* d_owning = static_cast<void*>(sparsity_owning.get_elements().data()); void* d_preserving = static_cast<void*>(sparsity_preserving.get_elements().data()); test_host_csr_owning_ref(sparsity_owning, d_owning); test_host_csr_owning_ref(sparsity_preserving, d_preserving); test_host_csr_sparsity_owning_ref(sparsity_owning, d_owning); test_host_csr_sparsity_preserving_ref(sparsity_preserving, d_preserving); } TEST(HostSparseCOOMatrix, Basic) { test_host_coo_matrix(); } TEST(HostSparseCSRMatrix, Basic) { test_host_csr_matrix(); } } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/mdspan_copy.cpp
/* * 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. */ #include "../test_utils.h" #include <cstdint> #include <gtest/gtest.h> #include <raft/core/copy.hpp> #ifndef RAFT_DISABLE_CUDA #include <raft/core/device_mdarray.hpp> #include <raft/core/device_resources.hpp> #endif #include <raft/core/host_mdarray.hpp> #include <raft/core/resources.hpp> namespace raft { TEST(MDSpanCopy, Mdspan1DHostHost) { auto res = resources{}; auto cols = std::uint32_t{2}; auto in_left = make_host_vector<float, std::uint32_t, layout_c_contiguous>(res, cols); auto gen_unique_entry = [](auto&& x) { return x; }; for (auto i = std::uint32_t{}; i < cols; ++i) { in_left(i) = gen_unique_entry(i); } auto out_right = make_host_vector<double, std::uint32_t, layout_f_contiguous>(res, cols); static_assert(detail::mdspan_copyable<true, decltype(out_right.view()), decltype(in_left.view())>::can_use_std_copy, "Current implementation should use std::copy for this copy"); copy(res, out_right.view(), in_left.view()); for (auto i = std::uint32_t{}; i < cols; ++i) { ASSERT_TRUE(match(out_right(i), double(gen_unique_entry(i)), CompareApprox<double>{0.0001})); } } #ifndef RAFT_DISABLE_CUDA TEST(MDSpanCopy, Mdspan1DHostDevice) { auto res = device_resources{}; auto cols = std::uint32_t{2}; auto in_left = make_host_vector<float, std::uint32_t, layout_c_contiguous>(res, cols); auto gen_unique_entry = [](auto&& x) { return x; }; for (auto i = std::uint32_t{}; i < cols; ++i) { in_left(i) = gen_unique_entry(i); } auto out_right = make_device_vector<float, std::uint32_t, layout_f_contiguous>(res, cols); static_assert(detail::mdspan_copyable<true, decltype(out_right.view()), decltype(in_left.view())>::can_use_raft_copy, "Current implementation should use raft::copy for this copy"); copy(res, out_right.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < cols; ++i) { ASSERT_TRUE( match(float(out_right(i)), float(gen_unique_entry(i)), CompareApprox<float>{0.0001f})); } } TEST(MDSpanCopy, Mdspan1DDeviceHost) { auto res = device_resources{}; auto cols = std::uint32_t{2}; auto in_left = make_device_vector<float, std::uint32_t, layout_c_contiguous>(res, cols); auto gen_unique_entry = [](auto&& x) { return x; }; for (auto i = std::uint32_t{}; i < cols; ++i) { in_left(i) = gen_unique_entry(i); } auto out_right = make_host_vector<float, std::uint32_t, layout_f_contiguous>(res, cols); static_assert(detail::mdspan_copyable<true, decltype(out_right.view()), decltype(in_left.view())>::can_use_raft_copy, "Current implementation should use raft::copy for this copy"); copy(res, out_right.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < cols; ++i) { ASSERT_TRUE( match(float(out_right(i)), float(gen_unique_entry(i)), CompareApprox<float>{0.0001f})); } } #endif TEST(MDSpanCopy, Mdspan3DHostHost) { auto res = resources{}; auto constexpr depth = std::uint32_t{500}; auto constexpr rows = std::uint32_t{300}; auto constexpr cols = std::uint32_t{200}; auto in_left = make_host_mdarray<float, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto in_right = make_host_mdarray<float, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto gen_unique_entry = [](auto&& x, auto&& y, auto&& z) { return x * 7 + y * 11 + z * 13; }; for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { in_left(i, j, k) = gen_unique_entry(i, j, k); in_right(i, j, k) = gen_unique_entry(i, j, k); } } } auto out_left = make_host_mdarray<double, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto out_right = make_host_mdarray<double, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); static_assert(detail::mdspan_copyable<true, decltype(out_right.view()), decltype(in_right.view())>::can_use_std_copy, "Current implementation should use std::copy for this copy"); copy(res, out_right.view(), in_right.view()); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_TRUE(match( out_right(i, j, k), double(gen_unique_entry(i, j, k)), CompareApprox<double>{0.0001})); } } } copy(res, out_right.view(), in_left.view()); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_TRUE(match( out_right(i, j, k), double(gen_unique_entry(i, j, k)), CompareApprox<double>{0.0001})); } } } copy(res, out_left.view(), in_right.view()); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_TRUE(match( out_left(i, j, k), double(gen_unique_entry(i, j, k)), CompareApprox<double>{0.0001})); } } } static_assert(detail::mdspan_copyable<true, decltype(out_left.view()), decltype(in_left.view())>:: can_use_std_copy, "Current implementation should use std::copy for this copy"); copy(res, out_left.view(), in_left.view()); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_TRUE(match( out_left(i, j, k), double(gen_unique_entry(i, j, k)), CompareApprox<double>{0.0001})); } } } } #ifndef RAFT_DISABLE_CUDA TEST(MDSpanCopy, Mdspan3DHostDevice) { auto res = device_resources{}; // Use smaller values here since host/device copy takes awhile. // Non-trivial logic is tested in the other cases. auto constexpr depth = std::uint32_t{5}; auto constexpr rows = std::uint32_t{3}; auto constexpr cols = std::uint32_t{2}; auto in_left = make_host_mdarray<float, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto in_right = make_host_mdarray<float, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto gen_unique_entry = [](auto&& x, auto&& y, auto&& z) { return x * 7 + y * 11 + z * 13; }; for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { in_left(i, j, k) = gen_unique_entry(i, j, k); in_right(i, j, k) = gen_unique_entry(i, j, k); } } } auto out_left = make_device_mdarray<float, std::uint32_t, layout_c_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); auto out_right = make_device_mdarray<float, std::uint32_t, layout_f_contiguous, depth, rows, cols>( res, extents<std::uint32_t, depth, rows, cols>{}); static_assert(detail::mdspan_copyable<true, decltype(out_right.view()), decltype(in_right.view())>::can_use_raft_copy, "Current implementation should use raft::copy for this copy"); copy(res, out_right.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_TRUE(match(float(out_right(i, j, k)), float(gen_unique_entry(i, j, k)), CompareApprox<float>{0.0001})); } } } static_assert(detail::mdspan_copyable<true, decltype(out_left.view()), decltype(in_left.view())>:: can_use_raft_copy, "Current implementation should use raft::copy for this copy"); copy(res, out_left.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < depth; ++i) { for (auto j = std::uint32_t{}; j < rows; ++j) { for (auto k = std::uint32_t{}; k < cols; ++k) { ASSERT_TRUE(match(float(out_left(i, j, k)), float(gen_unique_entry(i, j, k)), CompareApprox<float>{0.0001})); } } } } TEST(MDSpanCopy, Mdspan2DDeviceDevice) { auto res = device_resources{}; auto constexpr rows = std::uint32_t{300}; auto constexpr cols = std::uint32_t{200}; auto in_left = make_device_mdarray<float, std::uint32_t, layout_c_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto in_right = make_device_mdarray<float, std::uint32_t, layout_f_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto gen_unique_entry = [](auto&& x, auto&& y) { return x * 7 + y * 11; }; for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { in_left(i, j) = gen_unique_entry(i, j); in_right(i, j) = gen_unique_entry(i, j); } } auto out_left = make_device_mdarray<float, std::uint32_t, layout_c_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); auto out_right = make_device_mdarray<float, std::uint32_t, layout_f_contiguous, rows, cols>( res, extents<std::uint32_t, rows, cols>{}); static_assert(detail::mdspan_copyable<true, decltype(out_right.view()), decltype(in_right.view())>::can_use_raft_copy, "Current implementation should use raft::copy for this copy"); copy(res, out_right.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE( match(float(out_right(i, j)), float(gen_unique_entry(i, j)), CompareApprox<float>{0.0001})); } } static_assert(detail::mdspan_copyable<true, decltype(out_right.view()), decltype(in_left.view())>::can_use_cublas, "Current implementation should use cuBLAS for this copy"); copy(res, out_right.view(), in_left.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE( match(float(out_right(i, j)), float(gen_unique_entry(i, j)), CompareApprox<float>{0.0001})); } } static_assert(detail::mdspan_copyable<true, decltype(out_left.view()), decltype(in_right.view())>::can_use_cublas, "Current implementation should use cuBLAS for this copy"); copy(res, out_left.view(), in_right.view()); res.sync_stream(); for (auto i = std::uint32_t{}; i < rows; ++i) { for (auto j = std::uint32_t{}; j < cols; ++j) { ASSERT_TRUE( match(float(out_left(i, j)), float(gen_unique_entry(i, j)), CompareApprox<float>{0.0001})); } } } #endif } // namespace raft
0
rapidsai_public_repos/raft/cpp/test
rapidsai_public_repos/raft/cpp/test/core/seive.cu
/* * Copyright (c) 2019-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. */ #include <gtest/gtest.h> #include <raft/util/seive.hpp> namespace raft { namespace common { TEST(Seive, Test) { Seive s1(32); ASSERT_TRUE(s1.isPrime(17)); ASSERT_FALSE(s1.isPrime(28)); Seive s2(1024 * 1024); ASSERT_TRUE(s2.isPrime(107)); ASSERT_FALSE(s2.isPrime(111)); ASSERT_TRUE(s2.isPrime(6047)); } } // end namespace common } // end namespace raft
0