# Defines the function Sum with two parameters: start and target
def Sum(start, target):
if start == target:
# If the value of start is the same as target, returns start.
return start
else:
# If start is not equal to target, recursively call Sum with
# start incremented by 1, and add the result to start.
return start + Sum(start + 1, target)
def main():
# This translates to (1 + (2 + (3 + (...... + (999999 + 1000000)))))
# Note that this will overflow the maximum value of a number in Bend
return Sum(1, 1_000_000)
bend run-cu sequential_sum.bend
Failed to launch kernels. Error code: invalid argument.
Errors:
Failed to parse result from HVM.
System Settings
$ bend --version
bend-lang 0.2.36
$ hvm --version
hvm 2.0.22
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Aug_14_10:10:22_PDT_2024
Cuda compilation tools, release 12.6, V12.6.68
Build cuda_12.6.r12.6/compiler.34714021_0
Reproducing the behavior
running example code with cuda backend fails:
sequential_sum.bend
Failed to launch kernels. Error code: invalid argument. Errors: Failed to parse result from HVM.
System Settings
$ bend --version bend-lang 0.2.36
$ hvm --version hvm 2.0.22
$ nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2024 NVIDIA Corporation Built on Wed_Aug_14_10:10:22_PDT_2024 Cuda compilation tools, release 12.6, V12.6.68 Build cuda_12.6.r12.6/compiler.34714021_0