您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sys_max函数代码示例

51自学网 2021-06-03 08:37:15
  C++
这篇教程C++ sys_max函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sys_max函数的典型用法代码示例。如果您正苦于以下问题:C++ sys_max函数的具体用法?C++ sys_max怎么用?C++ sys_max使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sys_max函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: test_item4

static int test_item4(void){    int rc = TC_PASS;    TYPE_VALUE* target_addr = NULL;    TYPE_VALUE* source_addr = NULL;    TYPE_VALUE source_value = 0;    TYPE_VALUE expect_value = 0;    int num_proc = 0;    int my_proc = 0;    num_proc = _num_pes();    my_proc = _my_pe();    pWrk = shmalloc(sizeof(*pWrk) * sys_max(1/2 + 1, _SHMEM_REDUCE_MIN_WRKDATA_SIZE));    if (pWrk)    {        source_addr = shmalloc(sizeof(*source_addr));        target_addr = source_addr;    }    if (target_addr && source_addr)    {        TYPE_VALUE value = DEFAULT_VALUE;        int j = 0;        /* Set my value */        source_value = ( my_proc < OVERFLOW_FACTORIAL_LIMIT ? (TYPE_VALUE)(my_proc + 1) : 1);        *source_addr = source_value;        /* Define expected value */        expect_value = 1;        {            int k = ( num_proc <= OVERFLOW_FACTORIAL_LIMIT ? num_proc : OVERFLOW_FACTORIAL_LIMIT);            while (k) expect_value *= k--;        }        /* This guarantees that PE set initial value before peer change one */        for ( j = 0; j < _SHMEM_REDUCE_SYNC_SIZE; j++ )        {            pSync[j] = _SHMEM_SYNC_VALUE;        }        shmem_barrier_all();        /* Put value to peer */        FUNC_VALUE(target_addr, source_addr, 1, 0, 0, num_proc, pWrk, pSync);        /* Get value put by peer:         * These routines start the remote transfer and may return before the data         * is delivered to the remote PE         */        shmem_barrier_all();        {            int total_wait = 0;            while (sys_fcompare(*target_addr, DEFAULT_VALUE) && total_wait < 1000 * WAIT_COUNT)            {                total_wait++;                usleep(1);            }            value = *target_addr;        }        rc = (sys_fcompare(expect_value, value) ? TC_PASS : TC_FAIL);        log_debug(OSH_TC, "my#%d source = %Lf expected = %Lf actual = %Lf/n",                           my_proc, (long double)source_value, (long double)expect_value, (long double)value);    }    else    {        rc = TC_SETUP_FAIL;    }    if (source_addr)    {        shfree(source_addr);    }    if (pWrk)    {        shfree(pWrk);        pWrk = NULL;    }    return rc;}
开发者ID:alex-mikheev,项目名称:tests-mellanox,代码行数:85,


示例2: test_item5

static int test_item5(void){    int rc = TC_PASS;    TYPE_VALUE* target_addr = NULL;    TYPE_VALUE* source_addr = NULL;    TYPE_VALUE source_value = 0;    TYPE_VALUE expect_value = 0;    int my_proc = 0;    my_proc = _my_pe();    target_addr = (TYPE_VALUE*)shmalloc(sizeof(*target_addr) * __max_buffer_size);    source_addr = (TYPE_VALUE*)shmalloc(sizeof(*source_addr) * __max_buffer_size);    if (target_addr && source_addr)    {        TYPE_VALUE value = DEFAULT_VALUE;        int i = 0;        int j = 0;        long cur_buf_size = 0;        for (i = 0; (i < __cycle_count) && (rc == TC_PASS); i++)        {            cur_buf_size = sys_max(1, (i + 1) * __max_buffer_size / __cycle_count);            pWrk = shmalloc(sizeof(*pWrk) * sys_max(cur_buf_size/2 + 1, _SHMEM_REDUCE_MIN_WRKDATA_SIZE));            if (pWrk)            {                /* Set initial target value */                value = DEFAULT_VALUE;                fill_buffer((void *)target_addr, cur_buf_size, (void *)&value, sizeof(value));                /* Give some time to all PE for setting their values */                shmem_barrier_all();                /* Set my value */                source_value = (TYPE_VALUE)(BASE_VALUE + my_proc);                fill_buffer((void *)source_addr, cur_buf_size, (void *)&source_value, sizeof(source_value));                /* Define expected value */                expect_value = source_value;                /* This guarantees that PE set initial value before peer change one */                for ( j = 0; j < _SHMEM_REDUCE_SYNC_SIZE; j++ )                {                    pSync[j] = _SHMEM_SYNC_VALUE;                }                shmem_barrier_all();                /* Put value to peer */                FUNC_VALUE(target_addr, source_addr, cur_buf_size, my_proc, 0, 1, pWrk, pSync);                /* Get value put by peer:                 * These routines start the remote transfer and may return before the data                 * is delivered to the remote PE                 */                shmem_barrier_all();                {                    int wait = WAIT_COUNT;                    while (wait--)                    {                        value = *target_addr;                        if (sys_fcompare(expect_value, value)) break;                        sleep(1);                    }                }                rc = (!compare_buffer_with_const_longdouble(target_addr, cur_buf_size, expect_value) ? TC_PASS : TC_FAIL);                log_debug(OSH_TC, "my#%d source = %Lf expected = %Lf actual = %Lf buffer size = %lld/n",                                   my_proc, (long double)source_value, (long double)expect_value, (long double)value, (INT64_TYPE)cur_buf_size);                if (rc)                {                    TYPE_VALUE* check_addr = target_addr;                    int odd_index = compare_buffer_with_const_longdouble(check_addr, cur_buf_size, expect_value);                    int show_index = (odd_index > 1 ? odd_index - 2 : 0);                    int show_size = sizeof(*check_addr) * sys_min(3, cur_buf_size - odd_index - 1);                    log_debug(OSH_TC, "index of incorrect value: 0x%08X (%d)/n", odd_index - 1, odd_index - 1);                    log_debug(OSH_TC, "buffer interval: 0x%08X - 0x%08X/n", show_index, show_index + show_size);                    show_buffer(check_addr + show_index, show_size);                }                shfree(pWrk);            } else {                rc = TC_SETUP_FAIL;            }        }    }    else    {        rc = TC_SETUP_FAIL;    }    if (source_addr)    {        shfree(source_addr);    }    if (target_addr)//.........这里部分代码省略.........
开发者ID:alex-mikheev,项目名称:tests-mellanox,代码行数:101,


示例3: test_item5

static int test_item5(void){    int rc = TC_PASS;    static TYPE_VALUE shmem_addr[MAX_BUFFER_SIZE];    static TYPE_VALUE send_addr[MAX_BUFFER_SIZE];    TYPE_VALUE my_value = 0;    TYPE_VALUE peer_value = 0;    TYPE_VALUE expect_value = 0;    int num_proc = 0;    int my_proc = 0;    int peer_proc = 0;    num_proc = _num_pes();    my_proc = _my_pe();    {        INT64_TYPE i = 0;        long cur_buf_size = 0;        for (i = 0; (i < __cycle_count) && (rc == TC_PASS); i++)        {            cur_buf_size = sys_max(1, (i + 1) * MAX_BUFFER_SIZE / __cycle_count);            /* Set my value */            my_value = (-1);            fill_buffer((void *)shmem_addr, cur_buf_size, (void *)&my_value, sizeof(my_value));            /* Give some time to all PE for setting their values */            shmem_barrier_all();            /* Define peer and it value */            peer_proc = (my_proc + 1) % num_proc;            peer_value = (peer_proc % 2 ? 1 : -1) * (i * (MAX_VALUE / __cycle_count));            fill_buffer((void *)send_addr, cur_buf_size, (void *)&peer_value, sizeof(peer_value));            /* Define expected value */            expect_value = (my_proc % 2 ? 1 : -1) * (i * (MAX_VALUE / __cycle_count));            /* Get value put by peer */            FUNC_VALUE(shmem_addr, send_addr, cur_buf_size, peer_proc);            /* Get value put by peer:             * These routines start the remote transfer and may return before the data             * is delivered to the remote PE             */            wait_for_put_completion(peer_proc,10 /* wait for 10 secs */);            rc = (!compare_buffer_with_const_longdouble(shmem_addr, cur_buf_size, expect_value) ? TC_PASS : TC_FAIL);            log_debug(OSH_TC, "my(#%d:%Lf) peer(#%d:%Lf) expected = %Lf buffer size = %lld/n",                               my_proc, (long double)my_value, peer_proc, (long double)peer_value, (long double)expect_value, (INT64_TYPE)1);            if (rc)            {                TYPE_VALUE* check_addr = shmem_addr;                int odd_index = compare_buffer_with_const_longdouble(check_addr, cur_buf_size, expect_value);                int show_index = (odd_index > 1 ? odd_index - 2 : 0);                int show_size = sizeof(*check_addr) * sys_min(3, cur_buf_size - odd_index - 1);                log_debug(OSH_TC, "index of incorrect value: 0x%08X (%d)/n", odd_index - 1, odd_index - 1);                log_debug(OSH_TC, "buffer interval: 0x%08X - 0x%08X/n", show_index, show_index + show_size);                show_buffer(check_addr + show_index, show_size);            }        }    }    return rc;}
开发者ID:alex-mikheev,项目名称:tests-mellanox,代码行数:68,


示例4: test_item8

static int test_item8(void){    int rc = TC_PASS;    static TYPE_VALUE target_addr[MAX_BUFFER_SIZE * 2];    static TYPE_VALUE source_addr[MAX_BUFFER_SIZE * 2];    TYPE_VALUE source_value = 0;    TYPE_VALUE expect_value = 0;    int num_proc = 0;    int my_proc = 0;    long* pSyncMult = NULL;    TYPE_VALUE* pWrkMult = NULL;    int pSyncNum = 2;    int pWrkNum = 2;    num_proc = _num_pes();    my_proc = _my_pe();    pSyncMult = shmalloc(sizeof(*pSyncMult) * pSyncNum * _SHMEM_REDUCE_SYNC_SIZE);    if (pSyncMult)    {        TYPE_VALUE value = DEFAULT_VALUE;        int i = 0;        int j = 0;        long cur_buf_size = 0;        for ( j = 0; j < pSyncNum * _SHMEM_REDUCE_SYNC_SIZE; j++ )        {            pSyncMult[j] = _SHMEM_SYNC_VALUE;        }        /* Give some time to all PE for setting their values */        shmem_barrier_all();        pWrkMult = shmalloc(sizeof(*pWrkMult) * pWrkNum * sys_max(MAX_BUFFER_SIZE, _SHMEM_REDUCE_MIN_WRKDATA_SIZE));        if (pWrkMult)        {            value = DEFAULT_VALUE;            source_value = ( my_proc < OVERFLOW_FACTORIAL_LIMIT ? (TYPE_VALUE)(my_proc + 1) : 1);            fill_buffer((void *)source_addr, MAX_BUFFER_SIZE * 2, (void *)&source_value, sizeof(source_value));            fill_buffer((void *)target_addr, MAX_BUFFER_SIZE * 2, (void *)&value, sizeof(value));            shmem_barrier_all();            for (i = 0; (i < __cycle_count) && (rc == TC_PASS); i++)            {                cur_buf_size = sys_max(1, (i + 1) * MAX_BUFFER_SIZE / __cycle_count);                /* Set initial target value */                value = DEFAULT_VALUE;                /* Set my value */                source_value = ( my_proc < OVERFLOW_FACTORIAL_LIMIT ? (TYPE_VALUE)(my_proc + 1) : 1);                /* Define expected value */                expect_value = 1;                if (my_proc % 2)    expect_value = DEFAULT_VALUE;                else                {                    int k = ( num_proc <= OVERFLOW_FACTORIAL_LIMIT ? num_proc : OVERFLOW_FACTORIAL_LIMIT);                    while (k)                    {                        if (k % 2)  expect_value *= k;                        k--;                    }                }                /* Put value to peer */                FUNC_VALUE(target_addr + (i % 2) * MAX_BUFFER_SIZE, source_addr + (i % 2) * MAX_BUFFER_SIZE, cur_buf_size, 0, 1, ((num_proc / 2) + (num_proc % 2)), pWrkMult + (i % pWrkNum) * sys_max(MAX_BUFFER_SIZE, _SHMEM_REDUCE_MIN_WRKDATA_SIZE),  pSyncMult + (i % pSyncNum) * _SHMEM_REDUCE_SYNC_SIZE);                rc = (!compare_buffer_with_const(target_addr + (i % 2) * MAX_BUFFER_SIZE, cur_buf_size, &expect_value, sizeof(expect_value)) ? TC_PASS : TC_FAIL);                log_debug(OSH_TC, "my#%d source = %Lf expected = %Lf actual = %Lf buffer size = %lld/n",                                   my_proc, (long double)source_value, (long double)expect_value, (long double)value, (INT64_TYPE)cur_buf_size);                if (rc)                {                    TYPE_VALUE* check_addr = target_addr + (i % 2) * MAX_BUFFER_SIZE;                    int odd_index = compare_buffer_with_const(check_addr, cur_buf_size, &expect_value, sizeof(expect_value));                    int show_index = (odd_index > 1 ? odd_index - 2 : 0);                    int show_size = sizeof(*check_addr) * sys_min(3, cur_buf_size - odd_index - 1);                    log_debug(OSH_TC, "index of incorrect value: 0x%08X (%d)/n", odd_index - 1, odd_index - 1);                    log_debug(OSH_TC, "buffer interval: 0x%08X - 0x%08X/n", show_index, show_index + show_size);                    show_buffer(check_addr + show_index, show_size);                }                fill_buffer((void *)(source_addr + (i % 2) * MAX_BUFFER_SIZE), cur_buf_size, (void *)&source_value, sizeof(source_value));                fill_buffer((void *)(target_addr + (i % 2) * MAX_BUFFER_SIZE ), cur_buf_size, (void *)&value, sizeof(value));            }            shfree(pWrkMult);        } else {            rc = TC_SETUP_FAIL;        }        shfree(pSyncMult);    } else {        rc = TC_SETUP_FAIL;    }    return rc;}
开发者ID:alex-mikheev,项目名称:tests-mellanox,代码行数:95,


示例5: test_item8

static int test_item8(void){    int rc = TC_PASS;    static TYPE_VALUE target_addr[MAX_BUFFER_SIZE];    static TYPE_VALUE source_addr[MAX_BUFFER_SIZE];    TYPE_VALUE source_value = 0;    TYPE_VALUE expect_value = 0;    int num_proc = 0;    int my_proc = 0;    num_proc = _num_pes();    my_proc = _my_pe();    {        TYPE_VALUE value = DEFAULT_VALUE;        int i = 0;        int j = 0;        long cur_buf_size = 0;        for (i = 0; (i < __cycle_count) && (rc == TC_PASS); i++)        {            cur_buf_size = sys_max(1, (i + 1) * MAX_BUFFER_SIZE / __cycle_count);            pWrk = shmalloc(sizeof(*pWrk) * sys_max(cur_buf_size/2 + 1, _SHMEM_REDUCE_MIN_WRKDATA_SIZE));            if (pWrk)            {                /* Set initial target value */                value = DEFAULT_VALUE;                fill_buffer((void *)target_addr, cur_buf_size, (void *)&value, sizeof(value));                /* Give some time to all PE for setting their values */                shmem_barrier_all();                /* Set my value */                source_value = (TYPE_VALUE)( my_proc % 2 ? my_proc : (my_proc == 0 ? BASE_VALUE : num_proc ));                fill_buffer((void *)source_addr, cur_buf_size, (void *)&source_value, sizeof(source_value));                /* Define expected value */                expect_value = ( my_proc % 2 ? DEFAULT_VALUE : ( num_proc > 2 ? ((TYPE_VALUE)BASE_VALUE & (TYPE_VALUE)num_proc) : (TYPE_VALUE)BASE_VALUE ));                /* This guarantees that PE set initial value before peer change one */                for ( j = 0; j < _SHMEM_REDUCE_SYNC_SIZE; j++ )                {                    pSync[j] = _SHMEM_SYNC_VALUE;                }                shmem_barrier_all();                int in_active_set = check_within_active_set(0, 1, ((num_proc / 2) + (num_proc % 2)), my_proc, num_proc);                if ( in_active_set ) {                    /* Put value to peer */                    FUNC_VALUE(target_addr, source_addr, cur_buf_size, 0, 1, ((num_proc / 2) + (num_proc % 2)), pWrk, pSync);                }                /* Get value put by peer:                 * These routines start the remote transfer and may return before the data                 * is delivered to the remote PE                 */                shmem_barrier_all();                {                    int wait = WAIT_COUNT;                    while (wait--)                    {                        value = *target_addr;                        if (expect_value == value) break;                        sleep(1);                    }                }                if ( in_active_set ) {                    rc = (!compare_buffer_with_const(target_addr, cur_buf_size, &expect_value, sizeof(expect_value)) ? TC_PASS : TC_FAIL);                    log_debug(OSH_TC, "my#%d source = %lld expected = %lld actual = %lld buffer size = %lld/n",                                       my_proc, (INT64_TYPE)source_value, (INT64_TYPE)expect_value, (INT64_TYPE)value, (INT64_TYPE)cur_buf_size);                    if (rc)                    {                        TYPE_VALUE* check_addr = target_addr;                        int odd_index = compare_buffer_with_const(check_addr, cur_buf_size, &expect_value, sizeof(expect_value));                        int show_index = (odd_index > 1 ? odd_index - 2 : 0);                        int show_size = sizeof(*check_addr) * sys_min(3, cur_buf_size - odd_index - 1);                        log_debug(OSH_TC, "index of incorrect value: 0x%08X (%d)/n", odd_index - 1, odd_index - 1);                        log_debug(OSH_TC, "buffer interval: 0x%08X - 0x%08X/n", show_index, show_index + show_size);                        show_buffer(check_addr + show_index, show_size);                    }                }                shfree(pWrk);            } else {                rc = TC_SETUP_FAIL;            }        }    }    return rc;}
开发者ID:openshmem-org,项目名称:tests-mellanox,代码行数:97,


示例6: test_item3

static int test_item3(void){    int rc = TC_PASS;    TYPE_VALUE* target_addr = NULL;    TYPE_VALUE* source_addr = NULL;    TYPE_VALUE source_value = 0;    TYPE_VALUE expect_value = 0;    int my_proc = 0;    my_proc = _my_pe();    pWrk = shmalloc(sizeof(*pWrk) * sys_max(1/2 + 1, _SHMEM_REDUCE_MIN_WRKDATA_SIZE));    if (pWrk)    {        source_addr = shmalloc(sizeof(*source_addr));        target_addr = source_addr;    }    if (target_addr && source_addr)    {        TYPE_VALUE value = DEFAULT_VALUE;        int j = 0;        /* Set my value */        source_value = (TYPE_VALUE)(BASE_VALUE + my_proc);        *source_addr = source_value;        /* Define expected value */        expect_value = source_value;        /* This guarantees that PE set initial value before peer change one */        for ( j = 0; j < _SHMEM_REDUCE_SYNC_SIZE; j++ )        {            pSync[j] = _SHMEM_SYNC_VALUE;        }        shmem_barrier_all();        /* Put value to peer */        FUNC_VALUE(target_addr, source_addr, 1, my_proc, 0, 1, pWrk, pSync);        /* Get value put by peer:         * These routines start the remote transfer and may return before the data         * is delivered to the remote PE         */        shmem_barrier_all();        {            int total_wait = 0;            while (*target_addr == DEFAULT_VALUE && total_wait < 1000 * WAIT_COUNT)            {                total_wait++;                usleep(1);            }            value = *target_addr;        }        rc = (expect_value == value ? TC_PASS : TC_FAIL);        log_debug(OSH_TC, "my#%d source = %lld expected = %lld actual = %lld/n",                           my_proc, (INT64_TYPE)source_value, (INT64_TYPE)expect_value, (INT64_TYPE)value);    }    else    {        rc = TC_SETUP_FAIL;    }    if (source_addr)    {        shfree(source_addr);    }    if (pWrk)    {        shfree(pWrk);        pWrk = NULL;    }    return rc;}
开发者ID:openshmem-org,项目名称:tests-mellanox,代码行数:78,


示例7: test_item5

static int test_item5(void){    int rc = TC_PASS;    static TYPE_VALUE shmem_addr[MAX_BUFFER_SIZE];    static TYPE_VALUE recv_addr[MAX_BUFFER_SIZE];    TYPE_VALUE my_value = 0;    TYPE_VALUE peer_value = 0;    TYPE_VALUE expect_value = 0;    int num_proc = 0;    int my_proc = 0;    int peer_proc = 0;    num_proc = _num_pes();    my_proc = _my_pe();    {        INT64_TYPE i = 0;        long cur_buf_size = 0;        my_value = 0;        for (i = 0; (i < __cycle_count) && (rc == TC_PASS); i++)        {            /* Set my value */            my_value = (my_proc % 2 ? 1 : -1) * (i * (MAX_VALUE / __cycle_count));            cur_buf_size = sys_max(1, (i + 1) * MAX_BUFFER_SIZE / __cycle_count);            fill_buffer((void *)shmem_addr, cur_buf_size, (void *)&my_value, sizeof(my_value));            /* Give some time to all PE for setting their values */            shmem_barrier_all();            /* Define peer and it value */            peer_proc = (my_proc + 1) % num_proc;            peer_value = (peer_proc % 2 ? 1 : -1) * (i * (MAX_VALUE / __cycle_count));            /* Define expected value */            expect_value = peer_value;            /* Get value from peer */            FUNC_VALUE(recv_addr, shmem_addr, cur_buf_size, peer_proc);            rc = (!compare_buffer_with_const(recv_addr, cur_buf_size, &expect_value, sizeof(expect_value)) ? TC_PASS : TC_FAIL);            log_debug(OSH_TC, "my(#%d:%Lf) peer(#%d:%Lf) expected = %Lf buffer size = %lld/n",                               my_proc, (long double)my_value, peer_proc, (long double)peer_value, (long double)expect_value, (INT64_TYPE)cur_buf_size);            if (rc)            {                TYPE_VALUE* check_addr = recv_addr;                int odd_index = compare_buffer_with_const(check_addr, cur_buf_size, &expect_value, sizeof(expect_value));                int show_index = (odd_index > 1 ? odd_index - 2 : 0);                int show_size = sizeof(*check_addr) * sys_min(3, cur_buf_size - odd_index - 1);                log_debug(OSH_TC, "index of incorrect value: 0x%08X (%d)/n", odd_index - 1, odd_index - 1);                log_debug(OSH_TC, "buffer interval: 0x%08X - 0x%08X/n", show_index, show_index + show_size);                show_buffer(check_addr + show_index, show_size);            }            shmem_barrier_all();        }    }    return rc;}
开发者ID:openshmem-org,项目名称:tests-mellanox,代码行数:63,


示例8: test_item3

static int test_item3(void){    int rc = TC_PASS;    TYPE_VALUE* shmem_addr = NULL;    TYPE_VALUE* recv_addr = NULL;    TYPE_VALUE my_value = 0;    TYPE_VALUE peer_value = 0;    TYPE_VALUE expect_value = 0;    int my_proc = 0;    int peer_proc = 0;    my_proc = _my_pe();    shmem_addr = (TYPE_VALUE*)shmalloc(sizeof(*shmem_addr) * __max_buffer_size);    recv_addr = (TYPE_VALUE*)sys_malloc(sizeof(*recv_addr) * __max_buffer_size);    if (shmem_addr && recv_addr)    {        INT64_TYPE i = 0;        long cur_buf_size = 0;        my_value = 0;        for (i = 0; (i < __cycle_count) && (rc == TC_PASS); i++)        {            /* Set my value */            my_value = (my_proc % 2 ? 1 : -1) * (i * (MAX_VALUE / __cycle_count));            cur_buf_size = sys_max(1, (i + 1) * __max_buffer_size / __cycle_count);            fill_buffer((void *)shmem_addr, cur_buf_size, (void *)&my_value, sizeof(my_value));            /* Give some time to all PE for setting their values */            shmem_barrier_all();            /* Define peer and it value */            peer_proc = my_proc;            peer_value = my_value;            /* Define expected value */            expect_value = peer_value;            /* Get value from peer */            FUNC_VALUE(recv_addr, shmem_addr, cur_buf_size, peer_proc);            rc = (!compare_buffer_with_const(recv_addr, cur_buf_size, &expect_value, sizeof(expect_value)) ? TC_PASS : TC_FAIL);            log_debug(OSH_TC, "my(#%d:%lld) peer(#%d:%lld) expected = %lld buffer size = %lld/n",                               my_proc, (INT64_TYPE)my_value, peer_proc, (INT64_TYPE)peer_value, (INT64_TYPE)expect_value, (INT64_TYPE)cur_buf_size);            if (rc)            {                TYPE_VALUE* check_addr = recv_addr;                int odd_index = compare_buffer_with_const(check_addr, cur_buf_size, &expect_value, sizeof(expect_value));                int show_index = (odd_index > 1 ? odd_index - 2 : 0);                int show_size = sizeof(*check_addr) * sys_min(3, cur_buf_size - odd_index - 1);                log_debug(OSH_TC, "index of incorrect value: 0x%08X (%d)/n", odd_index - 1, odd_index - 1);                log_debug(OSH_TC, "buffer interval: 0x%08X - 0x%08X/n", show_index, show_index + show_size);                show_buffer(check_addr + show_index, show_size);            }            shmem_barrier_all();        }    }    else    {        rc = TC_SETUP_FAIL;    }    if (recv_addr)    {        sys_free(recv_addr);    }    if (shmem_addr)    {        shfree(shmem_addr);    }    return rc;}
开发者ID:alex-mikheev,项目名称:tests-mellanox,代码行数:78,


示例9: test_item6

static int test_item6(void){    int rc = TC_PASS;    static TYPE_VALUE shmem_addr[MAX_BUFFER_SIZE];    static TYPE_VALUE send_addr[MAX_BUFFER_SIZE];    TYPE_VALUE my_value = 0;    TYPE_VALUE peer_value = 0;    TYPE_VALUE expect_value = 0;    int num_proc = 0;    int my_proc = 0;    int root_proc = 0;    num_proc = _num_pes();    my_proc = _my_pe();    {        TYPE_VALUE value = DEFAULT_VALUE;        int i = 0;        int j = 0;        long cur_buf_size = 0;        for (i = 0; (i < __cycle_count) && (rc == TC_PASS); i++)        {            cur_buf_size = sys_max(1, (i + 1) * MAX_BUFFER_SIZE / __cycle_count);            /* Set my value */            my_value = DEFAULT_VALUE;            fill_buffer((void *)shmem_addr, cur_buf_size, (void *)&my_value, sizeof(my_value));            /* Give some time to all PE for setting their values */            shmem_barrier_all();            /* Define peer and it value */            peer_value = (i * (MAX_VALUE / __cycle_count));            fill_buffer((void *)send_addr, cur_buf_size, (void *)&peer_value, sizeof(peer_value));            /* Set root */            root_proc = 0;            /* Define expected value */            expect_value = (((my_proc % 2) == 0) && (my_proc != root_proc) ? peer_value : DEFAULT_VALUE);            /* This guarantees that PE set initial value before peer change one */            for ( j = 0; j < _SHMEM_COLLECT_SYNC_SIZE; j++ )            {                pSync[j] = _SHMEM_SYNC_VALUE;            }            shmem_barrier_all();            /* Put value to peer */            if ((my_proc % 2) == 0)            {                FUNC_VALUE(shmem_addr, send_addr, cur_buf_size, root_proc, 0, 1, ((num_proc / 2) + (num_proc % 2)), pSync);            }            /* Get value put by peer:             * These routines start the remote transfer and may return before the data             * is delivered to the remote PE             */            shmem_barrier_all();            {                int wait = WAIT_COUNT;                while (wait--)                {                    value = *shmem_addr;                    if (expect_value == value) break;                    sleep(1);                }            }            rc = (!compare_buffer_with_const(shmem_addr, cur_buf_size, &expect_value, sizeof(expect_value)) ? TC_PASS : TC_FAIL);            log_debug(OSH_TC, "my#%d root(#%d:%lld) expected = %lld actual = %lld buffer size = %lld/n",                               my_proc, root_proc, (INT64_TYPE)peer_value, (INT64_TYPE)expect_value, (INT64_TYPE)value, (INT64_TYPE)cur_buf_size);            if (rc)            {                TYPE_VALUE* check_addr = shmem_addr;                int odd_index = compare_buffer_with_const(check_addr, cur_buf_size, &expect_value, sizeof(expect_value));                int show_index = (odd_index > 1 ? odd_index - 2 : 0);                int show_size = sizeof(*check_addr) * sys_min(3, cur_buf_size - show_index);                log_debug(OSH_TC, "index of incorrect value: 0x%08X (%d)/n", odd_index - 1, odd_index - 1);                log_debug(OSH_TC, "buffer interval: 0x%08X - 0x%08X/n", show_index, show_index + show_size);                show_buffer(check_addr + show_index, show_size);            }        }    }    return rc;}
开发者ID:alex-mikheev,项目名称:tests-mellanox,代码行数:92,



注:本文中的sys_max函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sys_mbox_free函数代码示例
C++ sys_malloc函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。