Loading...
You are not logged-in Login/Register





  • Posts   Search Threads
  • Dmitriy VyukovJune 23, 2009 11:56 AM PDT   
    Line Segments: Test Data. Post your results.

    I've attached my test (1MB) input file.
    The process of generation is following. There are 3 input parameters: count, length, and limit. count is the number of line segments, length is the maximum length of a segment in each dimention, and limit determines range of values for coordinates. Here is piece of code:

    int coord [6];
    for (int n = 0; n != count; n += 1)
    {
    for (int j = 0; j != 3; j += 1)
    coord[j] = (int)(rand_gen() * limit);
    for (int j = 0; j != 3; j += 1)
    coord[j + 3] = coord[j] + (int)(rand_gen() * length * 2) - length;
    fprintf(f, "%s %d %d %d %d %d %dn", name, coord[0], coord[1], coord[2], coord[3], coord[4], coord[5]);
    }

    Parameters for attached file are: count = 100'000, limit = 200, length = 20.



    ---------------------------------------------
    All about lock-free algorithms, multicore, scalability, parallel computing and related topics:
    www.1024cores.net
     Attachments 

    Dmitriy VyukovJune 23, 2009 12:12 PM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    My program has found 1622 intersections in 21 sec.
    However I am not 100% sure in correctness of my program now. Since it's difficult to manually compare output of one program with output of another program, I propose following method for quick verification/comparison of results.
    The idea is to compute some "hash" of results. Hash must be stable to following reorderings:
    A B
    C D
    must yield the same hash as:
    D C
    B A

    But not stable to following reorderings:
    A B
    C D
    must not yield the same hash as:
    A C
    B D

    Here is algorithm I currently use:
    char hash [4] = {};
    for (size_t i = 0; i != results.size(); i += 1)
    {
    line_t const* line1 = results[i].line1;
    line_t const* line2 = results[i].line2;
    for (int t = 0; t != 4; t += 1)
    hash[t] ^= (line1->name[t] + line2->name[t]);
    }
    }
    printf("count=%u (%u)n", results.size(), *(unsigned*)sample);

    My output is:
    count=1622 (1711155)



    ---------------------------------------------
    All about lock-free algorithms, multicore, scalability, parallel computing and related topics:
    www.1024cores.net

    Dmitriy VyukovJune 23, 2009 12:33 PM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    Post your time and result (number of intersections and hash).

    Suggestions on how to improve input data generation process and hash calculation are welcome.




    ---------------------------------------------
    All about lock-free algorithms, multicore, scalability, parallel computing and related topics:
    www.1024cores.net

    Dmitriy VyukovJune 23, 2009 1:18 PM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    Quoting - Dmitriy Vyukov
    My program has found 1622 intersections in 21 sec.

    Simple optimization reduced time to 6247ms.



    ---------------------------------------------
    All about lock-free algorithms, multicore, scalability, parallel computing and related topics:
    www.1024cores.net

    Dmitriy VyukovJune 23, 2009 1:49 PM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    Quoting - Dmitriy Vyukov
    Simple optimization reduced time to 6247ms.

    Drop in single pragma omp. Time is 1731ms.



    ---------------------------------------------
    All about lock-free algorithms, multicore, scalability, parallel computing and related topics:
    www.1024cores.net

    BradleyKuszmaulJune 24, 2009 7:25 AM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    Quoting - Dmitriy Vyukov

    However I am not 100% sure in correctness of my program now. Since it's difficult to manually compare output of one program with output of another program, I propose following method for quick verification/comparison of results.
    The idea is to compute some "hash" of results....
    Another approach is to run the output through sort and then compare the sorted outputs.



    邓辉June 24, 2009 8:56 AM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    hi Dmitriy Vyukov

    My program has found 5352 intersections in 6 sec.


    写字楼里写字间,写字间里程序员
    程序人员写程序,又拿程序换酒钱
    酒醒只在网上坐,酒醉还来网下眠
    酒醉酒醒日复日,网上网下年复年

    akkiJune 24, 2009 9:30 AM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    Quoting - Dmitriy Vyukov

    Simple optimization reduced time to 6247ms.


    My brute force implementation says there are 4788 intersections...


    Dmitriy VyukovJune 24, 2009 9:31 AM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    Quoting - BradleyKuszmaul
    Another approach is to run the output through sort and then compare the sorted outputs.


    Well, this will definitely produce better results, however one will have to attach own results and download others results, then pass them through some utility, and somebody has to develop that utility first...
    What I would prefer is something much more "lightweight". Probably good variant will be to sort results and then calculate SHA1.



    ---------------------------------------------
    All about lock-free algorithms, multicore, scalability, parallel computing and related topics:
    www.1024cores.net

    akkiJune 24, 2009 9:38 AM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    Quoting - 邓辉
    hi Dmitriy Vyukov

    My program has found 5352 intersections in 6 sec.


    Can you post your results please? I want to verify visually whether I've missed any intersections. I'll let you know what I find out. Here's mine (linux)...

    Thanks.

     Attachments 

    Dmitriy VyukovJune 24, 2009 9:44 AM PDT
    Rate
     
    Re: Line Segments: Test Data. Post your results.

    Quoting - Dmitriy Vyukov
    My program has found 1622 intersections in 21 sec.


    Quoting - akki
    My brute force implementation says there are 4788 intersections...

    Quoting - 邓辉
    My program has found 5352 intersections in 6 sec.


    Cool! I like this :)

    For knapsack it was easier, if you have higher value and your solution is feasible then you are on the safe side. For line segments it's unclear which solution is "more right".
    My first attempt also yield some 4 thousands intersections, however then I re-implement it more carefully and it yield only 1622. It's not to say that my answer is correct, I am totally unsure that it is correct.

    I would be nice if somebody will construct input file with several tens of different corner cases and manually calculate correct answer... AMD Threadfest was much contestant-friendlier in this aspect - they initially provide a number of input datasets, pre-calculated correct results, simple reference implementation of the program and precisely describe input data generation process, so that contestants was able to concentrate on the problem itself...



    ---------------------------------------------
    All about lock-free algorithms, multicore, scalability, parallel computing and related topics:
    www.1024cores.net

Forum jump:  

Intel Software Network Forums Statistics

17,025 users have contributed to 48,317 threads and 172,754 posts to date.

In the past 24 hours, we have 9 new thread(s) 56 new posts(s), and 52 new user(s).

In the past 3 days, the most popular thread for everyone has been How to manage rounding by IVF ?? The most posts were made to Most likely, the issue is that The post with the most views is Optimalization of sine function\'s taylor expansion

Please welcome our newest member redfruit83


For more complete information about compiler optimizations, see our Optimization Notice.