Skip to content

Commit

Permalink
Add support to __half and nv_bfloat16 to most math functions (#1554)
Browse files Browse the repository at this point in the history
This PR adds support to __half and nb_bfloat16 to most math functions:

- cos
- sin
- exp
- log
- max
- min
- sqrt

Authors:
  - Nicolas Blin (https://github.com/Kh4ster)
  - Corey J. Nolet (https://github.com/cjnolet)

Approvers:
  - Louis Sugy (https://github.com/Nyrio)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #1554
  • Loading branch information
Kh4ster authored Jun 2, 2023
1 parent cfe27ec commit 6bc237f
Show file tree
Hide file tree
Showing 4 changed files with 430 additions and 11 deletions.
8 changes: 6 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ target_link_libraries(raft::raft INTERFACE
# Use `rapids_export` for 22.04 as it will have COMPONENT support
rapids_export(
INSTALL raft
EXPORT_SET raft-exports COMPONENTS ${raft_components} COMPONENTS_EXPORT_SET ${raft_export_sets}
EXPORT_SET raft-exports
COMPONENTS ${raft_components}
COMPONENTS_EXPORT_SET ${raft_export_sets}
GLOBAL_TARGETS raft compiled distributed
NAMESPACE raft::
DOCUMENTATION doc_string
Expand All @@ -613,7 +615,9 @@ rapids_export(
# * build export -------------------------------------------------------------
rapids_export(
BUILD raft
EXPORT_SET raft-exports COMPONENTS ${raft_components} COMPONENTS_EXPORT_SET ${raft_export_sets}
EXPORT_SET raft-exports
COMPONENTS ${raft_components}
COMPONENTS_EXPORT_SET ${raft_export_sets}
GLOBAL_TARGETS raft compiled distributed
DOCUMENTATION doc_string
NAMESPACE raft::
Expand Down
12 changes: 12 additions & 0 deletions cpp/include/raft/core/detail/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
#endif
#endif

#if defined(_RAFT_HAS_CUDA)
#define CUDA_CONDITION_ELSE_TRUE(condition) condition
#define CUDA_CONDITION_ELSE_FALSE(condition) condition
#else
#define CUDA_CONDITION_ELSE_TRUE(condition) true
#define CUDA_CONDITION_ELSE_FALSE(condition) false
#endif

#ifndef _RAFT_HOST_DEVICE
#if defined(_RAFT_HAS_CUDA)
#define _RAFT_DEVICE __device__
Expand All @@ -40,6 +48,10 @@
#define RAFT_INLINE_FUNCTION _RAFT_HOST_DEVICE _RAFT_FORCEINLINE
#endif

#ifndef RAFT_DEVICE_INLINE_FUNCTION
#define RAFT_DEVICE_INLINE_FUNCTION _RAFT_DEVICE _RAFT_FORCEINLINE
#endif

// The RAFT_INLINE_CONDITIONAL is a conditional inline specifier that removes
// the inline specification when RAFT_COMPILED is defined.
//
Expand Down
Loading

0 comments on commit 6bc237f

Please sign in to comment.