Skip to content

Commit abe2391

Browse files
Claus SusanneClaus Susanne
Claus Susanne
authored and
Claus Susanne
committed
expand comment for numba intrinsic function
1 parent 6ad0d88 commit abe2391

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

ffcx/codegeneration/utils.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,35 @@ def get_void_pointer(typingctx, arr):
125125
Args:
126126
typingctx: The typing context.
127127
arr: The NumPy array to get the void pointer from.
128+
In a multi-dimensional NumPy array, the memory is laid out in a contiguous
129+
block of memory in either row-major (C-style) or
130+
column-major (Fortran-style) order.
131+
By default, NumPy uses row-major order.
128132
129133
Returns:
130134
A Numba signature and a code generation function that returns a void pointer
131-
to the array's data.
135+
to the first element of the contiguous block of memory that stores the array's
136+
data in row-major order by default.
132137
"""
133138
if not isinstance(arr, numba.types.Array):
134139
raise TypeError("Expected a NumPy array")
135140

136141
def codegen(context, builder, signature, args):
142+
"""Generate LLVM IR code to convert a NumPy array to a void* pointer.
143+
144+
This function generates the necessary LLVM IR instructions to:
145+
1. Allocate memory for the array on the stack.
146+
2. Cast the allocated memory to a void* pointer.
147+
148+
Args:
149+
context: The LLVM context.
150+
builder: The LLVM IR builder.
151+
signature: The function signature.
152+
args: The input arguments (NumPy array).
153+
154+
Returns:
155+
A void* pointer to the array's data.
156+
"""
137157
[arr] = args
138158
raw_ptr = numba.core.cgutils.alloca_once_value(builder, arr)
139159
void_ptr = builder.bitcast(raw_ptr, context.get_value_type(numba.types.voidptr))

0 commit comments

Comments
 (0)