There's three members of a `D3D11_MAPPED_SUBRESOURCE`:

 1. a pointer to the beginning of the data;
 2. the number of bytes from the beginning of one row of data to the next row of data;
 3. the number of bytes from the beginning of one depth slice of data to the next depth slice of data.

As none of these members communicate anything about the actual extents of a row of data, you need to query your texture resource for a DESC or remember the column and row counts from when you created it.

The 2D layout of the data is such that there are solid rows of data with the potential of padding at the end. The row pitch in the mapping indicate the offsets you need to use to jump between rows.

Assuming you know those quantities, you would iterate your mapped data similiar to this:

    {
        uint32_t partialSum = 0u;
        // Point at the beginning of the first row
        BYTE const* rowPtr = msr.pData;
        for (size_t row = 0u; row < rows; ++row) {
            // Take the current row pointer and interpret as sequence of U32
            uint32_t const* p = reinterpret_cast<uint32_t const*>(rowPtr);
            for (size_t col = 0u; col < cols; ++col) {
                partialSum += *p;
                // Advance one U32
                ++p;
            }
            // Advance the row pointer to the beginning of the next row
            rowPtr += msr.RowPitch;
        }
    }

The in-place reinterpret of the data is fine as feature levels 10_0 and up guarantee 16-byte alignment of mappings, and feature levels below guarantee 4-byte alignment, which is enough for U32. If this would not be the case, a byte-wise copy would have to be made into a properly aligned value on the CPU side before touching it.