520 night mixed multi-threaded multi-process debug summary

Actually in the liver to the library now, or 520, so meaningful to be at Memorial

To look at the job (actually very simple, after all, gave us the source code, although a bunch of bug source, here played manually gg)

Third operation:

Analysis source matrix multiplication, the program flow chart shown, compile and run the program.

  • Analysis of the source code, explained one by one

  • Submission process flow chart and program solutions

  • Submit test source (50% Notes)

  • Auxiliary program (program generation matrix, matrix printing program)

  • Generating a generator matrix and the B matrix A program, forming two matrix file, and modified source program is read from the file A and B matrices, the matrix calculation result C output to a file, the printing by the printing matrix program matrix C

  • The results submitted

Well, the old rules, a bunch of error source code, in fact, if there is no operational requirements Article file, everything is so smooth. Not many bug:

Is a two-dimensional array of parameter passing problem, pointer arrays and array pointer, think about the headache, a lot of bloggers here refer Bowen, now still a little dizzy, but fortunately not difficult, according to the experience quickly resolved bug.

The second is found when running out the results matrix will always be repeated, especially when the number of processes when different, so carefully check the code, the underlying problem is found, if the number of processes is less than the dimension of the matrix when , a line will be repeated demand, rather than redistribution. In short these two relatively simple bug can be said that conscience.

So, I had some time more, to think about thinking questions: Under what circumstances would a deadlock it? Unfortunately, their own shallow knowledge of the operating system, really did not expect (or too much food, Wulian here). Then prepare to file a second operation code are transferred through the file operation is the little things right. But the fact is not the case, adding file operations, adjust the code to die ah! ! !

First , two matrices reading problems, Bing Chengjian never repeat ideas work, use a for loop, twice reads two matrix file, here draws on the operation of the print function, and a two-dimensional array dynamically allocated memory. Small bug did not say, resulting in a segment error! I a God! This fear array overflow problem. And I will not (do not want to take the time) debugging multi-process, only (well okay print Dafa) print debugging method. Then, look for a long time, and finally it is silent, the principle is crazy with int i as the loop variable, the value of i then changed several times! Oh my God! ! This sb error, this time I actually spend above .... silent, it will be easy to remember! !

 

Then, read the matrix, then encounters a second error crazy! : What terminate, exit code 11, error code check the internet, no good. Good manual gg! Continue Pirnt Dafa (OK, I really will print) and then found that eight is a matrix deposit does not go ah! Malloc is probably wrong, then quickly spit blood, to force memory errors naked, good, careful physical examination, and then look genmat source. Huh? Here's how to do it is to go double, my main program defaults to float! ! Ah a check, double 2 bytes like (control him what), anyway, float younger than him! ! My god! ! Change teacher source! ! ! Through a random change, teacher assistance program has been unrecognizable.

Then, how to write papers ah! ! Not as a line by line output to print, because I wanted to learn matgen practices, operating together and then written to the file, and because teachers need to print out a print function, the format must be written and matgen same. ok, continue to change the code, learn code. Found wrong ah! How files and print matrix matrix is ​​not the same ah! ! It should be the same ah! ! Crazy! This time has been 1:00! ! Continue to print, good find, file input several times! ! ? ? ? The problem is multi-process! ! God the amount, reminiscent of the first job! ! At this point ready to give up, crying, I do not want to sudden death! ! Go on trips to the bathroom, go for a walk or to the toilet halfway really my debug God assists! Repeatedly experience! Had an idea! In the main process should be completed finishing work ah! ! correct! Then wit is resolved, the two test samples, emmmm seems to be no problem, I do not want to find a bug, give me a break, I dry up! !

 

Well, step on pit understanding, 520 happy. I love parallel programming! Well, I'm going to bed. . . .

 

Guess you like

Origin blog.csdn.net/wooooooc/article/details/90365046