Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import libceed
import numpy as np
if __name__ == "__main__":
ceed = libceed.Ceed(sys.argv[1])
n = 10
x = ceed.Vector(n)
y = ceed.Vector(n)
a = np.arange(10, 10 + n, dtype="float64")
x.set_array(CEED_MEM_HOST, CEED_USE_POINTER, a)
b = x.get_array_read(CEED_MEM_DEVICE)
y.set_array(CEED_MEM_DEVICE, CEED_COPY_VALUES, b)
c = y.get_array_read(CEED_MEM_HOST)
for i in range(n):
if c[i] != 10+i:
# LCOV_EXCL_START
print("Error reading array c[%d] = %f"%(i, c[i]))
# LCOV_EXCL_STOP
y.restore_array_read()
if __name__ == "__main__":
ceed = libceed.Ceed(sys.argv[1])
n = 10
x = ceed.Vector(n)
y = ceed.Vector(n)
a = np.arange(10, 10 + n, dtype="float64")
x.set_array(MEM_HOST, CEED_USE_POINTER, a)
x_array = x.GetArray(CEED_MEM_HOST)
y.set_array(CEED_MEM_HOST, CEED_USE_POINTER, x_array)
x.restore_array()
y_array = y.get_array_read(CEED_MEM_HOST)
for i in range(n):
if y_array[i] != 10+i:
# LCOV_EXCL_START
print("Error reading array y[%d] = %f"%(i, y_array[i]))
# LCOV_EXCL_STOP
y.restore_array_read()
# Test CeedVectorGetArray state counter
import sys
from libceed import CEED_MEM_HOST
import libceed
import numpy as np
if __name__ == "__main__":
ceed = libceed.Ceed(sys.argv[1])
n = 10
x = ceed.Vector(n)
# Two write accesses should generate an error
a = x.get_array(CEED_MEM_HOST)
b = x.get_array(CEED_MEM_HOST)
# LCOV_EXCL_START
x.restore_array()
x.restore_array()
# LCOV_EXCL_STOP
from libceed import CEED_MEM_HOST, CEED_USE_POINTER
import libceed
import numpy as np
if __name__ == "__main__":
ceed = libceed.Ceed(sys.argv[1])
n = 10
x = ceed.Vector(n)
y = ceed.Vector(n)
a = np.arange(10, 10 + n, dtype="float64")
x.set_array(MEM_HOST, CEED_USE_POINTER, a)
x_array = x.GetArray(CEED_MEM_HOST)
y.set_array(CEED_MEM_HOST, CEED_USE_POINTER, x_array)
x.restore_array()
y_array = y.get_array_read(CEED_MEM_HOST)
for i in range(n):
if y_array[i] != 10+i:
# LCOV_EXCL_START
print("Error reading array y[%d] = %f"%(i, y_array[i]))
# LCOV_EXCL_STOP
y.restore_array_read()
# @file
# Test CeedVectorGetArray state counter
import sys
from libceed import CEED_MEM_HOST
import libceed
import numpy as np
if __name__ == "__main__":
ceed = libceed.Ceed(sys.argv[1])
n = 10
x = ceed.Vector(n)
# Two write accesses should generate an error
a = x.get_array(CEED_MEM_HOST)
b = x.get_array(CEED_MEM_HOST)
# LCOV_EXCL_START
x.restore_array()
x.restore_array()
# LCOV_EXCL_STOP
def check_values(ceed, x, value):
b = x.get_array_read(CEED_MEM_HOST)
for i in range(len(b)):
if b[i] != value:
# LCOV_EXCL_START
print("Error reading array b[%d] = %f"%(i,b[i]))
# LCOV_EXCL_STOP
x.restore_array_read()
# @file
# Test getArrayRead state counter
import sys
from libceed import CEED_MEM_HOST
import libceed
import numpy as np
if __name__ == "__main__":
ceed = libceed.Ceed(sys.argv[1])
n = 10
x = ceed.Vector(n)
# Two read accesses should not generate an error
a = x.GetArrayRead(CEED_MEM_HOST)
b = x.GetArrayRead(CEED_MEM_HOST)
x.RestoreArrayRead()
x.RestoreArrayRead()