Skip to content

Conversation

Copy link

Copilot AI commented Oct 31, 2025

Wildcards previously only supported float type. Extended to support uint8_t and notStupidBool_t for memory efficiency (75% reduction) and semantic clarity.

Implementation

Storage: Changed wildcard arrays from float* to char* with type metadata in DEMSimParams:

struct DEMSimParams {
    uint8_t contactWildcardTypes[DEME_MAX_WILDCARD_NUM];
    uint8_t ownerWildcardTypes[DEME_MAX_WILDCARD_NUM];
    uint8_t geoWildcardTypes[DEME_MAX_WILDCARD_NUM];
};

API: Added typed wildcard methods alongside existing APIs (default to float for backward compatibility):

// New: explicit types
std::unordered_map<std::string, WILDCARD_TYPE> wildcards = {
    {"delta_time", WILDCARD_TYPE::FLOAT},
    {"contact_broken", WILDCARD_TYPE::BOOL},
    {"collision_count", WILDCARD_TYPE::UINT8}
};
my_force_model->SetPerContactWildcardsWithTypes(wildcards);

// Existing: still works, defaults to float
my_force_model->SetPerContactWildcards({"delta_time", "delta_tan_x"});

Device access: Type-safe macros for CUDA kernels:

float delta_time = DEME_CONTACT_WILDCARD_FLOAT(simParams, contactWildcards, 0, myContactID);
uint8_t count = DEME_CONTACT_WILDCARD_UINT8(simParams, contactWildcards, 5, myContactID);
notStupidBool_t broken = DEME_CONTACT_WILDCARD_BOOL(simParams, contactWildcards, 4, myContactID);

Changes

  • Core: Defines.h - WILDCARD_TYPE enum, getWildcardTypeSize(), accessor macros
  • Storage: dT.h/cpp, kT.h/cpp - char-based allocation, type propagation through initialization chain
  • API: AuxClasses.h/cpp - *WithTypes() methods, type storage maps
  • Migration: dT.cpp - updated allocation, resize, and data copying to use actual element sizes

All existing code continues to work unchanged.

Original prompt

Now the concept of "wildcard" defaults to have all the wildcard arrays in float type. Can you make a big overhaul (and design how this can be done) such that it can support some other types (uint8, or notStupidBool_t, must be one of them)? This can be done by always allocating char array, and only casting before using these arrays, or some other ways of your choice.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Oct 31, 2025
Copilot AI and others added 6 commits October 31, 2025 17:28
Co-authored-by: Ruochun <24469442+Ruochun@users.noreply.github.com>
Co-authored-by: Ruochun <24469442+Ruochun@users.noreply.github.com>
Co-authored-by: Ruochun <24469442+Ruochun@users.noreply.github.com>
Co-authored-by: Ruochun <24469442+Ruochun@users.noreply.github.com>
Co-authored-by: Ruochun <24469442+Ruochun@users.noreply.github.com>
Co-authored-by: Ruochun <24469442+Ruochun@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for multiple types in wildcard arrays Add typed wildcard arrays (float, uint8, bool) Oct 31, 2025
Copilot finished work on behalf of Ruochun October 31, 2025 17:41
Copilot AI requested a review from Ruochun October 31, 2025 17:41
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.

2 participants