int dump()

in SDAccel/userspace/src/awssak.h [203:363]


    int dump(std::ostream& ostr) const {
        /*
         * xclGetUsageInfo not available for AWSMGMT
         * xclDeviceUsage devstat;
         * int result = xclGetUsageInfo(m_handle, &devstat);
         */
        unsigned numDDR = m_devinfo.mDDRBankCount;
        ostr << "DSA name:       " << m_devinfo.mName << "\n";
        ostr << "Vendor:         " << std::hex << m_devinfo.mVendorId << std::dec << "\n";
        ostr << "Device:         " << std::hex << m_devinfo.mDeviceId << std::dec << "\n";
        ostr << "SDevice:        " << std::hex << m_devinfo.mSubsystemId << std::dec << "\n";
        ostr << "SVendor:        " << std::hex << m_devinfo.mSubsystemVendorId << std::dec << "\n";
        ostr << "DDR size:       " << "0x" << std::hex << m_devinfo.mDDRSize/1024 << std::dec << " KB\n";

        ostr << "DDR count:      " << numDDR << "\n";
        ostr << "OnChip Temp:    " << m_devinfo.mOnChipTemp << " C\n";
        //ostr << "Fan Temp:       " << m_devinfo.mFanTemp<< " C\n";
        ostr << "VCC INT:        " << m_devinfo.mVInt << " mV\n";
        ostr << "VCC AUX:        " << m_devinfo.mVAux << " mV\n";
        ostr << "VCC BRAM:       " << m_devinfo.mVBram << " mV\n";
        ostr << "OCL Frequency:\n";
        for(unsigned i= 0; i < m_devinfo.mNumClocks; ++i) {
            ostr << "  " << std::setw(7) << i << ":      " <<  m_devinfo.mOCLFrequency[i] << " MHz\n";
        }
        ostr << "PCIe:           " << "GEN" << m_devinfo.mPCIeLinkSpeed << " x " << m_devinfo.mPCIeLinkWidth << "\n";
        ostr << "DMA bi-directional threads:    " << m_devinfo.mDMAThreads << "\n";
        ostr << "MIG Calibrated: " << std::boolalpha << m_devinfo.mMigCalib << std::noboolalpha << "\n";

        /*
         * devstat via xclGetUsageInfo not available for AWSMGMT
         *
         * std::cout << "\nDevice DDR Usage:" << "\n";
         * for (unsigned i = 0; !result & (i < numDDR); i++) {
         *     std::cout << "  Bank[" << i << "].mem:  0x" << std::hex << devstat.ddrMemUsed[i] / 1024 << std::dec << " KB\n";
         *     std::cout << "  Bank[" << i << "].bo:   " << devstat.ddrBOAllocated[i] << "\n";
         * }
         * std::cout << "\nTotal DMA Transfer Metrics:" << "\n";
         * for (unsigned i = 0; !result & (i < 2); i++) {
         *     std::cout << "  Chan[" << i << "].h2c:  0x" << std::hex << devstat.h2c[i] / 1024 << std::dec << " KB\n";
         *     std::cout << "  Chan[" << i << "].c2h:  0x" << std::hex << devstat.c2h[i] / 1024 << std::dec << " KB\n";
         * }
        */

#ifdef AXI_FIREWALL
        char cbuf[80];
        struct tm *ts;
        time_t temp;
        ostr << "\nFirewall Last Error Status:\n";
        for(unsigned i= 0; i < m_errinfo.mNumFirewalls; ++i) {
            ostr << "  " << std::setw(7) << i << ":      0x" << std::hex
                 << m_errinfo.mAXIErrorStatus[i].mErrFirewallStatus << std::dec << " "
                 << parseFirewallStatus(m_errinfo.mAXIErrorStatus[i].mErrFirewallStatus) ;
            if(m_errinfo.mAXIErrorStatus[i].mErrFirewallStatus != 0x0) {
                temp = (time_t)m_errinfo.mAXIErrorStatus[i].mErrFirewallTime;
                ts = localtime(&temp);
                strftime(cbuf, sizeof(cbuf), "%a %Y-%m-%d %H:%M:%S %Z",ts);
                ostr << ". Error occurred on " << cbuf;
            }
            ostr << "\n";
        }
#endif // AXI Firewall

        // report xclbinid
        const std::string devPath = "/sys/bus/pci/devices/" + xcldev::pci_device_scanner::device_list[ m_idx ].user_name;
        std::string binid_path = devPath + "/xclbinid";
        std::ifstream ifs;
        ifs.open( binid_path.c_str(), std::ifstream::binary );
        if( ifs.good() ) {
            struct stat sb;
            stat( binid_path.c_str(), &sb );
            char fileReadBuf[ sb.st_size ];
            ifs.read( fileReadBuf, sb.st_size );
            if( ifs.gcount() > 0 ) {
                fileReadBuf[ ifs.gcount() ] = '\0';
                ostr << std::endl << "Xclbin ID:" << std::endl << "  0x" << fileReadBuf << std::endl;
            } else { // xclbinid exists, but no data read or reported
                ostr << "WARNING: 'xclbinid' invalid, unable to report xclbinid. Has the bitstream been loaded? See 'xbsak program'.\n";
            }
            ifs.close();
        }

        // get DDR bank count from mem_topology if possible
        std::string mem_path = devPath + "/mem_topology";
        ifs.open( mem_path.c_str(), std::ifstream::binary );
        if( ifs.good() ) {
            struct stat sb;
            stat( mem_path.c_str(), &sb );
            char buffer[ sb.st_size ];
            ifs.read( buffer, sb.st_size );
            if( ifs.gcount() > 0 ) {
                const int fixed_w = 13;
                mem_topology *map;
                map = (mem_topology *)buffer;
                ostr << "\nMem Topology:\n";
                ostr << "    Bank" << "         Type" << "  Base Address" << "          Size\n";
                numDDR = map->m_count;
                for( unsigned i = 0; i < numDDR; i++ ) {
                    std::string str = "DDR[" + std::to_string( i ) + "]";
                    ostr << " " << std::setw( fixed_w - 6 ) << str.substr( 0, fixed_w ); // print bank

                    if( map->m_mem_data[ i ].m_used == 0 ) {
                        str = "**UNUSED**";
                    } else {
                        std::map<MEM_TYPE, std::string> my_map = { {MEM_DDR3, "MEM_DDR3"}, {MEM_DDR4, "MEM_DDR4"},
                                                                   {MEM_DRAM, "MEM_DRAM"}, {MEM_STREAMING, "MEM_STREAMING"},
                                                                   {MEM_PREALLOCATED_GLOB, "MEM_PREALLOCATED_GLOB"}, {MEM_ARE, "MEM_ARE"} };
                        auto search = my_map.find( (MEM_TYPE)map->m_mem_data[ i ].m_type );
                        str = search->second;
                    }
                    ostr << std::setw( fixed_w ) << str;
                    std::stringstream ss;
                    ss << "0x" << std::hex << map->m_mem_data[ i ].m_base_address;          // print base address
                    ostr << " " << std::setw( fixed_w ) << ss.str().substr( 0, fixed_w );
                    ss.str( "" );
                    ss << "0x" << std::hex << map->m_mem_data[ i ].m_size;                 // print size
                    ostr << " " << std::setw( fixed_w ) << ss.str().substr( 0, fixed_w ) << std::endl;
                }
            } else { // mem_topology exists, but no data read or reported
                ostr << "WARNING: 'mem_topology' invalid, unable to report topology. Has the bitstream been loaded? See 'xbsak program'." << std::endl;
            }
            ifs.close();
        }

        ostr << "\nCompute Unit Status:\n";
        std::string iplayout_path = devPath + "/ip_layout";
        ifs.open( iplayout_path.c_str(), std::ifstream::binary );
        // Test if ip_layout file exists, if not, use legacy mode.
        if( ifs.good() ) {
            struct stat sb;
            stat( iplayout_path.c_str(), &sb );
            char fileReadBuf[ sb.st_size ];
            ifs.read( fileReadBuf, sb.st_size );
            if( ifs.gcount() > 0 ) {
                ip_layout *map = (ip_layout *)fileReadBuf;
                for( int i = 0; i < map->m_count; i++ ) {
                    static int cuCnt = 0;
                    if( map->m_ip_data[ i ].m_type == IP_KERNEL ) {
                        unsigned statusBuf;
                        xclRead(m_handle, XCL_ADDR_KERNEL_CTRL, map->m_ip_data[ i ].m_base_address, &statusBuf, 4);
                        ostr << "  CU[" << cuCnt << "]: "
                             << map->m_ip_data[ i ].m_name
                             << "@0x" << std::hex << map->m_ip_data[ i ].m_base_address << ", "
                             << std::dec << parseCUStatus( statusBuf ) << "\n";
                        cuCnt++;
                    }
                }
            } else { // ip_layout exists, but no data read or reported
                ostr << "WARNING: 'ip_layout' invalid, unable to report Compute Units. Has the bitstream been loaded? See 'xbsak program'.\n";
            }
            ifs.close();
        } else {
            // Could not find ip_layout file, reporting in legacy mode.
            unsigned buf[16];
            for (unsigned i = 0; i < 4; i++) {
                xclRead(m_handle, XCL_ADDR_KERNEL_CTRL, i * 4096, static_cast<void *>(buf), 16);
                ostr << "  " << std::setw(7) << i << ":      0x" << std::hex << buf[0] << std::dec << " " << parseCUStatus(buf[0]) << "\n";
            }
        }

        return 0;
    }