Software Archive
Read-only legacy content
17061 Discussions

intrinsics for KNC, maybe some paths are missing

Valjean__Jean
Beginner
400 Views

Hello,

I am trying to make simple examples with intrinsics and I found it difficult, this is why I've tried also the friendly "vectorclass" from Agner Fog.

I didn't manage to compile the following code and my question is ... how to make intrinsics for offload to work?

Thank you for your help.

/*
host - avx
icpc tvec.c

mic
icpc -qoffload-arch=mic tvec.c
*/

#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#include "vectorclass.h"

int main(void) {

	int list[20] = {0,1,2,3,4,5,65,7,8,9,10,11,12,13,14,15,16,17,18,19};

	//int lv = 8; // case 1, 2
	int lv = 16;  // case 3, 4

	//#pragma offload target(mic) // case3
	{	
		//Vec8i n0, n1, res;  //case 1, 2
		Vec16i n0, n1, res;  // case 3, 4

		n0.load(list);
		n1.load(list + 2);

		res = select(n0 < n1, n0, n1);

		for (int j = 0; j < lv; j++)
			printf("%3d %3d %3d\n", n0, n1, res);
	}
	return 0;
}

______________________case 1 host - OK
[root@ma 17]# icpc tvec.c
[root@ma 17]# ./a.out
  0   2   0
  1   3   1
  2   4   2
  3   5   3
  4  65   4
  5   7   5
 65   8   8
  7   9   7
_________________case 2 for micnativeloadex - I think this error is normal, KNC has not 256 vectors (Vec8i)
[root@ma 17]# icpc -mmic tvec.c
tvec.c(29): (col. 21) error #13393: Opcode unsupported on target architecture: pcmpgtd
tvec.c(29): (col. 21) error #13393: Opcode unsupported on target architecture: pcmpgtd
tvec.c(29): (col. 29) error #13393: Opcode unsupported on target architecture: pand
tvec.c(29): (col. 29) error #13393: Opcode unsupported on target architecture: pandn
tvec.c(29): (col. 29) error #13393: Opcode unsupported on target architecture: por
tvec.c(29): (col. 29) error #13393: Opcode unsupported on target architecture: pand
tvec.c(29): (col. 29) error #13393: Opcode unsupported on target architecture: pandn
tvec.c(29): (col. 29) error #13393: Opcode unsupported on target architecture: por
tvec.c(14): catastrophic error: __vectorcall cannot be used when SSE2 not enabled.
compilation aborted for tvec.c (code 1)

____________________case 3 for offload - NOT OK
[root@ma 17]# icpc -qoffload-arch=mic tvec.c 
tvec.c(24): error: identifier "Vec16i" is undefined
                Vec16i n0, n1, res;
                ^
compilation aborted for tvec.c (code 2)

_________________case 4 compiled for micnativeloadex - NOT OK
[root@ma 17]# icpc -mmic tvec.c
tvec.c(24): error: identifier "Vec16i" is undefined
                Vec16i n0, n1, res;  // case 2, 4
                ^
compilation aborted for tvec.c (code 2)

ps: I am new in this subject maybe I wrote stupid things. My intention is to give work to micN.. using offload and use intrinsics only on hotspot. (maybe there is a different method - to compile separately for mic and link at the end). I found some pdfs but any material/links would be helpful.

0 Kudos
3 Replies
JJK
New Contributor III
400 Views

the vectorclass library you are using has not been ported/optimized to the KNC platform. The message you are seeing about the missing unsupported Opcodes is caused by the fact that the vectorclass  uses SSE2 instructions, which the KNC does not support.

If you read the vectorclass.pdf file that comes with the vectorclass package, you will find that there is a special KNC version of this library. You can get it using

git clone https://bitbucket.org/veclibknc/vclknc.git

 

0 Kudos
Valjean__Jean
Beginner
400 Views

Hi JJK

this is a quick answer.

If I remember corectly I used "vectorclass" version 1.27 from February 2017 (it is written on top of every file from that archive)

It has inside at "select" an intrinsics which I verified in the onlione list of intrinsict and belongs to KNC (_mm512_mask_mov_epi32).

If I don't manage to offload intrinsics, I will come later with questions, or maybe you have an example to start with...

thank you

0 Kudos
JJK
New Contributor III
400 Views

the vectorclass 1.27 library does not support the KNC/mic architecture. For that you'd need the version I posted earlier. However, I just noticed that that KNC port is far from complete and your tvec.c example does not run when compiled against it - there are quite a few functions that simply throw "assert(0)"  .  I'd refrain from using vectorclass.h for your code for now

0 Kudos
Reply