c++ - CUDA: Can allocate matrix once use in multi kernel? -
i have question is: if allocate 1 matrix 2d , memcpy gpu , have 2 kernel using same matrix, possible using don't memcpy matrix again kernel 2? , if auto memcpy matrix again kernel 2, take time auto memcpy again ?
you don't need transfer data host device twice, if want use in 2 kernels. once transfer it, in gpu memory , stay there until program terminates (or explicitly deallocate using e.g. cudafree
).
just pass pointer region/matrix both kernels. if first kernel modifies data , second kernel runs later (after first kernel finishes), second kernel see modified data.
Comments
Post a Comment