Skip to content

Commit 59b8bdc

Browse files
committed
Bind size_t as CSize in CUDA.Driver.Graph.Build
This seems to be the only module using CULong, and hence the only one that made the mistake of binding size_t to the platform-specific type (on Mac/Linux).
1 parent d1beaca commit 59b8bdc

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

‎cuda/src/Foreign/CUDA/Driver/Graph/Build.chs‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ import Foreign
6363
import Foreign.C
6464
import Foreign.Storable
6565

66+
{#typedef size_t CSize#}
67+
{#default in `Int' [size_t] fromIntegral#}
68+
{#default out `Int' [size_t] fromIntegral#}
69+
6670

6771
-- | Callback function executed on the host
6872
--
@@ -534,7 +538,7 @@ getEdges !g =
534538
{ useGraph `Graph'
535539
, castPtr `Ptr Node'
536540
, castPtr `Ptr Node'
537-
, id `Ptr CULong'
541+
, id `Ptr CSize'
538542
}
539543
-> `()' checkStatus*- #}
540544
#else
@@ -544,7 +548,7 @@ getEdges !g =
544548
, castPtr `Ptr Node'
545549
, castPtr `Ptr Node'
546550
, castPtr `Ptr edgeData'
547-
, id `Ptr CULong'
551+
, id `Ptr CSize'
548552
}
549553
-> `()' checkStatus*- #}
550554
#endif
@@ -575,7 +579,7 @@ getNodes !g =
575579
{# fun unsafe cuGraphGetNodes
576580
{ useGraph `Graph'
577581
, castPtr `Ptr Node'
578-
, id `Ptr CULong'
582+
, id `Ptr CSize'
579583
}
580584
-> `()' checkStatus*- #}
581585
#endif
@@ -605,7 +609,7 @@ getRootNodes g =
605609
{# fun unsafe cuGraphGetRootNodes
606610
{ useGraph `Graph'
607611
, castPtr `Ptr Node'
608-
, id `Ptr CULong'
612+
, id `Ptr CSize'
609613
}
610614
-> `()' checkStatus*- #}
611615
#endif
@@ -636,7 +640,7 @@ getDependencies !n =
636640
{# fun unsafe cuGraphNodeGetDependencies
637641
{ useNode `Node'
638642
, castPtr `Ptr Node'
639-
, id `Ptr CULong'
643+
, id `Ptr CSize'
640644
}
641645
-> `()' checkStatus*- #}
642646
#else
@@ -645,7 +649,7 @@ getDependencies !n =
645649
{ useNode `Node'
646650
, castPtr `Ptr Node'
647651
, castPtr `Ptr edgeData'
648-
, id `Ptr CULong'
652+
, id `Ptr CSize'
649653
}
650654
-> `()' checkStatus*- #}
651655
#endif
@@ -677,7 +681,7 @@ getDependents n =
677681
{# fun unsafe cuGraphNodeGetDependentNodes
678682
{ useNode `Node'
679683
, castPtr `Ptr Node'
680-
, id `Ptr CULong'
684+
, id `Ptr CSize'
681685
}
682686
-> `()' checkStatus*- #}
683687
#else
@@ -686,7 +690,7 @@ getDependents n =
686690
{ useNode `Node'
687691
, castPtr `Ptr Node'
688692
, castPtr `Ptr edgeData'
689-
, id `Ptr CULong'
693+
, id `Ptr CSize'
690694
}
691695
-> `()' checkStatus*- #}
692696
#endif
@@ -733,13 +737,13 @@ withNodeArray :: [Node] -> (Ptr {# type CUgraphNode #} -> IO a) -> IO a
733737
withNodeArray ns f = withArray ns (f . castPtr)
734738

735739
{-# INLINE withNodeArrayLen #-}
736-
withNodeArrayLen :: [Node] -> ((Ptr {# type CUgraphNode #}, CULong) -> IO a) -> IO a
740+
withNodeArrayLen :: [Node] -> ((Ptr {# type CUgraphNode #}, CSize) -> IO a) -> IO a
737741
withNodeArrayLen ns f = withArrayLen ns $ \i p -> f (castPtr p, cIntConv i)
738742
#endif
739743

740744
#if CUDA_VERSION >= 13000
741745
{-# INLINE withNullEdgeDataLen #-}
742-
withNullEdgeDataLen :: Int -> ((Ptr (), CULong) -> IO a) -> IO a
746+
withNullEdgeDataLen :: Int -> ((Ptr (), CSize) -> IO a) -> IO a
743747
withNullEdgeDataLen len f = f (nullPtr, cIntConv len)
744748
#endif
745749

0 commit comments

Comments
 (0)