Quantcast
Channel: Intel® Many Integrated Core Architecture
Viewing all articles
Browse latest Browse all 1347

file open failed in offload mode

$
0
0

hi~

I tried the following code in offload mode. However, it returns "file open failed". I know that I should set the environment variable about ./proxyfs/  However, I don't know whether I have successfully set it. Can anyone please tell me how to set it and how to test whether it's set successfully?

Thanks!

 

#pragma offload_attribute(push,target(mic))
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma offload_attribute(pop)

int main()
{
	FILE *fp;
	char buffer[7];
	#pragma offload target(mic) nocopy(fp)
	{
		fp = fopen("./proxyfs/myfile.txt","wb");
		if (fp==NULL)
		{
			fprintf(stderr,"Failed to open myfile.txt for write\n");
			exit(1);
		}
		fwrite("Hello\n",1,7,fp);
		fclose(fp);
	}

	#pragma offload target(mic) nocopy(fp) out(buffer)
	{
		fp = fopen("./proxyfs/myfile.txt","rb");
		if (fp==NULL)
		{
			fprintf(stderr,"Failed to open myfile.txt for write\n");
			exit(1);
		}
		fread(buffer,1,7,fp);
		fclose(fp);
		if (strcmp(buffer,"Hello\n")!=0)
		{
			fprintf(stderr,"File incorrectly read back on coproc\n");
			exit(1);
		}
	}
	printf("%s",buffer);

	return 0;
}

 


Viewing all articles
Browse latest Browse all 1347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>