110 likes | 199 Views
Industrial Project - 234313. Coding environment infrastructure for efficient parallel computing. Team. Developers: Vlad Krasnov Ady Abraham Supervisor: Dr. Roee Engelberg , LSI. Goals. Make programming with asynchronous non-blocking APIs intuitive. Preserve maximal efficiency.
E N D
Industrial Project - 234313 Coding environment infrastructure for efficientparallel computing
Team • Developers: VladKrasnov Ady Abraham • Supervisor: Dr. Roee Engelberg, LSI
Goals • Make programming with asynchronous non-blocking APIs intuitive. • Preserve maximal efficiency. The Project’s Goal: Legacy model: A(){ //some code here... some_async_IO(decision1); } decision1(){ if(...) C(); else B(); } B(){ //some code here... some_async_IO(A); } C(){ //some code here... some_async_IO(exit_func); } exit_func(){ return; } START(EXAMPLE); ASYNC(A); WHILE(...) ASYNC(B); ASYNC(A); ENDWHILE; ASYNC(C); END; // execution point EXEC(EXAMPLE);
Methodology • Define abstract computation model • Syntax definition. • Framework implementation in order to run the required flow. • Debug and validation.
Achievements • Framework with MACRO based syntax that provides Turing-complete semantics. • Second tier API with debugging capabilities. • Natural easy-to-use easy-to-read syntax. • No training required.
Achievements • Supports: • Synchronous functions. • Asynchronous functions. • If • While • Break • Goto / Labels • Exit
Example(legacy code) void GetAddressForWrite(void* ctx) { read_map(ctx, Continue1, ctx); // top snapshot } void Continue1(void* ctx) { if(error_occured(ctx)){ give_up_chunk(ctx); return; } if(map_exists(ctx)){ // in top snapshot update_address(ctx); return; } Loop(ctx); } void Loop(void* ctx) { if(!map_does_not_exist(ctx)){ ContinueFromLoop(ctx); return; } get_next_snapshot(ctx); read_map(ctx, Continue2, ctx); // of next snapshot } void Continue2(void* ctx) { if(error_occured(ctx)){ give_up_chunk(ctx); return; } Loop(ctx); } void ContinueFromLoop(void* ctx) { get_new_chunk(ctx); init_new_chunk(ctx, Continue3, ctx); }
Example(legacy code) cont. void Continue3(void* ctx) { if(error_occured(ctx)){ give_up_chunk(ctx); return; } update_map(ctx, Continue4, ctx); // of top snapshot } void Continue4(void* ctx) { if(error_occured(ctx)){ give_up_chunk(ctx); return; } update_address(ctx); Done(ctx); }
Example START(GET_ADDRESS_FOR_WRITE); ASYNC(read_map); // top snapshot IF(error_occured); GOTO(bail); ENDIF; IF(map_exists); // in top snapshot SYNC(update_address); EXIT; ENDIF; WHILE(map_does_not_exist); SYNC(get_next_snapshot); ASYNC(read_map); // of next snapshot IF(error_occured); GOTO(bail); ENDIF; ENDWHILE; SYNC(get_new_chunk); ASYNC(init_new_chunk); IF(error_occured); GOTO(bail); ENDIF; ASYNC(update_map); // of top snapshot IF(error_occured); GOTO(bail); ENDIF; SYNC(update_address); EXIT; LABEL(bail); SYNC(give_up_chunk); // only if was allocated SYNC(set_error); EXIT; END; EXEC(GET_ADDRESS_FOR_WRITE, ctx, Done);
Example Output ASYNC: read_map Done with async... map_exists(): FALSE map_does_not_exist(): TRUE SYNC: get_next_snapshot ASYNC: read_map Done with async... map_does_not_exist(): TRUE SYNC: get_next_snapshot ASYNC: read_map Done with async... map_does_not_exist(): TRUE SYNC: get_next_snapshot ASYNC: read_map Done with async... map_does_not_exist(): FALSE SYNC: get_new_chunk ASYNC: init_new_chunk Done with async... ASYNC: update_map Done with async... SYNC: update_address Flow terminated
Conclusions • The project is more user friendly and useful than was expected at first. • Writing code with async function has now became easy! • No reason to be afraid of programming with async functions anymore.