Software-Hardware Co-Design For Processing In-Memory Accelerators