From 76512260b003ec92f8af0ecd6aeba4b0f6dc3379 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 4 May 2010 19:46:53 -0700 Subject: [PATCH] cuda.memory, cuda.syntax: inline some more words, add cuda-malloc-type word that allocates n*heap-size bytes of memory --- extra/cuda/memory/memory.factor | 7 +++++-- extra/cuda/syntax/syntax.factor | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/extra/cuda/memory/memory.factor b/extra/cuda/memory/memory.factor index 248682aecc..9e856ad69b 100644 --- a/extra/cuda/memory/memory.factor +++ b/extra/cuda/memory/memory.factor @@ -9,10 +9,13 @@ IN: cuda.memory : cuda-malloc ( n -- ptr ) [ CUdeviceptr ] dip '[ _ cuMemAlloc cuda-error ] keep - c:*int ; + c:*int ; inline + +: cuda-malloc-type ( n type -- ptr ) + heap-size * cuda-malloc ; inline : cuda-free ( ptr -- ) - cuMemFree cuda-error ; + cuMemFree cuda-error ; inline DESTRUCTOR: cuda-free diff --git a/extra/cuda/syntax/syntax.factor b/extra/cuda/syntax/syntax.factor index 70a052726f..4e15fa383e 100644 --- a/extra/cuda/syntax/syntax.factor +++ b/extra/cuda/syntax/syntax.factor @@ -14,10 +14,10 @@ SYNTAX: CUDA-FUNCTION: ";" scan-c-args drop define-cuda-word ; : 2<<< ( dim-block dim-grid -- function-launcher ) - 0 f function-launcher boa ; + 0 f function-launcher boa ; inline : 3<<< ( dim-block dim-grid shared-size -- function-launcher ) - f function-launcher boa ; + f function-launcher boa ; inline : 4<<< ( dim-block dim-grid shared-size stream -- function-launcher ) - function-launcher boa ; + function-launcher boa ; inline