11/05/2018, 12:46
Cần anh em IT giúp đỡ
Mình bị lỗi ntn(có in đậm trong phần code) Lab3.cpp: In function ≤int main(int, char**)≥: Lab3.cpp 52: error: ≤strcat_s≥ was not declared in this scope strcat_s(message, sizeof(message), " back message"); Phía dưới là code trong linux #include "mpi.h" #include ...
Mình bị lỗi ntn(có in đậm trong phần code)
Lab3.cpp: In function ≤int main(int, char**)≥:
Lab3.cpp
52: error: ≤strcat_s≥ was not declared in this scope
strcat_s(message, sizeof(message), " back message");
Phía dưới là code trong linux
#include "mpi.h"
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
int rank, size;
char message[256] = "Hello the world";
MPI_Status stat;
MPI_Init(&argc, &argv);
double time1, time2;
time1 = MPI_Wtime();
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank > 0)
{
printf("proc %d recv msg[ %s ] from Proc %d ", rank, message, rank - 1);
MPI_Recv(&message, sizeof(message), MPI_CHAR, (rank - 1), 1, MPI_COMM_WORLD, &stat);
}
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank < size-1)
{
printf("proc %d send msg[ %s ] TO Proc %d ", rank, message, (rank + 1));
MPI_Send(&message, sizeof(message), MPI_CHAR, (rank + 1), 1, MPI_COMM_WORLD);
}
/// back side send message
strcat_s(message, sizeof(message), " back message");
if (rank < size - 1)
{
printf("proc %d recv msg[ %s ] from Proc %d ", rank, message, rank + 1);
MPI_Recv(&message, sizeof(message), MPI_CHAR, (rank+1), 1, MPI_COMM_WORLD, &stat);
}
if (rank > 0)
{
printf("proc %d send msg[ %s ] TO Proc %d ", rank, message, (rank - 1));
MPI_Send(&message, sizeof(message), MPI_CHAR, (rank - 1), 1, MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
if (rank == 0)
{
time2 = MPI_Wtime();
printf("Time: %f sec from rank: %d", (time2 - time1), rank);
}
MPI_Finalize();
return (0);
}
Lab3.cpp: In function ≤int main(int, char**)≥:
Lab3.cpp

strcat_s(message, sizeof(message), " back message");
Phía dưới là code trong linux
#include "mpi.h"
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
int rank, size;
char message[256] = "Hello the world";
MPI_Status stat;
MPI_Init(&argc, &argv);
double time1, time2;
time1 = MPI_Wtime();
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank > 0)
{
printf("proc %d recv msg[ %s ] from Proc %d ", rank, message, rank - 1);
MPI_Recv(&message, sizeof(message), MPI_CHAR, (rank - 1), 1, MPI_COMM_WORLD, &stat);
}
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank < size-1)
{
printf("proc %d send msg[ %s ] TO Proc %d ", rank, message, (rank + 1));
MPI_Send(&message, sizeof(message), MPI_CHAR, (rank + 1), 1, MPI_COMM_WORLD);
}
/// back side send message
strcat_s(message, sizeof(message), " back message");
if (rank < size - 1)
{
printf("proc %d recv msg[ %s ] from Proc %d ", rank, message, rank + 1);
MPI_Recv(&message, sizeof(message), MPI_CHAR, (rank+1), 1, MPI_COMM_WORLD, &stat);
}
if (rank > 0)
{
printf("proc %d send msg[ %s ] TO Proc %d ", rank, message, (rank - 1));
MPI_Send(&message, sizeof(message), MPI_CHAR, (rank - 1), 1, MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
if (rank == 0)
{
time2 = MPI_Wtime();
printf("Time: %f sec from rank: %d", (time2 - time1), rank);
}
MPI_Finalize();
return (0);
}