+
+ for(int r = 0; r<m_rows;r++){
+ matrix[r] = data + r * m_cols;
+ }
+
+ int chunk_size = m_cols / num_threads;
+ for (int i = 0; i < num_threads; i++) {
+ args[i].start = i * chunk_size;
+ if (i == num_threads - 1) {
+ args[i].end = m_cols;
+ } else {
+ args[i].end = (i + 1) * chunk_size;
+ }
+ if (pthread_create(&threads[i], NULL, ¶llel_populate_matrix, &args[i]) != 0) {
+ perror("Failed to create thread");
+ exit(1);
+ }
+ }
+
+ for (int i = 0; i < num_threads; i++) {
+ pthread_join(threads[i], NULL);
+ }
+ free(threads);
+ free(args);