-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lang] Simplify dense.bitmasked to bitmasked (#670)
* [Lang] Simplify dense.bitmasked to bitmasked * fix tests * put back * [skip ci] enforce code format Co-authored-by: Taichi Gardener <[email protected]>
- Loading branch information
1 parent
1371a07
commit 4443534
Showing
20 changed files
with
130 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
// Specialized Attributes and functions | ||
struct BitmaskedMeta : public StructMeta { | ||
bool _; | ||
}; | ||
|
||
STRUCT_FIELD(BitmaskedMeta, _); | ||
|
||
i32 Bitmasked_get_num_elements(Ptr meta, Ptr node) { | ||
return ((StructMeta *)meta)->max_num_elements; | ||
} | ||
|
||
void Bitmasked_activate(Ptr meta, Ptr node, int i) { | ||
auto smeta = (StructMeta *)meta; | ||
auto element_size = StructMeta_get_element_size(smeta); | ||
auto num_elements = Bitmasked_get_num_elements(meta, node); | ||
auto data_section_size = element_size * num_elements; | ||
auto mask_begin = (uint64 *)(node + data_section_size); | ||
atomic_or_u64(&mask_begin[i / 64], 1UL << (i % 64)); | ||
} | ||
|
||
i32 Bitmasked_is_active(Ptr meta, Ptr node, int i) { | ||
auto smeta = (StructMeta *)meta; | ||
auto element_size = StructMeta_get_element_size(smeta); | ||
auto num_elements = Dense_get_num_elements(meta, node); | ||
auto data_section_size = element_size * num_elements; | ||
auto mask_begin = node + data_section_size; | ||
return i32(bool((mask_begin[i / 8] >> (i % 8)) & 1)); | ||
} | ||
|
||
Ptr Bitmasked_lookup_element(Ptr meta, Ptr node, int i) { | ||
return node + ((StructMeta *)meta)->element_size * i; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.