MatX for element-wise tensor calculation #1113
-
|
Hi! I have a cluster of expressions with the form like p=Aexp(-(E-Fx)/(kBT)) to deal with in my project. I tried both MatX (numpy and matlab like) and thrust (with functor and transform function). It turns out that MatX is about half as fast as thrust. I think it reasonable, since MatX provides more user-friendly syntax. However, I still want to verify whether this is consistent with developers' expectations. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Hi @CrreeL , thanks for reporting this. We definitely do not expect thrust to be faster. We will test it out on our end. Can you please provide a sample of what your thrust syntax looks like so we can compare? |
Beta Was this translation helpful? Give feedback.
-
|
I tried MATX_DEVICE_MEMORY, and achieved significant speed up. Indeed, MatX is faster than thrust (transform +hand-writen functor), at least for my case, which is calculating element-wise expressions like p=Aexp(-(E-Fx)/(kBT)). |
Beta Was this translation helpful? Give feedback.
Hi @CrreeL , we do not necessarily think it should be faster than Thrust, but it shouldn't be slower. Both should use the same constructs under the hood, but there are cases where I would expect it to be the fastest.
As far as benchmarking,
make_tensorby default uses managed memory, and your first iteration of the loop with page the memory in and out of the GPU, which has a large negative contribution to the runtime. There are other reasons for the slowness on the first loop too, and in general, you should never take the first iteration as part of your measurements. For simple element-wise computations like you're doing there are likely only two sources of long time penalties: