Solved by ptrblck in post #9 
              
              
                Yes, the nonzero would need some time to be executed, but you are right that your profiling is wrong as it accumulates the model forward time into the nonzero operation, so it looks as if the nonzero op is more expensive than it is. 
As mentioned before, this operation is synchronizing, so should be…