Giter Site home page Giter Site logo

Comments (12)

moep0 avatar moep0 commented on August 15, 2024

And what is the use of the maker.template lines before the l2-doubleload bandwidth tests? Are they offering shuffle regions for the bandwidth tests? (maybe I should open another issue?)

from uarch-bench.

travisdowns avatar travisdowns commented on August 15, 2024

Looks like a shell quoting issue: zsh (your shell) is interpreting the *, not uarch-bench. Try it like:

sudo ./uarch-bench.sh '--test-name=studies/memory/l2-doubleload/*normal*'

from uarch-bench.

travisdowns avatar travisdowns commented on August 15, 2024

And what is the use of the maker.template lines before the l2-doubleload bandwidth tests? Are they offering shuffle regions for the bandwidth tests? (maybe I should open another issue?)

Lines 422 through 434 are part of the l2-doubleload tests. Each line defines an individual test. Take this line for example:

        maker.template make<serial_double_load_oneload> ("single-load-16k", "Just one load 16k region",  1, []{ return &shuffled_region(16 * 1024); });

This defines a test called "single-load-16k" which calls the function serial_double_load_oneload (written in asm) which is passed a "shuffled region" of 16 KiB (see the comments for "shuffled region" for what that is). The way the passed-in argument is used depends on the specific benchmark. This one does:

; one load only, as a baseline
define_bench serial_double_load_oneload
mov     rsi, [rsi + region.start]
.top:
mov rcx, [rsi]
mov rsi, rcx
dec rdi
jnz .top
ret

I.e., it "pointer chases" across the region in a loop.

Did that answer your question?

from uarch-bench.

moep0 avatar moep0 commented on August 15, 2024

Looks like a shell quoting issue: zsh (your shell) is interpreting the *, not uarch-bench. Try it like:

sudo ./uarch-bench.sh '--test-name=studies/memory/l2-doubleload/*normal*'

This works! Thank you!

Lines 422 through 434 are part of the l2-doubleload tests. Each line defines an individual test.

I got it. Can I ask one more question? I notice that the region is defined both in cpp and asm.

struc region
    .size  : resq 1
    .start : resq 1
endstruc
struct region {
    size_t size;
    void *start;  // actually a CacheLine object
};

I think instructions like mov rsi, [rsi + region.start] are using the asm definition. After executing shuffled_region in cpp and getting an address, how to pass the cpp struct data to the asm struct?

from uarch-bench.

travisdowns avatar travisdowns commented on August 15, 2024

I got it. Can I ask one more question?

Yes, of course, though in general I like separate issues for new questions.

I think instructions like mov rsi, [rsi + region.start] are using the asm definition.

That's correct, it's using nasm STRUC support described here.

After executing shuffled_region in cpp and getting an address, how to pass the cpp struct data to the asm struct?

The 4th argument to maker.make takes a function that returns a void *, and this is passed to the asm where it is available in the rsi register. The rdi register contains the number of loops requested by the C++ code. A function is used instead of passing a void * directly in C++ to avoid running all the code for every test when the tests are just being registers: this lets us register the tests while referring the generation of their argument.

Does it make sense?

from uarch-bench.

moep0 avatar moep0 commented on August 15, 2024

Sorry I'm poor at c++. I am a little bit confused. How does the void * pointer pass its value to the rsi register? And how does the rsi register pass it to region.start?

from uarch-bench.

travisdowns avatar travisdowns commented on August 15, 2024

I don't think I can cover all the background required to understand this in a GitHub issue. I'm already linked to nasm STRUC doc, which is part of the puzzle, but you'll have to learn about x64 ABI and C++ for the rest.

In my experience you can get good answers on StackOverflow.

from uarch-bench.

travisdowns avatar travisdowns commented on August 15, 2024

Look up the SysV ABI to see how function parameters (in this case a void pointer) are passed to x86 registers. The second parameter goes in rsi by this convention.

from uarch-bench.

moep0 avatar moep0 commented on August 15, 2024

Thank you for all the answers! Maybe I don't express clearly. I do know that the first one goes to rdi and second one to rsi and so on. I will try to read nasm STRUC doc to see how the two structs are linked.

from uarch-bench.

travisdowns avatar travisdowns commented on August 15, 2024

from uarch-bench.

moep0 avatar moep0 commented on August 15, 2024

OK, totally got it. region.size and region.start are just offsets. Thanks for your patience and sorry for the trouble. Next time I will read the background first and then ask questions.

from uarch-bench.

travisdowns avatar travisdowns commented on August 15, 2024

from uarch-bench.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.