Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing cruft headers from library tests and guarding mutexes in the memory manager #711

Conversation

sripathi-muralitharan
Copy link
Contributor

@sripathi-muralitharan sripathi-muralitharan commented Apr 1, 2021

This PR removes cruft headers from the library tests and adds a macro guard around the use of mutexes.

  • Removes the use of sys/ioctl.h
  • Removes the use of sys/mman.h
  • Adds a ifdef around the memory manager mutex (using MMAN_MUTEX)

@dpetrisko
Copy link
Collaborator

I would separate out the header changes that are RISC-V agnostic and open a different PR for the hammerparrot platform

@sripathi-muralitharan
Copy link
Contributor Author

sripathi-muralitharan commented Apr 2, 2021

To run upto compilation of the library files, I think we require hardware.mk, compilation.mk and link.mk. So, I thought I might as well add the other two which is basically the entire platform. hardware.mk, link.mk, execution.mk and library.mk are exact copies from the files in bigblade-vcs. Only compilation.mk is changed.

@@ -166,7 +165,7 @@ int test_manycore_eva () {
tgt_epa = rand() % DRAM_EPA_SIZE; // Small, but we'll deal.

tgt_x = (rand() % (dim_x - 1)) + origin_x;
tgt_y = hb_mc_config_get_dram_y(config);
// tgt_y = hb_mc_config_get_dram_y(config);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No y coordinates required for DRAM pods?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is, but it's handled in a different way. This is @mrutt92's least favorite test

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test suuuuuuuuuuuxxxxxxxxxx. When it fails, 99 times out of 100 the solution is to fix the test instead of any RTL or library code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use these now with pods

static inline hb_mc_idx_t
.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh okay.

@@ -26,7 +26,6 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test superseded by test_packet?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? @mrutt92 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol - whoops. forgot this exists.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my defense, what a non-descript name?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can nuke this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I get rid of it then before we merge?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate PR I think

@dpetrisko
Copy link
Collaborator

Sweet, my feedback is addressed, I’ll leave the rest to @drichmond and @mrutt92

@dpetrisko
Copy link
Collaborator

Can we remove the hammerparrot platform and get the header removals / additions in?

@drichmond
Copy link
Collaborator

Is that to us or @sripathi-muralitharan?

@dpetrisko
Copy link
Collaborator

@sripathi-muralitharan for the separation, @drichmond for the review :P

@sripathi-muralitharan
Copy link
Contributor Author

Removed the platform makefiles and hardware. Only the header file additions and removals now remain.

@drichmond
Copy link
Collaborator

What about the argp header, and changes to .gitignore?

@sripathi-muralitharan
Copy link
Contributor Author

argp.h is required for the software port. Its used at some point. I have pointed to the file from where I take it and its an exact copy from that location. Unfortunately, this header does not exist in the newlib+dramfs toolchain, so I had to copy it over from the linux version.

I can get rid of the .gitignore

@drichmond
Copy link
Collaborator

But that's part of the platform

@sripathi-muralitharan
Copy link
Contributor Author

Wait, you don't want any of the headers at all?

@@ -164,7 +163,7 @@ int test_manycore_alignment() {
dram_coord_y,
BASE_ADDR + 1);
write_data = rand();
err = hb_mc_manycore_write32(mc, &npa, &write_data);
err = hb_mc_manycore_write32(mc, &npa, write_data);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just an outdated test? What went wrong here?

Copy link
Contributor Author

@sripathi-muralitharan sripathi-muralitharan Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hb_mc_manycore_write* functions call the hb_mc_manycore_write functions by passing the address of the third argument (i,e write_data here). Passing the third argument as an address, would make the call to hb_mc_manycore_write, a pointer to a pointer. Is that the intention? If it is, I am wrong and I will revert it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you're probably right. Just confused why this wasn't caught before. Does the test pass?

Copy link
Contributor Author

@sripathi-muralitharan sripathi-muralitharan Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the test passes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly because I'm still miffed :p

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both versions of the test (with the changes I proposed and without them) work. So, I am not sure what is the course of action of here. Keep it the same?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh an always passing test, that’s a classic.

Course of action is revert the change and file an issue

Copy link
Contributor Author

@sripathi-muralitharan sripathi-muralitharan Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted change and opened #713 for this.

Also found that the test_pod_iteration library test fails due to an Invalid Input error raised by the hb_mc_platform_init function. Opened #712 for that

@drichmond
Copy link
Collaborator

git rm libraries/platforms/hammerparrot-vcs/

Nothing in that directory should be in this PR

@dpetrisko
Copy link
Collaborator

argp.h is required for the software port. Its used at some point. I have pointed to the file from where I take it and its an exact copy from that location. Unfortunately, this header does not exist in the newlib+dramfs toolchain, so I had to copy it over from the linux version.

I guess the question is if we want to use different headers for different platforms. Totally up to you, but it makes sense to me to include this header in the main library so that everything is using the same C++ codebase

@drichmond
Copy link
Collaborator

argp.h is required for the software port. Its used at some point. I have pointed to the file from where I take it and its an exact copy from that location. Unfortunately, this header does not exist in the newlib+dramfs toolchain, so I had to copy it over from the linux version.

I guess the question is if we want to use different headers for different platforms. Totally up to you, but it makes sense to me to include this header in the main library so that everything is using the same C++ codebase

If that's the case, then the main libraries directory, or the examples directory are better places. And it should be a separate PR.

@sripathi-muralitharan sripathi-muralitharan force-pushed the bigblade-hammerparrot branch 2 times, most recently from 876a554 to 9c3a94b Compare April 7, 2021 01:41
@dpetrisko
Copy link
Collaborator

argp.h is required for the software port. Its used at some point. I have pointed to the file from where I take it and its an exact copy from that location. Unfortunately, this header does not exist in the newlib+dramfs toolchain, so I had to copy it over from the linux version.

I guess the question is if we want to use different headers for different platforms. Totally up to you, but it makes sense to me to include this header in the main library so that everything is using the same C++ codebase

If that's the case, then the main libraries directory, or the examples directory are better places. And it should be a separate PR.

Yup agree with both

@mrutt92 mrutt92 self-requested a review April 7, 2021 19:54
Copy link
Collaborator

@mrutt92 mrutt92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks good to me. I might change the name of this PR to "Removes cruft headers and macro guards mutex" and edit the description with bullets saying what it does. The current name suggests something... bigger.

@sripathi-muralitharan sripathi-muralitharan changed the title Software Port from x86 GCC to RISC-V Newlib+Dramfs Removing cruft headers from library tests and guarding mutexes in the memory manager Apr 7, 2021
@taylor-bsg
Copy link
Contributor

taylor-bsg commented Apr 8, 2021 via email

@dpetrisko
Copy link
Collaborator

This ready to go? Possibly with new issue opening for this:

I suggest having a link from the EVA code to this test as something that
needs to be updated if EVA map is changed.

@sripathi-muralitharan
Copy link
Contributor Author

New issue or just a link to https://github.com/bespoke-silicon-group/bsg_manycore/blob/ci_bigblade/v/bsg_manycore_eva_to_npa.v?
There already seems to be a link back to the cuda-lite library code in the SV file.

@dpetrisko
Copy link
Collaborator

I think michael's suggestion is to add a link to the brittle test as well as the library

Comment on lines +31 to +33
#ifdef _MMAN_MUTEX_
std::mutex mMemManagerMutex;
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a standard macro? Or is this something we need to define now?

Copy link
Contributor Author

@sripathi-muralitharan sripathi-muralitharan Apr 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is a standard macro. We will need to define it separately. Is libraries.mk a good spot for this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more basic switch? Like if newlib?

Copy link
Contributor Author

@sripathi-muralitharan sripathi-muralitharan Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might conflict with something in newlib. I guess, we can be safer and say if NOPARROT or something like that. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the macro how it is.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not standard (and doesn't conflict with anything): good
Descriptive (does exactly what the name would imply): good
Does the job: excellent
What's the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the original question was if this was a standard macro which you just confirmed it isn't. So, there is no problem.

@sripathi-muralitharan
Copy link
Contributor Author

Are there any other changes required for this PR?

@mrutt92
Copy link
Collaborator

mrutt92 commented Apr 30, 2021

I think this fine, let's hammer this parrot!

@mrutt92 mrutt92 merged commit 4ea650a into bespoke-silicon-group:bigblade Apr 30, 2021
mrutt92 pushed a commit that referenced this pull request May 1, 2021
… memory manager (#711)

* Software fixes

* Add comment to update EVA tests when EVA map is changed
dpetrisko pushed a commit that referenced this pull request Oct 4, 2021
… memory manager (#711)

* Software fixes

* Add comment to update EVA tests when EVA map is changed
dpetrisko pushed a commit that referenced this pull request Jan 17, 2023
… memory manager (#711)

* Software fixes

* Add comment to update EVA tests when EVA map is changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants