Bend
Bend copied to clipboard
Script stuck when using GPU with bend-cu but not when using CPU with bend or bend-c
Reproducing the behavior
I have this code that can only execute when using bend or bend-c (or their compiled equivalent). When using the GPU with bend-cu (or their compiled equivalent) it get stuck and use half of my GPU memory.
def BASE(): # global variable
return 10
def pow_binary(number, power): # power of an int
if power < 1:
return 1
else:
bend x=power:
when x>1:
left = (x / 2)
right = x - left
mult = fork(left) * fork(right)
else:
mult = number
return mult
def get_digit(number, Nth_digit):
return (number / pow_binary(BASE(0), Nth_digit - 1)) % BASE(0)
def validate_narc(number, Nd): # Check if the number is a Narcissistic number
bend Nth_digit = Nd:
when Nth_digit > 1:
digit = get_digit(number, Nth_digit)
power_sum = pow_binary(digit, Nd) + fork(Nth_digit - 1)
else:
power_sum = pow_binary(number % BASE(0), Nd)
return power_sum == number
def main:
return validate_arm(407, 3)
The following functions work fine: get_digit(407, 1), get_digit(407, 2), get_digit(407, 3), get_digit(407, 4), pow_binary(10, 0), pow_binary(10, 1), ... Only validate_arm creates the bug.
Even more strange is that I have tried replacing number by the value 407 (while using bend-cu) like so:
def validate_narc(number, Nd): # Check if the number is a Narcissistic number
bend Nth_digit = Nd:
when Nth_digit > 1:
digit = get_digit(407, Nth_digit)
power_sum = pow_binary(digit, Nd) + fork(Nth_digit - 1)
else:
power_sum = pow_binary(number % BASE(0), Nd)
return power_sum == number
And this did not get stuck.
(Other numbers than 407 also do not work)
System Settings
- OS: WSL (Ubuntu 22.04)
- CPU: Intel i5-12600K
- GPU: GTX 1080Ti
- Cuda Version 12.3
- Updated version of bend+HVM 5 minutes ago
Additional context
No response