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

Divsufsort made header-only #45

Merged
merged 4 commits into from
Sep 11, 2018
Merged

Conversation

cpockrandt
Copy link
Collaborator

@cpockrandt cpockrandt commented Jul 14, 2018

This should not be merged before merging #44 (cmake/ctest refactoring) so Travis runs the full test suite.

  • write test cases

@h-2 feel free to start reviewing :)

@cpockrandt cpockrandt force-pushed the divsufsort branch 2 times, most recently from 63292ef to 0955cef Compare July 16, 2018 20:05
Copy link

@h-2 h-2 left a comment

Choose a reason for hiding this comment

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

I think the code is still super hard to read with all the macros. I would propose to decide which of the configurables you want to preserve and put them in the config and remove the rest. Also you rely on BUILD_DIVSUFSORT64 in multiple places, but it is never set. Should this instead depend on saidx_t?


namespace sdsl {

#define PROJECT_VERSION_FULL "2.0.1-15-g22e6b23"
Copy link

Choose a reason for hiding this comment

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

why do you need this?

#define SS_INSERTIONSORT_THRESHOLD (8)
#define SS_BLOCKSIZE (1024)
#define SS_MISORT_STACKSIZE (16)
#define TR_INSERTIONSORT_THRESHOLD (8)
Copy link

Choose a reason for hiding this comment

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

why are these not part of the config?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They don't depend on 32/64 bit versions. We could move them in a separate config struct. But I only want to change the code when necessary.

#else
#define BUCKET_B(_c0, _c1) (bucket_B[(_c1) * ALPHABET_SIZE + (_c0)])
#define BUCKET_BSTAR(_c0, _c1) (bucket_B[(_c0) * ALPHABET_SIZE + (_c1)])
#endif
Copy link

Choose a reason for hiding this comment

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

Can you not just insert the actual code instead? Or make inline functions that do this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Then we should move the stack operations to functions as well. But the stack macro functions work with all combinations of parameters (values and pointers) at different lines of codes depending on the stack. Don't really want to start touching all that code. 👀

do {\
stack[ssize].a = (_a), stack[ssize].b = (_b),\
stack[ssize].c = (_c), stack[ssize++].d = (_d);\
} while(0)
Copy link

Choose a reason for hiding this comment

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

do while(0) 😨

7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
};

#if (SS_BLOCKSIZE == 0) || (SS_INSERTIONSORT_THRESHOLD < SS_BLOCKSIZE)
Copy link

Choose a reason for hiding this comment

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

Both macros are fixed values in this file so either this condition is always true or always false

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd keep this as well just in case.

int32_t
ss_ilg(saidx_t n) {
#if SS_BLOCKSIZE == 0
# if defined(BUILD_DIVSUFSORT64)
Copy link

Choose a reason for hiding this comment

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

this is never defined so the block is never evaluated


/*---------------------------------------------------------------------------*/

#if (SS_BLOCKSIZE != 1) && (SS_INSERTIONSORT_THRESHOLD != 1)
Copy link

Choose a reason for hiding this comment

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

again, please remove dead code and/or checks as it will likely reduce the code considerably and make it easier to maintain

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I suggest keeping it for now (in case someone wants to take a look at it later and tune parameters). If I remove all the code now, you'd have to start from scratch again.

/*---------------------------------------------------------------------------*/

template <typename saidx_t>
static
Copy link

Choose a reason for hiding this comment

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

don't mark any of the functions static (they are free functions anyway), but do mark all of them as inline!

}



Copy link

Choose a reason for hiding this comment

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

search and replace the multiple empty lines maybe 💅

@mpetri
Copy link

mpetri commented Jul 20, 2018

is it possible to merge the code of divsufsort and divsufsort64?

@cpockrandt
Copy link
Collaborator Author

I'll add some test cases and after merging #44 this can be merged in my opinion.

@cpockrandt
Copy link
Collaborator Author

Tests are added and are passing.

@mpetri From my point of view this PR is in a mergable state now. Or did you mean something different with your last question?

@cpockrandt cpockrandt merged commit 8ee9dc0 into xxsds:master Sep 11, 2018
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.

3 participants