How to use the libceed.CEED_MEM_HOST function in libceed

To help you get started, we’ve selected a few libceed examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t105-vec.py View on Github external
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()
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t103-vec.py View on Github external
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()
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t110-vec.py View on Github external
# 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
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t103-vec.py View on Github external
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()
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t110-vec.py View on Github external
# @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
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t101-vec.py View on Github external
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()
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t102-vec.py View on Github external
# @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()