Shared memory, per-thread stats

Reviewer: @harshsin