2021-07-25 09:55:31 +00:00
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
F i n d C U D A T o o l k i t
- - - - - - - - - - - - - - -
. . v e r s i o n a d d e d : : 3 . 1 7
T h i s s c r i p t l o c a t e s t h e N V I D I A C U D A t o o l k i t a n d t h e a s s o c i a t e d l i b r a r i e s , b u t
d o e s n o t r e q u i r e t h e ` ` C U D A ` ` l a n g u a g e b e e n a b l e d f o r a g i v e n p r o j e c t . T h i s
m o d u l e d o e s n o t s e a r c h f o r t h e N V I D I A C U D A S a m p l e s .
. . v e r s i o n a d d e d : : 3 . 1 9
Q N X s u p p o r t .
S e a r c h B e h a v i o r
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
T h e C U D A T o o l k i t s e a r c h b e h a v i o r u s e s t h e f o l l o w i n g o r d e r :
1 . I f t h e ` ` C U D A ` ` l a n g u a g e h a s b e e n e n a b l e d w e w i l l u s e t h e d i r e c t o r y
c o n t a i n i n g t h e c o m p i l e r a s t h e f i r s t s e a r c h l o c a t i o n f o r ` ` n v c c ` ` .
2 . I f t h e ` ` C U D A T o o l k i t _ R O O T ` ` c m a k e c o n f i g u r a t i o n variable ( e.g.,
` ` - D C U D A T o o l k i t _ R O O T = / s o m e / p a t h ` ` ) * o r * e n v i r o n m e n t v a r i a b l e i s d e f i n e d , i t
w i l l b e s e a r c h e d . I f b o t h a n e n v i r o n m e n t v a r i a b l e * * a n d * * a
c o n f i g u r a t i o n v a r i a b l e a r e s p e c i f i e d , t h e * c o n f i g u r a t i o n * v a r i a b l e t a k e s
p r e c e d e n c e .
T h e d i r e c t o r y s p e c i f i e d h e r e m u s t b e s u c h t h a t t h e e x e c u t a b l e ` ` n v c c ` ` o r
t h e a p p r o p r i a t e ` ` v e r s i o n . t x t ` ` f i l e c a n b e f o u n d u n d e r n e a t h t h e s p e c i f i e d
d i r e c t o r y .
3 . I f t h e C U D A _ P A T H e n v i r o n m e n t v a r i a b l e i s d e f i n e d , i t w i l l b e s e a r c h e d
f o r ` ` n v c c ` ` .
4 . T h e u s e r ' s p a t h i s s e a r c h e d f o r ` ` n v c c ` ` u s i n g : c o m m a n d : ` f i n d _ p r o g r a m ` . I f
t h i s i s f o u n d , n o s u b s e q u e n t s e a r c h a t t e m p t s a r e p e r f o r m e d . U s e r s a r e
r e s p o n s i b l e f o r e n s u r i n g t h a t t h e f i r s t ` ` n v c c ` ` t o s h o w u p i n t h e p a t h i s
t h e d e s i r e d p a t h i n t h e e v e n t t h a t m u l t i p l e C U D A T o o l k i t s a r e i n s t a l l e d .
5 . O n U n i x s y s t e m s , i f t h e s y m b o l i c l i n k ` ` / u s r / l o c a l / c u d a ` ` e x i s t s , t h i s i s
u s e d . N o s u b s e q u e n t s e a r c h a t t e m p t s a r e p e r f o r m e d . N o d e f a u l t s y m b o l i c l i n k
l o c a t i o n e x i s t s f o r t h e W i n d o w s p l a t f o r m .
6 . T h e p l a t f o r m s p e c i f i c d e f a u l t i n s t a l l l o c a t i o n s a r e s e a r c h e d . I f e x a c t l y o n e
c a n d i d a t e i s f o u n d , t h i s i s u s e d . T h e d e f a u l t C U D A T o o l k i t i n s t a l l l o c a t i o n s
s e a r c h e d a r e :
+ - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| P l a t f o r m | S e a r c h P a t t e r n |
+ = = = = = = = = = = = = = + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = +
| m a c O S | ` ` / D e v e l o p e r / N V I D I A / C U D A - X . Y ` ` |
+ - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| O t h e r U n i x | ` ` / u s r / l o c a l / c u d a - X . Y ` ` |
+ - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| W i n d o w s | ` ` C : \ P r o g r a m F i l e s \ N V I D I A G P U C o m p u t i n g T o o l k i t \ C U D A \ v X . Y ` ` |
+ - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
W h e r e ` ` X . Y ` ` w o u l d b e a s p e c i f i c v e r s i o n o f t h e C U D A T o o l k i t , s u c h a s
` ` / u s r / l o c a l / c u d a - 9 . 0 ` ` o r
` ` C : \ P r o g r a m F i l e s \ N V I D I A G P U C o m p u t i n g T o o l k i t \ C U D A \ v 9 . 0 ` `
. . n o t e : :
W h e n m u l t i p l e C U D A T o o l k i t s a r e i n s t a l l e d i n t h e d e f a u l t l o c a t i o n o f a
system ( e.g., both ``/usr/local/cuda-9.0`` and ``/usr/local/cuda-10.0``
e x i s t b u t t h e ` ` / u s r / l o c a l / c u d a ` ` s y m b o l i c l i n k d o e s * * n o t * * e x i s t ) , t h i s
p a c k a g e i s m a r k e d a s * * n o t * * f o u n d .
T h e r e a r e t o o m a n y f a c t o r s i n v o l v e d i n m a k i n g a n a u t o m a t i c d e c i s i o n i n
t h e p r e s e n c e o f m u l t i p l e C U D A T o o l k i t s b e i n g i n s t a l l e d . I n t h i s
s i t u a t i o n , u s e r s a r e e n c o u r a g e d t o either ( 1 ) s e t ` ` C U D A T o o l k i t _ R O O T ` ` o r
( 2 ) e n s u r e t h a t t h e c o r r e c t ` ` n v c c ` ` e x e c u t a b l e s h o w s u p i n ` ` $ P A T H ` ` f o r
: c o m m a n d : ` f i n d _ p r o g r a m ` t o f i n d .
A r g u m e n t s
^ ^ ^ ^ ^ ^ ^ ^ ^
` ` [ < v e r s i o n > ] ` `
T h e ` ` [ < v e r s i o n > ] ` ` a r g u m e n t r e q u e s t s a v e r s i o n w i t h w h i c h t h e p a c k a g e f o u n d
s h o u l d b e c o m p a t i b l e . S e e : r e f : ` f i n d _ p a c k a g e v e r s i o n f o r m a t < F I N D _ P A C K A G E _ V E R S I O N _ F O R M A T > `
f o r m o r e d e t a i l s .
O p t i o n s
^ ^ ^ ^ ^ ^ ^
` ` R E Q U I R E D ` `
I f s p e c i f i e d , c o n f i g u r a t i o n w i l l e r r o r i f a s u i t a b l e C U D A T o o l k i t i s n o t
f o u n d .
` ` Q U I E T ` `
I f s p e c i f i e d , t h e s e a r c h f o r a s u i t a b l e C U D A T o o l k i t w i l l n o t p r o d u c e a n y
m e s s a g e s .
` ` E X A C T ` `
I f s p e c i f i e d , t h e C U D A T o o l k i t i s c o n s i d e r e d f o u n d o n l y i f t h e e x a c t
` ` V E R S I O N ` ` s p e c i f i e d i s r e c o v e r e d .
I m p o r t e d t a r g e t s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
A n : r e f : ` i m p o r t e d t a r g e t < I m p o r t e d t a r g e t s > ` n a m e d ` ` C U D A : : t o o l k i t ` ` i s p r o v i d e d .
T h i s m o d u l e d e f i n e s : p r o p _ t g t : ` I M P O R T E D ` t a r g e t s f o r e a c h
o f t h e f o l l o w i n g l i b r a r i e s t h a t a r e p a r t o f t h e C U D A T o o l k i t :
- : r e f : ` C U D A R u n t i m e L i b r a r y < c u d a _ t o o l k i t _ r t _ l i b > `
- : r e f : ` C U D A D r i v e r L i b r a r y < c u d a _ t o o l k i t _ d r i v e r _ l i b > `
- : r e f : ` c u B L A S < c u d a _ t o o l k i t _ c u B L A S > `
2023-01-10 14:42:48 +00:00
- : r e f : ` c u F i l e < c u d a _ t o o l k i t _ c u F i l e > `
2021-07-25 09:55:31 +00:00
- : r e f : ` c u F F T < c u d a _ t o o l k i t _ c u F F T > `
- : r e f : ` c u R A N D < c u d a _ t o o l k i t _ c u R A N D > `
- : r e f : ` c u S O L V E R < c u d a _ t o o l k i t _ c u S O L V E R > `
- : r e f : ` c u S P A R S E < c u d a _ t o o l k i t _ c u S P A R S E > `
- : r e f : ` c u P T I < c u d a _ t o o l k i t _ c u p t i > `
- : r e f : ` N P P < c u d a _ t o o l k i t _ N P P > `
- : r e f : ` n v B L A S < c u d a _ t o o l k i t _ n v B L A S > `
- : r e f : ` n v G R A P H < c u d a _ t o o l k i t _ n v G R A P H > `
- : r e f : ` n v J P E G < c u d a _ t o o l k i t _ n v J P E G > `
- : r e f : ` n v i d i a - M L < c u d a _ t o o l k i t _ n v M L > `
2023-01-10 14:42:48 +00:00
- : r e f : ` n v P T X C o m p i l e r < c u d a _ t o o l k i t _ n v p t x > `
2021-07-25 09:55:31 +00:00
- : r e f : ` n v R T C < c u d a _ t o o l k i t _ n v R T C > `
- : r e f : ` n v T o o l s E x t < c u d a _ t o o l k i t _ n v T o o l s E x t > `
2023-01-10 14:42:48 +00:00
- : r e f : ` n v t x 3 < c u d a _ t o o l k i t _ n v t x 3 > `
2021-07-25 09:55:31 +00:00
- : r e f : ` O p e n C L < c u d a _ t o o l k i t _ o p e n c l > `
- : r e f : ` c u L I B O S < c u d a _ t o o l k i t _ c u L I B O S > `
. . _ ` c u d a _ t o o l k i t _ r t _ l i b ` :
C U D A R u n t i m e L i b r a r y
" " " " " " " " " " " " " " " " " " " "
T h e C U D A R u n t i m e library ( cudart ) a r e w h a t m o s t a p p l i c a t i o n s w i l l t y p i c a l l y
n e e d t o l i n k a g a i n s t t o m a k e a n y c a l l s s u c h a s ` c u d a M a l l o c ` , a n d ` c u d a F r e e ` .
T a r g e t s C r e a t e d :
- ` ` C U D A : : c u d a r t ` `
- ` ` C U D A : : c u d a r t _ s t a t i c ` `
. . _ ` c u d a _ t o o l k i t _ d r i v e r _ l i b ` :
C U D A D r i v e r L i b r a r y
" " " " " " " " " " " " " " " " " " " "
T h e C U D A D r i v e r library ( cuda ) a r e u s e d b y a p p l i c a t i o n s t h a t u s e c a l l s
2023-01-10 14:42:48 +00:00
s u c h a s ` c u M e m A l l o c ` , a n d ` c u M e m F r e e ` .
2021-07-25 09:55:31 +00:00
T a r g e t s C r e a t e d :
- ` ` C U D A : : c u d a _ d r i v e r ` `
. . _ ` c u d a _ t o o l k i t _ c u B L A S ` :
c u B L A S
" " " " " "
T h e ` c u B L A S < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / c u b l a s / i n d e x . h t m l > ` _ l i b r a r y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : c u b l a s ` `
- ` ` C U D A : : c u b l a s _ s t a t i c ` `
- ` ` C U D A : : c u b l a s L t ` ` s t a r t i n g i n C U D A 1 0 . 1
- ` ` C U D A : : c u b l a s L t _ s t a t i c ` ` s t a r t i n g i n C U D A 1 0 . 1
2023-01-10 14:42:48 +00:00
. . _ ` c u d a _ t o o l k i t _ c u F i l e ` :
c u F i l e
" " " " " "
. . v e r s i o n a d d e d : : 3 . 2 5
T h e N V I D I A G P U D i r e c t S t o r a g e ` c u F i l e < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / c u f i l e - a p i / i n d e x . h t m l > ` _ l i b r a r y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : c u F i l e ` ` s t a r t i n g i n C U D A 1 1 . 4
- ` ` C U D A : : c u F i l e _ s t a t i c ` ` s t a r t i n g i n C U D A 1 1 . 4
- ` ` C U D A : : c u F i l e _ r d m a ` ` s t a r t i n g i n C U D A 1 1 . 4
- ` ` C U D A : : c u F i l e _ r d m a _ s t a t i c ` ` s t a r t i n g i n C U D A 1 1 . 4
2021-07-25 09:55:31 +00:00
. . _ ` c u d a _ t o o l k i t _ c u F F T ` :
c u F F T
" " " " "
T h e ` c u F F T < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / c u f f t / i n d e x . h t m l > ` _ l i b r a r y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : c u f f t ` `
- ` ` C U D A : : c u f f t w ` `
- ` ` C U D A : : c u f f t _ s t a t i c ` `
2023-01-10 14:42:48 +00:00
- ` ` C U D A : : c u f f t _ s t a t i c _ n o c a l l b a c k ` ` s t a r t i n g i n C U D A 9 . 2 , r e q u i r e s C M a k e 3 . 2 3 +
2021-07-25 09:55:31 +00:00
- ` ` C U D A : : c u f f t w _ s t a t i c ` `
c u R A N D
" " " " " "
T h e ` c u R A N D < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / c u r a n d / i n d e x . h t m l > ` _ l i b r a r y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : c u r a n d ` `
- ` ` C U D A : : c u r a n d _ s t a t i c ` `
. . _ ` c u d a _ t o o l k i t _ c u S O L V E R ` :
c u S O L V E R
" " " " " " " "
T h e ` c u S O L V E R < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / c u s o l v e r / i n d e x . h t m l > ` _ l i b r a r y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : c u s o l v e r ` `
- ` ` C U D A : : c u s o l v e r _ s t a t i c ` `
. . _ ` c u d a _ t o o l k i t _ c u S P A R S E ` :
c u S P A R S E
" " " " " " " "
T h e ` c u S P A R S E < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / c u s p a r s e / i n d e x . h t m l > ` _ l i b r a r y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : c u s p a r s e ` `
- ` ` C U D A : : c u s p a r s e _ s t a t i c ` `
. . _ ` c u d a _ t o o l k i t _ c u p t i ` :
c u p t i
" " " " "
T h e ` N V I D I A C U D A P r o f i l i n g T o o l s I n t e r f a c e < h t t p s : / / d e v e l o p e r . n v i d i a . c o m / C U P T I > ` _ .
T a r g e t s C r e a t e d :
- ` ` C U D A : : c u p t i ` `
- ` ` C U D A : : c u p t i _ s t a t i c ` `
. . _ ` c u d a _ t o o l k i t _ N P P ` :
N P P
" " "
T h e ` N P P < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / n p p / i n d e x . h t m l > ` _ l i b r a r i e s .
T a r g e t s C r e a t e d :
- ` n p p c ` :
- ` ` C U D A : : n p p c ` `
- ` ` C U D A : : n p p c _ s t a t i c ` `
- ` n p p i a l ` : A r i t h m e t i c a n d l o g i c a l o p e r a t i o n f u n c t i o n s i n ` n p p i _ a r i t h m e t i c _ a n d _ l o g i c a l _ o p e r a t i o n s . h `
- ` ` C U D A : : n p p i a l ` `
- ` ` C U D A : : n p p i a l _ s t a t i c ` `
- ` n p p i c c ` : C o l o r c o n v e r s i o n a n d s a m p l i n g f u n c t i o n s i n ` n p p i _ c o l o r _ c o n v e r s i o n . h `
- ` ` C U D A : : n p p i c c ` `
- ` ` C U D A : : n p p i c c _ s t a t i c ` `
- ` n p p i c o m ` : J P E G c o m p r e s s i o n a n d d e c o m p r e s s i o n f u n c t i o n s i n ` n p p i _ c o m p r e s s i o n _ f u n c t i o n s . h `
R e m o v e d s t a r t i n g i n C U D A 1 1 . 0 , u s e : r e f : ` n v J P E G < c u d a _ t o o l k i t _ n v J P E G > ` i n s t e a d .
- ` ` C U D A : : n p p i c o m ` `
- ` ` C U D A : : n p p i c o m _ s t a t i c ` `
- ` n p p i d e i ` : D a t a e x c h a n g e a n d i n i t i a l i z a t i o n f u n c t i o n s i n ` n p p i _ d a t a _ e x c h a n g e _ a n d _ i n i t i a l i z a t i o n . h `
- ` ` C U D A : : n p p i d e i ` `
- ` ` C U D A : : n p p i d e i _ s t a t i c ` `
- ` n p p i f ` : F i l t e r i n g a n d c o m p u t e r v i s i o n f u n c t i o n s i n ` n p p i _ f i l t e r _ f u n c t i o n s . h `
- ` ` C U D A : : n p p i f ` `
- ` ` C U D A : : n p p i f _ s t a t i c ` `
- ` n p p i g ` : G e o m e t r y t r a n s f o r m a t i o n f u n c t i o n s f o u n d i n ` n p p i _ g e o m e t r y _ t r a n s f o r m s . h `
- ` ` C U D A : : n p p i g ` `
- ` ` C U D A : : n p p i g _ s t a t i c ` `
- ` n p p i m ` : M o r p h o l o g i c a l o p e r a t i o n f u n c t i o n s f o u n d i n ` n p p i _ m o r p h o l o g i c a l _ o p e r a t i o n s . h `
- ` ` C U D A : : n p p i m ` `
- ` ` C U D A : : n p p i m _ s t a t i c ` `
- ` n p p i s t ` : S t a t i s t i c s a n d l i n e a r t r a n s f o r m i n ` n p p i _ s t a t i s t i c s _ f u n c t i o n s . h ` a n d ` n p p i _ l i n e a r _ t r a n s f o r m s . h `
- ` ` C U D A : : n p p i s t ` `
- ` ` C U D A : : n p p i s t _ s t a t i c ` `
- ` n p p i s u ` : M e m o r y s u p p o r t f u n c t i o n s i n ` n p p i _ s u p p o r t _ f u n c t i o n s . h `
- ` ` C U D A : : n p p i s u ` `
- ` ` C U D A : : n p p i s u _ s t a t i c ` `
- ` n p p i t c ` : T h r e s h o l d a n d c o m p a r e o p e r a t i o n f u n c t i o n s i n ` n p p i _ t h r e s h o l d _ a n d _ c o m p a r e _ o p e r a t i o n s . h `
- ` ` C U D A : : n p p i t c ` `
- ` ` C U D A : : n p p i t c _ s t a t i c ` `
- ` n p p s ` :
- ` ` C U D A : : n p p s ` `
- ` ` C U D A : : n p p s _ s t a t i c ` `
. . _ ` c u d a _ t o o l k i t _ n v B L A S ` :
n v B L A S
" " " " " "
T h e ` n v B L A S < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / n v b l a s / i n d e x . h t m l > ` _ l i b r a r i e s .
T h i s i s a s h a r e d l i b r a r y o n l y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : n v b l a s ` `
. . _ ` c u d a _ t o o l k i t _ n v G R A P H ` :
n v G R A P H
" " " " " " "
T h e ` n v G R A P H < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / n v g r a p h / i n d e x . h t m l > ` _ l i b r a r y .
R e m o v e d s t a r t i n g i n C U D A 1 1 . 0
T a r g e t s C r e a t e d :
- ` ` C U D A : : n v g r a p h ` `
- ` ` C U D A : : n v g r a p h _ s t a t i c ` `
. . _ ` c u d a _ t o o l k i t _ n v J P E G ` :
n v J P E G
" " " " " "
T h e ` n v J P E G < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / n v j p e g / i n d e x . h t m l > ` _ l i b r a r y .
I n t r o d u c e d i n C U D A 1 0 .
T a r g e t s C r e a t e d :
- ` ` C U D A : : n v j p e g ` `
- ` ` C U D A : : n v j p e g _ s t a t i c ` `
2023-01-10 14:42:48 +00:00
. . _ ` c u d a _ t o o l k i t _ n v P T X ` :
n v P T X C o m p i l e r
" " " " " " " " " " " " " "
. . v e r s i o n a d d e d : : 3 . 2 5
T h e ` n v P T X < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / p t x - c o m p i l e r - a p i / i n d e x . h t m l > ` _ ( PTX Compilation ) l i b r a r y .
T h e P T X C o m p i l e r A P I s a r e a s e t o f A P I s w h i c h c a n b e u s e d t o c o m p i l e a P T X p r o g r a m i n t o G P U a s s e m b l y c o d e .
I n t r o d u c e d i n C U D A 1 1 . 1
T h i s i s a s t a t i c l i b r a r y o n l y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : n v p t x c o m p i l e r _ s t a t i c ` ` s t a r t i n g i n C U D A 1 1 . 1
2021-07-25 09:55:31 +00:00
. . _ ` c u d a _ t o o l k i t _ n v R T C ` :
n v R T C
" " " " "
T h e ` n v R T C < h t t p s : / / d o c s . n v i d i a . c o m / c u d a / n v r t c / i n d e x . h t m l > ` _ ( Runtime Compilation ) l i b r a r y .
T h i s i s a s h a r e d l i b r a r y o n l y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : n v r t c ` `
. . _ ` c u d a _ t o o l k i t _ n v m l ` :
n v i d i a - M L
" " " " " " " " "
T h e ` N V I D I A M a n a g e m e n t L i b r a r y < h t t p s : / / d e v e l o p e r . n v i d i a . c o m / n v i d i a - m a n a g e m e n t - l i b r a r y - n v m l > ` _ .
T h i s i s a s h a r e d l i b r a r y o n l y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : n v m l ` `
. . _ ` c u d a _ t o o l k i t _ n v T o o l s E x t ` :
n v T o o l s E x t
" " " " " " " " " "
2023-01-10 14:42:48 +00:00
. . d e p r e c a t e d : : 3 . 2 5 W i t h C U D A 1 0 . 0 + , u s e : r e f : ` n v t x 3 < c u d a _ t o o l k i t _ n v t x 3 > ` .
2021-07-25 09:55:31 +00:00
T h e ` N V I D I A T o o l s E x t e n s i o n < h t t p s : / / d o c s . n v i d i a . c o m / g a m e w o r k s / c o n t e n t / g a m e w o r k s l i b r a r y / n v t x / n v i d i a _ t o o l s _ e x t e n s i o n _ l i b r a r y _ n v t x . h t m > ` _ .
T h i s i s a s h a r e d l i b r a r y o n l y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : n v T o o l s E x t ` `
2023-01-10 14:42:48 +00:00
. . _ ` c u d a _ t o o l k i t _ n v t x 3 ` :
n v t x 3
" " " " "
. . v e r s i o n a d d e d : : 3 . 2 5
T h e h e a d e r - o n l y ` N V I D I A T o o l s E x t e n s i o n L i b r a r y < h t t p s : / / n v i d i a . g i t h u b . i o / N V T X / d o x y g e n / i n d e x . h t m l > ` _ .
I n t r o d u c e d i n C U D A 1 0 . 0 .
T a r g e t s c r e a t e d :
- ` ` C U D A : : n v t x 3 ` `
2021-07-25 09:55:31 +00:00
. . _ ` c u d a _ t o o l k i t _ o p e n c l ` :
O p e n C L
" " " " " "
T h e ` N V I D I A O p e n C L L i b r a r y < h t t p s : / / d e v e l o p e r . n v i d i a . c o m / o p e n c l > ` _ .
T h i s i s a s h a r e d l i b r a r y o n l y .
T a r g e t s C r e a t e d :
- ` ` C U D A : : O p e n C L ` `
. . _ ` c u d a _ t o o l k i t _ c u L I B O S ` :
c u L I B O S
" " " " " " "
T h e c u L I B O S l i b r a r y i s a b a c k e n d t h r e a d a b s t r a c t i o n l a y e r l i b r a r y w h i c h i s
s t a t i c o n l y . T h e ` ` C U D A : : c u b l a s _ s t a t i c ` ` , ` ` C U D A : : c u s p a r s e _ s t a t i c ` ` ,
` ` C U D A : : c u f f t _ s t a t i c ` ` , ` ` C U D A : : c u r a n d _ s t a t i c ` ` , and ( when implemented ) N P P
l i b r a r i e s a l l a u t o m a t i c a l l y h a v e t h i s d e p e n d e n c y l i n k e d .
T a r g e t C r e a t e d :
- ` ` C U D A : : c u l i b o s ` `
* * N o t e * * : d i r e c t u s a g e o f t h i s t a r g e t b y c o n s u m e r s s h o u l d n o t b e n e c e s s a r y .
. . _ ` c u d a _ t o o l k i t _ c u R A N D ` :
R e s u l t v a r i a b l e s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
` ` C U D A T o o l k i t _ F O U N D ` `
A b o o l e a n s p e c i f y i n g w h e t h e r o r n o t t h e C U D A T o o l k i t w a s f o u n d .
` ` C U D A T o o l k i t _ V E R S I O N ` `
T h e e x a c t v e r s i o n o f t h e C U D A T o o l k i t found ( as reported by
` ` n v c c - - v e r s i o n ` ` o r ` ` v e r s i o n . t x t ` ` ) .
` ` C U D A T o o l k i t _ V E R S I O N _ M A J O R ` `
T h e m a j o r v e r s i o n o f t h e C U D A T o o l k i t .
` ` C U D A T o o l k i t _ V E R S I O N _ M I N O R ` `
T h e m i n o r v e r s i o n o f t h e C U D A T o o l k i t .
` ` C U D A T o o l k i t _ V E R S I O N _ P A T C H ` `
T h e p a t c h v e r s i o n o f t h e C U D A T o o l k i t .
` ` C U D A T o o l k i t _ B I N _ D I R ` `
T h e p a t h t o t h e C U D A T o o l k i t l i b r a r y d i r e c t o r y t h a t c o n t a i n s t h e C U D A
e x e c u t a b l e ` ` n v c c ` ` .
` ` C U D A T o o l k i t _ I N C L U D E _ D I R S ` `
T h e p a t h t o t h e C U D A T o o l k i t ` ` i n c l u d e ` ` f o l d e r c o n t a i n i n g t h e h e a d e r f i l e s
r e q u i r e d t o c o m p i l e a p r o j e c t l i n k i n g a g a i n s t C U D A .
` ` C U D A T o o l k i t _ L I B R A R Y _ D I R ` `
T h e p a t h t o t h e C U D A T o o l k i t l i b r a r y d i r e c t o r y t h a t c o n t a i n s t h e C U D A
R u n t i m e l i b r a r y ` ` c u d a r t ` ` .
` ` C U D A T o o l k i t _ L I B R A R Y _ R O O T ` `
. . v e r s i o n a d d e d : : 3 . 1 8
T h e p a t h t o t h e C U D A T o o l k i t d i r e c t o r y c o n t a i n i n g t h e n v v m d i r e c t o r y a n d
v e r s i o n . t x t .
` ` C U D A T o o l k i t _ T A R G E T _ D I R ` `
T h e p a t h t o t h e C U D A T o o l k i t d i r e c t o r y i n c l u d i n g t h e t a r g e t a r c h i t e c t u r e
w h e n c r o s s - c o m p i l i n g . W h e n n o t c r o s s - c o m p i l i n g t h i s w i l l b e e q u i v a l e n t t o
t h e p a r e n t d i r e c t o r y o f ` ` C U D A T o o l k i t _ B I N _ D I R ` ` .
` ` C U D A T o o l k i t _ N V C C _ E X E C U T A B L E ` `
T h e p a t h t o t h e N V I D I A C U D A c o m p i l e r ` ` n v c c ` ` . N o t e t h a t t h i s p a t h m a y
* * n o t * * b e t h e s a m e a s
: v a r i a b l e : ` C M A K E _ C U D A _ C O M P I L E R < C M A K E _ < L A N G > _ C O M P I L E R > ` . ` ` n v c c ` ` m u s t b e
f o u n d t o d e t e r m i n e t h e C U D A T o o l k i t v e r s i o n a s w e l l a s d e t e r m i n i n g o t h e r
f e a t u r e s o f t h e T o o l k i t . T h i s v a r i a b l e i s s e t f o r t h e c o n v e n i e n c e o f
m o d u l e s t h a t d e p e n d o n t h i s o n e .
#]=======================================================================]
# NOTE: much of this was simply extracted from FindCUDA.cmake.
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
#
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
#
# Copyright (c) 2007-2009
# Scientific Computing and Imaging Institute, University of Utah
#
# This code is licensed under the MIT License. See the FindCUDA.cmake script
# for the text of the license.
# The MIT License
#
# License for the specific language governing rights and limitations under
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
###############################################################################
# The toolkit is located during compiler detection for CUDA and stored in CMakeCUDACompiler.cmake as
# CMAKE_CUDA_COMPILER_TOOLKIT_ROOT and CMAKE_CUDA_COMPILER_LIBRARY_ROOT.
# We compute the rest based on those here to avoid re-searching and to avoid finding a possibly
# different installation.
if ( CMAKE_CUDA_COMPILER_TOOLKIT_ROOT )
set ( CUDAToolkit_ROOT_DIR "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}" )
set ( CUDAToolkit_LIBRARY_ROOT "${CMAKE_CUDA_COMPILER_LIBRARY_ROOT}" )
set ( CUDAToolkit_BIN_DIR "${CUDAToolkit_ROOT_DIR}/bin" )
set ( CUDAToolkit_NVCC_EXECUTABLE "${CUDAToolkit_BIN_DIR}/nvcc${CMAKE_EXECUTABLE_SUFFIX}" )
2023-01-10 14:42:48 +00:00
set ( CUDAToolkit_VERSION "${CMAKE_CUDA_COMPILER_TOOLKIT_VERSION}" )
2021-07-25 09:55:31 +00:00
2023-01-10 14:42:48 +00:00
if ( CUDAToolkit_VERSION MATCHES [=[([0-9]+ ) \ . ( [ 0 - 9 ] + ) \ . ( [ 0 - 9 ] + ) ] = ] )
set ( CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}" )
set ( CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}" )
set ( CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}" )
endif ( )
else ( )
2021-07-25 09:55:31 +00:00
function ( _CUDAToolkit_find_root_dir )
cmake_parse_arguments ( arg "" "" "SEARCH_PATHS;FIND_FLAGS" ${ ARGN } )
if ( NOT CUDAToolkit_BIN_DIR )
if ( NOT CUDAToolkit_SENTINEL_FILE )
find_program ( CUDAToolkit_NVCC_EXECUTABLE
N A M E S n v c c n v c c . e x e
P A T H S $ { a r g _ S E A R C H _ P A T H S }
$ { a r g _ F I N D _ F L A G S }
)
endif ( )
if ( NOT CUDAToolkit_NVCC_EXECUTABLE )
find_file ( CUDAToolkit_SENTINEL_FILE
N A M E S v e r s i o n . t x t
P A T H S $ { a r g _ S E A R C H _ P A T H S }
N O _ D E F A U L T _ P A T H
)
endif ( )
if ( EXISTS "${CUDAToolkit_NVCC_EXECUTABLE}" )
# If NVCC exists then invoke it to find the toolkit location.
# This allows us to support wrapper scripts (e.g. ccache or colornvcc), CUDA Toolkit,
# NVIDIA HPC SDK, and distro's splayed layouts
execute_process ( COMMAND ${ CUDAToolkit_NVCC_EXECUTABLE } "-v" "__cmake_determine_cuda"
O U T P U T _ V A R I A B L E _ C U D A _ N V C C _ O U T E R R O R _ V A R I A B L E _ C U D A _ N V C C _ O U T )
if ( _CUDA_NVCC_OUT MATCHES "\\#\\$ TOP=([^\r\n]*)" )
get_filename_component ( CUDAToolkit_BIN_DIR "${CMAKE_MATCH_1}/bin" ABSOLUTE )
else ( )
get_filename_component ( CUDAToolkit_BIN_DIR "${CUDAToolkit_NVCC_EXECUTABLE}" DIRECTORY )
endif ( )
unset ( _CUDA_NVCC_OUT )
mark_as_advanced ( CUDAToolkit_BIN_DIR )
set ( CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "" FORCE )
endif ( )
if ( CUDAToolkit_SENTINEL_FILE )
get_filename_component ( CUDAToolkit_BIN_DIR ${ CUDAToolkit_SENTINEL_FILE } DIRECTORY ABSOLUTE )
set ( CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}/bin" )
set ( CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "" FORCE )
mark_as_advanced ( CUDAToolkit_BIN_DIR )
endif ( )
endif ( )
if ( CUDAToolkit_BIN_DIR )
get_filename_component ( CUDAToolkit_ROOT_DIR ${ CUDAToolkit_BIN_DIR } DIRECTORY ABSOLUTE )
set ( CUDAToolkit_ROOT_DIR "${CUDAToolkit_ROOT_DIR}" PARENT_SCOPE )
endif ( )
endfunction ( )
function ( _CUDAToolkit_find_version_file result_variable )
# We first check for a non-scattered installation to prefer it over a scattered installation.
if ( CUDAToolkit_ROOT AND EXISTS "${CUDAToolkit_ROOT}/version.txt" )
set ( ${ result_variable } "${CUDAToolkit_ROOT}/version.txt" PARENT_SCOPE )
elseif ( CUDAToolkit_ROOT_DIR AND EXISTS "${CUDAToolkit_ROOT_DIR}/version.txt" )
set ( ${ result_variable } "${CUDAToolkit_ROOT_DIR}/version.txt" PARENT_SCOPE )
elseif ( CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt" )
set ( ${ result_variable } "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt" PARENT_SCOPE )
elseif ( EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt" )
set ( ${ result_variable } "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt" PARENT_SCOPE )
endif ( )
endfunction ( )
# For NVCC we can easily deduce the SDK binary directory from the compiler path.
if ( CMAKE_CUDA_COMPILER_LOADED AND NOT CUDAToolkit_BIN_DIR AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" )
get_filename_component ( CUDAToolkit_BIN_DIR "${CMAKE_CUDA_COMPILER}" DIRECTORY )
set ( CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "" )
# Try language provided path first.
_CUDAToolkit_find_root_dir ( SEARCH_PATHS "${CUDAToolkit_BIN_DIR}" FIND_FLAGS NO_DEFAULT_PATH )
mark_as_advanced ( CUDAToolkit_BIN_DIR )
endif ( )
# Try user provided path
if ( NOT CUDAToolkit_ROOT_DIR AND CUDAToolkit_ROOT )
_CUDAToolkit_find_root_dir ( SEARCH_PATHS "${CUDAToolkit_ROOT}" FIND_FLAGS PATH_SUFFIXES bin NO_DEFAULT_PATH )
endif ( )
if ( NOT CUDAToolkit_ROOT_DIR )
_CUDAToolkit_find_root_dir ( FIND_FLAGS PATHS ENV CUDA_PATH PATH_SUFFIXES bin )
endif ( )
# If the user specified CUDAToolkit_ROOT but the toolkit could not be found, this is an error.
if ( NOT CUDAToolkit_ROOT_DIR AND ( DEFINED CUDAToolkit_ROOT OR DEFINED ENV{CUDAToolkit_ROOT} ) )
# Declare error messages now, print later depending on find_package args.
set ( fail_base "Could not find nvcc executable in path specified by" )
set ( cuda_root_fail "${fail_base} CUDAToolkit_ROOT=${CUDAToolkit_ROOT}" )
set ( env_cuda_root_fail "${fail_base} environment variable CUDAToolkit_ROOT=$ENV{CUDAToolkit_ROOT}" )
if ( CUDAToolkit_FIND_REQUIRED )
if ( DEFINED CUDAToolkit_ROOT )
message ( FATAL_ERROR ${ cuda_root_fail } )
elseif ( DEFINED ENV{CUDAToolkit_ROOT} )
message ( FATAL_ERROR ${ env_cuda_root_fail } )
endif ( )
else ( )
if ( NOT CUDAToolkit_FIND_QUIETLY )
if ( DEFINED CUDAToolkit_ROOT )
message ( STATUS ${ cuda_root_fail } )
elseif ( DEFINED ENV{CUDAToolkit_ROOT} )
message ( STATUS ${ env_cuda_root_fail } )
endif ( )
endif ( )
set ( CUDAToolkit_FOUND FALSE )
unset ( fail_base )
unset ( cuda_root_fail )
unset ( env_cuda_root_fail )
return ( )
endif ( )
endif ( )
# CUDAToolkit_ROOT cmake / env variable not specified, try platform defaults.
#
# - Linux: /usr/local/cuda-X.Y
# - macOS: /Developer/NVIDIA/CUDA-X.Y
# - Windows: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y
#
# We will also search the default symlink location /usr/local/cuda first since
# if CUDAToolkit_ROOT is not specified, it is assumed that the symlinked
# directory is the desired location.
if ( NOT CUDAToolkit_ROOT_DIR )
if ( UNIX )
if ( NOT APPLE )
set ( platform_base "/usr/local/cuda-" )
else ( )
set ( platform_base "/Developer/NVIDIA/CUDA-" )
endif ( )
else ( )
set ( platform_base "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v" )
endif ( )
# Build out a descending list of possible cuda installations, e.g.
file ( GLOB possible_paths "${platform_base}*" )
# Iterate the glob results and create a descending list.
set ( versions )
foreach ( p ${ possible_paths } )
# Extract version number from end of string
string ( REGEX MATCH "[0-9][0-9]?\\.[0-9]$" p_version ${ p } )
if ( IS_DIRECTORY ${ p } AND p_version )
list ( APPEND versions ${ p_version } )
endif ( )
endforeach ( )
# Sort numerically in descending order, so we try the newest versions first.
list ( SORT versions COMPARE NATURAL ORDER DESCENDING )
# With a descending list of versions, populate possible paths to search.
set ( search_paths )
foreach ( v ${ versions } )
list ( APPEND search_paths "${platform_base}${v}" )
endforeach ( )
# Force the global default /usr/local/cuda to the front on Unix.
if ( UNIX )
list ( INSERT search_paths 0 "/usr/local/cuda" )
endif ( )
# Now search for the toolkit again using the platform default search paths.
_CUDAToolkit_find_root_dir ( SEARCH_PATHS "${search_paths}" FIND_FLAGS PATH_SUFFIXES bin )
# We are done with these variables now, cleanup for caller.
unset ( platform_base )
unset ( possible_paths )
unset ( versions )
unset ( search_paths )
if ( NOT CUDAToolkit_ROOT_DIR )
if ( CUDAToolkit_FIND_REQUIRED )
message ( FATAL_ERROR "Could not find nvcc, please set CUDAToolkit_ROOT." )
elseif ( NOT CUDAToolkit_FIND_QUIETLY )
message ( STATUS "Could not find nvcc, please set CUDAToolkit_ROOT." )
endif ( )
set ( CUDAToolkit_FOUND FALSE )
return ( )
endif ( )
endif ( )
_CUDAToolkit_find_version_file ( _CUDAToolkit_version_file )
if ( _CUDAToolkit_version_file )
# CUDAToolkit_LIBRARY_ROOT contains the device library and version file.
get_filename_component ( CUDAToolkit_LIBRARY_ROOT "${_CUDAToolkit_version_file}" DIRECTORY ABSOLUTE )
endif ( )
unset ( _CUDAToolkit_version_file )
2023-01-10 14:42:48 +00:00
if ( CUDAToolkit_NVCC_EXECUTABLE AND
C M A K E _ C U D A _ C O M P I L E R _ V E R S I O N A N D
C U D A T o o l k i t _ N V C C _ E X E C U T A B L E S T R E Q U A L C M A K E _ C U D A _ C O M P I L E R )
# Need to set these based off the already computed CMAKE_CUDA_COMPILER_VERSION value
# This if statement will always match, but is used to provide variables for MATCH 1,2,3...
if ( CMAKE_CUDA_COMPILER_VERSION MATCHES [=[([0-9]+ ) \ . ( [ 0 - 9 ] + ) \ . ( [ 0 - 9 ] + ) ] = ] )
set ( CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}" )
set ( CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}" )
set ( CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}" )
set ( CUDAToolkit_VERSION "${CMAKE_CUDA_COMPILER_VERSION}" )
endif ( )
elseif ( CUDAToolkit_NVCC_EXECUTABLE )
# Compute the version by invoking nvcc
execute_process ( COMMAND ${ CUDAToolkit_NVCC_EXECUTABLE } "--version" OUTPUT_VARIABLE NVCC_OUT )
if ( NVCC_OUT MATCHES [=[ V([0-9]+ ) \ . ( [ 0 - 9 ] + ) \ . ( [ 0 - 9 ] + ) ] = ] )
set ( CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}" )
set ( CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}" )
set ( CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}" )
set ( CUDAToolkit_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" )
endif ( )
unset ( NVCC_OUT )
else ( )
_CUDAToolkit_find_version_file ( version_file )
if ( version_file )
file ( READ "${version_file}" VERSION_INFO )
if ( VERSION_INFO MATCHES [=[CUDA Version ( [0-9]+ ) \.([0-9]+)\.([0-9]+)]=])
set ( CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}" )
set ( CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}" )
set ( CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}" )
set ( CUDAToolkit_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" )
endif ( )
endif ( )
endif ( )
2021-07-25 09:55:31 +00:00
endif ( )
# Find target directory when crosscompiling.
if ( CMAKE_CROSSCOMPILING )
if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a" )
# Support for NVPACK
set ( CUDAToolkit_TARGET_NAME "armv7-linux-androideabi" )
elseif ( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" )
set ( CUDAToolkit_TARGET_NAME "armv7-linux-gnueabihf" )
elseif ( CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" )
if ( ANDROID_ARCH_NAME STREQUAL "arm64" )
set ( CUDAToolkit_TARGET_NAME "aarch64-linux-androideabi" )
elseif ( CMAKE_SYSTEM_NAME STREQUAL "QNX" )
set ( CUDAToolkit_TARGET_NAME "aarch64-qnx" )
else ( )
set ( CUDAToolkit_TARGET_NAME "aarch64-linux" )
endif ( ANDROID_ARCH_NAME STREQUAL "arm64" )
elseif ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
set ( CUDAToolkit_TARGET_NAME "x86_64-linux" )
endif ( )
if ( EXISTS "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}" )
set ( CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}" )
# add known CUDA target root path to the set of directories we search for programs, libraries and headers
list ( PREPEND CMAKE_FIND_ROOT_PATH "${CUDAToolkit_TARGET_DIR}" )
# Mark that we need to pop the root search path changes after we have
# found all cuda libraries so that searches for our cross-compilation
# libraries work when another cuda sdk is in CMAKE_PREFIX_PATH or
# PATh
set ( _CUDAToolkit_Pop_ROOT_PATH True )
endif ( )
endif ( )
# If not already set we can simply use the toolkit root or it's a scattered installation.
if ( NOT CUDAToolkit_TARGET_DIR )
# Not cross compiling
set ( CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}" )
# Now that we have the real ROOT_DIR, find components inside it.
list ( APPEND CMAKE_PREFIX_PATH ${ CUDAToolkit_ROOT_DIR } )
# Mark that we need to pop the prefix path changes after we have
# found the cudart library.
set ( _CUDAToolkit_Pop_Prefix True )
endif ( )
# CUDAToolkit_TARGET_DIR always points to the directory containing the include directory.
# On a scattered installation /usr, on a non-scattered something like /usr/local/cuda or /usr/local/cuda-10.2/targets/aarch64-linux.
if ( EXISTS "${CUDAToolkit_TARGET_DIR}/include/cuda_runtime.h" )
set ( CUDAToolkit_INCLUDE_DIR "${CUDAToolkit_TARGET_DIR}/include" )
elseif ( NOT CUDAToolkit_FIND_QUIETLY )
message ( STATUS "Unable to find cuda_runtime.h in \" ${ CUDAToolkit_TARGET_DIR } /include\ " for CUDAToolkit_INCLUDE_DIR." )
endif ( )
2023-01-10 14:42:48 +00:00
# The NVHPC layout moves math library headers and libraries to a sibling directory.
# Create a separate variable so this directory can be selectively added to math targets.
if ( NOT EXISTS "${CUDAToolkit_INCLUDE_DIR}/cublas_v2.h" )
set ( CUDAToolkit_MATH_INCLUDE_DIR "${CUDAToolkit_TARGET_DIR}/../../math_libs/include" )
cmake_path ( NORMAL_PATH CUDAToolkit_MATH_INCLUDE_DIR )
if ( NOT EXISTS "${CUDAToolkit_MATH_INCLUDE_DIR}/cublas_v2.h" )
if ( NOT CUDAToolkit_FIND_QUIETLY )
message ( STATUS "Unable to find cublas_v2.h in either \" ${ CUDAToolkit_INCLUDE_DIR } \" or \"${CUDAToolkit_MATH_INCLUDE_DIR}\"")
2021-07-25 09:55:31 +00:00
endif ( )
2023-01-10 14:42:48 +00:00
unset ( CUDAToolkit_MATH_INCLUDE_DIR )
2021-07-25 09:55:31 +00:00
endif ( )
endif ( )
# Find the CUDA Runtime Library libcudart
find_library ( CUDA_CUDART
N A M E S c u d a r t
P A T H _ S U F F I X E S l i b 6 4 l i b / x 6 4
)
find_library ( CUDA_CUDART
N A M E S c u d a r t
P A T H _ S U F F I X E S l i b 6 4 / s t u b s l i b / x 6 4 / s t u b s
)
if ( NOT CUDA_CUDART AND NOT CUDAToolkit_FIND_QUIETLY )
message ( STATUS "Unable to find cudart library." )
endif ( )
if ( _CUDAToolkit_Pop_Prefix )
list ( REMOVE_AT CMAKE_PREFIX_PATH -1 )
unset ( _CUDAToolkit_Pop_Prefix )
endif ( )
#-----------------------------------------------------------------------------
# Perform version comparison and validate all required variables are set.
include ( ${ CMAKE_CURRENT_LIST_DIR } /FindPackageHandleStandardArgs.cmake )
find_package_handle_standard_args ( CUDAToolkit
R E Q U I R E D _ V A R S
C U D A T o o l k i t _ I N C L U D E _ D I R
C U D A _ C U D A R T
C U D A T o o l k i t _ B I N _ D I R
V E R S I O N _ V A R
C U D A T o o l k i t _ V E R S I O N
)
unset ( CUDAToolkit_ROOT_DIR )
mark_as_advanced ( CUDA_CUDART
C U D A T o o l k i t _ I N C L U D E _ D I R
C U D A T o o l k i t _ N V C C _ E X E C U T A B L E
C U D A T o o l k i t _ S E N T I N E L _ F I L E
)
#-----------------------------------------------------------------------------
# Construct result variables
if ( CUDAToolkit_FOUND )
set ( CUDAToolkit_INCLUDE_DIRS ${ CUDAToolkit_INCLUDE_DIR } )
get_filename_component ( CUDAToolkit_LIBRARY_DIR ${ CUDA_CUDART } DIRECTORY ABSOLUTE )
endif ( )
#-----------------------------------------------------------------------------
# Construct import targets
if ( CUDAToolkit_FOUND )
function ( _CUDAToolkit_find_and_add_import_lib lib_name )
2023-01-10 14:42:48 +00:00
cmake_parse_arguments ( arg "" "" "ALT;DEPS;EXTRA_PATH_SUFFIXES;EXTRA_INCLUDE_DIRS" ${ ARGN } )
2021-07-25 09:55:31 +00:00
set ( search_names ${ lib_name } ${ arg_ALT } )
find_library ( CUDA_ ${ lib_name } _LIBRARY
N A M E S $ { s e a r c h _ n a m e s }
H I N T S $ { C U D A T o o l k i t _ L I B R A R Y _ D I R }
E N V C U D A _ P A T H
P A T H _ S U F F I X E S n v i d i a / c u r r e n t l i b 6 4 l i b / x 6 4 l i b
$ { a r g _ E X T R A _ P A T H _ S U F F I X E S }
)
# Don't try any stub directories until we have exhausted all other
# search locations.
find_library ( CUDA_ ${ lib_name } _LIBRARY
N A M E S $ { s e a r c h _ n a m e s }
H I N T S $ { C U D A T o o l k i t _ L I B R A R Y _ D I R }
E N V C U D A _ P A T H
P A T H _ S U F F I X E S l i b 6 4 / s t u b s l i b / x 6 4 / s t u b s l i b / s t u b s s t u b s
2023-01-10 14:42:48 +00:00
# Support NVHPC splayed math library layout
. . / . . / m a t h _ l i b s / $ { C U D A T o o l k i t _ V E R S I O N _ M A J O R } . $ { C U D A T o o l k i t _ V E R S I O N _ M I N O R } / l i b 6 4
. . / . . / m a t h _ l i b s / l i b 6 4
2021-07-25 09:55:31 +00:00
)
mark_as_advanced ( CUDA_ ${ lib_name } _LIBRARY )
if ( NOT TARGET CUDA:: ${ lib_name } AND CUDA_ ${ lib_name } _LIBRARY )
2023-01-10 14:42:48 +00:00
add_library ( CUDA:: ${ lib_name } UNKNOWN IMPORTED )
2021-07-25 09:55:31 +00:00
target_include_directories ( CUDA:: ${ lib_name } SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}" )
2023-01-10 14:42:48 +00:00
if ( DEFINED CUDAToolkit_MATH_INCLUDE_DIR )
string ( FIND ${ CUDA_${lib_name } _LIBRARY} "math_libs" math_libs )
if ( NOT ${ math_libs } EQUAL -1 )
target_include_directories ( CUDA:: ${ lib_name } SYSTEM INTERFACE "${CUDAToolkit_MATH_INCLUDE_DIR}" )
endif ( )
endif ( )
set_property ( TARGET CUDA:: ${ lib_name } PROPERTY IMPORTED_LOCATION "${CUDA_${lib_name}_LIBRARY}" )
2021-07-25 09:55:31 +00:00
foreach ( dep ${ arg_DEPS } )
if ( TARGET CUDA:: ${ dep } )
target_link_libraries ( CUDA:: ${ lib_name } INTERFACE CUDA:: ${ dep } )
endif ( )
endforeach ( )
2023-01-10 14:42:48 +00:00
if ( arg_EXTRA_INCLUDE_DIRS )
target_include_directories ( CUDA:: ${ lib_name } SYSTEM INTERFACE "${arg_EXTRA_INCLUDE_DIRS}" )
endif ( )
2021-07-25 09:55:31 +00:00
endif ( )
endfunction ( )
if ( NOT TARGET CUDA::toolkit )
add_library ( CUDA::toolkit IMPORTED INTERFACE )
target_include_directories ( CUDA::toolkit SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}" )
target_link_directories ( CUDA::toolkit INTERFACE "${CUDAToolkit_LIBRARY_DIR}" )
endif ( )
_CUDAToolkit_find_and_add_import_lib ( cuda_driver ALT cuda )
_CUDAToolkit_find_and_add_import_lib ( cudart )
_CUDAToolkit_find_and_add_import_lib ( cudart_static )
# setup dependencies that are required for cudart_static when building
# on linux. These are generally only required when using the CUDA toolkit
# when CUDA language is disabled
if ( NOT TARGET CUDA::cudart_static_deps
A N D T A R G E T C U D A : : c u d a r t _ s t a t i c )
add_library ( CUDA::cudart_static_deps IMPORTED INTERFACE )
target_link_libraries ( CUDA::cudart_static INTERFACE CUDA::cudart_static_deps )
if ( UNIX AND ( CMAKE_C_COMPILER OR CMAKE_CXX_COMPILER ) )
find_package ( Threads REQUIRED )
target_link_libraries ( CUDA::cudart_static_deps INTERFACE Threads::Threads ${ CMAKE_DL_LIBS } )
endif ( )
if ( UNIX AND NOT APPLE AND NOT ( CMAKE_SYSTEM_NAME STREQUAL "QNX" ) )
# On Linux, you must link against librt when using the static cuda runtime.
find_library ( CUDAToolkit_rt_LIBRARY rt )
mark_as_advanced ( CUDAToolkit_rt_LIBRARY )
if ( NOT CUDAToolkit_rt_LIBRARY )
message ( WARNING "Could not find librt library, needed by CUDA::cudart_static" )
else ( )
target_link_libraries ( CUDA::cudart_static_deps INTERFACE ${ CUDAToolkit_rt_LIBRARY } )
endif ( )
endif ( )
endif ( )
_CUDAToolkit_find_and_add_import_lib ( culibos ) # it's a static library
2023-01-10 14:42:48 +00:00
foreach ( cuda_lib cublasLt cufft curand cusparse nppc nvjpeg )
2021-07-25 09:55:31 +00:00
_CUDAToolkit_find_and_add_import_lib ( ${ cuda_lib } )
_CUDAToolkit_find_and_add_import_lib ( ${ cuda_lib } _static DEPS culibos )
endforeach ( )
2023-01-10 14:42:48 +00:00
if ( CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.0.0 )
# cublas depends on cublasLt
# https://docs.nvidia.com/cuda/archive/11.0/cublas/index.html#static-library
_CUDAToolkit_find_and_add_import_lib ( cublas DEPS cublasLt culibos )
_CUDAToolkit_find_and_add_import_lib ( cublas_static DEPS cublasLt_static culibos )
else ( )
_CUDAToolkit_find_and_add_import_lib ( cublas DEPS culibos )
_CUDAToolkit_find_and_add_import_lib ( cublas_static DEPS culibos )
endif ( )
if ( CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.4 )
_CUDAToolkit_find_and_add_import_lib ( cuFile DEPS culibos )
_CUDAToolkit_find_and_add_import_lib ( cuFile_static DEPS culibos )
_CUDAToolkit_find_and_add_import_lib ( cuFile_rdma DEPS cuFile culibos )
_CUDAToolkit_find_and_add_import_lib ( cuFile_rdma_static DEPS cuFile_static culibos )
endif ( )
2021-07-25 09:55:31 +00:00
# cuFFTW depends on cuFFT
_CUDAToolkit_find_and_add_import_lib ( cufftw DEPS cufft )
2023-01-10 14:42:48 +00:00
_CUDAToolkit_find_and_add_import_lib ( cufftw_static DEPS cufft_static )
if ( CUDAToolkit_VERSION VERSION_GREATER_EQUAL 9.2 )
_CUDAToolkit_find_and_add_import_lib ( cufft_static_nocallback DEPS culibos )
endif ( )
2021-07-25 09:55:31 +00:00
# cuSOLVER depends on cuBLAS, and cuSPARSE
2023-01-10 14:42:48 +00:00
set ( cusolver_deps cublas cusparse )
set ( cusolver_static_deps cublas_static cusparse_static culibos )
if ( CUDAToolkit_VERSION VERSION_GREATER 11.2.1 )
# cusolver depends on libcusolver_metis and cublasLt
# https://docs.nvidia.com/cuda/archive/11.2.2/cusolver/index.html#link-dependency
list ( APPEND cusolver_deps cublasLt )
_CUDAToolkit_find_and_add_import_lib ( cusolver_metis_static ALT metis_static ) # implementation detail static lib
list ( APPEND cusolver_static_deps cusolver_metis_static cublasLt_static )
endif ( )
if ( CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.1.2 )
# cusolver depends on liblapack_static.a starting with CUDA 10.1 update 2,
# https://docs.nvidia.com/cuda/archive/11.5.0/cusolver/index.html#static-link-lapack
_CUDAToolkit_find_and_add_import_lib ( cusolver_lapack_static ALT lapack_static ) # implementation detail static lib
list ( APPEND cusolver_static_deps cusolver_lapack_static )
endif ( )
_CUDAToolkit_find_and_add_import_lib ( cusolver DEPS ${ cusolver_deps } )
_CUDAToolkit_find_and_add_import_lib ( cusolver_static DEPS ${ cusolver_static_deps } )
unset ( cusolver_deps )
unset ( cusolver_static_deps )
2021-07-25 09:55:31 +00:00
# nvGRAPH depends on cuRAND, and cuSOLVER.
_CUDAToolkit_find_and_add_import_lib ( nvgraph DEPS curand cusolver )
_CUDAToolkit_find_and_add_import_lib ( nvgraph_static DEPS curand_static cusolver_static )
# Process the majority of the NPP libraries.
foreach ( cuda_lib nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu )
_CUDAToolkit_find_and_add_import_lib ( ${ cuda_lib } DEPS nppc )
_CUDAToolkit_find_and_add_import_lib ( ${ cuda_lib } _static DEPS nppc_static )
endforeach ( )
2023-01-10 14:42:48 +00:00
find_path ( CUDAToolkit_CUPTI_INCLUDE_DIR cupti.h PATHS
" $ { C U D A T o o l k i t _ R O O T _ D I R } / e x t r a s / C U P T I / i n c l u d e "
" $ { C U D A T o o l k i t _ I N C L U D E _ D I R } / . . / e x t r a s / C U P T I / i n c l u d e "
" $ { C U D A T o o l k i t _ I N C L U D E _ D I R } "
N O _ D E F A U L T _ P A T H )
if ( CUDAToolkit_CUPTI_INCLUDE_DIR )
_CUDAToolkit_find_and_add_import_lib ( cupti
E X T R A _ P A T H _ S U F F I X E S . . / e x t r a s / C U P T I / l i b 6 4 /
. . / e x t r a s / C U P T I / l i b /
E X T R A _ I N C L U D E _ D I R S " $ { C U D A T o o l k i t _ C U P T I _ I N C L U D E _ D I R } " )
_CUDAToolkit_find_and_add_import_lib ( cupti_static
E X T R A _ P A T H _ S U F F I X E S . . / e x t r a s / C U P T I / l i b 6 4 /
. . / e x t r a s / C U P T I / l i b /
E X T R A _ I N C L U D E _ D I R S " $ { C U D A T o o l k i t _ C U P T I _ I N C L U D E _ D I R } " )
endif ( )
2021-07-25 09:55:31 +00:00
_CUDAToolkit_find_and_add_import_lib ( nvrtc DEPS cuda_driver )
2023-01-10 14:42:48 +00:00
if ( CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.1.0 )
if ( NOT TARGET CUDA::nvptxcompiler_static )
_CUDAToolkit_find_and_add_import_lib ( nvptxcompiler_static DEPS cuda_driver )
if ( TARGET CUDA::nvptxcompiler_static )
target_link_libraries ( CUDA::nvptxcompiler_static INTERFACE Threads::Threads )
endif ( )
endif ( )
endif ( )
2021-07-25 09:55:31 +00:00
_CUDAToolkit_find_and_add_import_lib ( nvml ALT nvidia-ml nvml )
if ( WIN32 )
# nvtools can be installed outside the CUDA toolkit directory
# so prefer the NVTOOLSEXT_PATH windows only environment variable
# In addition on windows the most common name is nvToolsExt64_1
find_library ( CUDA_nvToolsExt_LIBRARY
N A M E S n v T o o l s E x t 6 4 _ 1 n v T o o l s E x t 6 4 n v T o o l s E x t
P A T H S E N V N V T O O L S E X T _ P A T H
E N V C U D A _ P A T H
P A T H _ S U F F I X E S l i b / x 6 4 l i b
)
endif ( )
_CUDAToolkit_find_and_add_import_lib ( nvToolsExt ALT nvToolsExt64 )
2023-01-10 14:42:48 +00:00
if ( CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.0 )
# nvToolsExt is deprecated since nvtx3 introduction.
# Warn only if the project requires a sufficiently new CMake to make migration possible.
if ( CMAKE_MINIMUM_REQUIRED_VERSION VERSION_GREATER_EQUAL 3.25 )
set_property ( TARGET CUDA::nvToolsExt PROPERTY DEPRECATION "nvToolsExt has been superseded by nvtx3 since CUDA 10.0 and CMake 3.25. Use CUDA::nvtx3 and include <nvtx3/nvToolsExt.h> instead." )
endif ( )
# Header-only variant. Uses dlopen().
if ( NOT TARGET CUDA::nvtx3 )
add_library ( CUDA::nvtx3 INTERFACE IMPORTED )
target_include_directories ( CUDA::nvtx3 SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}" )
target_link_libraries ( CUDA::nvtx3 INTERFACE ${ CMAKE_DL_LIBS } )
endif ( )
endif ( )
2021-07-25 09:55:31 +00:00
_CUDAToolkit_find_and_add_import_lib ( OpenCL )
endif ( )
if ( _CUDAToolkit_Pop_ROOT_PATH )
list ( REMOVE_AT CMAKE_FIND_ROOT_PATH 0 )
unset ( _CUDAToolkit_Pop_ROOT_PATH )
endif ( )