//////////////////////////////// // VISUAL C++ PRO 2010 Beta2 // //////////////////////////////// //CAN WOEK ALSO COMPATIBLE Icc & Mingw //FOR COMPILE // SET OMP_BLOCKTIME=0 // cl /Ox /EHsc /openmp vc_ficat9.cc //EXAMPLE (NUMBER THREAD DEPEND MACHINE) // vc_ficat9 175 12 1 1000 1 50 (with 12 threads) // vc_ficat9 175 1 1 1000 1 50 (with unique thread) #include #include #include #include #include #include #include #include //////////////////////////////////////////////////////////////////////////////// //VOID COUNT_ARRAY_OCCURS_0 FOR COUNT ARRAY OCCURRENCES ASYNCHRONY IN AN STRING// //////////////////////////////////////////////////////////////////////////////// int count_array_occurs_0 (char *a, char **b, int c, int d, int e,int f,int g) { // A IS GLOBAL STRING WHERE MUST COUNTED OCCURRENCE // B IS ARRAY OF WORDS OCCURRENCES AS MUST COUNTED IN A // C IS SIZE CALLED OF ARRAY // D IS NUMBER PROBABILITY OCCURENCES RELATION REQUIRED TO AN DEDUCTION // E IS NUMBER THREADS // F IS FLAG TO SHOW int lc[58]; int la = strlen (a); //SIZE STRING RECEIV int noc[58]; //ARRAY SIZED TO C int pos[4096][58]; //ARRAY SIZED TO 2 CHUNKS: SIZE STRING & NUMBER ELEMENT REQUIRED FINDING int j; int x; int k; int p = 0; int af = 0; int gtn=0; int v=0; int i=0; char * ve[58]; //NEW ARRAY FOR RECEIVE ALEATORY (OLD IS STATIC ELEMENT MEMORY POINTED) omp_set_nested (0); // omp_set_dynamic (0); omp_set_num_threads (e); #pragma omp parallel for private(v) // FOR ARRAY ALEATORY //DISABLE = IMPROVE /2 for (v = 0; v <= c-1 ; v++) //LOOP TO INITIALIZE ARRAY IN SALAD { ve[i]= b[v]; lc[i] = strlen (ve[i]); noc[i] = 0; i++; } gtn = omp_get_thread_num (); #pragma omp parallel shared(a,p,f) private(j,k,x,v) { for (int i = 0; i <= c-1 ; i++) //LOOP FIRST LEVEL { // gtn = omp_get_thread_num (); // HERE RECEIVED BY ICC CORRECT THREAD if ((i % 2) == 0) //ALTERNATE CONDITION PAIR IMPAIR TO AFFINITY # 0 & 1 (SEE VOID ALEAT ADDED TO BIG MACHINE) { af = 0; } else { af = 1; } if(g==0) { /*cpu_set_t mask; CPU_ZERO (&mask); CPU_SET (af, &mask); if (sched_setaffinity (af, sizeof (cpu_set_t), &mask) < 0) { perror ("sched_setaffinity"); }*/ } if (p >= d ) //FLAG HALT POINT { i = c - 1; } #pragma omp sections nowait // { #pragma omp section for (j = 0; j <= la ; j++) //SECONDARY LEVEL { gtn = omp_get_thread_num (); //HERE THIS LEVEL INTEL ICC && BUFFALO SHOW THREAD //std::cout << " " << gtn; // UNCOMENT TO SHOW ALL THREADS OK OR 0 x = 0; if (a[j] == ve[i][0]) { for (k = j; k <= j + lc[i]-1 ; k++) //THIRD LEVEL LOOP,HERE STRANGE WITH ICC ß [ 0 ] [ # 2 ] { if (a[k] == ve[i][x] && x <= lc[i]-1 ) // && FOR HALT BEFORE MORE OCCURENCES EXISTING { x++; } if (x == lc[i] && noc[i]<=d-1 && p<=d-1) // && FOR HALT BEFORE MORE OCCURENCES EXISTING { noc[i]++; pos[noc[i]][i] = k - x; p++; gtn = omp_get_thread_num (); //HERE INTEL SHOW 0 NEAL, BUFFALO SHOW NICE ALL THREAD ... if (f==0) { std::cout << " [ß " << gtn << " ]"; //IS OTHER ENVIRONMENT EXIST LEADED DEFAULT ?? std::cout << " [ # " << omp_get_num_procs () << "," <= d ) //FLAG HALT POINT if (p > d || gtn ==0 ) TO VERIFY ICC ALWAY REAL THREAD 0 { if (f==0) { std::cout << "\n[Thread " << gtn << " ]"; //IS OTHER ENVIRONMENT EXIST LEADED DEFAULT ?? std::cout << " [ # " << omp_get_num_procs () << "," < " << ve[i] << std::endl; } int m = 1; while (pos[m][i] != 0) { //ENABLE TO SHOW POSITION // std::cout << pos[m][i] << " <-POS-> " << ve[i] << " <-TO-> " << pos[m][i] + strlen (ve[i]) << std::endl; m++; } } } if(f==0) { std::cout << "Sum : " << sum << std::endl; } sum =0; return (i); } /////////////////////////////////////////////////////////////////////////////////// //VOID COUNT_ARRAY_OCCURS_1 FOR COUNT ARRAY OCCURRENCES ASYNCHRONY IN AN STRING// //////////////////////////////////////////////////////////////////////////////////// int count_array_occurs_1 (char *a, char **b, int c, int d, int e, int f,int g) { // A IS GLOBAL STRING WHERE MUST COUNTED OCCURRENCE // B IS ARRAY OF WORDS OCCURRENCES AS MUST COUNTED IN A // C IS SIZE CALLED OF ARRAY // D IS NUMBER PROBABILITY OCCURENCES RELATION REQUIRED TO AN DEDUCTION // E IS NUMBER THREADS // F IS FLAG TO SHOW // G int la = strlen (a); //SIZE STRING RECEIVED int lc[58]; //ARRAY SIZED TO C int noc[58]; //ARRAY SIZED TO C int pos[4096][58]; //ARRAY SIZED TO 2 CHUNKS: SIZE STRING & NUMBER ELEMENT REQUIRED FINDING int j; int x; int k; int p = 0; int af = 0; int gtn=0; int v=0; int i=0; char * ve[58]; //NEW ARRAY FOR RECEIVE ALEATORY (OLD IS STATIC ELEMENT MEMORY POINTED) // cpu_set_t mask; // WITH OR WITHOUT AFFINITY 2 FUNCTIONS SAME (PROBLEM ???) ICC omp_set_nested (0); omp_set_dynamic (0); omp_set_num_threads (e); //NUM THREAD DEPEND ALSO FOR FREE THAT YOU NOT HAVE USE (IMPROVE FOR ALL SYSTEM) #pragma omp parallel for // FOR ARRAY ALEATORY for (v = 0; v <= c-1 ; v++) //LOOP TO INITIALIZE ARRAY IN MIXED SALAD { ve[i]= b[v]; lc[i] = strlen (ve[i]); noc[i] = 0; i++; /* for (int z= 0; z <= 5; z++) //LOOP TO WAIT IF YOUR # IS OLD. { std::cout << "\0"; }*/ // for(int z=0;z<=2;z++){std::cout << "\0 ";} //IF AN OLD SLOW # UNABLE TICK ALLOWED ADD FICTIVE LOOP HERE FOR SLOW //ONLY IF YOU HAVING LOOP RESULT NORMALLY INCREASED //ALEATORY RESULT IS BETTER IF YOU HAVE WELL MODEL #++ } omp_set_num_threads (e); gtn = omp_get_thread_num (); #pragma omp parallel shared(a,p) private(j,k,x,v) { for (int i = 0; i <= c-1 ; i++) //LOOP FIRST LEVEL { gtn = omp_get_thread_num (); // HERE CALL NUM THREAD if ((gtn % 2) == 0) //ALTERNATE CONDITION THREAD PAIR IMPAIR TO AFFINITY # 0 & 1 { af = 0; } else { af = 1; } if(g==0) { /* cpu_set_t mask; CPU_ZERO (&mask); CPU_SET (af, &mask); if (sched_setaffinity (af, sizeof (cpu_set_t), &mask) < 0) { perror ("sched_setaffinity"); }*/ } if (p >= d ) //FLAG HALT POINT LOOP { i = c - 1; } #pragma omp for nowait // for (j = 0; j <= la ; j++) //SECONDARY LEVEL { gtn = omp_get_thread_num (); // HERE CALL NUM THREAD x = 0; if (a[j] == ve[i][0]) { for (k = j; k <= j + lc[i]-1 ; k++) { if (a[k] == ve[i][x] && x <= lc[i]-1 ) // && FOR HALT BEFORE MORE OCCURENCES EXISTING { x++; } if (x == lc[i] && noc[i]<=d-1 && (p+noc[i+1])<=d-1) // && FOR HALT BEFORE MORE OCCURENCES EXISTING { noc[i]++; pos[noc[i]][i] = k - x; p++; gtn = omp_get_thread_num (); if (f==0) { std::cout << " [ß " << gtn << " ]"; //IS OTHER ENVIRONMENT EXIST LEADED DEFAULT ?? std::cout << " [ # " << omp_get_num_procs () << "," <= d ) //FLAG HALT POINT IN LOOP LEVEL3 { if (f==0) { std::cout << " \n[Thread: " << gtn << " ]"; //IS OTHER ENVIRONMENT EXIST LEADED DEFAULT ?? std::cout << " [ # " << omp_get_num_procs () << "," < " << ve[i] << std::endl; } sum=sum+noc[i]; int m = 1; while (pos[m][i] != 0) { //ENABLE TO SHOW POSITION // std::cout << pos[m][i] << " <-POS-> " << ve[i] << " <-TO-> " << pos[m][i] + strlen (ve[i]) << std::endl; m++; } } } if (f==0) { std::cout << "Sum : " << sum << std::endl; } sum =0; return (i); } int main (int argc, char *argv[]) { if (argv[1]==NULL || argv[2]==NULL || argv[3]==NULL || argv[4]==NULL ) { std::cout << "7 parameters (3 optional) required \nName program + \n[1](number occurences ) \n[2](number threads) \n[3](Type aleatory (0 or 1)) \n[4](Number element loop) \n[5](Show trace (optional) 0 or 1) \n[6](Affinity (optional) # 0=2 # or 1=1 #) \n[7](Numbers element array words (optional))"<< std::endl; exit(0); } std::cout << "7 parameters (3 optional) required \nName program + \n[1](number occurences ) \n[2](number threads) \n[3](Type aleatory (0 or 1)) \n[4](Number element loop) \n[5](Show trace (optional) 0 or 1) \n[6](Affinity (optional)# 0=2 # or 1=1 # ) \n[7](Numbers element array words (optional))\nOk task is working.."<< std::endl; char * testocc ; // USE THIS SIZE ICC OR GREATER TO INCREASE RESERVED SPACE (no Segmentation fault with trace) char * strtab [] = {"another","time","Non-Commercial ","increase","are","happy","display","copy","some","drive","allready","otherwise","as","Site","1.","2","disclosure","harassing","4.","5.","6","7.",".","9.","Unless","as","and","personal","any","forum", "Non", "system", "otherwise", "vulgar", "allready","reverse","not", "state", "computer", "on", "the", "server", "to","tx","each","Intel", "faults", "gate","screen","pre", "ch", "thread","na", "is", ",", "back","by" }; int nps = atoi(argv[1]); int nt = atoi(argv[2]); int ty = atoi(argv[3]); int lo = atoi(argv[4]); int sh=0; int uaf=0; int nema=57; double chro[3]; chro[0]=omp_get_wtime(); omp_set_num_threads (0); omp_set_num_threads (201); if (argv[5]!=NULL) { sh = atoi(argv[5]); } if (argv[6]!=NULL) { uaf = atoi(argv[6]); } if (argv[7]!=NULL && strlen(argv[7])>3) //TO SUSE (argv[7] USED ??? { nema=57; } if (argv[7]!=NULL && strlen(argv[7])<3) { nema = atoi(argv[7]); if (nema >57) { nema=57; } } testocc="Personal Non-Commercial Use: This Web Site is for personal and non-commercial use. Unless otherwise specified or as provided in these Terms, you may not modify, copy, distribute, transmit, display, perform, reproduce, publish, license, create derivative works from, transfer, or sell any information, software, products or services obtained from the Materials\nNo Unlawful or Prohibited Use: You agree that you will not use the Web Sites or Material for any purpose that is unlawful or prohibited by these Terms of Use. You may not:\n 1. upload, post, email, transmit or otherwise make available any content that is unlawful, harmful, threatening, abusive, harassing, tortuous, defamatory, vulgar, obscene, libelous, invasive of another's privacy, hateful, or racially, ethnically or otherwise objectionable;\n 2. use the Web Sites, Materials, Services or activities to \"stalk\" or otherwise harass or harm another;\n 3. impersonate any person or entity, including, but not limited to, an Intel official, forum leader, guide or host, or falsely state or otherwise misrepresent your affiliation with a person or entity or collect or store personal data about other users in connection with the prohibited conduct and activities;\n 4. forge headers or otherwise manipulate identifiers in order to disguise the origin of any content transmitted through the Web Site or Materials;\n 5. upload, post, email, transmit or otherwise make available any content that you do not have a right to make available under any law or under contractual or fiduciary relationships (such as inside information, proprietary and confidential information learned or disclosed as part of employment relationships or under nondisclosure agreements);\n 6. upload, post, email, transmit or otherwise make available any content that infringes any patent, trademark, trade secret, copyright or other proprietary rights (\"Rights\") of any party;\n 7. upload, post, email, transmit or otherwise make available any unsolicited or unauthorized advertising, promotional materials, \"junk mail,\" \"spam,\" \"chain letters,\" \"pyramid schemes,\" or any other form of solicitation;\n 8. upload, post, email, transmit or otherwise make available any material that contains software viruses or any other computer code, files or programs designed to interrupt, destroy or limit the functionality of any computer software or hardware or telecommunications equipment;\n 9. you may not use the Web Site or Materials in any manner that could damage, disable, overburden, or impair any Intel server, or network(s) connections, disobey any requirements, procedures, policies or regulations of networks connected to the Web Site or Materials or interfere with any other party's use and enjoyment of the Web Sites or Materials;\n 10. you may not attempt to gain unauthorized access to any Web Site or Material, other accounts, computer systems or networks connected to any Intel server or Materials, through hacking, password mining or any other means or obtain or attempt to obtain any materials or information through any means not intentionally made available through the Web Sites or Materials;\n 11. intentionally or unintentionally violate any applicable local, state, national or international law, including, but not limited to, regulations promulgated by the U.S. Securities and Exchange Commission, any rules of any national or other securities exchange, including, without limitation, the New York Stock Exchange, the American Stock Exchange or the NASDAQ, and any regulations having the force of law; and/or\n 12. provide material support or resources (or to conceal or disguise the nature, location, source, or ownership of material support or resources) to any organization(s) designated by the United States government as a foreign terrorist organization pursuant to section 219 of the Immigration and Nationality Act.\nUS Government Restricted Rights: The Materials including Intel Software are provided with \"RESTRICTED RIGHTS.\" Use, duplication, or disclosure by the Government is subject to restrictions as set forth in FAR52.227-14 and DFAR252.227-7013 et seq. or its successor. Use of the Materials by the Government constitutes acknowledgment of Intel \'s proprietary rights in them\n"; int v; int res=0; int sumres=0; if (ty==0) { for ( v=0 ;v<=lo; v++) // FICTIVE SMALL NUMBER RECORD TUPLES ENGINE DATABASE SIMULATE (USE OPTION NOWAIT) { res=count_array_occurs_0 (testocc,&strtab[NULL],nema,nps,nt,sh,uaf); sumres=sumres+res; } } if (ty==1) { for ( v=0 ;v<=lo; v++) // FICTIVE SMALL NUMBER RECORD TUPLES ENGINE DATABASE SIMULATE (USE OPTION NOWAIT) { res=count_array_occurs_1 (testocc,&strtab[NULL],nema,nps,nt,sh,uaf); sumres=sumres+res; } } chro[1] =omp_get_wtime(); chro[2]=chro[1] - chro[0] ; std::cout << "\nIn sound coffe....: onSmokerOver isToFogLower()\n 2,4,8 or ++ Intel cores, you have probably an using exact for your money, No ?.. " << std::endl; std::cout << "\nOpenMp is very very nice product.. , No ?.." << std::endl; std::cout <<"\n\nResult : " << sumres << " Occurrences generated with loop " <