@@ -294,19 +294,20 @@ def extract_initialization_code(code: str, langs: Code) -> str:
294
294
295
295
296
296
def format_argument_fortran (p_type : str , p_size : int , p_name : str ) -> str :
297
+ argument = ""
297
298
if "float*" in p_type :
298
- return f"real (c_float), dimension({ p_size } ) :: { p_name } "
299
+ argument = f"real (c_float), dimension({ p_size } ) :: { p_name } "
299
300
elif "double*" in p_type :
300
- return f"real (c_double), dimension({ p_size } ) :: { p_name } "
301
+ argument = f"real (c_double), dimension({ p_size } ) :: { p_name } "
301
302
elif "int*" in p_type :
302
- return f"integer (c_int), dimension({ p_size } ) :: { p_name } "
303
+ argument = f"integer (c_int), dimension({ p_size } ) :: { p_name } "
303
304
elif "float" in p_type :
304
- return f"real (c_float), value :: { p_name } "
305
+ argument = f"real (c_float), value :: { p_name } "
305
306
elif "double" in p_type :
306
- return f"real (c_double), value :: { p_name } "
307
+ argument = f"real (c_double), value :: { p_name } "
307
308
elif "int" in p_type :
308
- return f"integer (c_int), value :: { p_name } "
309
- return ""
309
+ argument = f"integer (c_int), value :: { p_name } "
310
+ return argument
310
311
311
312
312
313
def extract_directive_signature (code : str , langs : Code , kernel_name : str = None ) -> dict :
@@ -454,33 +455,39 @@ def generate_directive_function(
454
455
455
456
456
457
def allocate_array (p_type : str , size : int ) -> np .ndarray :
458
+ """Allocate a Numpy array"""
459
+ max_int = 1024
460
+ array = None
457
461
if p_type == "float*" :
458
- return np .random .rand (size ).astype (np .float32 )
462
+ array = np .random .rand (size ).astype (np .float32 )
459
463
elif p_type == "double*" :
460
- return np .random .rand (size ).astype (np .float64 )
464
+ array = np .random .rand (size ).astype (np .float64 )
461
465
elif p_type == "int*" :
462
- return np .random .randint (max_int , size = size )
466
+ array = np .random .randint (max_int , size = size )
463
467
else :
464
468
# The parameter is an array of user defined types
465
- return np .random .rand (size ).astype (np .byte )
469
+ array = np .random .rand (size ).astype (np .byte )
470
+ return array
466
471
467
472
468
473
def allocate_scalar (p_type : str , size : int ) -> np .number :
474
+ """Allocate a Numpy scalar"""
475
+ scalar = None
469
476
if p_type == "float" :
470
- return np .float32 (size )
477
+ scalar = np .float32 (size )
471
478
elif p_type == "double" :
472
- return np .float64 (size )
479
+ scalar = np .float64 (size )
473
480
elif p_type == "int" :
474
- return np .int32 (size )
481
+ scalar = np .int32 (size )
475
482
else :
476
483
# The parameter is some user defined type
477
- return np .byte (size )
484
+ scalar = np .byte (size )
485
+ return scalar
478
486
479
487
480
488
def allocate_signature_memory (data : dict , preprocessor : list = None , user_dimensions : dict = None ) -> list :
481
489
"""Allocates the data needed by a kernel and returns the arguments array"""
482
490
args = []
483
- max_int = 1024
484
491
485
492
for parameter in data .keys ():
486
493
p_type = data [parameter ][0 ]
0 commit comments