Hardware and software co-optimization for the initialization failure of the ReRAM based cross-bar array