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

fix: remove Long64_t from common header-only #2084

Conversation

ianna
Copy link
Collaborator

@ianna ianna commented Jan 6, 2023

@ianna ianna marked this pull request as draft January 6, 2023 15:48
…e-and-cppyy-shouldnt-be-in-awkwardheader-only
@codecov
Copy link

codecov bot commented Jan 6, 2023

Codecov Report

Merging #2084 (6b99430) into main (54ab9f3) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

@ianna ianna temporarily deployed to docs-preview January 6, 2023 16:02 — with GitHub Actions Inactive
@ianna ianna temporarily deployed to docs-preview January 10, 2023 09:27 — with GitHub Actions Inactive
@ianna ianna temporarily deployed to docs-preview January 10, 2023 10:25 — with GitHub Actions Inactive
@ianna ianna force-pushed the ianna/2032-c++-for-jit-compilation-rdataframe-and-cppyy-shouldnt-be-in-awkwardheader-only branch from ca53e2a to dbe5dc6 Compare January 10, 2023 13:00
@ianna ianna temporarily deployed to docs-preview January 10, 2023 13:14 — with GitHub Actions Inactive
…e-and-cppyy-shouldnt-be-in-awkwardheader-only
@ianna ianna temporarily deployed to docs-preview January 10, 2023 13:35 — with GitHub Actions Inactive
…e-and-cppyy-shouldnt-be-in-awkwardheader-only
@ianna ianna marked this pull request as ready for review January 11, 2023 10:23
@ianna ianna temporarily deployed to docs-preview January 11, 2023 10:40 — with GitHub Actions Inactive
Copy link
Collaborator Author

@ianna ianna left a comment

Choose a reason for hiding this comment

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

@jpivarski - I think, using a fundamental type here is ok for either ROOT users or those who don't have it installed. The Long64_t is a type alias for a long type (that is also an int64_t) on Mac, but it's a long long on Ubuntu.

header-only/awkward/utils.h Outdated Show resolved Hide resolved
@ianna ianna requested a review from jpivarski January 11, 2023 13:47
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

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

Looks good! I'd accept it as it is, but I made a suggestion to consider before merging it. Whether you decide to accept the suggestion or not, you can merge this PR.

If you merge it today (i.e. in the next few hours), then it will be included in the next awkward-cpp release. Otherwise, we'll do another awkward-cpp release later.

header-only/awkward/utils.h Outdated Show resolved Hide resolved
header-only/awkward/utils.h Show resolved Hide resolved
Copy link
Collaborator Author

@ianna ianna left a comment

Choose a reason for hiding this comment

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

@jpivarski - please, check. I'm done with this PR for today. Thanks!

header-only/awkward/utils.h Show resolved Hide resolved
…e-and-cppyy-shouldnt-be-in-awkwardheader-only
@ianna ianna requested a review from jpivarski January 12, 2023 17:46
@ianna ianna temporarily deployed to docs-preview January 12, 2023 17:53 — with GitHub Actions Inactive
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

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

See below. I'll try committing this change and auto-merging.

header-only/awkward/utils.h Outdated Show resolved Hide resolved
@jpivarski jpivarski enabled auto-merge (squash) January 12, 2023 19:41
@jpivarski
Copy link
Member

E               TypeError: while calling
E               
E                   ak.from_rdataframe(
E                       rdf = RInterface<ROOT::Detail::RDF::RLoopManager,void>-instance
E                       columns = 'x'
E                   )
E               
E               Error details: unrecognized primitive: 'unsupported_primitive_type'. Must be one of
E               
E                   bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, complex64, complex128, datetime64, timedelta64, float16, float128, complex256
E               
E               or a datetime64/timedelta64 with units (e.g. 'datetime64[15us]')

out        = None
primitive  = 'unsupported_primitive_type'

Okay, I'm going to check it out locally and see what's happening.

@jpivarski jpivarski temporarily deployed to docs-preview January 12, 2023 20:06 — with GitHub Actions Inactive
@jpivarski
Copy link
Member

jpivarski commented Jan 12, 2023

And since std::is_same_v<T, bool> checks compatibility/equivalence, rather than exact alias names...

std::is_same_v<T, bool> does not check for compatibility/equivalence. It checks for exact equality in some sense (possibly depends on how stdint.h was written):

root [0] std::is_same_v<Long64_t, int64_t>
(const bool) false

But this should do it:

root [1] std::is_integral_v<Long64_t> && std::is_signed_v<Long64_t> && sizeof(Long64_t) == 8
(bool) true

I'm updating the code.

@jpivarski
Copy link
Member

This is working for me, locally:

/// @brief Returns the name of a primitive type as a string.
template <typename T>
const std::string
type_to_name() {
if (std::is_integral_v<T>) {
if (std::is_signed_v<T>) {
if (sizeof(T) == 1) {
return "int8";
}
else if (sizeof(T) == 2) {
return "int16";
}
else if (sizeof(T) == 4) {
return "int32";
}
else if (sizeof(T) == 8) {
return "int64";
}
}
else {
if (sizeof(T) == 1) {
return "uint8";
}
else if (sizeof(T) == 2) {
return "uint16";
}
else if (sizeof(T) == 4) {
return "uint32";
}
else if (sizeof(T) == 8) {
return "uint64";
}
}
}
else if (std::is_same_v<T, float>) {
return "float32";
}
else if (std::is_same_v<T, double>) {
return "float64";
}
else if (std::is_same_v<T, std::complex<float>>) {
return "complex64";
}
else if (std::is_same_v<T, std::complex<double>>) {
return "complex128";
}
// std::is_integral_v<T> and sizeof(T) not in (1, 2, 4, 8) can get here.
// Don't connect this line with the above as an 'else' clause.
return std::string("unsupported primitive type: ") + typeid(T).name();
}
template <>
const std::string
type_to_name<bool>() {
// This takes precedence over the unspecialized template, and therefore any
// 8-bit data that is not named bool will be mapped to "int8" or "uint8".
return "bool";
}

@jpivarski jpivarski temporarily deployed to docs-preview January 12, 2023 20:46 — with GitHub Actions Inactive
@jpivarski jpivarski merged commit 12a3101 into main Jan 12, 2023
@jpivarski jpivarski deleted the ianna/2032-c++-for-jit-compilation-rdataframe-and-cppyy-shouldnt-be-in-awkwardheader-only branch January 12, 2023 20:47
Copy link
Collaborator Author

@ianna ianna left a comment

Choose a reason for hiding this comment

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

@jpivarski - thanks! It looks great. I will try to run more extensive tests to check the containers of strings/chars.

header-only/awkward/utils.h Show resolved Hide resolved
@ianna
Copy link
Collaborator Author

ianna commented Jan 13, 2023

And since std::is_same_v<T, bool> checks compatibility/equivalence, rather than exact alias names...

std::is_same_v<T, bool> does not check for compatibility/equivalence. It checks for exact equality in some sense (possibly depends on how stdint.h was written):

root [0] std::is_same_v<Long64_t, int64_t>
(const bool) false

yes, because in this case:

root [0] std::is_same_v<Long64_t, int64_t>
(const bool) false
root [1] std::is_same_v<Long64_t, long long>
(const bool) true
root [2] std::is_same_v<int64_t, long>
(const bool) true

But this should do it:

root [1] std::is_integral_v<Long64_t> && std::is_signed_v<Long64_t> && sizeof(Long64_t) == 8
(bool) true

I'm updating the code.

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.

C++ for JIT-compilation (RDataFrame and cppyy) shouldn't be in awkward/header-only.
2 participants