Skip to content

Commit

Permalink
Merge branch 'veloxchem'
Browse files Browse the repository at this point in the history
  • Loading branch information
scanberg committed Nov 20, 2024
2 parents 8b52c66 + f9b1cd2 commit ef7a2d3
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 241 deletions.
18 changes: 10 additions & 8 deletions src/components/ramachandran/ramachandran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,11 +1271,14 @@ struct Ramachandran : viamd::EventHandler {
uint32_t frame_end;
uint32_t frame_stride;
float sigma;
md_allocator_i* alloc;
};

md_allocator_i* alloc = md_get_heap_allocator();

uint64_t tex_size = sizeof(vec4_t) * density_tex_dim * density_tex_dim;
uint64_t alloc_size = sizeof(UserData) + tex_size + alignof(vec4_t);
UserData* user_data = (UserData*)md_alloc(md_get_heap_allocator(), sizeof(UserData) + tex_size);
UserData* user_data = (UserData*)md_alloc(alloc, alloc_size);
vec4_t* density_tex = (vec4_t*)NEXT_ALIGNED_ADDRESS(user_data + 1, alignof(vec4_t));
memset(density_tex, 0, tex_size);

Expand All @@ -1291,9 +1294,9 @@ struct Ramachandran : viamd::EventHandler {
user_data->frame_end = frame_end;
user_data->frame_stride = frame_stride;
user_data->sigma = blur_sigma;
user_data->alloc = alloc;

task_system::ID async_task = task_system::create_pool_task(STR_LIT("Rama density"), [](void* user_data) {
UserData* data = (UserData*)user_data;
task_system::ID async_task = task_system::create_pool_task(STR_LIT("Rama density"), [data = user_data]() {
const float angle_to_coord_scale = 1.0f / (2.0f * PI);
const float angle_to_coord_offset = 0.5f;

Expand Down Expand Up @@ -1333,13 +1336,12 @@ struct Ramachandran : viamd::EventHandler {
data->rep->den_sum[1] = (float)sum[1];
data->rep->den_sum[2] = (float)sum[2];
data->rep->den_sum[3] = (float)sum[3];
}, user_data);
});

task_system::ID main_task = task_system::create_main_task(STR_LIT("##Update rama texture"), [](void* user_data) {
UserData* data = (UserData*)user_data;
task_system::ID main_task = task_system::create_main_task(STR_LIT("##Update rama texture"), [data = user_data]() {
gl::set_texture_2D_data(data->rep->den_tex, data->density_tex, GL_RGBA32F);
md_free(md_get_heap_allocator(), data, data->alloc_size);
}, user_data);
md_free(data->alloc, data, data->alloc_size);
});

task_system::set_task_dependency(main_task, async_task);
task_system::enqueue_task(async_task);
Expand Down
5 changes: 2 additions & 3 deletions src/components/shapespace/shapespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,8 @@ struct Shapespace : viamd::EventHandler {
md_array_resize(coords, num_frames * num_structures, arena);
MEMSET(weights, 0, md_array_bytes(weights));
MEMSET(coords, 0, md_array_bytes(coords));
evaluate_task = task_system::create_pool_task(STR_LIT("Eval Shape Space"), 0, (uint32_t)num_frames, [](uint32_t range_beg, uint32_t range_end, void* user_data, uint32_t thread_num) {
evaluate_task = task_system::create_pool_task(STR_LIT("Eval Shape Space"), (uint32_t)num_frames, [shapespace = this](uint32_t range_beg, uint32_t range_end, uint32_t thread_num) {
(void)thread_num;
Shapespace* shapespace = (Shapespace*)user_data;
ApplicationState* app_state = shapespace->app_state;
const size_t stride = ALIGN_TO(app_state->mold.mol.atom.count, 8);
const size_t bytes = stride * 3 * sizeof(float);
Expand Down Expand Up @@ -423,7 +422,7 @@ struct Shapespace : viamd::EventHandler {
}
}
md_array_free(xyzw, md_get_heap_allocator());
}, this);
});

task_system::enqueue_task(evaluate_task);
}
Expand Down
Loading

0 comments on commit ef7a2d3

Please sign in to comment.