В .isp c файле с использованием pthread генерируются следующие ошибки: (1) t.isp c: 2: 13: ошибка: недопустимо возвращать «изменяющийся» или векторный тип из экспортируемой функции «matrix_mult_pl» экспорта void * matrix_mult_pl (void * arg)
(2) t.isp c: 2: 36: Ошибка: параметр типа изменяющегося указателя "arg" недопустим в экспортируемой функции. экспорт void * matrix_mult_pl (void * arg)
(3) t.isp c: 6: 11: ошибка: синтаксическая ошибка, неожиданное 'int'. tid = * (int *) (arg); // получаем идентификатор потока, назначенный последовательно. ^^^
и многие другие ошибки. Кодер прилагается ниже. Пожалуйста, изучите вопрос использования pthreads в потоках ISP C.
. c file
/**
* Thread routine.
* Each thread works on a portion of the 'matrix1'.
* The start and end of the portion depend on the 'arg' which
* is the ID assigned to threads sequentially.
*/
void * matrix_mult_pl( void *arg )
{
int rows, cols, j, tid, portion_size, row_start, row_end;
tid = *(int *)(arg); // get the thread ID assigned sequentially.
portion_size = size / num_threads;
row_start = tid * portion_size;
row_end = (tid+1) * portion_size;
for (rows = row_start; rows < row_end; ++rows) { // hold row index of 'matrix1'
for (j = 0; j < size; ++j) { // hold column index of 'matrix2'
// hold value of a cell
/* one pass to sum the multiplications of corresponding cells
in the row vector and column vector. */
for(cols=0; cols<size; cols++) {
result_pl[ rows ][ cols ] += matrix1[ rows ][ j ] * matrix2[ j ][ cols ];
}
}
}
}
threads.isp c file
export void * matrix_mult_pl( void *arg )
{
int rows, cols, j, tid, portion_size, row_start, row_end;
tid = *(int *)(arg); // get the thread ID assigned sequentially.
portion_size = size / num_threads;
row_start = tid * portion_size;
row_end = (tid+1) * portion_size;
for (rows = row_start; rows < row_end; ++rows) { // hold row index of 'matrix1'
for (j = 0; j < size; ++j) { // hold column index of 'matrix2'
// hold value of a cell
/* one pass to sum the multiplications of corresponding cells
in the row vector and column vector. */
for(cols=0; cols<size; cols++) {
result_pl[ rows ][ cols ] += matrix1[ rows ][ j ] * matrix2[ j ][ cols ];
}
}
}
}
Почему ISP C файл не векторизовал выполнение с распараллеливанием по pthreads?