/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcitool/cli.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-10-22 13:57:59 UTC
  • Revision ID: csa@suren.me-20151022135759-nqs5wowy38tvbw09
Documentation update

Show diffs side-by-side

added added

removed removed

Lines of Context:
964
964
            err = pcilib_wait_irq(handle, 0, 0, &irqs);
965
965
            if (err) irqs = 0;
966
966
            
967
 
            printf("%8zu KB - ", size / 1024);
 
967
            printf("%8zu KiB - ", size / 1024);
968
968
            
969
969
            printf("RW: ");
970
970
            if (mbs < 0) printf("failed ...   ");
971
 
            else printf("%8.2lf MB/s", mbs);
 
971
            else printf("%8.2lf MiB/s", mbs);
972
972
 
973
973
            printf(", R: ");
974
974
            if (mbs_in < 0) printf("failed ...   ");
975
 
            else printf("%8.2lf MB/s", mbs_in);
 
975
            else printf("%8.2lf MiB/s", mbs_in);
976
976
 
977
977
            printf(", W: ");
978
978
            if (mbs_out < 0) printf("failed ...   ");
979
 
            else printf("%8.2lf MB/s", mbs_out);
 
979
            else printf("%8.2lf MiB/s", mbs_out);
980
980
            
981
981
            if (irqs) {
982
982
                printf(", IRQs: %lu", irqs);
1022
1022
    if (!err) err = posix_memalign( (void**)&check, 256, max_size );
1023
1023
    if ((err)||(!buf)||(!check)) Error("Allocation of %i bytes of memory have failed", max_size);
1024
1024
 
1025
 
    data = pcilib_map_bar(handle, bar);
1026
 
    if (!data) Error("Can't map bar %i", bar);
1027
 
 
1028
1025
    if (mode == ACCESS_FIFO) {
1029
 
        fifo = data + (addr - board_info->bar_start[bar]) + (board_info->bar_start[bar] & pcilib_get_page_mask());
1030
 
//      pcilib_resolve_register_address(handle, bar, addr);
 
1026
        fifo = pcilib_resolve_bar_address(handle, bar, addr);
1031
1027
        if (!fifo) Error("Can't resolve address (%lx) in bar (%u)", addr, bar);
 
1028
    } else {
 
1029
        data = pcilib_resolve_bar_address(handle, bar, 0);
 
1030
        if (!data) Error("Can't resolve start of bar (%u)", bar);
1032
1031
    }
1033
1032
 
1034
1033
    if (mode == ACCESS_FIFO)
1052
1051
        gettimeofday(&end,NULL);
1053
1052
 
1054
1053
        time = (end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec);
1055
 
        printf("%8zu bytes - read: %8.2lf MB/s", size, 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
 
1054
        printf("%8zu bytes - read: %8.2lf MiB/s", size, 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
1056
1055
        
1057
1056
        fflush(0);
1058
1057
 
1071
1070
        gettimeofday(&end,NULL);
1072
1071
 
1073
1072
        time = (end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec);
1074
 
        printf(", write: %8.2lf MB/s\n", 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
 
1073
        printf(", write: %8.2lf MiB/s\n", 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
1075
1074
    }
1076
1075
    
1077
 
    pcilib_unmap_bar(handle, bar, data);
1078
 
 
1079
1076
    printf("\n\nOpen-Transfer-Close time: \n");
1080
1077
    
1081
1078
    for (size = 4 ; size < max_size; size *= 8) {
1092
1089
        gettimeofday(&end,NULL);
1093
1090
 
1094
1091
        time = (end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec);
1095
 
        printf("%8zu bytes - read: %8.2lf MB/s", size, 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
 
1092
        printf("%8zu bytes - read: %8.2lf MiB/s", size, 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
1096
1093
        
1097
1094
        fflush(0);
1098
1095
 
1110
1107
        gettimeofday(&end,NULL);
1111
1108
 
1112
1109
        time = (end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec);
1113
 
        printf(", write: %8.2lf MB/s", 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
 
1110
        printf(", write: %8.2lf MiB/s", 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
1114
1111
 
1115
1112
        if (mode == ACCESS_BAR) {
1116
1113
            gettimeofday(&start,NULL);
1122
1119
            gettimeofday(&end,NULL);
1123
1120
 
1124
1121
            time = (end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec);
1125
 
            printf(", write-verify: %8.2lf MB/s", 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
 
1122
            printf(", write-verify: %8.2lf MiB/s", 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024. * 1024.));
1126
1123
            if (errors) printf(", errors: %u of %u", errors, BENCHMARK_ITERATIONS);
1127
1124
        }
1128
1125
        printf("\n");
1687
1684
    struct timeval stop_time;
1688
1685
} GRABContext;
1689
1686
 
1690
 
int GrabCallback(pcilib_event_id_t event_id, pcilib_event_info_t *info, void *user) {
 
1687
int GrabCallback(pcilib_event_id_t event_id, const pcilib_event_info_t *info, void *user) {
1691
1688
    int err = 0;
1692
1689
    void *data;
1693
1690
    size_t size;
1784
1781
    return PCILIB_STREAMING_CONTINUE;
1785
1782
}
1786
1783
 
1787
 
int raw_data(pcilib_event_id_t event_id, pcilib_event_info_t *info, pcilib_event_flags_t flags, size_t size, void *data, void *user) {
 
1784
int raw_data(pcilib_event_id_t event_id, const pcilib_event_info_t *info, pcilib_event_flags_t flags, size_t size, void *data, void *user) {
1788
1785
    int err;
1789
1786
 
1790
1787
    GRABContext *ctx = (GRABContext*)user;
2149
2146
    }
2150
2147
    
2151
2148
    if (flags&PCILIB_EVENT_FLAG_PREPROCESS) {
2152
 
        pcilib_configure_preprocessing_threads(handle, threads);
 
2149
        pcilib_write_register(handle, "conf", "max_threads", threads);
2153
2150
    }
2154
2151
    
2155
2152
    if (grab_mode&GRAB_MODE_TRIGGER) {
3419
3416
                    buffer *= 1024 * 1024;
3420
3417
                } else {
3421
3418
                    buffer = get_free_memory();
3422
 
                    if (buffer < 256) Error("Not enough free memory (%lz MB) for buffering", buffer / 1024 / 1024);
 
3419
                    if (buffer < 256) Error("Not enough free memory (%lz MiB) for buffering", buffer / 1024 / 1024);
3423
3420
                    
3424
3421
                    buffer -= 128 + buffer/16;
3425
3422
                }