spmp function implementation