Skip to content

bm_get_vpu_instant_usage不生效? #162

@imaben

Description

@imaben

代码如下:


TEST_F(VPUTest, VPUUsage) {
    unsigned int card_num = 0;
    bm_status_t ret;
    ret = bm_get_card_num(&card_num);
    ASSERT_EQ(ret, BM_SUCCESS);
    std::cout << "Card num: " << card_num << std::endl;
    for (unsigned int i = 0; i < card_num; i++) {
        unsigned int chip_num = 0;
        unsigned int dev_start_index = 0;
        ret = bm_get_chip_num_from_card(i, &chip_num, &dev_start_index);
        if (ret != BM_SUCCESS) {
            std::cerr << "Error: Failed to get chip num from card " << i << ", skipping..." << std::endl;
            continue;
        }
        std::cout << "Card " << i << ": Chip num: " << chip_num << " Dev start index: " << dev_start_index << std::endl;
        for (unsigned int j = 0; j < chip_num; j++) {
            unsigned int dev_id = dev_start_index + j;
            bm_handle_t handle = nullptr;
            ret = bm_dev_request(&handle, dev_id);
            EXPECT_EQ(ret, BM_SUCCESS) << "Failed to request device " << dev_id;
            if (ret != BM_SUCCESS) {
                std::cerr << "Error: Failed to request device " << dev_id << ", skipping..." << std::endl;
                continue;
            }
            int vpu_usage = 0;
            ret = bm_get_vpu_instant_usage(handle, &vpu_usage);
            if (ret == BM_SUCCESS) {
                std::cout << "Device " << dev_id << " (Card " << i << ", Chip " << j << ") VPU usage: " << vpu_usage << std::endl;
            } else {
                std::cerr << "Error: Failed to get VPU usage for device " << dev_id << ", ret=" << ret << std::endl;
            }
            bm_dev_free(handle);
        }
    }
}

实际执行结果:

Card num: 8
Card 0: Chip num: 3 Dev start index: 0
Device 0 (Card 0, Chip 0) VPU usage: -1973305992
Device 1 (Card 0, Chip 1) VPU usage: -1973305992
Device 2 (Card 0, Chip 2) VPU usage: -1973305992
Card 1: Chip num: 3 Dev start index: 3
Device 3 (Card 1, Chip 0) VPU usage: -1973305992
Device 4 (Card 1, Chip 1) VPU usage: -1973305992
Device 5 (Card 1, Chip 2) VPU usage: -1973305992
Card 2: Chip num: 3 Dev start index: 6
Device 6 (Card 2, Chip 0) VPU usage: -1973305992
Device 7 (Card 2, Chip 1) VPU usage: -1973305992
Device 8 (Card 2, Chip 2) VPU usage: -1973305992
Card 3: Chip num: 3 Dev start index: 9
Device 9 (Card 3, Chip 0) VPU usage: -1973305992
Device 10 (Card 3, Chip 1) VPU usage: -1973305992
Device 11 (Card 3, Chip 2) VPU usage: -1973305992
Card 4: Chip num: 3 Dev start index: 12
Device 12 (Card 4, Chip 0) VPU usage: -1973305992
Device 13 (Card 4, Chip 1) VPU usage: -1973305992
Device 14 (Card 4, Chip 2) VPU usage: -1973305992
Card 5: Chip num: 3 Dev start index: 15
Device 15 (Card 5, Chip 0) VPU usage: -1973305992
Device 16 (Card 5, Chip 1) VPU usage: -1973305992
Device 17 (Card 5, Chip 2) VPU usage: -1973305992
Card 6: Chip num: 3 Dev start index: 18
Device 18 (Card 6, Chip 0) VPU usage: -1973305992
Device 19 (Card 6, Chip 1) VPU usage: -1973305992
Device 20 (Card 6, Chip 2) VPU usage: -1973305992
Card 7: Chip num: 3 Dev start index: 21
Device 21 (Card 7, Chip 0) VPU usage: -1973305992
Device 22 (Card 7, Chip 1) VPU usage: -1973305992
Device 23 (Card 7, Chip 2) VPU usage: -1973305992

看着usage完全不生效,每次取出来的数值都在变,像是内存随机值

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions