How to check if a pointer points to allocated GPU memory?

I’m wondering if there is a way to determine if a pointer points to a memory allocated on GPU or CPU.
This seems like a trivial problem, but I can’t fine the appropriate API to do this beside try to read memory and catch the error.

__host__ ​cudaError_t cudaPointerGetAttributes ( cudaPointerAttributes* attributes, const void* ptr )

Great, thanks!