Andreas,
I found that the previous error is the problem of initialization.
Instead of pycuda.autoinit, I made the context by myself with MAP_HOST flag.
It seems working fine now.
Thank you so much!
My code looks like below now.
##CODE START######################
import pycuda.driver as drv
drv.init()
dev = drv.Device(0)
ctx = dev.make_context(drv.ctx_flags.SCHED_AUTO | drv.ctx_flags.MAP_HOST)
k = pycuda.compiler.SourceModule("""
__global__ void krnl(float* a) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
a[i] = i;
}
""").get_function("krnl")
a = drv.pagelocked_empty((10, 10), numpy.float32,
mem_flags=drv.host_alloc_flags.DEVICEMAP)
aa = numpy.intp(a.base.get_device_pointer())
k(aa, grid=(100,1), block=(1,1,1))
ctx.pop()
##CODE END######################
On 5 December 2012 17:14, Daisuke Nishino <[email protected]> wrote:
> Andreas,
> Thank you for your reply.
>
> When I add mem_flags=pycuda.driver.host_alloc_flags.DEVICEMAP in
> pagelocked_empty(),
> it results in error:
> pycuda._driver.LogicError: cuMemHostAlloc failed: invalid value
>
> Does this mean my card doesn't support this functionality?
> I'm not sure if it is relevant, but CAN_MAP_HOST_MEMORY entry in
> pycuda.driver.Context.get_driver().get_attributes() is 1.
>
> Thanks,
> Daisuke
>
>
>
> On 5 December 2012 16:47, Andreas Kloeckner <[email protected]>wrote:
>
>> Daisuke Nishino <[email protected]> writes:
>>
>> > Hi, all*.
>> >
>> > *I have a problem using pagelocked memory.
>> > I allocated one with pagelocked_xxx or PageLockedMemoryPool, but how
>> can I
>> > pass it into a kernel?
>> > I put a simple code below.
>> > What should "aa" be?
>> >
>> > aa = pycuda.driver.Out(a) works just fine, but I guess it involves a
>> copy.
>>
>>
>> http://documen.tician.de/pycuda/driver.html#pycuda.driver.host_alloc_flags.DEVICEMAP
>>
>>
>> http://documen.tician.de/pycuda/driver.html#pycuda.driver.HostPointer.get_device_pointer
>>
>> Andreas
>>
>>
>
>
> --
> Daisuke Nishino
>
--
Daisuke Nishino
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda