180 likes | 561 Views
PANINI. Harshit Sahay Shuchi Agarwal Sumeet Jindal. Introduction. Panini is a language for parallel computing over multiple machines We have named our language after the Sanskrit grammarian, Panini Using Panini the task is distributed among different machines specified by the user.
E N D
PANINI Harshit Sahay Shuchi Agarwal Sumeet Jindal
Introduction • Panini is a language for parallel computing over multiple machines • We have named our language after the Sanskrit grammarian, Panini • Using Panini the task is distributed among different machines specified by the user
Features of Panini • Panini is a declarative language • Panini is simple and easy-to-use • Panini is flexible
Panini Architecture VC++ compiler Programmer’s VC++ project sample.cpp Panini compiler sample.panini
Communication between the machines Servicing machine output2 Requesting machine Libname+funcname+data2 output1 Servicing machine output0 Libname+funcname+data1 Libname+funcname+data0 Servicing machine
A sample PANINI program PANINI { CREATE NODE n1="209.2.235.32"; CREATE NODE n2="209.2.226.71"; { LIBNAME “D:\libdll.dll" FUNCTIONNAME "word_count" } }
char * n1="209.2.235.32"; char * n2="209.2.226.71"; bstr_t nodes_array[]={"209.2.235.32","209.2.226.71"}; void Create_Queue() {…} void libdll_word_count_Fire(char *function_inputs[],int number_of_tasks,char *guids[]) { CString library_name="libdll.dll"; CString function_name="word_count"; IMSMQQueueInfoPtr spQInfo("MSMQ.MSMQQueueInfo"); IMSMQQueuePtr spQSend; for(loop_i=0;loop_i<number_of_tasks;loop_i++) { IMSMQMessagePtr spQMsg("MSMQ.MSMQMessage"); spQMsg->Label = g; spQMsg->Body = BSTR(paniniMessage); spQMsg->Delivery = MQMSG_DELIVERY_RECOVERABLE; spQMsg->Send(spQSend); } } sample.cpp
sample.cpp(contd.) void Wait_For_Output(char *guids[],int number_of_guids,char *output[]) {) IMSMQQueueInfoPtr spQInfo1("MSMQ.MSMQQueueInfo"); IMSMQMessagePtr spRMsg; spRMsg= spQRec->PeekCurrent(&vtMissing, &vtMissing); while(1) { for(guid_i=0;guid_i<number_of_guids;guid_i++) { if(_stricmp((char*)spRMsg->Label,guids[guid_i])==0) num_of_guids_matched++; break; } if(guid_i<number_of_guids) { spRMsg=spQRec->ReceiveCurrent(&vtMissing, &vtMissing, &vtMissing); temp_str=spRMsg->Body; while(a<length) output[guid_i][a]=(char)temp_str.GetAt(a); if(num_of_guids_matched!=number_of_guids) {spRMsg= spQRec->PeekCurrent(&vtMissing, &vtMissing); } } else spRMsg=spQRec->PeekNext(&vtMissing, &vtMissing); } }
//user_code.cpp #include”sample.cpp”//output of Panini int _tmain(int argc, _TCHAR* argv[]){ CoInitialize(NULL); char *arr[]={"C:\\data1.txt","C:\\data2.txt","C:\\data3.tx t","C:\\data4.txt"}; char *output[8]; char *guids[8]; Create_Queue(); libdll_word_count_Fire(arr,4,guids);Wait_For_Output(guids,4,output); int no_words=0; for(int i=0;i<7;i++) no_words+=atoi(output[i]); cout<<"Total number of words in all files"<<no_words<<endl; CoUninitialize(); return 0; } //sample.cpp void Create_Queue(){ ... } void libdll_word_count_Fire(char *function_inputs[],int number_of_tasks,char *guids[]){ ... } void Wait_For_Output(char *guids[],int number_of_guids,char *output[]){ ... } Including and using Panini output in user code
Keywords of Panini • PANINI • CREATE • NODE • LIBNAME • FUNCTIONNAME
Service running on all machines int Receive() { /***********OPEN AND RECEIVE MESSAGE BEGIN**********/ IMSMQMessagePtr ReceiveMsg = ReceiveQueuePtr->Receive(&vtMissing, &vtMissing, &vtMissing, &vtReceiveTimeout); /************PARSE RECEIVED MESSAGE BEGIN*************/ while (resToken != ""){ if(i == 1) ipaddr = resToken; if(i == 2) libName = (LPCWSTR)resToken; if(i == 3) funcName = resToken; if(i == 4) inputToFunc = resToken; resToken = msg.Tokenize(_T("*"), cur_pos); i++; } /*************LOAD LIB + FUNCTION CALL BEGIN****************/ FunctionPtr = (FunctionType)GetProcAddress((HMODULE)hLib, funcName_1); FunctionPtr(input_to_function, output_from_function); /***************SEND MESSAGE BEGIN***********************/ BSTR bstr_paniniMessageOut = outMsg.AllocSysString(); ipaddr = "DIRECT=TCP:" + ipaddr + "\\PRIVATE$\\listening_queue"; Send(bstr_FormatName, bstr_guid, bstr_paniniMessageOut); return 0; }
Development tools and environment • Visual Studio 2005 • Microsoft Message Queueing(MSMQ) • Lex and Yacc • Google Docs
Test Plan • Every grammar production was tested • Testing communication between machines was a major component of testing
Conclusion • Great learning experience • Learnt about message queuing • Realized that implementing parallel computing is not so easy • We achieved our basic objective-to create a language for parallelizing tasks • So, if you have some set of instructions which you want to easily execute over multiple sets of data, then use our language