예제 #1
0
  void py_curand_get_direction_vectors(
      curandDirectionVectorSet_t set, py::object dst, int count)
  {
    int n = 0;

    py_buffer_wrapper buf_wrapper;
    buf_wrapper.get(dst.ptr(), PyBUF_ANY_CONTIGUOUS | PyBUF_WRITABLE);

    void *buf = buf_wrapper.m_buf.buf;
    PYCUDA_BUFFER_SIZE_T len = buf_wrapper.m_buf.len;

    if (CURAND_DIRECTION_VECTORS_32_JOEKUO6 == set
#if CUDAPP_CUDA_VERSION >= 4000
      || CURAND_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6 == set
#endif
    ) {
      curandDirectionVectors32_t *vectors;
      CURAND_CALL_GUARDED(curandGetDirectionVectors32, (&vectors, set));
      while (count > 0) {
        int size = ((count > 20000) ? 20000 : count)*sizeof(curandDirectionVectors32_t);
        memcpy((unsigned int *)buf+n*20000*sizeof(curandDirectionVectors32_t)/sizeof(unsigned int), vectors, size);
	count -= size/sizeof(curandDirectionVectors32_t);
        n++;
      }
    }
#if CUDAPP_CUDA_VERSION >= 4000
    if (CURAND_DIRECTION_VECTORS_64_JOEKUO6 == set
      || CURAND_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6 == set) {
      curandDirectionVectors64_t *vectors;
      CURAND_CALL_GUARDED(curandGetDirectionVectors64, (&vectors, set));
      while (count > 0) {
        int size = ((count > 20000) ? 20000 : count)*sizeof(curandDirectionVectors64_t);
        memcpy((unsigned long long *)buf+n*20000*sizeof(curandDirectionVectors64_t)/sizeof(unsigned long long), vectors, size);
	count -= size/sizeof(curandDirectionVectors64_t);
        n++;
      }
    }
#endif
  }
예제 #2
0
  void py_curand_get_direction_vectors(
      curandDirectionVectorSet_t set, py::object dst, int count)
  {
    void *buf;
    PYCUDA_BUFFER_SIZE_T len;
    int n = 0;

    if (PyObject_AsWriteBuffer(dst.ptr(), &buf, &len))
      throw py::error_already_set();
    if (CURAND_DIRECTION_VECTORS_32_JOEKUO6 == set
#if CUDAPP_CUDA_VERSION >= 4000
      || CURAND_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6 == set
#endif
    ) {
      curandDirectionVectors32_t *vectors;
      CURAND_CALL_GUARDED(curandGetDirectionVectors32, (&vectors, set));
      while (count > 0) {
        int size = ((count > 20000) ? 20000 : count)*sizeof(curandDirectionVectors32_t);
        memcpy((unsigned int *)buf+n*20000*sizeof(curandDirectionVectors32_t)/sizeof(unsigned int), vectors, size);
	count -= size/sizeof(curandDirectionVectors32_t);
        n++;
      }
    }
#if CUDAPP_CUDA_VERSION >= 4000
    if (CURAND_DIRECTION_VECTORS_64_JOEKUO6 == set
      || CURAND_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6 == set) {
      curandDirectionVectors64_t *vectors;
      CURAND_CALL_GUARDED(curandGetDirectionVectors64, (&vectors, set));
      while (count > 0) {
        int size = ((count > 20000) ? 20000 : count)*sizeof(curandDirectionVectors64_t);
        memcpy((unsigned long long *)buf+n*20000*sizeof(curandDirectionVectors64_t)/sizeof(unsigned long long), vectors, size);
	count -= size/sizeof(curandDirectionVectors64_t);
        n++;
      }
    }
#endif
  }
예제 #3
0
  void py_curand_get_scramble_constants32(py::object dst, int count)
  {
    void *buf;
    PYCUDA_BUFFER_SIZE_T len;
    int n = 0;

    if (PyObject_AsWriteBuffer(dst.ptr(), &buf, &len))
      throw py::error_already_set();
    unsigned int *vectors;
    CURAND_CALL_GUARDED(curandGetScrambleConstants32, (&vectors));
// Documentation does not mention number of dimensions
// Assuming the same as in getDirectionVectors*
    while (count > 0) {
      int size = ((count > 20000) ? 20000 : count)*sizeof(unsigned int);
      memcpy((unsigned int *)buf+n*20000, vectors, size);
      count -= size/sizeof(unsigned int);
      n++;
    }
  }
예제 #4
0
  void py_curand_get_scramble_constants32(py::object dst, int count)
  {
    int n = 0;

    py_buffer_wrapper buf_wrapper;
    buf_wrapper.get(dst.ptr(), PyBUF_ANY_CONTIGUOUS | PyBUF_WRITABLE);

    void *buf = buf_wrapper.m_buf.buf;
    PYCUDA_BUFFER_SIZE_T len = buf_wrapper.m_buf.len;

    unsigned int *vectors;
    CURAND_CALL_GUARDED(curandGetScrambleConstants32, (&vectors));
// Documentation does not mention number of dimensions
// Assuming the same as in getDirectionVectors*
    while (count > 0) {
      int size = ((count > 20000) ? 20000 : count)*sizeof(unsigned int);
      memcpy((unsigned int *)buf+n*20000, vectors, size);
      count -= size/sizeof(unsigned int);
      n++;
    }
  }